@tinkerlandai/longplay-sdk 0.10.15 → 0.10.16
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 +6 -0
- package/README.md +13 -15
- package/README.zh-CN.md +14 -16
- package/dist/{ai-usage-C3dCagmQ.d.ts → ai-usage-DejUdb17.d.ts} +1 -1
- package/dist/{api-Cefn6AaL.d.ts → api-RQUBSSEJ.d.ts} +60 -26
- package/dist/{chunk-OZZMZH7X.js → chunk-26HU2HXU.js} +1 -1
- package/dist/chunk-4IGRIYOQ.js +1 -0
- package/dist/{chunk-V73OHOTK.js → chunk-55MXKW5J.js} +1 -1
- package/dist/{chunk-6RZKX552.js → chunk-67XTOBGE.js} +1 -1
- package/dist/{chunk-RT35MPPD.js → chunk-6MBVIE3H.js} +1 -1
- package/dist/chunk-AC32XJZW.js +1 -0
- package/dist/{chunk-VXY2C4AL.js → chunk-APO7QUBB.js} +1 -1
- package/dist/chunk-EEZLS2YP.js +1 -0
- package/dist/chunk-EFFXE6CX.js +6 -0
- package/dist/chunk-FKBSUKXE.js +1 -0
- package/dist/{chunk-TPAQWTO4.js → chunk-JKLILKI5.js} +1 -1
- package/dist/{chunk-VSMITXQD.js → chunk-LC2VUKYM.js} +1 -1
- package/dist/{chunk-LUIKKMG5.js → chunk-M5HQW67G.js} +1 -1
- package/dist/chunk-ML6EHT43.js +10 -0
- package/dist/chunk-PFHS7HK3.js +17 -0
- package/dist/chunk-T5COWMDA.js +1 -0
- package/dist/{configuration-sync-D2n_gGj6.d.ts → configuration-sync-C2jtm37f.d.ts} +97 -9
- package/dist/{content-WXHCWIUL.js → content-XCLXWNGN.js} +1 -1
- package/dist/{funnel-local-client-9U-_hkEE.d.ts → funnel-local-client-P_R6FHVV.d.ts} +7995 -5523
- package/dist/{funnel-node-evaluation-DSSSmXHX.d.ts → funnel-node-evaluation-BLnJp8vj.d.ts} +11 -13
- package/dist/{funnel-process-client-BaHMeArI.d.ts → funnel-process-client-CY-GQ_SF.d.ts} +5498 -4539
- package/dist/funnel-runtime-host-GFTN7KQK.js +1 -0
- package/dist/index.d.ts +1258 -273
- package/dist/index.js +1 -1
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.d.ts +3 -3
- package/dist/openrouter.js +1 -1
- package/dist/page.d.ts +2 -2
- package/dist/page.js +1 -1
- package/dist/paywall-H3KQZEJG.js +1 -0
- package/dist/popup.d.ts +11 -5
- package/dist/popup.js +1 -1
- package/dist/react-native.d.ts +1541 -7
- package/dist/react-native.js +1 -1
- package/dist/{screen-D81zCpfi.d.ts → screen-DRP7nsrQ.d.ts} +613 -357
- package/dist/screen-renderer-IZ3VJGU6.js +1 -0
- package/dist/server.d.ts +717 -9
- package/dist/server.js +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-33FQUT3Z.js +0 -179
- package/dist/chunk-E5ECPR6Z.js +0 -1
- package/dist/chunk-LHA6VWP7.js +0 -1
- package/dist/chunk-MOWYD2TV.js +0 -1
- package/dist/chunk-RQZ42NQJ.js +0 -6
- package/dist/chunk-VSJOHWDL.js +0 -17
- package/dist/chunk-XAHWOLRT.js +0 -1
- package/dist/funnel-runtime-host-WQ64FAME.js +0 -1
- package/dist/paywall-H4YN4FTL.js +0 -1
- package/dist/screen-renderer-NHJ6OQTF.js +0 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{$ as Qt,A as ee,Aa as ct,B as Ge,Ba as gi,C as rt,D as St,E as sr,Ea as Ta,F as Ht,G as ga,H as wn,I as ha,J as ba,K as ya,L as _n,M as xa,N as Sa,O as mi,P as Jt,Q as va,R as Ia,S as Oa,T as ja,U as Aa,V as cr,W as Wt,X as wa,Y as _a,Z as Pn,_ as Pa,a as ci,aa as Ca,b as sa,c as ca,ca as ka,da as Ra,ea as Ea,fa as Ma,g as ie,h as ui,i as ua,ia as ur,j as nt,ja as ft,k as be,l as pi,m as dt,ma as Cn,n as pa,o as ir,oa as gt,p as la,pa as Ke,q as ma,qa as Xt,ra as di,sa as vt,t as or,u as ar,v as da,va as fi,w as li,x as fa,y as An,ya as pr,za as Rt}from"./chunk-PFHS7HK3.js";import{z as g}from"zod";import{z as m}from"zod";var Te=m.string().min(1).max(200),Ve=m.iso.datetime({offset:!0}),je=m.number().int().nonnegative().max(1e8),lr=m.string().regex(/^[A-Z]{3}$/),nl=["purchase.subscription","purchase.one_time","purchase.prepaid","purchase.trial","purchase.seats","purchase.tiered","tax.automatic","discount.percent.once","discount.percent.repeating","discount.percent.forever","discount.amount.once","discount.amount.repeating","discount.amount.forever","subscription.cancel.immediate","subscription.cancel.renewal","subscription.resume","subscription.plan.immediate","subscription.plan.renewal","subscription.seats","subscription.quantity","subscription.billing_cycle","subscription.proration","refund.full","refund.partial","refund.revoke"],Da=m.enum(nl),Ba=m.strictObject({priceId:m.uuid(),productVersionId:m.uuid(),productId:Te,quantity:m.number().int().min(1).max(1e6),unitAmountMinor:je,totalMinor:je,interval:m.enum(["week","month","year","one_off"]),intervalCount:m.number().int().min(1).max(52),kind:m.enum(["fixed","prepaid","seat"]),tiers:m.strictObject({mode:m.enum(["graduated","volume"]),tiers:m.array(m.strictObject({upTo:m.number().int().positive().nullable(),unitAmountMinor:je,flatAmountMinor:je.optional()})).min(2).max(12)}).nullable()}),rl=m.strictObject({grantId:m.uuid(),couponId:m.uuid(),amountMinor:je,terms:m.discriminatedUnion("type",[m.strictObject({type:m.literal("percent"),percentOff:m.number().gt(0).max(100)}),m.strictObject({type:m.literal("amount"),amountOffMinor:je,currency:lr})]),duration:m.discriminatedUnion("type",[m.strictObject({type:m.literal("once")}),m.strictObject({type:m.literal("forever")}),m.strictObject({type:m.literal("repeating"),months:m.number().int().min(1).max(36)})])}),xi={provider:m.literal("merchant"),executor:m.literal("merchant"),operationId:m.uuid(),customerId:m.uuid(),configurationRevision:m.number().int().nonnegative(),connectionRevision:m.number().int().nonnegative(),currency:lr,expiresAt:Ve},mr=m.strictObject({...xi,type:m.literal("purchase"),mode:m.enum(["payment","subscription"]),lineItems:m.array(Ba).min(1).max(100),catalogAmountMinor:je,discount:rl.nullable(),trialPeriodDays:m.number().int().min(1).max(730).nullable(),automaticTax:m.boolean()}).refine(e=>e.lineItems.reduce((t,n)=>t+n.totalMinor,0)===e.catalogAmountMinor&&(!e.discount||e.discount.amountMinor<=e.catalogAmountMinor)&&new Set(e.lineItems.map(t=>t.priceId)).size===e.lineItems.length,"Purchase lines must retain the original total and unique Price identities"),dr=m.strictObject({...xi,type:m.literal("subscription_change"),subscriptionId:m.uuid(),merchantSubscriptionId:Te,membershipId:m.uuid(),subscriptionAction:m.enum(["update","cancel","schedule","release"]),supersedesOperationId:m.uuid().nullable(),change:m.discriminatedUnion("type",[m.strictObject({type:m.literal("cancel")}),m.strictObject({type:m.literal("uncancel")}),m.strictObject({type:m.literal("plan"),productVersionId:m.uuid()}),m.strictObject({type:m.literal("seats"),licenseKey:Te,quantity:m.number().int().nonnegative().max(1e6)}),m.strictObject({type:m.literal("quantity"),internal_feature_id:m.uuid(),quantity:m.number().int().nonnegative().max(1e6)}),m.strictObject({type:m.literal("billing_cycle"),billingCycleAnchor:m.union([m.literal("now"),m.number().int().positive()])})]),timing:m.enum(["immediate","renewal"]),effectiveAt:Ve,creditMinor:je,debitMinor:je,totalMinor:je,discountMinor:je,taxMinor:je,proration:m.enum(["none","create_prorations","always_invoice"]),lineItems:m.array(Ba.extend({quantity:m.number().int().nonnegative().max(1e6)})).max(100),removePriceIds:m.array(m.uuid()).max(100)}),fr=m.strictObject({...xi,type:m.literal("refund"),invoiceId:m.uuid(),merchantInvoiceId:Te,amountMinor:je.refine(e=>e>0),mode:m.enum(["full","partial"]),entitlementAction:m.enum(["retain","revoke"]),cancelSubscriptions:m.array(Te).max(100)}),za=m.discriminatedUnion("type",[mr,dr,fr]);function _g(e){let t=new Set;if(e.type==="purchase")t.add(e.mode==="subscription"?"purchase.subscription":"purchase.one_time"),e.lineItems.some(n=>n.kind==="prepaid")&&t.add("purchase.prepaid"),e.lineItems.some(n=>n.kind==="seat")&&t.add("purchase.seats"),e.lineItems.some(n=>n.tiers!==null)&&t.add("purchase.tiered"),e.trialPeriodDays!==null&&t.add("purchase.trial"),e.automaticTax&&t.add("tax.automatic"),e.discount&&t.add(`discount.${e.discount.terms.type}.${e.discount.duration.type}`);else if(e.type==="refund")t.add(`refund.${e.mode}`),e.entitlementAction==="revoke"&&t.add("refund.revoke");else{let n=e.change.type;n==="cancel"?t.add(`subscription.cancel.${e.timing}`):n==="uncancel"?t.add("subscription.resume"):n==="plan"?t.add(`subscription.plan.${e.timing}`):t.add(`subscription.${n}`),e.proration!=="none"&&t.add("subscription.proration")}return[...t].sort()}function Pg(e){return e.type==="purchase"?e.mode==="subscription"?["purchase.completed","purchase.closed","subscription.observed","invoice.paid"]:["purchase.completed","purchase.closed"]:e.type==="subscription_change"?["subscription.change.completed","subscription.observed",...e.change.type==="cancel"||e.change.type==="uncancel"?[]:["invoice.paid"]]:["refund.updated",...e.entitlementAction==="revoke"&&e.cancelSubscriptions.length?["subscription.observed"]:[]]}var kn=m.strictObject({phase:m.enum(["execution","payment","fulfillment","recording"]),code:ci,reason:ca.optional(),recovery:sa,retryable:m.boolean()}).refine(e=>e.reason!=="RESULT_UNKNOWN"||!e.retryable&&e.recovery==="recover_operation","Unknown financial effects require recovery of the original operation"),hi={operationId:m.uuid(),customerId:m.uuid(),merchantExecutionId:Te,fulfillmentStatus:m.enum(["not_started","pending","applied","failed","not_applicable"]),recordingStatus:m.enum(["not_ready","pending","accepted","failed"]),updatedAt:Ve,problem:kn.nullable(),pollAfterMs:m.number().int().min(1e3).max(6e4).nullable()},Et=m.discriminatedUnion("type",[m.strictObject({...hi,type:m.literal("purchase"),merchantOrderId:Te.nullable(),paymentStatus:m.enum(["not_started","pending","succeeded","not_required","failed","expired","unknown"]),checkoutUrl:m.url().refine(e=>new URL(e).protocol==="https:").nullable(),checkoutExpiresAt:Ve.nullable()}).refine(e=>!e.checkoutUrl||["not_started","pending"].includes(e.paymentStatus)&&e.checkoutExpiresAt!==null,"Only an unfinished original purchase may expose its checkout"),m.strictObject({...hi,type:m.literal("subscription_change"),status:m.enum(["pending","scheduled","applied","failed","unknown"]),merchantSubscriptionId:Te,scheduledFor:Ve.nullable()}).refine(e=>e.status==="scheduled"==(e.scheduledFor!==null),"A scheduled change retains its future effective time"),m.strictObject({...hi,type:m.literal("refund"),status:m.enum(["pending","succeeded","failed","unknown"]),merchantRefundId:Te.nullable()}).refine(e=>e.status!=="succeeded"||e.merchantRefundId!==null,"A successful refund retains its original merchant identity")]),qa=m.discriminatedUnion("lookup",[m.strictObject({lookup:m.literal("found"),operationId:m.uuid(),customerId:m.uuid(),execution:Et,readAt:Ve}),m.strictObject({lookup:m.literal("not_received"),operationId:m.uuid(),customerId:m.uuid(),execution:m.null(),readAt:Ve})]).refine(e=>!e.execution||e.execution.operationId===e.operationId&&e.execution.customerId===e.customerId,"Lookup must retain the original Customer and operation"),bi=m.strictObject({merchantSubscriptionId:Te,revision:m.number().int().positive(),status:m.enum(["incomplete","trialing","active","past_due","canceled","unpaid","paused","incomplete_expired"]),periodStartsAt:Ve,periodEndsAt:Ve,cancelAtPeriodEnd:m.boolean(),hasDiscounts:m.boolean(),items:m.array(m.strictObject({merchantItemId:Te,priceId:m.uuid(),quantity:m.number().int().positive().max(1e6)})).min(1).max(100)}).refine(e=>Date.parse(e.periodEndsAt)>Date.parse(e.periodStartsAt)&&new Set(e.items.map(t=>t.priceId)).size===e.items.length,"Subscription periods and Price identities must be unambiguous"),yi=m.strictObject({merchantInvoiceId:Te,currency:lr,subtotalMinor:je,discountMinor:je,taxMinor:je,totalMinor:je,paidMinor:je,periodStartsAt:Ve.nullable(),periodEndsAt:Ve.nullable(),lines:m.array(m.strictObject({merchantLineId:Te,priceId:m.uuid(),quantity:m.number().int().nonnegative().max(1e6),subtotalMinor:m.number().int().min(-1e8).max(1e8),discountMinor:je,taxMinor:je,totalMinor:m.number().int().min(-1e8).max(2e8),periodStartsAt:Ve.nullable(),periodEndsAt:Ve.nullable()}).refine(e=>e.subtotalMinor-e.discountMinor+e.taxMinor===e.totalMinor&&(e.subtotalMinor<0?e.discountMinor===0&&e.taxMinor===0:e.discountMinor<=e.subtotalMinor),"Invoice line amounts must retain the complete debit or credit")).min(1).max(100)}).refine(e=>e.subtotalMinor-e.discountMinor+e.taxMinor===e.totalMinor&&e.discountMinor<=e.subtotalMinor&&e.paidMinor===e.totalMinor&&new Set(e.lines.map(t=>t.merchantLineId)).size===e.lines.length&&e.lines.reduce((t,n)=>t+n.subtotalMinor,0)===e.subtotalMinor&&e.lines.reduce((t,n)=>t+n.discountMinor,0)===e.discountMinor&&e.lines.reduce((t,n)=>t+n.taxMinor,0)===e.taxMinor&&e.lines.reduce((t,n)=>t+n.totalMinor,0)===e.totalMinor,"A paid Invoice retains the complete financial amounts"),Yt={provider:m.literal("merchant"),eventId:m.string().regex(/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,199}$/),customerId:m.uuid(),occurredAt:Ve},Fa=m.enum(["purchase.completed","purchase.closed","subscription.observed","subscription.change.completed","invoice.paid","refund.updated"]),Na=m.discriminatedUnion("type",[m.strictObject({...Yt,type:m.literal("purchase.completed"),operationId:m.uuid(),merchantOrderId:Te,paymentStatus:m.enum(["paid","trialing","no_payment_required"]),invoice:yi.nullable(),subscription:bi.nullable()}).refine(e=>e.paymentStatus!=="paid"||e.invoice!==null,"A paid purchase includes its Invoice"),m.strictObject({...Yt,type:m.literal("purchase.closed"),operationId:m.uuid(),status:m.enum(["failed","expired","canceled"])}),m.strictObject({...Yt,type:m.literal("subscription.observed"),operationId:m.uuid().nullable(),subscription:bi}),m.strictObject({...Yt,type:m.literal("subscription.change.completed"),operationId:m.uuid(),status:m.enum(["scheduled","applied"]),scheduledFor:Ve.nullable(),subscription:bi,invoice:yi.nullable()}).refine(e=>e.status==="scheduled"==(e.scheduledFor!==null),"Scheduled and applied changes are distinct facts"),m.strictObject({...Yt,type:m.literal("invoice.paid"),merchantSubscriptionId:Te.nullable(),invoice:yi}),m.strictObject({...Yt,type:m.literal("refund.updated"),operationId:m.uuid().nullable(),merchantInvoiceId:Te.optional(),merchantRefundId:Te,status:m.enum(["pending","succeeded","failed"]),amountMinor:je.refine(e=>e>0),currency:lr}).refine(e=>e.operationId!==null||e.merchantInvoiceId!==void 0,"A native refund names its Invoice")]);import{z as Mt}from"zod";var ut=/^gg_ct_[A-Za-z0-9_-]{32,128}$/,en=Mt.object({customerId:Mt.uuid(),sessionId:Mt.uuid(),accessToken:Mt.string().regex(/^gg_ct_[A-Za-z0-9_-]{43}$/),refreshToken:Mt.string().regex(/^gg_rt_[A-Za-z0-9_-]{43}$/),expiresAt:Mt.iso.datetime(),refreshExpiresAt:Mt.iso.datetime()});var tn=3,Va="/integrations/indiana",Dg="X-Indiana-Merchant-Bridge-Version",il=["session","catalog","customer_commerce","presentation","presentation_events","purchases","operation_status","billing_records","subscription_changes","refunds"],ol=g.enum(il),Bg={session:{command:"session.create",authority:"merchant_user"},catalog:{command:"catalog.read",authority:"merchant_catalog_reader"},customer_commerce:{command:"customer.commerce.read",authority:"merchant_user"},presentation:{command:"presentation.resolve",authority:"merchant_user"},presentation_events:{command:"presentation.report",authority:"merchant_user"},purchases:{command:"purchase.execute",authority:"merchant_user"},operation_status:{command:"operation.read",authority:"merchant_user"},billing_records:{command:null,authority:"indiana_server_key"},subscription_changes:{command:"subscription.change",authority:"merchant_user"},refunds:{command:"refund.execute",authority:"merchant_refund_authority"}},$a=g.enum(["bridge.ping","bridge.describe","session.create","catalog.read","customer.commerce.read","presentation.resolve","presentation.report","purchase.execute","operation.read","subscription.change","refund.execute"]),Ga=g.string().regex(/^[A-Za-z0-9_-]{1,64}$/),al=g.string().regex(/^[A-Za-z0-9_-]{43}$/).refine(e=>"AEIMQUYcgkosw048".includes(e.at(-1)),"Use canonical base64url for a 32-byte key"),vi=g.strictObject({keyId:Ga,signingSecret:al}),sl=g.string().max(300).superRefine((e,t)=>{try{let n=new URL(e);if(n.protocol!=="https:"||n.username||n.password||n.search||n.hash||n.pathname!=="/"||n.port&&n.port!=="443"||!/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?\.[a-z]{2,63}$/.test(n.hostname)||/(?:^|\.)(?:localhost|local|internal)$/.test(n.hostname))throw new Error("invalid origin")}catch{t.addIssue({code:"custom",message:"Use an exact public HTTPS origin"})}}).transform(e=>new URL(e).origin),Ka=g.array(ol).max(10).refine(e=>new Set(e).size===e.length,"Capabilities must be unique"),La=g.strictObject({bridgeVersion:g.literal(tn),projectId:g.uuid(),environmentId:g.uuid(),environment:g.enum(["sandbox","live"]),capabilities:Ka,catalog:g.enum(["endpoint","static","none"]),billingEvents:g.array(Fa).max(6),profiles:g.array(Da).max(32).refine(e=>new Set(e).size===e.length,"Profiles must be unique")}).superRefine((e,t)=>{let n=r=>e.capabilities.includes(r);n("catalog")!==(e.catalog!=="none")&&t.addIssue({code:"custom",path:["catalog"],message:"Catalog declaration differs from its capability"}),(n("billing_records")!==e.billingEvents.length>0||new Set(e.billingEvents).size!==e.billingEvents.length)&&t.addIssue({code:"custom",path:["billingEvents"],message:"Declare the unique supported billing events"})}),Za=g.strictObject({origin:sl,requiredCapabilities:Ka}),cl=g.strictObject({revision:g.number().int().nonnegative(),checkedAt:g.iso.datetime(),outcome:g.enum(["valid","unreachable","invalid","scope_mismatch","authentication_failed","credentials_missing"]),diagnostics:g.strictObject({ping:g.enum(["passed","failed","not_checked"]),authentication:g.enum(["passed","failed","not_checked"]),catalog:g.enum(["passed","failed","not_checked","static","unsupported"])}),manifest:La.nullable()}).superRefine((e,t)=>{e.outcome==="valid"!=(e.manifest!==null)&&t.addIssue({code:"custom",path:["manifest"],message:"Only a valid declaration carries a manifest"})}),zg=g.strictObject({projectId:g.uuid(),environmentId:g.uuid(),environment:g.enum(["sandbox","live"]),execution:g.enum(["indiana","record_only"]),accountId:g.string().nullable(),revision:g.number().int().nonnegative(),authentication:g.strictObject({keyId:Ga}).nullable(),secretStoreConfigured:g.boolean().optional(),connection:Za.nullable(),check:cl.nullable()});var Ua=g.strictObject({projectId:g.uuid(),environmentId:g.uuid()}),qg=g.discriminatedUnion("action",[Ua.extend({action:g.literal("save"),revision:g.number().int().nonnegative(),connection:Za,authentication:vi.optional()}),Ua.extend({action:g.literal("check"),revision:g.number().int().nonnegative()})]),hr=g.strictObject({projectId:g.uuid(),environmentId:g.uuid(),environment:g.enum(["sandbox","live"])});function Fg(e){return g.strictObject({bridgeVersion:g.literal(tn),requestId:g.uuid(),command:$a,scope:hr,data:e})}var ul=g.strictObject({nativeUserId:g.string().min(1).max(128),session:en.strict()}),pl=g.strictObject({nativeUserId:g.string().min(1).max(128),presentation:g.strictObject({customerId:g.uuid(),decisionId:g.uuid(),offeringVersionId:g.uuid(),paywallVersionId:g.uuid(),variant:g.string().min(1).max(128)}).nullable()}),ll=g.strictObject({decisionId:g.uuid(),eventId:g.uuid()}),gr=g.strictObject({operationId:g.uuid(),customerId:g.uuid()}),br=g.strictObject({scope:hr,operationId:g.uuid(),customerId:g.uuid(),confirmedAt:g.iso.datetime({offset:!0}).nullable(),initialExecutionAllowed:g.boolean(),instruction:za}).refine(e=>e.operationId===e.instruction.operationId&&e.customerId===e.instruction.customerId,"Authority must refer to the original Customer and operation"),Si=Et,ht=g.string().min(1).max(120),ml=g.string().regex(/^-?[0-9]+(?:\.[0-9]{1,6})?$/),dl=g.strictObject({revision:ht,updatedAt:g.iso.datetime(),provider:g.literal("merchant"),items:g.array(g.strictObject({merchantProductId:ht,productVersionId:g.uuid(),name:g.string().min(1).max(255),kind:g.enum(["subscription","credit_pack"]),merchantPriceId:ht,currency:g.string().regex(/^[a-z]{3}$/),amountMinor:g.number().int().nonnegative().max(1e8),interval:g.enum(["one_time","month","year"]),intervalCount:g.literal(1),includedCredits:g.string().regex(/^[0-9]{1,18}(?:\.[0-9]{1,6})?$/),creditReset:g.enum(["none","month"]),creditPolicyId:ht,available:g.boolean()}).superRefine((e,t)=>{(e.kind==="credit_pack"&&(e.interval!=="one_time"||e.creditReset!=="none")||e.kind==="subscription"&&e.interval==="one_time"||e.available&&e.amountMinor===0)&&t.addIssue({code:"custom",message:"Unsupported version 1 catalog terms"})})).max(500)}),fl=g.strictObject({customerId:g.uuid(),revision:g.string().min(1).max(128),observedAt:g.iso.datetime(),subscriptions:g.array(g.strictObject({merchantSubscriptionId:ht,merchantProductId:ht,productVersionId:g.uuid().nullable(),status:g.enum(["active","trialing","past_due","cancelled","expired"]),currentPeriodStartsAt:g.iso.datetime().nullable(),currentPeriodEndsAt:g.iso.datetime().nullable(),cancelAtPeriodEnd:g.boolean(),scheduledChange:g.strictObject({effectiveAt:g.iso.datetime(),merchantProductId:ht}).nullable()})).max(100),purchaseHistory:g.strictObject({complete:g.boolean(),hasPaidPurchase:g.boolean(),lastPaidAt:g.iso.datetime().nullable()}),balances:g.array(g.strictObject({bucketId:ht,key:ht,available:ml,expiresAt:g.iso.datetime().nullable(),nextResetAt:g.iso.datetime().nullable()})).max(100)}),Ng=g.strictObject({bridgeVersion:g.literal(tn),requestId:g.uuid(),command:g.string().min(1).max(64),scope:hr,error:g.strictObject({code:g.string().regex(/^MERCHANT_BRIDGE_[A-Z_]+$/),message:g.string().min(1).max(500),retryable:g.boolean(),recovery:g.string().min(1).max(80)})}),Rn=g.strictObject({}),gl={"bridge.ping":g.strictObject({challenge:g.uuid()}),"bridge.describe":Rn,"session.create":Rn,"catalog.read":Rn,"customer.commerce.read":Rn,"presentation.resolve":Rn,"presentation.report":ll,"purchase.execute":gr,"operation.read":gr,"subscription.change":gr,"refund.execute":gr},Ug={"bridge.ping":g.strictObject({challenge:g.uuid()}),"bridge.describe":La,"session.create":ul,"catalog.read":dl,"customer.commerce.read":fl,"presentation.resolve":pl,"presentation.report":g.strictObject({queued:g.literal(!0)}),"purchase.execute":Si,"operation.read":qa,"subscription.change":Si,"refund.execute":Si},Vg=g.strictObject({bridgeVersion:g.literal(tn),requestId:g.uuid(),scope:hr,command:$a,data:g.unknown()}).superRefine((e,t)=>{gl[e.command].safeParse(e.data).success||t.addIssue({code:"custom",path:["data"],message:"Invalid command data"})});var Ha="X-Indiana-Bridge-Signature",Ja="X-Indiana-Bridge-Key-Id";function hl(e){return new TextEncoder().encode(e)}function Wa(e){return Uint8Array.from(atob(e.replaceAll("-","+").replaceAll("_","/")),t=>t.charCodeAt(0))}function Qa(e,t,n){return hl(`indiana-merchant-bridge:${tn}
|
|
2
|
+
${t}
|
|
3
|
+
POST
|
|
4
|
+
${Va}
|
|
5
|
+
${n}
|
|
6
|
+
${e}`)}async function Xa(e){let t=vi.parse(e);return crypto.subtle.importKey("raw",Wa(t.signingSecret),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"])}async function Kg(e,t,n,r=Date.now()){let o=String(Math.floor(r/1e3)),a=new Uint8Array(await crypto.subtle.sign("HMAC",await Xa(t),Qa(e,n,o))),l=btoa(String.fromCharCode(...a)).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"");return{[Ja]:t.keyId,[Ha]:`t=${o},v1=${l}`}}async function Lg(e,t,n,r,o=Date.now()){try{if(t.get(Ja)!==n.keyId)return!1;let a=/^t=([0-9]{1,12}),v1=([A-Za-z0-9_-]{43})$/.exec(t.get(Ha)??"");return!a||Math.abs(o/1e3-Number(a[1]))>300?!1:await crypto.subtle.verify("HMAC",await Xa(n),Wa(a[2]),Qa(e,r,a[1]))}catch{return!1}}var Ya={"zh-Hans":{merchandise:"\u51CF {discount}\uFF08\u5355\u6B21\u4F7F\u7528\uFF09",once:"\u9996\u671F\u51CF {discount}",repeating:"\u524D {months} \u4E2A\u6708\u6BCF\u6708\u51CF {discount}",forever:"\u6BCF\u671F\u51CF {discount}"},"zh-Hant":{merchandise:"\u6E1B {discount}\uFF08\u55AE\u6B21\u4F7F\u7528\uFF09",once:"\u9996\u671F\u6E1B {discount}",repeating:"\u524D {months} \u500B\u6708\u6BCF\u6708\u6E1B {discount}",forever:"\u6BCF\u671F\u6E1B {discount}"},en:{merchandise:"{discount} off \xB7 one use",once:"{discount} off your first payment",repeating:"{discount} off each month for the first {months} months",repeatingOne:"{discount} off the first month",forever:"{discount} off every payment"},ja:{merchandise:"{discount} \u5272\u5F15\uFF081\u56DE\u306E\u307F\uFF09",once:"\u521D\u56DE\u306E\u304A\u652F\u6255\u3044\u304C {discount} \u5272\u5F15",repeating:"\u6700\u521D\u306E {months} \u304B\u6708\u9593\u3001\u6BCE\u6708 {discount} \u5272\u5F15",forever:"\u6BCE\u56DE\u306E\u304A\u652F\u6255\u3044\u304C {discount} \u5272\u5F15"},ko:{merchandise:"{discount} \uD560\uC778 \xB7 1\uD68C \uC0AC\uC6A9",once:"\uCCAB \uACB0\uC81C {discount} \uD560\uC778",repeating:"\uCCAB {months}\uAC1C\uC6D4 \uB3D9\uC548 \uB9E4\uC6D4 {discount} \uD560\uC778",forever:"\uB9E4 \uACB0\uC81C {discount} \uD560\uC778"},es:{merchandise:"{discount} de descuento \xB7 un uso",once:"{discount} de descuento en el primer pago",repeating:"{discount} de descuento cada mes durante los primeros {months} meses",forever:"{discount} de descuento en cada pago",repeatingOne:"{discount} de descuento durante el primer mes"},fr:{merchandise:"{discount} de r\xE9duction \xB7 une utilisation",once:"{discount} de r\xE9duction sur le premier paiement",repeating:"{discount} de r\xE9duction par mois pendant les {months} premiers mois",forever:"{discount} de r\xE9duction sur chaque paiement",repeatingOne:"{discount} de r\xE9duction pendant le premier mois"},de:{merchandise:"{discount} Rabatt \xB7 einmalig",once:"{discount} Rabatt auf die erste Zahlung",repeating:"{discount} Rabatt pro Monat f\xFCr die ersten {months} Monate",forever:"{discount} Rabatt auf jede Zahlung",repeatingOne:"{discount} Rabatt im ersten Monat"},pt:{merchandise:"{discount} de desconto \xB7 um uso",once:"{discount} de desconto no primeiro pagamento",repeating:"{discount} de desconto por m\xEAs nos primeiros {months} meses",forever:"{discount} de desconto em cada pagamento",repeatingOne:"{discount} de desconto no primeiro m\xEAs"},it:{merchandise:"{discount} di sconto \xB7 un utilizzo",once:"{discount} di sconto sul primo pagamento",repeating:"{discount} di sconto al mese per i primi {months} mesi",forever:"{discount} di sconto su ogni pagamento",repeatingOne:"{discount} di sconto per il primo mese"},ru:{merchandise:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \xB7 \u043E\u0434\u043D\u043E \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0435",once:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043D\u0430 \u043F\u0435\u0440\u0432\u044B\u0439 \u043F\u043B\u0430\u0442\u0451\u0436",repeating:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043A\u0430\u0436\u0434\u044B\u0439 \u043C\u0435\u0441\u044F\u0446 \u0432 \u0442\u0435\u0447\u0435\u043D\u0438\u0435 \u043F\u0435\u0440\u0432\u044B\u0445 {months} \u043C\u0435\u0441.",repeatingOne:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u0432 \u043F\u0435\u0440\u0432\u044B\u0439 \u043C\u0435\u0441\u044F\u0446",forever:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043D\u0430 \u043A\u0430\u0436\u0434\u044B\u0439 \u043F\u043B\u0430\u0442\u0451\u0436"},vi:{merchandise:"Gi\u1EA3m {discount} \xB7 d\xF9ng m\u1ED9t l\u1EA7n",once:"Gi\u1EA3m {discount} cho l\u1EA7n thanh to\xE1n \u0111\u1EA7u ti\xEAn",repeating:"Gi\u1EA3m {discount} m\u1ED7i th\xE1ng trong {months} th\xE1ng \u0111\u1EA7u",forever:"Gi\u1EA3m {discount} cho m\u1ED7i l\u1EA7n thanh to\xE1n"},th:{merchandise:"\u0E25\u0E14 {discount} \xB7 \u0E43\u0E0A\u0E49\u0E44\u0E14\u0E49\u0E04\u0E23\u0E31\u0E49\u0E07\u0E40\u0E14\u0E35\u0E22\u0E27",once:"\u0E25\u0E14 {discount} \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E0A\u0E33\u0E23\u0E30\u0E40\u0E07\u0E34\u0E19\u0E04\u0E23\u0E31\u0E49\u0E07\u0E41\u0E23\u0E01",repeating:"\u0E25\u0E14 {discount} \u0E15\u0E48\u0E2D\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E43\u0E19\u0E0A\u0E48\u0E27\u0E07 {months} \u0E40\u0E14\u0E37\u0E2D\u0E19\u0E41\u0E23\u0E01",forever:"\u0E25\u0E14 {discount} \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E0A\u0E33\u0E23\u0E30\u0E40\u0E07\u0E34\u0E19\u0E17\u0E38\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07"},id:{merchandise:"Diskon {discount} \xB7 sekali pakai",once:"Diskon {discount} untuk pembayaran pertama",repeating:"Diskon {discount} setiap bulan selama {months} bulan pertama",forever:"Diskon {discount} untuk setiap pembayaran"},ar:{merchandise:"\u062E\u0635\u0645 {discount} \xB7 \u0627\u0633\u062A\u062E\u062F\u0627\u0645 \u0648\u0627\u062D\u062F",once:"\u062E\u0635\u0645 {discount} \u0639\u0644\u0649 \u0627\u0644\u062F\u0641\u0639\u0629 \u0627\u0644\u0623\u0648\u0644\u0649",repeating:"\u062E\u0635\u0645 {discount} \u0634\u0647\u0631\u064A\u064B\u0627 \u0644\u0645\u062F\u0629 {period}",forever:"\u062E\u0635\u0645 {discount} \u0639\u0644\u0649 \u0643\u0644 \u062F\u0641\u0639\u0629"}};function Ii(e){let t=ga(e)??"en",n=t.split("-"),r=n[0]==="zh"?n.includes("Hans")?"zh-Hans":n.includes("Hant")||n.some(a=>["TW","HK","MO"].includes(a))?"zh-Hant":"zh-Hans":n[0]??"en",o=Ya[r];return o?{locale:t,copy:o}:{locale:"en",copy:Ya.en}}function bl(e,t,n="zh-CN"){let r=ui(t);return ua(e,t,Ii(n).locale,{currencyDisplay:"narrowSymbol",minimumFractionDigits:e%10**r===0?0:r,maximumFractionDigits:r})}function yl(e,t="zh-CN"){let n=Ii(t).locale;return e.type==="percent"?new Intl.NumberFormat(n,{style:"percent",maximumFractionDigits:2}).format(e.percentOff/100):bl(e.amountOffCents,e.currency,n)}var es={zh:"\u524D {months} \u4E2A\u6708\u5185\u5F00\u51FA\u7684\u8D26\u5355\u51CF {discount}","zh-Hant":"\u524D {months} \u500B\u6708\u5167\u958B\u51FA\u7684\u5E33\u55AE\u6E1B {discount}",en:"{discount} off invoices issued within the first {months} months",ja:"\u6700\u521D\u306E {months} \u304B\u6708\u4EE5\u5185\u306E\u8ACB\u6C42\u304C {discount} \u5272\u5F15",ko:"\uCCAB {months}\uAC1C\uC6D4 \uB0B4 \uCCAD\uAD6C\uC11C {discount} \uD560\uC778",es:"{discount} de descuento en facturas emitidas durante los primeros {months} meses",fr:"{discount} de r\xE9duction sur les factures \xE9mises pendant les {months} premiers mois",de:"{discount} Rabatt auf Rechnungen innerhalb der ersten {months} Monate",pt:"{discount} de desconto nas faturas emitidas nos primeiros {months} meses",it:"{discount} di sconto sulle fatture emesse nei primi {months} mesi",ru:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043D\u0430 \u0441\u0447\u0435\u0442\u0430 \u0432 \u0442\u0435\u0447\u0435\u043D\u0438\u0435 \u043F\u0435\u0440\u0432\u044B\u0445 {months} \u043C\u0435\u0441.",vi:"Gi\u1EA3m {discount} cho h\xF3a \u0111\u01A1n trong {months} th\xE1ng \u0111\u1EA7u",th:"\u0E25\u0E14 {discount} \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E43\u0E1A\u0E41\u0E08\u0E49\u0E07\u0E2B\u0E19\u0E35\u0E49\u0E43\u0E19\u0E0A\u0E48\u0E27\u0E07 {months} \u0E40\u0E14\u0E37\u0E2D\u0E19\u0E41\u0E23\u0E01",id:"Diskon {discount} untuk tagihan dalam {months} bulan pertama",ar:"\u062E\u0635\u0645 {discount} \u0639\u0644\u0649 \u0627\u0644\u0641\u0648\u0627\u062A\u064A\u0631 \u0627\u0644\u0635\u0627\u062F\u0631\u0629 \u062E\u0644\u0627\u0644 \u0623\u0648\u0644 {period}"};function Wg(e,t="zh-CN",n="month"){let r=Ii(t),o=yl(e.discount,r.locale);if(e.appliesTo?.type==="merchandise")return r.copy.merchandise.replace("{discount}",o);let a=e.duration.type==="repeating"?new Intl.NumberFormat(r.locale).format(e.duration.months):"",l=r.locale.split("-")[0]??"en",p=l==="zh"&&/(?:Hant|TW|HK|MO)/.test(r.locale)?"zh-Hant":l,d=e.duration.type==="repeating"&&n!=="month"?es[p]??es.en:e.duration.type==="repeating"&&e.duration.months===1?r.copy.repeatingOne??r.copy.repeating:r.copy[e.duration.type],v=e.duration.type==="repeating"?new Intl.NumberFormat(r.locale,{style:"unit",unit:"month",unitDisplay:"long"}).format(e.duration.months):"";return d.replace("{discount}",o).replace("{months}",a).replace("{period}",v)}import{z as W}from"zod";import{z as De}from"zod";var Ae=De.string().min(1).max(255).regex(/^[A-Za-z0-9_][A-Za-z0-9_.:-]*$/).refine(e=>e.split(".").every(t=>t.length>0&&!["__proto__","constructor","prototype"].includes(t)),"Reserved or empty variable path"),Oi=De.strictObject({type:De.enum(["string","number","boolean","strings","json","offering_version","reward","paywall_version"]),nullable:De.boolean(),enum:De.array(De.string().max(255)).min(1).max(100).optional()}),nn=Oi.extend({type:De.enum([...Oi.shape.type.options,"array"]),items:Oi.optional()}).superRefine((e,t)=>{(e.type==="array"!=!!e.items||e.enum&&e.type!=="string"||e.items?.enum&&e.items.type!=="string")&&t.addIssue({code:"custom",message:"Array requires items; only strings support enum"})}),rn=nn.safeExtend({source:De.discriminatedUnion("type",[De.strictObject({type:De.literal("input")}),De.strictObject({type:De.literal("node")}),De.strictObject({type:De.enum(["parameter","attribute"]),key:Ae})])}),xl=De.record(Ae,rn),yr=De.record(Ae,Ae).refine(e=>Object.keys(e).length<=20);function Qe(e,t){return e?t===null?e.nullable:e.enum&&(typeof t!="string"||!e.enum.includes(t))?!1:e.type==="array"?Array.isArray(t)&&t.length<=100&&!!e.items&&t.every(n=>Qe(e.items,n)):["offering_version","reward","paywall_version"].includes(e.type)?typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===2&&t.type===e.type&&De.uuid().safeParse(t.id).success:e.type==="json"||(e.type==="strings"?Array.isArray(t)&&t.every(n=>typeof n=="string"):typeof t===e.type):!1}function ji(e,t){return e.nullable&&!t.nullable?!1:t.type==="json"?!0:e.type!==t.type||t.enum&&(!e.enum||e.enum.some(n=>!t.enum.includes(n)))?!1:e.type!=="array"||!!e.items&&!!t.items&&ji(e.items,t.items)}function En(e,t){let n={};for(let[r,o]of Object.entries(e)){let a=o.source,l=a.type==="input"?t.answers:a.type==="node"?t.results??{}:a.type==="parameter"?t.parameters:t.attributes,p=a.type==="parameter"||a.type==="attribute"?a.key:r,d=Object.hasOwn(l,p),v=l[p];if(a.type==="attribute"&&p.includes(".")&&(!d||p.startsWith("merchandise."))){v=l,d=!0;for(let h of p.split(".")){if(!v||typeof v!="object"||!Object.hasOwn(v,h)||Array.isArray(v)&&(!/^(0|[1-9]\d*)$/.test(h)||Number(h)>=v.length)){d=!1;break}v=v[h]}}if(!(!d||v===void 0)){if(!Qe(o,v))throw new Error(`Invalid variable value: ${r}`);n[r]=v}}return n}function Tt(e,t){let n={};for(let[r,o]of Object.entries(e.writes??{})){if(!Object.hasOwn(t,r))throw new Error(`Node output is missing: ${r}`);if(Object.hasOwn(n,o))throw new Error("Node outputs cannot overwrite one another");n[o]=t[r]}return n}function Ai(e,t,n){let r=new Set(Object.values(t.writes??{}));for(let[o,a]of Object.entries(n))if(!r.has(o)||e[o]?.source.type!=="node"||!Qe(e[o],a))throw new Error(`Invalid node variable write: ${o}`);if(r.size!==Object.keys(n).length)throw new Error("Node output is incomplete")}import{z as Dt}from"zod";var it=Dt.string().min(1).max(255).regex(/^[a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+){0,9}$/).refine(e=>e.split(".").every(t=>!["__proto__","constructor","prototype"].includes(t)),"Reserved value path"),pt=Dt.discriminatedUnion("source",[Dt.strictObject({source:Dt.literal("literal"),value:ee}),Dt.strictObject({source:Dt.literal("variable"),key:Dt.string().min(1).max(255),path:it.optional()})]);function ts(e,t){if(!t)return e;for(let n of it.parse(t).split(".")){if(Array.isArray(e)){if(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=e.length)return;e=e[Number(n)];continue}if(e===null||typeof e!="object"||!Object.hasOwn(e,n))return;e=Reflect.get(e,n)}return e}function wi(e,t){if(e.source==="literal")return structuredClone(e.value);let n=En(t.declarations,t);if(!Object.hasOwn(n,e.key))throw new Error("Capability input is missing");return structuredClone(ee.parse(ts(n[e.key],e.path)))}function _i(e,t){let n=[...t].sort((o,a)=>a.length-o.length).find(o=>e===o||e.startsWith(o+"."));if(!n)return null;let r=e===n?void 0:e.slice(n.length+1);return r&&!it.safeParse(r).success?null:{key:n,path:r}}function Pi(e){let t=Object.values(e.strings.locales).flatMap(n=>Object.values(n));return gt(e,n=>{n.type==="custom_html"&&t.push(...Object.values(n.html))}),[...new Set(t.flatMap(Ca))]}function xr(e){return Pi(e).filter(t=>t.startsWith("variables.")).map(t=>t.slice(10))}function Le(e){let t=JSON.stringify(e);if(t===void 0)throw new TypeError("A JSON value is required");let n=new TextEncoder().encode(t).length,r=!1;for(let o=0;o<t.length;o++){let a=t.charAt(o);if(r)a==="\\"?o++:a==='"'&&(r=!1);else if(a==='"')r=!0;else if(a===":"||a===",")n++;else if(a==="-"||a>="0"&&a<="9"){let l=o;for(;o+1<t.length&&/[0-9.eE+-]/.test(t.charAt(o+1));)o++;let p=t.slice(l,o+1);if(!/[eE]/.test(p))continue;let[d="",v]=p.split(/[eE]/),h=d.replace(/^-/,""),T=h.replace(".","").length,$=(h.includes(".")?h.indexOf("."):T)+Number(v),C=$<=0?2-$+T:$>=T?$:T+1;n+=C+(d.startsWith("-")?1:0)-p.length}}return n}var It=W.enum(["page","popup","banner"]),Sl=3e5,ns=W.strictObject({type:W.enum(["string","number","boolean","strings","json"]),nullable:W.boolean()}),vl=W.strictObject({inputs:W.record(Cn,ns.extend({required:W.boolean()})).refine(e=>Object.keys(e).length<=40,"Too many content inputs"),outputs:W.record(Cn,ns).refine(e=>Object.keys(e).length<=40,"Too many content outputs")}),Il=W.strictObject({kind:It,schemaVersion:W.literal(1),name:W.string().trim().min(1).max(80),screen:Ke,contract:vl}),Sr=Il.superRefine((e,t)=>{let n=(o,a)=>t.addIssue({code:"custom",message:o,path:a});e.screen.surface!==e.kind&&n("Content surface must match its domain",["screen","surface"]),e.screen.name!==e.name&&n("Content has one editable name",["screen","name"]),e.kind==="banner"&&e.screen.presentation.type!=="inline"&&n("Banner requires an inline container",["screen","presentation"]),e.kind!=="banner"&&e.screen.presentation.type==="inline"&&n("Inline presentation belongs to Banner",["screen","presentation"]),e.screen.actions.some(o=>o.type!=="event"&&o.type!=="navigate")&&n("Content actions must emit host intents or navigate locally",["screen","actions"]);let r=new Set(e.screen.actions.filter(o=>o.type==="event").map(o=>o.id));(Object.keys(e.contract.outputs).some(o=>!r.has(o))||[...r].some(o=>!Object.hasOwn(e.contract.outputs,o)))&&n("Every event needs exactly one output declaration",["contract","outputs"]),Le(e)>Sl&&n("Content document exceeds its byte budget",[])});function Ol(e,t){if(e===null)return t.nullable;switch(t.type){case"json":return!0;case"string":return typeof e=="string";case"number":return typeof e=="number"&&Number.isFinite(e);case"boolean":return typeof e=="boolean";case"strings":return Array.isArray(e)&&e.every(n=>typeof n=="string")}}var jl=Sr.superRefine((e,t)=>{for(let n of xr(e.screen))Object.keys(e.contract.inputs).some(r=>n===r||n.startsWith(r+"."))||t.addIssue({code:"custom",path:["contract","inputs"],message:"Declare every reusable input read"});for(let n of e.screen.actions){if(n.type!=="event")continue;let r=e.contract.outputs[n.id],o=Object.hasOwn(n.properties,"value")?n.properties.value:n.properties;r&&!Ol(o,r)&&t.addIssue({code:"custom",path:["contract","outputs",n.id],message:"Action value differs from its declared type"})}vt(e.screen).some(n=>!n.complete)&&t.addIssue({code:"custom",path:["screen","strings"],message:"Content needs complete localized copy"})}),rs=W.strictObject({id:W.uuid(),kind:It,projectId:W.uuid(),environmentId:W.uuid(),name:W.string(),revision:W.number().int().nonnegative(),status:W.enum(["draft","published","archived"]),publishedVersionId:W.uuid().nullable(),createdAt:W.iso.datetime({offset:!0}),updatedAt:W.iso.datetime({offset:!0})}),fh=rs.extend({draft:Sr}),gh=W.strictObject({rows:W.array(rs).max(200),nextCursor:W.uuid().nullable()}),Ci=W.strictObject({id:W.uuid(),kind:It,resourceId:W.uuid(),projectId:W.uuid(),environmentId:W.uuid(),version:W.number().int().positive(),sourceRevision:W.number().int().nonnegative(),document:jl,createdAt:W.iso.datetime({offset:!0})}),hh=Ci.omit({document:!0}),bh=W.discriminatedUnion("action",[W.strictObject({action:W.literal("create"),kind:It,id:W.uuid(),document:Sr}),W.strictObject({action:W.literal("save"),kind:It,id:W.uuid(),revision:W.number().int().nonnegative(),document:Sr}),W.strictObject({action:W.enum(["publish","archive"]),kind:It,id:W.uuid(),revision:W.number().int().nonnegative()})]).superRefine((e,t)=>{"document"in e&&e.document.kind!==e.kind&&t.addIssue({code:"custom",path:["document","kind"],message:"Content cannot change domain"})});import{z as on}from"zod";var vr=on.strictObject({items:on.array(on.strictObject({productVersionId:on.string().min(1).max(200),label:on.string().trim().max(40)})).max(20).refine(e=>new Set(e.map(t=>t.productVersionId)).size===e.length,"Duplicate Paywall Product"),defaultProductVersionId:on.string().min(1).max(200).nullable(),grouping:Ra.optional()});function vh(e,t,n){let r=e.type==="fixed"?e.productVersionId:t[e.pickerId];return typeof r!="string"||!Object.values(n.plans).some(o=>o.versionId===r&&o.available)||e.type==="picker"&&(!e.allowedProductVersionIds.includes(r)||!n.pickers[e.pickerId]?.options.includes(r))?null:r}import{z as ki}from"zod";var Al=ki.enum(["sandbox","live"]),le=ki.object({projectId:ki.string().min(1),environment:Al}).strict();import{z as ce}from"zod";var Mn=ce.number().int().min(1).max(Number.MAX_SAFE_INTEGER),is=ce.enum(["unknown","denied","provisional","granted"]),os=ce.enum(["ios","android"]),Ir=ce.strictObject({installationId:ce.uuid(),publicKey:ce.string().regex(/^[A-Za-z0-9_-]{80,200}$/),issuedAt:ce.iso.datetime({offset:!0}),signature:ce.string().regex(/^[A-Za-z0-9_-]{86}$/)}),Ri=ce.string().regex(/^[a-f0-9]{64}$/),as=Ir.extend({sequence:Mn,platform:os,credentialDigest:Ri}),ss=Ir.extend({credentialDigest:Ri}),wh=Ir.extend({sequence:Mn,platform:os}),Or=Ir.extend({sequence:Mn,credentialDigest:Ri,connectionId:ce.uuid().nullable(),kind:ce.enum(["fcm_token","apns_token"]).nullable(),token:ce.string().regex(/^[\x21-\x7e]{16,4096}$/).nullable(),permission:is}),_h=Or,Ph=Or.extend({challenge:ce.string().regex(/^[A-Za-z0-9_-]{100,3500}$/)}),Ch=ce.strictObject({requested:ce.literal(!0),expiresAt:ce.iso.datetime({offset:!0})}),jr=ce.strictObject({installationId:ce.uuid(),bound:ce.boolean(),identitySeq:Mn,bindingGeneration:Mn,addressSeq:ce.number().int().min(0).max(Number.MAX_SAFE_INTEGER),addressRevision:ce.number().int().min(0).max(Number.MAX_SAFE_INTEGER),connectionId:ce.uuid().nullable(),addressStatus:ce.enum(["active","invalid"]).nullable(),permission:is}),Ei=ce.strictObject({channel:ce.enum(["email","sms","voice","push"]),state:ce.enum(["unknown","allowed","denied"]),revision:ce.number().int().min(0).max(Number.MAX_SAFE_INTEGER),updatedAt:ce.iso.datetime({offset:!0}).nullable()}),kh=ce.strictObject({state:ce.enum(["allowed","denied"]),revision:ce.number().int().min(0).max(Number.MAX_SAFE_INTEGER-1)});function Rh(e,t,n){let r=["indiana_push_v1",e,t.projectId,t.environment,n.installationId,n.publicKey,n.issuedAt];e==="bind"?r.push(n.sequence,n.platform,n.credentialDigest):e==="detach"?r.push(n.sequence,n.platform):e==="read"?r.push(n.credentialDigest):r.push(n.sequence,n.credentialDigest,n.connectionId,n.kind,n.token,n.permission),e==="recovery_confirm"&&r.push(n.challenge);let o=JSON.stringify(r);if([...o].some(a=>a.charCodeAt(0)>127))throw new Error("Push proof fields must be ASCII");return Uint8Array.from(o,a=>a.charCodeAt(0))}var Mh="X-Indiana-Protocol",Th="X-Indiana-SDK-Version";var Dh={current:"0.10"};import{z as an}from"zod";var Ar=an.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/,"ID \u4F7F\u7528\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u4E0B\u5212\u7EBF\uFF0C\u5E76\u4EE5\u5B57\u6BCD\u5F00\u5934"),Fh=an.object({amountCents:an.number().int().min(0).max(1e8),currency:ie,interval:an.enum(["free","month","year"]),currencyOptions:an.partialRecord(ie,an.number().int().min(1).max(1e8)).optional()}).refine(e=>e.interval==="free"?e.amountCents===0:e.amountCents>0,"\u514D\u8D39\u5957\u9910\u91D1\u989D\u5FC5\u987B\u4E3A 0\uFF0C\u4ED8\u8D39\u91D1\u989D\u5FC5\u987B\u5927\u4E8E 0").refine(e=>!e.currencyOptions||!Object.hasOwn(e.currencyOptions,e.currency)&&(e.interval!=="free"||Object.keys(e.currencyOptions).length===0),"\u9644\u52A0\u5E01\u79CD\u4E0D\u80FD\u91CD\u590D\u9ED8\u8BA4\u5E01\u79CD\uFF1B\u514D\u8D39\u5957\u9910\u4E0D\u8BBE\u7F6E\u9644\u52A0\u4EF7\u683C");import{z as y}from"zod";var wl=y.string().min(1).regex(/^[a-zA-Z0-9_-]+$/),ps=y.enum(["single_use","continuous_use"]),Mi=y.record(y.string(),y.union([y.string(),y.number(),y.boolean()]).transform(String).pipe(y.string())),cs=y.string().min(1).max(64).refine(e=>!e.includes("::")),ls={credit_amount:y.number(),tier_behavior:y.never().optional(),tiers:y.never().optional()},ms={credit_amount:y.never().optional(),tier_behavior:y.literal("graduated"),tiers:y.array(y.strictObject({to:y.union([y.number(),y.literal("inf")]),credit_amount:y.number()}))},_l=y.union([y.strictObject({match:Mi,priority:y.number().int().optional(),...ls}),y.strictObject({match:Mi,priority:y.number().int().optional(),...ms})]),Pl=y.strictObject({match:Mi,factor:y.number().positive().optional(),add:y.number().optional()}).refine(e=>e.factor!==void 0||e.add!==void 0),us={metered_feature_id:y.string(),feature_amount:y.number().optional(),dimensions:y.record(cs,_l).optional(),multipliers:y.record(cs,Pl).optional()},Ti=y.union([y.strictObject({...us,...ls}),y.strictObject({...us,...ms})]),_r=y.number().min(-100),ds=y.record(y.string(),y.strictObject({markup:_r})).nullish(),Pr=y.record(y.string().regex(/.+\/.+/),y.strictObject({markup:_r.optional(),input_cost:y.number().min(0).optional(),output_cost:y.number().min(0).optional()})).nullish(),Cl=y.strictObject({default_markup:_r.optional(),provider_markups:ds,model_markups:Pr}),Vh=y.strictObject({schema:y.array(Ti).optional(),markups:Cl.optional()}),kl=y.strictObject({filters:y.array(y.strictObject({property:y.string(),operator:y.string(),value:y.array(y.string())})),aggregate:y.strictObject({type:y.string(),property:y.string().nullable()}),usage_type:ps}),fs=y.strictObject({schema:y.array(Ti).min(1).refine(e=>new Set(e.map(t=>t.metered_feature_id)).size===e.length,"Credit rates must name each metered feature once"),invoice_credit:y.boolean().optional(),usage_type:ps.default("single_use").overwrite(()=>"single_use"),default_markup:_r.optional(),provider_markups:ds}),Di=fs.safeExtend({schema:y.array(Ti).length(0)}),wr={id:wl,name:y.string().min(1),display:y.strictObject({singular:y.string().optional(),plural:y.string().optional()}).nullish(),event_names:y.array(y.string()).default([]),model_markups:Pr,stripe_meter:y.strictObject({id:y.string(),event_name:y.string()}).nullish(),stripe_product_id:y.string().nullish()},Bi=e=>y.discriminatedUnion("type",[y.strictObject({...wr,...e,type:y.literal("boolean"),config:y.null()}),y.strictObject({...wr,...e,type:y.literal("metered"),config:kl}),y.strictObject({...wr,...e,type:y.literal("credit_system"),config:fs}),y.strictObject({...wr,...e,type:y.literal("ai_credit_system"),config:Di})]),$h=Bi({}),Rl=y.strictObject({id:y.boolean(),type:y.boolean(),usage_type:y.boolean()}),El={internal_id:y.uuid(),org_id:y.uuid(),created_at:y.number(),env:y.enum(["sandbox","live"]),archived:y.boolean(),project_id:y.uuid(),environment_id:y.uuid(),revision:y.number().int().nonnegative(),update_rules:Rl},gs=Bi(El),Gh=y.strictObject({rows:y.array(gs).max(200),nextCursor:y.uuid().nullable()}),Kh=y.strictObject({features:y.array(gs).max(500),limited:y.boolean()}),Lh=y.union([Bi({action:y.literal("save"),internal_id:y.uuid().nullable(),revision:y.number().int().nonnegative()}),y.strictObject({action:y.enum(["archive","restore","delete"]),internal_id:y.uuid(),revision:y.number().int().nonnegative()})]);import{z as s}from"zod";import{z as M}from"zod";import{z as ke}from"zod";function Ot(e){let t=new Set,n=a=>a!==null&&typeof a=="object"&&!Array.isArray(a);function r(a,l){if(n(a))for(let[p,d]of Object.entries(a))p==="$elemMatch"?o(d,l):p==="$not"?r(d,l):p==="$all"&&Array.isArray(d)&&d.forEach(v=>r(v,l))}function o(a,l=""){if(n(a)){for(let[p,d]of Object.entries(a))if(["$and","$or","$nor"].includes(p)&&Array.isArray(d))d.forEach(v=>o(v,l));else if(p==="$not")o(d,l);else if(p==="$savedGroup"&&n(d))typeof d.attributeKey=="string"&&t.add(d.attributeKey);else if(!p.startsWith("$")){let v=l?`${l}.${p}`:p;t.add(v),r(d,v)}}}return o(e),[...t]}var Ml=ke.enum(["active","inactive"]),Tl=ke.preprocess((e,t)=>{let n=0;function r(o,a){if(!(++n>1e4||a>20)){if(Array.isArray(o))o.forEach(l=>r(l,a+1));else if(o&&typeof o=="object")for(let[l,p]of Object.entries(o))["__proto__","constructor","prototype"].includes(l)&&t.addIssue({code:"custom",message:"Reserved merchandise attribute"}),r(p,a+1)}}return r(e,0),e},Ge),Dl=ke.strictObject({id:ke.string().trim().min(1).max(255),name:ke.string().trim().min(1).max(255),status:Ml,metadata:Tl}),Xh=Dl.extend({internal_id:ke.uuid(),project_id:ke.uuid(),environment_id:ke.uuid(),created_at:ke.iso.datetime({offset:!0}),updated_at:ke.iso.datetime({offset:!0})}),bs=ke.union([ke.strictObject({id:ke.string().trim().min(1).max(255)}),ke.strictObject({internalId:ke.uuid()})]),Yh=ke.enum(["customer","merchandise","context"]),eb=ke.enum(["system","stored","request"]),tb=ke.enum(["customer","merchandise","mixed"]),hs=e=>e==="merchandiseId"||e==="merchandise"||e.startsWith("merchandise.");function zi(e,t={},n=new Set){if(Ot(e).some(hs))return!0;for(let r of St(e)){if(n.has(r))continue;n.add(r);let o=t[r];if(o?.type==="list"&&hs(o.attributeKey)||o?.type==="condition"&&zi(o.condition,t,n))return!0}return!1}var sb=M.enum(["draft","active","paused","archived"]),jt=M.discriminatedUnion("type",[M.object({type:M.literal("percent"),percentOff:M.number().min(1).max(100).multipleOf(.01)}).strict(),M.object({type:M.literal("amount"),amountOffCents:M.number().int().min(1).max(1e8),currency:ie}).strict()]),Ze=M.discriminatedUnion("type",[M.object({type:M.literal("once")}).strict(),M.object({type:M.literal("repeating"),months:M.number().int().min(1).max(36)}).strict(),M.object({type:M.literal("forever")}).strict()]),ys=[M.object({type:M.literal("all")}).strict(),M.object({type:M.literal("plans"),planIds:M.array(M.uuid()).min(1).max(50).refine(e=>new Set(e).size===e.length,"\u5957\u9910\u4E0D\u80FD\u91CD\u590D")}).strict()],Bl=M.discriminatedUnion("type",[...ys,M.strictObject({type:M.literal("merchandise"),scope:M.discriminatedUnion("type",[M.strictObject({type:M.literal("all")}),M.strictObject({type:M.literal("selected"),merchandiseIds:M.array(M.uuid()).min(1).max(1e3).refine(e=>new Set(e).size===e.length,"Duplicate merchandise")}),M.strictObject({type:M.literal("condition"),condition:rt})])})]),qi=M.discriminatedUnion("type",[...ys,M.strictObject({type:M.literal("merchandise"),scope:M.strictObject({type:M.enum(["all","selected","condition"])})})]),zl=M.strictObject({firstPurchaseOnly:M.boolean(),condition:rt}),cb=M.object({name:M.string().trim().min(1).max(80),description:M.string().max(500),discount:jt,duration:Ze,appliesTo:Bl,eligibility:zl,selfClaimEnabled:M.boolean().default(!1),startsAt:M.iso.datetime().nullable(),endsAt:M.iso.datetime().nullable(),totalLimit:M.number().int().min(1).max(1e6).nullable(),perCustomerLimit:M.number().int().min(1).max(10),grantWindowHours:M.number().int().min(1).max(2160)}).strict().refine(e=>!e.startsAt||!e.endsAt||Date.parse(e.endsAt)>Date.parse(e.startsAt),{message:"\u7ED3\u675F\u65F6\u95F4\u5FC5\u987B\u665A\u4E8E\u5F00\u59CB\u65F6\u95F4",path:["endsAt"]}).refine(e=>!zi(e.eligibility.condition),{message:"Customer eligibility cannot read merchandise; use merchandise applicability",path:["eligibility","condition"]}).refine(e=>e.appliesTo.type!=="merchandise"||e.duration.type==="once",{message:"Merchandise Coupons apply to one purchase",path:["duration"]}).refine(e=>e.appliesTo.type!=="merchandise"||!e.eligibility.firstPurchaseOnly,{message:"Merchant purchase eligibility requires trusted targeting attributes",path:["eligibility","firstPurchaseOnly"]}),ub=M.object({code:M.string().trim().transform(e=>e.toUpperCase()).pipe(M.string().regex(/^[A-Z0-9][A-Z0-9_-]{2,31}$/,"\u4F18\u60E0\u7801\u53EA\u80FD\u7528 3\u201332 \u4F4D\u5B57\u6BCD\u3001\u6570\u5B57\u3001- \u548C _\uFF0C\u4EE5\u5B57\u6BCD\u6216\u6570\u5B57\u5F00\u5934")),maxRedemptions:M.number().int().min(1).max(1e6).nullable(),expiresAt:M.iso.datetime().nullable(),firstPurchaseOnly:M.boolean(),minimumAmountCents:M.number().int().min(1).max(1e8).nullable(),minimumAmountCurrency:ie.nullable()}).strict().refine(e=>e.minimumAmountCents===null==(e.minimumAmountCurrency===null),"Minimum amount requires its currency");var Tn=M.object({id:M.uuid(),couponId:M.uuid(),status:M.enum(["issued","reserved","redeemed","revoked","expired"]),issuedAt:M.iso.datetime(),expiresAt:M.iso.datetime(),coupon:M.object({name:M.string(),discount:jt,duration:Ze,appliesTo:qi}).strict()}).strict(),xs=M.enum(["claim_disabled","unavailable","inactive","outside_window","not_targeted","not_first_purchase","limit_reached","sold_out"]);var js=s.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/),Fi=s.string().regex(/^(0|[1-9]\d{0,14})$/),sn=s.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,30})?$/),ql=s.string().regex(/^(?:[1-9]\d{0,7}|1\d{8}|200000000)$/),Dn=ql,bt=be.refine(e=>/[1-9]/.test(e)),qe=s.iso.datetime({offset:!0}),Cr=e=>{let[t,n=""]=e.split(".");if(t===void 0||t==="")throw new Error("Invalid decimal value");return BigInt(t)*1000000n+BigInt(n.padEnd(6,"0"))},Fl=s.array(s.object({upTo:bt.nullable(),unitAmountMinor:js,flatAmountMinor:s.number().int().min(0).max(1e8).optional()}).strict()).min(1).max(12).refine(e=>{try{return e.at(-1)?.upTo===null&&e.slice(0,-1).every((t,n)=>{let r=e[n-1]?.upTo;return t.upTo!==null&&(n===0||r!=null&&Cr(t.upTo)>Cr(r))})}catch{return!1}},"Tier ceilings must increase and the final tier must be unbounded"),Nl=s.discriminatedUnion("kind",[s.object({kind:s.literal("flat"),units:bt,unitAmountMinor:js}).strict(),s.object({kind:s.enum(["graduated","volume"]),units:bt,tiers:Fl}).strict()]).refine(e=>e.kind==="flat"||!e.tiers.some(t=>(t.flatAmountMinor??0)>0)||e.kind==="volume"&&e.tiers.length>1,"Tier flat fees require volume pricing with multiple tiers"),Ul=s.strictObject({interval:s.enum(["month","year"]),count:s.number().int().min(1).max(12),anchor:s.enum(["membership","calendar"])}),Bn=s.object({currency:ie,pricing:Nl,billingCycle:Ul.optional()}).strict().refine(e=>e.pricing.kind!=="volume"||e.pricing.tiers.length===1,"Multiple volume tiers require prepaid billing");var Ss={requestId:s.uuid(),productVersionId:s.uuid(),internal_feature_id:s.uuid(),currency:ie},As=s.strictObject({interval:s.enum(["hour","day","week","month"]),intervalCount:s.number().int().min(1).max(12),limit:s.number().int().min(1).max(1e6)}),ws=s.discriminatedUnion("kind",[s.object({...Ss,kind:s.literal("auto_topup"),threshold:pi,quantity:bt.refine(e=>Number(e)>=1,"AutoTopup quantity must be at least 1"),purchaseLimit:As.optional()}).strict(),s.object({...Ss,kind:s.literal("postpaid"),maxAmountMinorPerPeriod:Dn,maxOutstandingMinor:Dn}).strict()]),vs={productVersionId:s.uuid(),internal_feature_id:s.uuid(),currency:ie},_s=s.discriminatedUnion("kind",[s.object({...vs,kind:s.literal("auto_topup"),threshold:pi,quantity:bt.refine(e=>Number(e)>=1,"AutoTopup quantity must be at least 1"),purchaseLimit:As.optional(),purchaseAmountMinor:Dn,purchaseUnits:bt}).strict(),s.object({...vs,kind:s.literal("postpaid"),maxAmountMinorPerPeriod:Dn,maxOutstandingMinor:Dn,cashPrice:Bn}).strict().refine(e=>e.cashPrice.currency===e.currency,"Currency must match")]),kr=s.object({id:s.uuid(),terms:_s,status:s.enum(["prepared","active","revoked","blocked"]),createdAt:qe,acceptedAt:qe.nullable(),effectiveAt:qe.nullable(),revokedAt:qe.nullable()}).strict().refine(e=>(e.status==="prepared"?e.acceptedAt===null:!0)&&(e.status==="active"?e.acceptedAt!==null&&e.effectiveAt!==null:!0)&&(e.status==="revoked"?e.revokedAt!==null:e.revokedAt===null),"Authorization consent and revocation must be explicit"),Ps=s.object({authorizationId:s.uuid(),terms:_s,setupUrl:s.url().nullable()}).strict(),Cs=s.object({authorizationId:s.uuid(),accepted:s.literal(!0)}).strict(),ks=s.object({authorizationId:s.uuid(),requestId:s.uuid()}).strict(),Rs=s.object({internal_feature_id:s.uuid(),entityId:s.uuid().nullable(),interval:s.enum(["day","week","month","year"]),anchor:s.enum(["billing_cycle","utc"]).optional(),basis:s.enum(["usage","credits"]),filter:dt.optional(),limit:be.nullable(),thresholds:s.array(s.number().positive().max(1)).max(8),includedThresholds:s.array(s.number().positive().max(1)).max(8).optional(),absoluteThresholds:s.array(bt).max(8).optional()}).strict().refine(e=>e.thresholds.every((t,n)=>{let r=e.thresholds[n-1];return n===0||r!==void 0&&t>r})&&(e.includedThresholds??[]).every((t,n,r)=>{let o=r[n-1];return n===0||o!==void 0&&t>o})&&(e.absoluteThresholds??[]).every((t,n,r)=>{let o=r[n-1];return n===0||o!==void 0&&Cr(t)>Cr(o)}),"Notification thresholds must increase"),Vl=Rs.safeExtend({requestId:s.uuid()}),Is={control:s.literal("overage"),requestId:s.uuid(),internal_feature_id:s.uuid(),entityId:s.uuid().nullable()},$l=s.discriminatedUnion("action",[s.strictObject({...Is,action:s.literal("set"),allowed:s.boolean().nullable(),overageLimit:be.nullable(),skipOverageBilling:s.boolean()}),s.strictObject({...Is,action:s.literal("remove")})]),Es=s.union([Vl,$l]),Gl=s.strictObject({internal_feature_id:s.uuid(),entityId:s.uuid().nullable(),allowed:s.boolean().nullable(),overageLimit:be.nullable(),skipOverageBilling:s.boolean(),interval:s.enum(["day","week","month","year"]),startsAt:qe,endsAt:qe,used:s.string().regex(/^(0|[1-9]\d{0,23})(\.\d{1,6})?$/),reserved:s.string().regex(/^(0|[1-9]\d{0,23})(\.\d{1,6})?$/),remaining:s.string().regex(/^-?(0|[1-9]\d{0,23})(\.\d{1,6})?$/).nullable()}),Kl=s.object({internal_feature_id:s.uuid(),entityId:s.uuid().nullable(),interval:s.enum(["day","week","month","year"]),anchor:s.enum(["billing_cycle","utc"]).optional(),basis:s.enum(["usage","credits"]),filter:dt.optional(),startsAt:qe,endsAt:qe,used:nt,reserved:nt,limit:be.nullable(),thresholds:s.array(s.number().positive().max(1)).max(8),notifiedThresholds:s.array(s.number().positive().max(1)).max(1024),includedThresholds:s.array(s.number().positive().max(1)).max(8).optional(),includedAllowance:s.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,12})?$/).optional(),notifiedIncludedThresholds:s.array(s.number().positive().max(1)).max(1024).optional(),absoluteThresholds:s.array(bt).max(8).optional(),notifiedAbsoluteThresholds:s.array(bt).max(1024).optional()}).strict().refine(e=>e.basis!=="usage"||be.safeParse(e.used).success&&be.safeParse(e.reserved).success,"Usage counters retain six decimals; credit costs retain twelve"),Ll=s.object({authorizationId:s.uuid(),status:s.enum(["idle","pending","blocked"]),taskId:s.uuid().nullable(),invoiceId:s.uuid().nullable(),hostedInvoiceUrl:s.url().nullable(),purchaseCount:s.number().int().nonnegative(),purchaseWindowEndsAt:qe.nullable(),attemptCount:s.number().int().nonnegative(),failedAttemptCount:s.number().int().nonnegative(),suspendedAt:qe.nullable(),nextAttemptAt:qe.nullable(),failureReason:s.string().min(1).max(240).nullable()}).strict(),Ms=s.object({internal_feature_id:s.uuid().optional(),entityId:s.uuid().optional()}).strict(),Ni=s.object({authorizations:s.array(kr).max(100),limits:s.array(Rs).max(100),overages:s.array(Gl).max(100).optional(),windows:s.array(Kl).max(200),autoTopups:s.array(Ll).max(100),limited:s.boolean()}).strict(),Zl=s.object({id:s.uuid(),internal_feature_id:s.uuid(),productVersionId:s.uuid(),authorizationId:s.uuid(),entityId:s.uuid().nullable(),units:be,amountMinor:sn,cashPrice:Bn}).strict(),zn=s.object({id:s.uuid(),sourceKind:s.enum(["product","usage","manual"]),providerInvoiceId:s.string().min(1).max(240).nullable(),status:s.enum(["accruing","open","pending","paid","failed","void"]),currency:ie,startsAt:qe.nullable(),endsAt:qe.nullable(),amountMinor:s.string().regex(/^-?(0|[1-9]\d{0,14})$/),grossAmountMinor:s.string().regex(/^-?(0|[1-9]\d{0,14})$/),discountMinor:Fi,paidAmountMinor:Fi,refundedAmountMinor:Fi,createdAt:qe,hostedInvoiceUrl:s.url().nullable(),adjustment:s.object({originalInvoiceId:s.uuid(),amountMinor:s.string().regex(/^-?(0|[1-9]\d{0,8})$/).refine(e=>e!=="-0"&&/^-?(0|[1-9]\d{0,8})$/.test(e)&&BigInt(e)>=-200000000n&&BigInt(e)<=200000000n,"Invoice adjustment exceeds the bounded minor amount"),acceptedAt:qe.nullable(),reason:s.string().min(1).max(500).optional()}).strict().nullable(),lines:s.array(Zl).max(100),linesLimited:s.boolean()}).strict(),Ts=s.object({invoiceId:s.uuid(),accepted:s.literal(!0)}).strict(),Ds=s.strictObject({requestId:s.uuid(),originalInvoiceId:s.uuid(),amountMinor:s.string().regex(/^[1-9]\d{0,8}$/).refine(e=>/^[1-9]\d{0,8}$/.test(e)&&BigInt(e)<=200000000n,"Supplemental amount exceeds the bounded minor amount"),reason:s.string().trim().min(1).max(500)}),Bs=s.object({after:s.uuid().nullable(),limit:s.number().int().min(1).max(100)}).strict(),zs=s.object({rows:s.array(zn).max(100),nextCursor:s.uuid().nullable()}).strict(),Os=s.strictObject({id:s.string(),coupon:s.string(),start:s.number().nonnegative(),end:s.number().nullable()}),Hl=s.strictObject({subscriptionId:s.string(),customerId:s.string(),accountId:s.string(),sourceItems:s.array(s.strictObject({id:s.string(),price_id:s.string(),quantity:s.number().int(),discounts:s.array(Os).optional()})).max(100),items:s.array(s.strictObject({id:s.string(),price:s.string(),quantity:s.number().int(),discounts:s.array(s.strictObject({coupon:s.string().optional(),terms:s.strictObject({id:s.string(),name:s.string().optional(),percent_off:s.number().optional(),amount_off:s.number().optional(),currency:s.string().optional(),duration:s.enum(["once","forever","repeating"]),duration_in_months:s.number().optional()}).optional(),discount:s.string().optional(),receipt:Os.optional()})).max(20)})).max(100)}),qs=s.strictObject({membershipId:s.uuid(),requestId:s.uuid(),grantIds:s.array(s.uuid()).max(20).refine(e=>new Set(e).size===e.length,"Duplicate Coupon grants")}),Fs=s.strictObject({membershipId:s.uuid(),operationId:s.uuid(),status:s.enum(["pending","effective"]),execution:Hl.nullable(),grants:s.array(s.strictObject({id:s.uuid(),couponId:s.uuid(),name:s.string(),discount:jt,duration:Ze,startedAt:qe.nullable()})).max(20)});import{z as qn}from"zod";var Ns=qn.enum(["minute","hour","day","week","month","quarter","semi_annual","year","lifetime"]),Us=qn.number().int().min(1).max(1e3),Rr=qn.object({cap:be.refine(e=>/[1-9]/.test(e)).nullable(),capPercentage:qn.number().positive().max(1e4).nullable(),cycles:qn.number().int().min(1).max(1200).nullable()}).strict().refine(e=>e.cap===null||e.capPercentage===null,"Choose a fixed or percentage cap");import{z as At}from"zod";var Vs=At.strictObject({itemKey:At.string().regex(/^paid:feature:[a-f0-9]{8}-[a-f0-9]{4}-[1-8][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/),internal_feature_id:At.uuid(),includedAmount:At.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/),quantity:At.number().int().min(0).max(1e4),terms:la,pricing:pa.optional(),unitAmountMinor:At.number().int().min(0).max(1e8),productId:At.string().min(1).max(255).nullable(),priceId:At.string().min(1).max(255).nullable()}).superRefine((e,t)=>{(e.quantity<e.terms.minimumQuantity||e.quantity>e.terms.maximumQuantity||e.productId===null!=(e.priceId===null)||e.quantity>0&&(e.pricing||e.unitAmountMinor>0)&&e.priceId===null)&&t.addIssue({code:"custom",message:"Purchased quantities need their published bounds and immutable price binding"});try{ma(e.includedAmount,e.terms.units,e.quantity),ir({quantity:e.quantity,unitAmountMinor:e.unitAmountMinor,...e.pricing===void 0?{}:{pricing:e.pricing}})}catch{t.addIssue({code:"custom",message:"Purchased allowance exceeds the ledger quantity limit"})}});import{z as ne}from"zod";var Bt=ne.iso.datetime({offset:!0}),$s=be.refine(e=>/[1-9]/.test(e)),Gs=ne.strictObject({interval:Ns.exclude(["lifetime"]),count:Us}),Jl=ne.strictObject({action:ne.literal("create"),requestId:ne.uuid(),internal_feature_id:ne.uuid(),entityId:ne.uuid().nullable(),amount:$s.nullable(),expiresAt:Bt.nullable(),reset:Gs.nullable(),rollover:Rr.nullable(),nextResetAt:Bt.nullable()}).refine(e=>e.amount!==null||e.reset===null&&e.rollover===null,"Unlimited grants cannot reset or roll over").refine(e=>!e.rollover||e.reset!==null,"Rollover requires a recurring grant").refine(e=>e.nextResetAt===null||e.reset!==null&&(e.expiresAt===null||Date.parse(e.nextResetAt)<Date.parse(e.expiresAt)),"The first reset needs a reset interval and must precede expiry"),Ks=ne.discriminatedUnion("action",[Jl,ne.strictObject({action:ne.literal("update"),requestId:ne.uuid(),grantId:ne.uuid(),revision:ne.number().int().nonnegative(),amount:$s.nullable(),expiresAt:Bt.nullable(),rollover:Rr.nullable(),nextResetAt:Bt.nullable()}),ne.strictObject({action:ne.enum(["add","subtract","set_remaining"]),requestId:ne.uuid(),grantId:ne.uuid(),revision:ne.number().int().nonnegative(),amount:be}),ne.strictObject({action:ne.literal("revoke"),requestId:ne.uuid(),grantId:ne.uuid(),revision:ne.number().int().nonnegative()})]),Ui=ne.strictObject({id:ne.uuid(),internal_feature_id:ne.uuid(),entityId:ne.uuid().nullable(),amount:be.nullable(),reset:Gs.nullable(),rollover:Rr.nullable(),nextResetAt:Bt.nullable(),startsAt:Bt,expiresAt:Bt.nullable(),revision:ne.number().int().nonnegative(),revoked:ne.boolean(),available:nt,held:nt,spent:nt}),Ls=ne.strictObject({customerId:ne.uuid(),after:ne.uuid().nullable(),limit:ne.number().int().min(1).max(100)}),Zs=ne.strictObject({rows:ne.array(Ui).max(100),nextCursor:ne.uuid().nullable()});import{z as D}from"zod";var lt=D.iso.datetime({offset:!0}),Hs=D.strictObject({invoiceId:D.uuid(),after:D.string().min(1).max(180).nullable(),limit:D.number().int().min(1).max(100)}),Wl=D.strictObject({kind:D.literal("product"),key:D.string(),productVersionId:D.uuid(),productName:D.string(),itemKey:D.string(),entityId:D.uuid().nullable(),quantity:D.number().positive(),subtotalMinor:D.string().regex(/^-?\d+$/),discountMinor:D.string().regex(/^\d+$/),taxMinor:D.string().regex(/^-?\d+$/).nullable(),totalMinor:D.string().regex(/^-?\d+$/),startsAt:lt.nullable(),endsAt:lt.nullable(),providerLineId:D.string().nullable(),providerItemId:D.string()}),Js=D.strictObject({invoice:zn,items:D.array(D.discriminatedUnion("kind",[Wl,D.strictObject({kind:D.literal("invoice_credit"),key:D.string(),internal_feature_id:D.uuid(),internal_credit_feature_id:D.uuid(),name:D.string(),units:be,reserved:be,amountMinor:sn,grossAmountMinor:sn,creditsAppliedMinor:sn,properties:dt,cashPrice:Bn,providerItemId:D.string().nullable(),creditProviderItemId:D.string().nullable()}),D.strictObject({kind:D.literal("usage"),key:D.string(),internal_feature_id:D.uuid(),name:D.string(),units:be,reserved:be,amountMinor:sn,cashPrice:Bn})])).max(100),nextCursor:D.string().min(1).max(180).nullable()}),Ql=D.string().regex(/^-?(0|[1-9]\d{0,17})(\.\d{1,12})?$/).refine(e=>!/^\-0(?:\.0+)?$/.test(e)),Vi=D.strictObject({from:lt,to:lt,entityId:D.uuid().optional(),snapshotAt:lt.nullable(),after:D.strictObject({at:lt,id:D.uuid(),position:D.number().int().nonnegative()}).nullable(),limit:D.number().int().min(1).max(100)}).refine(e=>Date.parse(e.from)<Date.parse(e.to)&&Date.parse(e.to)-Date.parse(e.from)<=366*864e5,"Statement range must be positive and at most 366 days").refine(e=>e.after===null||e.snapshotAt!==null,"A cursor requires the original snapshot time"),Ws=D.strictObject({customerId:D.uuid(),entityId:D.uuid().nullable(),from:lt,to:lt,snapshotAt:lt,totals:D.array(D.strictObject({internal_credit_feature_id:D.uuid(),name:D.string(),consumed:nt,refunded:nt,net:Ql})).max(1e3),rows:D.array(D.strictObject({operationId:D.uuid(),position:D.number().int().nonnegative(),kind:D.enum(["consume","confirm","refund"]),originalId:D.uuid().nullable(),occurredAt:lt,internal_feature_id:D.uuid(),entitlementName:D.string(),sourceId:D.uuid(),internal_credit_feature_id:D.uuid(),creditName:D.string(),units:ba,amount:nt,pricing:D.array(ha).max(12),properties:dt})).max(100),nextCursor:Vi.shape.after});import{z as U}from"zod";var Xs=U.object({customerId:U.uuid()}).strict(),Ys=U.discriminatedUnion("action",[U.object({customerId:U.uuid(),requestId:U.uuid(),action:U.literal("assign"),poolId:U.uuid(),memberCustomerId:U.uuid()}).strict(),U.strictObject({customerId:U.uuid(),requestId:U.uuid(),action:U.literal("assign_entity"),poolId:U.uuid(),entityId:U.uuid()}),U.object({customerId:U.uuid(),requestId:U.uuid(),action:U.literal("release"),poolId:U.uuid(),slotId:U.uuid()}).strict()]),Fn=U.number().int().nonnegative(),$i=U.iso.datetime({offset:!0}),Gi=U.strictObject({internalId:U.uuid(),id:U.string(),name:U.string().nullable(),version:U.number().int().positive()}),Qs=U.enum(["active","past_due"]),Ki=U.strictObject({customerId:U.uuid(),licenses:U.array(U.strictObject({id:U.uuid(),linkId:U.uuid(),parent:U.strictObject({customerProductId:U.uuid(),status:Qs,product:Gi}),product:Gi,planLicense:U.strictObject({id:U.uuid(),prepaidOnly:U.boolean(),isCustom:U.boolean()}).nullable(),granted:Fn,included:Fn,paidQuantity:Fn,usage:Fn,remaining:Fn,createdAt:$i}).refine(e=>e.granted===e.included+e.paidQuantity&&e.granted===e.usage+e.remaining,"Granted seats are included plus paid, and usage plus remaining")).max(2e3),assignments:U.array(U.strictObject({id:U.uuid(),linkId:U.uuid(),status:Qs,product:Gi,entity:U.strictObject({internalId:U.uuid(),id:U.string().nullable(),name:U.string().nullable()}).nullable(),beneficiary:U.strictObject({internalId:U.uuid(),id:U.string().nullable(),name:U.string().nullable()}).nullable(),startedAt:$i.nullable(),endedAt:$i.nullable()}).refine(e=>e.entity!==null||e.beneficiary!==null,"A seat assignment has a holder")).max(1e4),limited:U.boolean()});import{z as N}from"zod";var Nn=N.enum(["email","sms","voice","push"]),Db=N.enum(["resend","twilio","fcm","apns"]);var Bb=N.string().regex(/^\+[1-9]\d{1,14}$/),Xl=N.enum(["email_recipient","sms_segment","voice_second","push_device"]);var Yl=N.string().trim().min(1).max(200).refine(e=>!/[\r\n\0]/.test(e),"Invalid email header"),em=N.strictObject({subject:Yl,html:N.string().min(1).max(131072).optional(),text:N.string().min(1).max(65536).optional()}).refine(e=>e.html!==void 0||e.text!==void 0,{message:"Email requires HTML or text content"}),tm=N.strictObject({body:N.string().min(1).max(1600).refine(e=>e.trim().length>0)}),nm=N.strictObject({text:N.string().trim().min(1).max(4e3),language:N.string().regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/).max(35),maxDurationSeconds:N.number().int().min(1).max(900)}),rm=N.record(N.string().min(1).max(64),N.string().max(256)).refine(e=>Object.keys(e).length<=20&&Object.keys(e).every(t=>!/^(?:indiana_|google\.|gcm\.)/i.test(t)&&t!=="aps"),"Push data contains reserved fields or too many entries"),im=N.strictObject({title:N.string().trim().min(1).max(200),body:N.string().trim().min(1).max(2e3),url:N.url().max(2048).refine(e=>!/^(?:javascript|data|file|vbscript):/i.test(e)).optional(),data:rm.optional()}).refine(e=>new TextEncoder().encode(JSON.stringify(e)).length<=3072,"Push content exceeds the provider payload budget"),ec=N.discriminatedUnion("channel",[N.strictObject({channel:N.literal("email"),content:em}),N.strictObject({channel:N.literal("sms"),content:tm}),N.strictObject({channel:N.literal("voice"),content:nm}),N.strictObject({channel:N.literal("push"),content:im})]),tc=N.strictObject({requestId:N.uuid(),customerId:N.uuid(),connectionId:N.uuid().optional(),message:ec,expiresAt:N.iso.datetime({offset:!0})}),om=N.array(N.uuid()).min(1).max(1e4).refine(e=>new Set(e).size===e.length,"Duplicate Customer"),am=N.discriminatedUnion("kind",[N.strictObject({kind:N.literal("all")}),N.strictObject({kind:N.literal("customers"),customerIds:om})]),zb=N.strictObject({name:N.string().trim().min(1).max(120),connectionId:N.uuid().optional(),message:ec,audience:am,frequencyLimit:N.number().int().min(1).max(100)}),nc=N.strictObject({requestId:N.uuid(),channel:Nn,state:N.enum(["allowed","denied"]),expectedRevision:N.number().int().min(0).max(Number.MAX_SAFE_INTEGER-1)}),rc=N.enum(["queued","leased","dispatching","accepted","unknown","retry","skipped","failed","canceled"]),ic=N.enum(["accepted","sent","delivered","delayed","bounced","complained","unsubscribed","opened","clicked","ringing","answered","completed","busy","no_answer","failed","cost_finalized"]),qb=N.strictObject({meter:Xl,estimatedUnits:N.string().regex(/^(0|[1-9]\d{0,11})$/),observedUnits:N.string().regex(/^(0|[1-9]\d{0,11})$/).nullable()});import{z as oc}from"zod";var cn={funnelId:oc.uuid().optional(),funnelVersionId:oc.uuid().optional()};import{z as Er}from"zod";var Mr=Er.strictObject({runId:Er.uuid(),bindingId:Er.uuid(),receiptId:Er.uuid()});import{z as ye}from"zod";import{z as ae}from"zod";import{z as fe}from"zod";var Kb=fe.discriminatedUnion("action",[fe.strictObject({action:fe.literal("create"),couponId:fe.uuid(),productBindingId:fe.uuid(),storeOfferId:fe.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/).nullable(),storeOfferType:fe.enum(["introductory","promotional"])}),fe.strictObject({action:fe.literal("set_enabled"),id:fe.uuid(),revision:fe.number().int().nonnegative(),enabled:fe.boolean()})]),Lb=fe.array(fe.strictObject({id:fe.uuid(),couponId:fe.uuid(),productBindingId:fe.uuid(),storeOfferId:fe.string().min(1).max(255).nullable(),storeOfferType:fe.enum(["introductory","promotional"]),enabled:fe.boolean(),revision:fe.number().int().nonnegative()})).max(500),un=fe.strictObject({offerKind:fe.enum(["none","introductory","promotional"]),offerId:fe.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/).nullable(),discountMinor:fe.number().int().min(0).max(1e8),trialDays:fe.number().int().min(1).max(730).nullable()}).superRefine((e,t)=>{(e.offerKind==="none"&&(e.offerId!==null||e.discountMinor!==0||e.trialDays!==null)||e.trialDays!==null&&e.discountMinor!==0)&&t.addIssue({code:"custom",message:"Select one store purchase option with its exact terms"})}),Zb=fe.record(fe.uuid(),un).refine(e=>Object.keys(e).length<=20,"At most 20 native store selections");var Li=ae.object({type:ae.literal("native_purchase"),receiptId:ae.uuid(),orderId:ae.uuid(),productVersionId:ae.uuid(),provider:ae.enum(["apple","google"]),productId:ae.string().min(1).max(255),productKind:Aa,replacement:ae.strictObject({sourceOrderId:ae.uuid(),sourceProductId:ae.string().min(1).max(255),policy:ae.enum(["apple_store","google_full_price"]),sourceAccountTokens:ae.array(ae.uuid()).max(50)}).nullable(),appAccountToken:ae.uuid().optional(),obfuscatedAccountId:ae.string().min(1).max(64).optional(),obfuscatedProfileId:ae.uuid().optional(),basePlanId:ae.string().min(1).max(255).optional(),offerId:ae.string().min(1).max(255).optional(),offerKind:ae.enum(["none","introductory","promotional"]),currency:ie,catalogAmountMinor:ae.number().int().nonnegative().max(1e8),discountMinor:ae.number().int().nonnegative().max(1e8),trialDays:ae.number().int().min(1).max(730).nullable(),seatBundle:ae.array(ae.strictObject({key:ae.string().regex(/^[a-z][a-z0-9_]{0,63}$/),quantity:ae.number().int().min(1).max(1e4)})).max(20),applePromotionalOffer:ae.strictObject({offerId:ae.string().min(1).max(255),keyId:ae.string().min(1).max(255),nonce:ae.uuid(),signature:ae.string().min(1).max(1024),timestamp:ae.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)}).nullable()}).strict().superRefine((e,t)=>{let n=e.provider==="apple";(e.replacement!==null&&(e.productKind!=="membership"||e.offerKind!=="none"||e.trialDays!==null||e.replacement.policy!==(n?"apple_store":"google_full_price"))||e.productKind!=="membership"&&(e.trialDays!==null||e.offerKind!=="none"||e.basePlanId!==void 0)||!n&&e.productKind==="membership"&&e.basePlanId===void 0||e.discountMinor>e.catalogAmountMinor||new Set(e.seatBundle.map(o=>o.key)).size!==e.seatBundle.length||e.trialDays!==null&&(e.discountMinor!==0||e.offerKind==="none")||e.offerKind==="none"&&e.discountMinor!==0||(n?!e.appAccountToken||e.obfuscatedAccountId!==void 0||e.obfuscatedProfileId!==void 0||e.basePlanId!==void 0||e.offerKind==="promotional"!=(e.applePromotionalOffer!==null)||e.offerKind==="promotional"!=(e.offerId!==void 0)||e.applePromotionalOffer!==null&&e.applePromotionalOffer.offerId!==e.offerId:e.appAccountToken!==void 0||!e.obfuscatedAccountId||!e.obfuscatedProfileId||e.applePromotionalOffer!==null||e.offerKind==="none"!=(e.offerId===void 0)))&&t.addIssue({code:"custom",message:"Native purchase terms must match the accepted store selection"})});import{z as i}from"zod";import{z as Q}from"zod/v4";import{z as sm}from"zod/v4";var cm=sm.registry(),{BillingInterval:ac}=(()=>{var e;return(function(t){t.OneOff="one_off",t.Week="week",t.Month="month",t.Quarter="quarter",t.SemiAnnual="semi_annual",t.Year="year"})(e||(e={})),{BillingInterval:e}})(),{DisplaySchema:um}=(e=>({DisplaySchema:e.object({primary_text:e.string().meta({description:"Main display text (e.g. '$10' or '100 messages')."}),secondary_text:e.string().optional().meta({description:"Secondary display text (e.g. 'per month' or 'then $0.5 per 100')."})})}))(Q),{withSpecDefault:pm}=(e=>({withSpecDefault:({schema:n,defaultValue:r,description:o})=>(e.add(n,{description:o,default:r}),n)}))(cm),{COMMON:sc}={COMMON:["usd","eur","gbp","cad","aud","jpy","chf","cny","inr"]},{STRIPE_PRESENTMENT_CURRENCIES:lm}={STRIPE_PRESENTMENT_CURRENCIES:["usd","aed","afn","all","amd","ang","aoa","ars","aud","awg","azn","bam","bbd","bdt","bif","bmd","bnd","bob","brl","bsd","bwp","byn","bzd","cad","cdf","chf","clp","cny","cop","crc","cve","czk","djf","dkk","dop","dzd","egp","etb","eur","fjd","fkp","gbp","gel","gip","gmd","gnf","gtq","gyd","hkd","hnl","htg","huf","idr","ils","inr","isk","jmd","jpy","kes","kgs","khr","kmf","krw","kyd","kzt","lak","lbp","lkr","lrd","lsl","mad","mdl","mga","mkd","mmk","mnt","mop","mur","mvr","mwk","mxn","myr","mzn","nad","ngn","nio","nok","npr","nzd","pab","pen","pgk","php","pkr","pln","pyg","qar","ron","rsd","rub","rwf","sar","sbd","scr","sek","sgd","shp","sle","sos","srd","std","szl","thb","tjs","top","try","ttd","twd","tzs","uah","ugx","uyu","uzs","vnd","vuv","wst","xaf","xcd","xcg","xof","xpf","yer","zar","zmw"]},{COMMON_SET:mm}=(e=>({COMMON_SET:new Set(e)}))(sc),{hasNoDuplicateCurrencies:cc}={hasNoDuplicateCurrencies:t=>{let n=new Set;for(let{currency:r}of t){let o=r.toLowerCase();if(n.has(o))return!1;n.add(o)}return!0}},{DUPLICATE_CURRENCY_MESSAGE:uc}={DUPLICATE_CURRENCY_MESSAGE:"Each currency may appear at most once in additional_currencies."},{ApiStripePriceProcessorSchema:dm}=(e=>({ApiStripePriceProcessorSchema:e.object({price_id:e.string().meta({description:"Stripe price ID. For prepaid with included > 0 this is the V2 price."})})}))(Q),{Infinite:fm}={Infinite:"inf"},{TierBehavior:gm}=(()=>{var e;return(function(t){t.Graduated="graduated",t.VolumeBased="volume"})(e||(e={})),{TierBehavior:e}})(),{BillingMethod:pc}=(()=>{var e;return(function(t){t.Prepaid="prepaid",t.UsageBased="usage_based"})(e||(e={})),{BillingMethod:e}})(),{AllocatedBilling:hm}=(()=>{var e;return(function(t){t.Arrear="arrear",t.ProratedLegacy="prorated_legacy"})(e||(e={})),{AllocatedBilling:e}})(),{CREDIT_DIMENSION_NAME_MAX_LENGTH:bm}={CREDIT_DIMENSION_NAME_MAX_LENGTH:64},{USAGE_ATTRIBUTION_DIMENSION_SEPARATOR:ym}={USAGE_ATTRIBUTION_DIMENSION_SEPARATOR:"::"},{CreditMatchSchema:xm}=(e=>({CreditMatchSchema:e.record(e.string(),e.union([e.string(),e.number(),e.boolean()]).transform(String).pipe(e.string()))}))(Q),{ApiCreditTierSchema:lc}=(e=>({ApiCreditTierSchema:e.object({to:e.union([e.number().positive(),e.enum(["inf"])]).meta({description:"Inclusive upper usage boundary for this graduated tier. The final tier must be 'inf'."}),credit_cost:e.number().min(0).meta({description:"Credits consumed per billing-unit group within this tier."})})}))(Q),{VIOLATION_MESSAGES:Sm}={VIOLATION_MESSAGES:{non_final_infinity:"Only the final tier may use an 'inf' boundary.",not_increasing:"Tier boundaries must be strictly increasing.",final_not_infinity:"The final tier must use an 'inf' boundary."}},{MarkupEntrySchema:mc}=(e=>({MarkupEntrySchema:e.object({markup:e.number().min(-100)})}))(Q),{ModelMarkupsSchema:vm}=((e,t)=>({ModelMarkupsSchema:e.record(e.string().regex(/.+\/.+/,'Model keys are "<provider>/<model>", e.g. "openai/gpt-4o" or "custom/my-model".'),t.extend({markup:e.number().min(-100).optional(),input_cost:e.number().min(0).optional(),output_cost:e.number().min(0).optional()})).nullish()}))(Q,mc),{InvoiceUsageEntrySchema:Im}=(e=>({InvoiceUsageEntrySchema:e.object({feature_id:e.string().meta({description:"The metered feature whose units are being converted."}),quantity:e.number().nonnegative().meta({description:"Billable units of the metered feature. Converted to the credit-system feature through its rate card."}),properties:e.record(e.string(),e.unknown()).optional().meta({description:"Event properties used to pick the rate card dimension and multipliers."})}).strict()}))(Q),{AttachDiscountSchema:dc}=(e=>({AttachDiscountSchema:e.object({reward_id:e.string().optional().meta({description:"The ID of the reward to apply as a discount."}),promotion_code:e.string().optional().meta({description:"The promotion code to apply as a discount."})}).refine(n=>n.reward_id||n.promotion_code,{message:"Either reward_id or promotion_code must be provided."}).meta({title:"AttachDiscount",description:"A discount to apply. Can be either a reward ID or a promotion code."})}))(Q),{CustomLineItemSchema:Om}=(e=>({CustomLineItemSchema:e.object({amount:e.number().meta({description:"Amount in dollars for this line item (e.g. 10.50). Can be negative for credits."}),description:e.string().meta({description:"Description for the line item."})})}))(Q),{UnixMsTimestampSchema:jm}=(e=>({UnixMsTimestampSchema:e.number().int().safe().nonnegative()}))(Q),{CreateInvoicePreviewLineSchema:Am}=(e=>({CreateInvoicePreviewLineSchema:e.object({plan_id:e.string().nullable(),feature_id:e.string().nullable(),description:e.string(),amount:e.number(),amount_after_discounts:e.number(),quantity:e.number().nullable(),prorated:e.boolean(),period_start:e.number().nullable(),period_end:e.number().nullable()})}))(Q),{ReissueInvoiceParamsSchema:fc}=(e=>({ReissueInvoiceParamsSchema:e.object({invoice_id:e.string().meta({description:"The Autumn invoice ID to void and replace.",example:"inv_2b3c4d5e6f7g8h"}),invoice_template_id:e.string().optional().meta({description:"ID of an invoice template (configured in billing settings) whose footer and memo are applied to the replacement invoice."}),net_terms_days:e.number().int().positive().optional().meta({description:"Number of days the customer has to pay the replacement invoice. Defaults to the original invoice's due date; required when that date has already passed."}),update_customer_email:e.email().optional().meta({description:"Updates the customer's billing email before the replacement is issued, so Stripe sends the new invoice to this address."})})}))(Q),{InvoiceModeParamsSchema:zt}=(e=>({InvoiceModeParamsSchema:e.object({enabled:e.boolean().meta({description:"When true, creates an invoice and sends it to the customer instead of charging their card immediately. Uses Stripe's send_invoice collection method."}),enable_plan_immediately:e.boolean().default(!1).meta({description:"If true, enables the plan immediately even though the invoice is not paid yet."}),finalize:e.boolean().default(!0).meta({description:"If true, finalizes the invoice so it can be sent to the customer. If false, keeps it as a draft for manual review."}),invoice_template_id:e.string().optional().meta({description:"ID of an invoice template (configured in billing settings) whose footer (e.g. bank details) is applied to the invoice."}),net_terms_days:e.number().int().positive().optional().meta({description:"Number of days the customer has to pay the invoice before it is due (Stripe days_until_due)."})}).meta({title:"InvoiceMode",description:"Invoice mode configuration. Creates an invoice instead of charging the card immediately."})}))(Q),{InvoiceTemplateSchema:wm}=(e=>({InvoiceTemplateSchema:e.object({id:e.string().meta({description:"Unique identifier for the invoice template."}),name:e.string().meta({description:"User-defined name to distinguish this template when sending an invoice."}),footer:e.string().optional().meta({description:"Footer text rendered on the invoice, typically bank details so customers can pay directly."}),memo:e.string().optional().meta({description:"Memo shown near the top of the invoice (Stripe invoice description), e.g. a contact line for payment questions."}),net_terms_days:e.number().int().positive().optional().meta({description:"Default number of days the customer has to pay before the invoice is due. Overridable when sending."}),created_at:e.number().optional().meta({description:"Timestamp (ms) when the template was created."})})}))(Q),{BasePriceSchema:_m}=((e,t,n)=>({BasePriceSchema:e.object({amount:e.number().meta({description:"Base price amount for the plan, in major currency units (e.g. dollars)."}),interval:e.enum(t).meta({description:"Billing interval (e.g. 'month', 'year')."}),interval_count:e.number().optional().meta({description:"Number of intervals per billing cycle. Defaults to 1."}),display:n.optional().meta({description:"Display text for showing this price in pricing pages."})})}))(Q,ac,um),{CURRENCY_CODES:Pm}=((e,t,n)=>({CURRENCY_CODES:[...e,...t.filter(o=>!n.has(o)).sort()]}))(sc,lm,mm),{ApiPriceProcessorsSchema:gc}=((e,t)=>({ApiPriceProcessorsSchema:e.object({stripe:t.nullish()}).meta({"x-atmn-mapping":!0})}))(Q,dm),{AllocatedBillingFieldSchema:Cm}=((e,t)=>({AllocatedBillingFieldSchema:e.enum(t).optional().meta({internal:!0,description:"How an allocated usage_based price bills mid-cycle quantity changes. 'arrear' (default) bills at period end. 'prorated_legacy' is only returned for prices still on the legacy immediate-proration behavior; omit it to migrate the price to 'arrear'."})}))(Q,hm),{CreditDimensionNameSchema:km}=((e,t,n)=>({CreditDimensionNameSchema:e.string().min(1).max(t).refine(o=>!o.includes(n),{message:`Dimension names cannot contain "${n}"`})}))(Q,bm,ym),{ApiCreditMatchSchema:hc}=(e=>({ApiCreditMatchSchema:e.meta({description:"Event properties this entry applies to. Every key must equal the tracked property, compared as strings."})}))(xm),{findCreditTierViolations:Rm}=(e=>({findCreditTierViolations:n=>{let r=[],o=(l,p)=>r.push({index:l,reason:p,message:e[p]}),a=0;for(let[l,p]of n.entries()){let d=l===n.length-1;if(p==="inf"){d||o(l,"non_final_infinity");continue}(!Number.isFinite(p)||p<=a)&&o(l,"not_increasing"),a=p,d&&o(l,"final_not_infinity")}return r}}))(Sm),{ApiCreditMultiplierSchema:Em}=((e,t)=>({ApiCreditMultiplierSchema:e.object({match:t,factor:e.number().positive().optional().meta({description:"Multiplies the matched rate. All matching multipliers stack."}),add:e.number().optional().meta({description:"Added to the rate after every factor is applied, in credits per billing-unit group."})}).strict().refine(r=>r.factor!==void 0||r.add!==void 0,{message:"A multiplier needs a factor or an add."})}))(Q,hc),{ProviderMarkupsSchema:Mm}=((e,t)=>({ProviderMarkupsSchema:e.record(e.string(),t).nullish()}))(Q,mc),{InvoiceFeatureQuantitySchema:bc}=((e,t,n)=>({InvoiceFeatureQuantitySchema:e.object({feature_id:e.string().meta({description:"The feature to bill."}),billing_behavior:e.enum(t).meta({description:"Which of the feature's prices to use: 'prepaid' or 'usage_based'."}),quantity:e.number().nonnegative().optional().meta({description:"Billable feature units in total, exclusive of any included usage. Not per seat or per entity. For a credit-system feature this is the number of credits."}),usage:e.array(n).optional().meta({description:"For credit-system features: billable units of the source features, converted through the credit rate card. Mutually exclusive with quantity."}),prorate:e.boolean().optional().meta({description:"Whether to prorate this line against period_start / period_end. Defaults to true for prepaid and false for usage-based."})}).strict().refine(o=>o.quantity!==void 0!=(o.usage!==void 0),{message:"Provide exactly one of quantity or usage."})}))(Q,pc,Im),{CreateInvoicePreviewSchema:Zi}=((e,t)=>({CreateInvoicePreviewSchema:e.object({currency:e.string(),lines:e.array(t),subtotal:e.number(),discount_total:e.number(),tax:e.object({total:e.number(),amount_inclusive:e.number(),amount_exclusive:e.number(),status:e.enum(["complete","incomplete"])}).nullable(),total:e.number(),due_date:e.number().nullable()})}))(Q,Am),{SUPPORTED_SET:Tm}=(e=>({SUPPORTED_SET:new Set(e)}))(Pm),{ApiCreditDimensionBaseSchema:Dm}=((e,t)=>({ApiCreditDimensionBaseSchema:e.object({match:t,priority:e.number().int().optional().meta({description:"Breaks ties between dimensions that match the same number of keys. Higher wins."})})}))(Q,hc),{refineGraduatedTiers:yc}=(e=>({refineGraduatedTiers:(n,r)=>{let o=e(n.tiers.map(a=>a.to));for(let{index:a,message:l}of o)r.addIssue({code:"custom",message:l,path:["tiers",a,"to"]})}}))(Rm),{ApiFeatureMarkupsOverrideSchema:Bm}=((e,t,n)=>({ApiFeatureMarkupsOverrideSchema:e.strictObject({default_markup:e.number().min(-100).optional().meta({description:"Default percentage markup for customers on this plan. Use -100 to make usage free."}),provider_markups:t.meta({description:"Per-provider markup percentages for customers on this plan."}),model_markups:n.meta({description:"Per-model markup overrides for customers on this plan."})})}))(Q,Mm,vm),{isValidCurrencyCode:zm}=(e=>({isValidCurrencyCode:n=>!!n&&e.has(n.toLowerCase())}))(Tm),{ApiCreditDimensionSchema:qm}=((e,t,n,r)=>({ApiCreditDimensionSchema:e.union([t.extend({tier_behavior:e.literal("graduated"),tiers:e.array(n).min(1)}).strict().superRefine(r),t.extend({credit_cost:e.number().min(0).meta({description:"Credits consumed per billing-unit group when this dimension matches."})}).strict()])}))(Q,Dm,lc,yc),{CurrencyCodeSchema:xc}=((e,t)=>({CurrencyCodeSchema:e.string().refine(t,"must be a Stripe-supported currency code").meta({description:"Three-letter Stripe-supported currency code (e.g. 'eur', 'gbp')."})}))(Q,zm),{AdditionalCurrencyTierSchema:Fm}=((e,t)=>({AdditionalCurrencyTierSchema:e.object({currency:t,amount:e.number().optional().meta({description:"Per-unit amount for this tier in this currency."}),flat_amount:e.number().optional().meta({description:"Flat amount for this tier in this currency, if the tier uses one."})}).refine(r=>r.amount!==void 0||r.flat_amount!==void 0,{message:"Either amount or flat_amount, or both must be defined",path:["amount","flat_amount"]})}))(Q,xc),{ApiCreditSchemaItemBaseSchema:Sc}=((e,t,n,r)=>({ApiCreditSchemaItemBaseSchema:e.object({metered_feature_id:e.string().nonempty().meta({description:"ID of the metered feature that draws from this credit system."}),billing_units:e.number().positive().optional().meta({description:"Number of metered-feature units priced together. Defaults to one when omitted."}),dimensions:e.record(t,n).optional().meta({description:"Named rates chosen by event properties. The most specific match sets the rate; with no match the item's own rate applies."}),multipliers:e.record(t,r).optional().meta({description:"Named adjustments chosen by event properties. Every match applies: factors multiply, then adds are summed."})})}))(Q,km,qm,Em),{ApiFlatCreditSchemaItemSchema:Nm}=((e,t)=>({ApiFlatCreditSchemaItemSchema:e.extend({credit_cost:t.number().min(0).meta({description:"Credits consumed per billing-unit group."})}).strict()}))(Sc,Q),{AdditionalCurrencyPriceSchema:Um}=((e,t)=>({AdditionalCurrencyPriceSchema:e.object({currency:t,amount:e.number().meta({description:"Price amount in this currency. Set explicitly per currency, not converted from the base amount."})})}))(Q,xc),{AdditionalCurrencyTierArraySchema:Vm}=((e,t,n,r)=>({AdditionalCurrencyTierArraySchema:e.array(t).refine(n,{message:r})}))(Q,Fm,cc,uc),{ApiGraduatedCreditSchemaItemSchema:$m}=((e,t,n,r)=>({ApiGraduatedCreditSchemaItemSchema:e.extend({tier_behavior:t.literal("graduated"),tiers:t.array(n).min(1)}).strict().superRefine(r)}))(Sc,Q,lc,yc),{AdditionalCurrencyPriceArraySchema:vc}=((e,t,n,r)=>({AdditionalCurrencyPriceArraySchema:e.array(t).refine(n,{message:r})}))(Q,Um,cc,uc),{ApiUsageTierWithCurrenciesSchema:Gm}=((e,t,n)=>({ApiUsageTierWithCurrenciesSchema:e.object({to:e.number().or(e.literal(t)),amount:e.number().optional(),flat_amount:e.number().optional(),additional_currencies:n.optional().meta({description:"Per-currency amounts for this tier. Tier boundaries ('to') are shared across all currencies."})}).refine(o=>o.amount!==void 0||o.flat_amount!==void 0,{message:"Either amount or flat_amount, or both must be defined",path:["amount","flat_amount"]}).transform(o=>({...o,amount:o.amount??0})).pipe(e.object({to:e.number().or(e.literal(t)),amount:e.number(),flat_amount:e.number().optional(),additional_currencies:n.optional()}))}))(Q,fm,Vm),{ApiCreditSchemaItemSchema:Km}=((e,t,n)=>({ApiCreditSchemaItemSchema:e.union([t,n])}))(Q,$m,Nm),{BasePriceParamsSchema:Lm}=((e,t,n,r)=>({BasePriceParamsSchema:e.omit({display:!0}).extend({interval_count:t({schema:n.number().optional(),defaultValue:1,description:"Number of intervals per billing cycle. Defaults to 1."}),additional_currencies:r.optional().meta({description:"Base price amounts in additional currencies. The base 'amount' is in the org's default currency."}),base_currency:n.string().optional().meta({internal:!0}),entitlement_id:n.string().optional().meta({internal:!0}),price_id:n.string().optional().meta({internal:!0}),stripe_price_id:n.string().optional().meta({description:"Stripe price id this base price is billed under. Set by sync flows to capture the actual Stripe price when it differs from the catalog default.",internal:!0})}).meta({title:"BasePrice",description:"Base price configuration for a plan."})}))(_m,pm,Q,vc),{PlanItemPriceParamsSchema:Zm}=((e,t,n,r,o,a,l)=>({PlanItemPriceParamsSchema:e.object({stripe_price_id:e.string().nullish().transform(d=>d??void 0).meta({description:"Stripe price id this feature price is billed under. Set by sync flows to preserve an existing Stripe price.",internal:!0}).optional(),amount:e.number().optional().meta({description:"Price per billing_units after included usage. Either 'amount' or 'tiers' is required."}),additional_currencies:t.optional().meta({description:"Amounts in additional currencies for this flat price. The base 'amount' is in the org's default currency. Only valid with 'amount', not 'tiers'."}),tiers:e.array(n).optional().meta({description:"Tiered pricing. Either 'amount' or 'tiers' is required."}),tier_behavior:e.enum(r).optional(),interval:e.enum(o).meta({description:"Billing interval. For consumable features, should match reset.interval."}),interval_count:e.number().default(1).optional().meta({description:"Number of intervals per billing cycle. Defaults to 1."}),billing_units:e.number().default(1).optional().meta({description:"Units per price increment. Usage is rounded UP when billed (e.g. billing_units=100 means 101 rounds to 200)."}),billing_method:e.enum(a).meta({description:"'prepaid' for upfront payment (seats), 'usage_based' for pay-as-you-go."}),allocated_billing:l,max_purchase:e.number().nullish().meta({description:"Max units purchasable beyond included. E.g. included=100, max_purchase=300 allows 400 total. Null for no limit."})})}))(Q,vc,Gm,gm,ac,pc,Cm),{ApiFeatureOverrideSchema:Hm}=((e,t,n)=>({ApiFeatureOverrideSchema:e.strictObject({credit_schema:e.array(t).optional().meta({description:"For credit system features: replaces the feature's credit_schema entirely for customers on this plan."}),markups:n.optional().meta({description:"For AI credit system features: replaces the feature's markup chain entirely for customers on this plan. An unset level means no markup at that level rather than inheriting the feature's."})})}))(Q,Km,Bm),{InvoiceBasePriceParamsSchema:Ic}=((e,t)=>({InvoiceBasePriceParamsSchema:e.pick({amount:!0,interval:!0,interval_count:!0}).extend({processors:t.optional().meta({description:"Bill this line under an existing Stripe price instead of an inline one."})}).strict()}))(Lm,gc),{InvoiceItemPriceParamsSchema:Jm}=((e,t)=>({InvoiceItemPriceParamsSchema:e.pick({amount:!0,tiers:!0,tier_behavior:!0,interval:!0,interval_count:!0,billing_units:!0,billing_method:!0}).extend({processors:t.optional().meta({description:"Bill this line under an existing Stripe price instead of an inline one."})}).strict()}))(Zm,gc),{InvoiceLicenseQuantitySchema:Wm}=((e,t,n)=>({InvoiceLicenseQuantitySchema:e.object({license_plan_id:e.string().meta({description:"The license plan linked to the parent plan."}),quantity:e.number().int().nonnegative().meta({description:"Billable seats, exclusive of any included seats."}),customize:e.object({price:t.nullable().optional()}).strict().optional().meta({description:"Override the license's per-seat price on this invoice."}),feature_quantities:e.array(n).optional().meta({description:"Feature charges priced through the license plan."}),prorate:e.boolean().optional().meta({description:"Whether to prorate seat charges against period_start / period_end. Defaults to true."})}).strict()}))(Q,Ic,bc),{InvoiceCustomizeItemSchema:Qm}=((e,t,n)=>({InvoiceCustomizeItemSchema:e.object({feature_id:e.string().meta({description:"The feature whose pricing is overridden on this invoice."}),price:t.optional().meta({description:"Pricing to use for this feature on this invoice."}),feature_override:n.pick({credit_schema:!0}).strict().optional().meta({description:"For credit-system features: a credit rate card to use when converting `usage` on this invoice."})}).strict()}))(Q,Jm,Hm),{InvoiceCustomizeSchema:Xm}=((e,t,n)=>({InvoiceCustomizeSchema:e.object({price:t.nullable().optional().meta({description:"Override the plan's base price for this invoice. Pass null or an amount of 0 to omit the base price line."}),items:e.array(n).optional().meta({description:"Override feature pricing for this invoice. Only pricing fields are accepted; grants, resets and rollovers are not part of an invoice."})}).strict().meta({title:"InvoiceCustomize",description:"Pricing overrides applied to this invoice only. The catalog and the customer's plan are not changed."})}))(Q,Ic,Qm),{InvoicePlanParamsSchema:Ym}=((e,t,n,r,o)=>({InvoicePlanParamsSchema:e.object({plan_id:e.string().meta({description:"The catalog plan (or variant) whose pricing to use."}),version:e.number().optional().meta({description:"Plan version. Defaults to the active version."}),customize:t.optional(),feature_quantities:e.array(n).optional(),license_quantities:e.array(r).optional(),discounts:e.array(o).optional().meta({description:"Discounts applied only to this plan's lines."}),prorate:e.boolean().optional().meta({description:"Whether to prorate the base price against period_start / period_end. Defaults to true."})}).strict()}))(Q,Xm,bc,Wm,dc),{CreateInvoiceParamsSchema:pn}=((e,t,n,r,o)=>({CreateInvoiceParamsSchema:e.object({customer_id:e.string().meta({description:"The customer to invoice."}),plans:e.array(t).optional(),custom_line_items:e.array(n).optional().meta({description:"Charges that are not tied to any plan or feature."}),discounts:e.array(r).optional().meta({description:"Discounts applied to the whole invoice."}),invoice_template_id:e.string().optional().meta({description:"ID of an invoice template whose footer, memo and default payment terms are applied."}),net_terms_days:e.number().int().positive().optional().meta({description:"Days until the invoice is due. Defaults to the template's terms, then the org default."}),tax_rate_id:e.string().optional().meta({description:"Stripe tax rate ID (txr_...) applied to every line."}),period_start:o.optional().meta({description:"Start of the period being invoiced, in milliseconds. Prorated lines are charged for period_start \u2192 period_end against one price interval starting at period_start."}),period_end:o.optional().meta({description:"End of the period being invoiced, in milliseconds."}),preview:e.boolean().optional().meta({description:"If true, returns the calculated lines and totals without creating an invoice."})}).strict().refine(l=>l.period_start===void 0==(l.period_end===void 0),{message:"period_start and period_end must be provided together."}).refine(l=>l.period_start===void 0||l.period_end===void 0||l.period_end>l.period_start,{message:"period_end must be after period_start."})}))(Q,Ym,Om,dc,jm);var Ac=i.strictObject({requestId:i.uuid(),predecessorOperationId:i.uuid().optional(),invoiceMode:zt.optional(),entityId:i.uuid().optional(),billingSubscriptionId:i.uuid().optional(),newBillingSubscription:i.literal(!0).optional(),offerId:i.uuid().optional(),nativeOffer:un.optional(),plans:i.array(i.strictObject({productVersionId:i.uuid(),seatQuantities:i.record(Ar,i.number().int().min(0).max(1e4)).optional(),featureQuantities:i.record(i.uuid(),i.number().int().min(0).max(1e4)).refine(e=>Object.keys(e).length<=100,"At most 100 feature quantities").optional()})).min(1).max(20).refine(e=>new Set(e.map(t=>t.productVersionId)).size===e.length,"Plan versions must be unique"),provider:i.enum(["stripe","apple","google","merchant"]),currency:ie}).refine(e=>!e.offerId||!e.billingSubscriptionId&&(["stripe","merchant"].includes(e.provider)||e.nativeOffer!==void 0),"Held offers apply to new purchases; existing subscriptions use billing coupons").refine(e=>!e.nativeOffer||["apple","google"].includes(e.provider)&&e.plans.length===1,"A store selection applies to exactly one native SKU").refine(e=>!e.newBillingSubscription||["stripe","merchant"].includes(e.provider)&&!e.billingSubscriptionId,"A new billing subscription has no existing subscription target").refine(e=>!e.invoiceMode?.enabled||e.provider==="stripe"&&!e.entityId,"Invoice mode requires a Stripe subscription without an Entity target"),Ft=i.strictObject({operationId:i.uuid()}),Re=i.number().int().min(0).max(1e8),ed=i.strictObject({lineId:i.uuid(),productVersionId:i.uuid(),productName:i.string().min(1).max(80),interval:i.enum(["free","week","month","year","one_time"]),intervalCount:i.number().int().min(1).max(156).optional(),baseAmountMinor:Re,seats:i.array(i.strictObject({key:Ar,quantity:i.number().int().min(0).max(1e4),includedQuantity:i.number().int().min(0).max(1e4),maximumQuantity:i.number().int().min(0).max(1e4),unitAmountMinor:Re})).max(20),prepaid:i.array(Vs).max(100).optional(),catalogAmountMinor:Re,trial:i.strictObject({days:i.number().int().min(1).max(730),cardRequired:i.boolean()}).nullable()}).refine(e=>new Set(e.seats.map(t=>t.key)).size===e.seats.length&&e.seats.every(t=>t.quantity>=t.includedQuantity&&t.quantity<=t.maximumQuantity)&&e.baseAmountMinor+e.seats.reduce((t,n)=>t+n.unitAmountMinor*(n.quantity-n.includedQuantity),0)+(e.prepaid??[]).reduce((t,n)=>t+ir({quantity:n.quantity,unitAmountMinor:n.unitAmountMinor,...n.pricing===void 0?{}:{pricing:n.pricing}}),0)===e.catalogAmountMinor,"Quote must retain its published base price and component quantities"),wc=i.string().regex(/^[A-Za-z0-9_-]{1,200}$/),td=i.strictObject({id:wc,name:i.string().min(1).max(40),percent_off:i.number().gt(0).max(100).optional(),amount_off:i.number().int().positive().optional(),currency:i.string().regex(/^[a-z]{3}$/).optional(),duration:i.enum(["once","repeating","forever"]),duration_in_months:i.number().int().min(1).max(36).optional()}).refine(e=>e.percent_off===void 0!=(e.amount_off===void 0)&&e.amount_off===void 0==(e.currency===void 0)&&e.duration==="repeating"==(e.duration_in_months!==void 0),"A Stripe coupon has one percentage or amount and months only when repeating"),nd=i.strictObject({subscriptionId:i.string().regex(/^sub_[A-Za-z0-9]+$/),customerId:i.string().regex(/^cus_[A-Za-z0-9]+$/),sourceItems:i.array(i.strictObject({id:i.string(),price_id:i.string(),quantity:i.number().int().nonnegative(),discounts:i.array(i.strictObject({id:i.string(),coupon:i.string(),start:i.number(),end:i.number().nullable()})).optional()})).min(1).max(100),prorationDate:i.number().int().nonnegative(),amountMinor:i.number().int().positive(),periodStartMs:i.number(),periodEndMs:i.number()}),_c=i.strictObject({invoiceMode:zt.optional(),append:nd.optional(),provider:i.literal("stripe"),executor:i.enum(["indiana","merchant"]),accountId:i.string().regex(/^acct_[A-Za-z0-9]+$/),mode:i.enum(["payment","subscription"]),lineItems:i.array(i.strictObject({price:i.string().regex(/^price_[A-Za-z0-9]+$/).nullable(),quantity:i.number().int().min(1).max(1e4),priceId:i.uuid(),productName:i.string().min(1).max(80),amountMinor:i.number().int().min(0).max(1e8),currency:i.string().regex(/^[a-z]{3}$/),interval:i.enum(["week","month","year","one_off"]),intervalCount:i.number().int().min(1).max(52),slot:i.enum(["stripe_price_id","stripe_empty_price_id"]),tiers:i.strictObject({mode:i.enum(["graduated","volume"]),tiers:i.array(i.strictObject({upTo:i.number().int().min(1).max(1e6).nullable(),unitAmountMinor:i.number().int().min(0).max(1e8),flatAmountMinor:i.number().int().min(0).max(1e8).optional()})).min(2).max(12)}).nullable()})).min(1).max(100),discounts:i.array(i.strictObject({coupon:wc,terms:td})).max(1),trialPeriodDays:i.number().int().min(1).max(730).nullable(),metadata:i.strictObject({grooveCheckoutId:i.uuid(),grooveCustomerId:i.uuid()}),expiresAt:i.iso.datetime({offset:!0})}),ln=i.strictObject({operationId:i.uuid(),entityId:i.uuid().nullable(),billingSubscriptionId:i.uuid().nullable(),discount:i.strictObject({offerId:i.uuid(),couponId:i.uuid(),discount:jt,duration:Ze,amountMinor:Re,allocations:i.array(i.strictObject({productVersionId:i.uuid(),amountMinor:Re})).min(1).max(20),expiresAt:i.iso.datetime({offset:!0})}).nullable(),charge:i.strictObject({effectiveAt:i.iso.datetime({offset:!0}),periodEndsAt:i.iso.datetime({offset:!0}),debitMinor:Re,discountMinor:Re,taxMinor:Re,totalMinor:Re}).nullable(),expiresAt:i.iso.datetime({offset:!0}),provider:i.enum(["stripe","apple","google","merchant"]),nativeOffer:un.optional(),currency:ie,lines:i.array(ed).min(1).max(20),catalogAmountMinor:Re,automaticTax:i.boolean(),execution:i.union([_c,mr]).nullable()}).refine(e=>e.provider==="merchant"?e.execution?.provider==="merchant"&&e.execution.operationId===e.operationId&&e.execution.catalogAmountMinor===e.catalogAmountMinor&&e.execution.currency===e.currency&&Date.parse(e.execution.expiresAt)<=Date.parse(e.expiresAt)&&e.execution.trialPeriodDays===(e.lines[0]?.trial?.days??null)&&e.execution.discount?.grantId===e.discount?.offerId:e.provider==="stripe"?e.execution?.provider!=="merchant"&&(e.lines[0]?.trial?.cardRequired===!1&&!e.execution?.invoiceMode?.enabled?e.execution===null&&e.discount===null:e.execution!==null&&e.execution.metadata.grooveCheckoutId===e.operationId&&Date.parse(e.execution.expiresAt)<=Date.parse(e.expiresAt)&&e.execution.mode===(e.lines.some(t=>!["one_time","free"].includes(t.interval))?"subscription":"payment")&&e.execution.trialPeriodDays===(e.lines[0]?.trial?.days??null)&&(e.execution.executor==="indiana"||e.execution.lineItems.every(t=>t.price!==null))&&e.execution.discounts.every(t=>t.coupon===t.terms.id)&&e.execution.discounts.length===(e.discount?1:0)&&e.execution.discounts.every(t=>e.discount!==null&&(t.coupon===e.discount.couponId||e.discount.discount.type==="amount"&&t.coupon===`${e.discount.couponId}_credit_${e.discount.offerId}_${t.terms.amount_off}`&&t.terms.amount_off===e.discount.discount.amountOffCents&&t.terms.currency?.toUpperCase()===e.currency&&t.terms.duration==="once"))):e.execution===null,"Stripe execution must carry the quote identity, expiry, mode, trial and held coupon").refine(e=>(!e.discount||!e.billingSubscriptionId&&(["stripe","merchant"].includes(e.provider)||e.discount.duration.type==="once")&&e.discount.amountMinor<=e.catalogAmountMinor&&e.discount.allocations.length===e.lines.length&&e.discount.allocations.every((t,n)=>{let r=e.lines[n];return r!==void 0&&t.productVersionId===r.productVersionId&&t.amountMinor<=r.catalogAmountMinor})&&e.discount.allocations.reduce((t,n)=>t+n.amountMinor,0)===e.discount.amountMinor)&&(["stripe","merchant"].includes(e.provider)?e.nativeOffer===void 0:e.nativeOffer!==void 0&&e.lines.length===1&&e.nativeOffer.discountMinor<=e.catalogAmountMinor&&e.nativeOffer.trialDays===(e.lines[0]?.trial?.days??null)&&(!e.discount||e.nativeOffer.discountMinor===e.discount.amountMinor))&&(!e.charge||e.billingSubscriptionId!==null&&e.charge.totalMinor===e.charge.debitMinor-e.charge.discountMinor+e.charge.taxMinor&&e.charge.discountMinor<=e.charge.debitMinor&&Date.parse(e.charge.periodEndsAt)>Date.parse(e.charge.effectiveAt))&&new Set(e.lines.map(t=>t.lineId)).size===e.lines.length&&e.lines.reduce((t,n)=>t+n.catalogAmountMinor,0)===e.catalogAmountMinor,"Quote lines must conserve the catalog amount"),mn=i.strictObject({operationId:i.uuid(),orderId:i.uuid(),append:i.boolean().optional(),invoiceMode:i.boolean().optional(),status:i.enum(["pending","complete","cancelled","failed"]),executor:i.enum(["indiana","merchant"]),checkoutUrl:i.url().refine(e=>new URL(e).protocol==="https:").nullable(),execution:i.union([_c,mr]).nullable(),currency:ie,catalogAmountMinor:Re,taxMinor:Re,totalMinor:i.number().int().min(0).max(2e8).nullable(),quoteFinalized:i.boolean(),nativePurchase:Li.nullable(),confirmedAt:i.iso.datetime({offset:!0}).nullable().optional(),quote:ln.optional(),merchantExecution:Et.nullable().optional(),problem:kn.nullable().optional(),authority:br.optional()}).refine(e=>(e.checkoutUrl===null||e.executor==="indiana"||e.merchantExecution?.type==="purchase")&&(e.execution===null||e.executor==="merchant"),"Only Indiana-executed purchases carry a Checkout URL and only record-only purchases carry execution instructions"),Dr=i.strictObject({enabled:i.literal(!0),featureIds:i.array(i.uuid()).min(1).max(100).refine(e=>new Set(e).size===e.length,"Feature IDs must be unique").optional()}),Pc=i.strictObject({requestId:i.uuid(),invoiceMode:zt.optional(),membershipId:i.uuid(),carryOverBalances:Dr.optional(),carryOverUsages:Dr.optional(),membershipIds:i.array(i.uuid()).min(1).max(20).optional(),prorationBehavior:i.enum(["prorate_immediately","none","bill_difference"]).optional(),timing:i.enum(["immediate","renewal","store"]),change:i.discriminatedUnion("type",[i.strictObject({type:i.literal("plan"),productVersionId:i.uuid()}),i.strictObject({type:i.literal("seats"),licenseKey:Ar,quantity:i.number().int().min(0).max(1e4)}),i.strictObject({type:i.literal("quantity"),internal_feature_id:i.uuid(),quantity:i.number().int().min(0).max(1e4)}),i.strictObject({type:i.literal("cancel")}),i.strictObject({type:i.literal("uncancel")}),i.strictObject({type:i.literal("billing_cycle"),billingCycleAnchor:i.union([i.literal("now"),i.number().int().positive().max(0xe677d21fdbff)])})])}).refine(e=>e.timing!=="store"||e.change.type==="plan","Store timing applies to a native plan replacement").refine(e=>e.change.type!=="billing_cycle"||e.timing===(e.change.billingCycleAnchor==="now"?"immediate":"renewal"),"Use immediate for now and renewal for a future millisecond anchor").refine(e=>!e.membershipIds||["cancel","uncancel"].includes(e.change.type)&&e.membershipIds.includes(e.membershipId)&&new Set(e.membershipIds).size===e.membershipIds.length,"Grouped actions require unique cancel/uncancel targets including the primary membership").refine(e=>!e.carryOverBalances&&!e.carryOverUsages||e.change.type==="plan"&&e.timing==="immediate","Carry applies only to immediate upgrades").refine(e=>!e.prorationBehavior||e.change.type==="quantity","prorationBehavior applies to prepaid quantity changes"),Tr=i.string().regex(/^price_[A-Za-z0-9]+$/),Oc=i.strictObject({grooveUpdateId:i.uuid(),grooveCustomerId:i.uuid()}),jc=i.strictObject({price:Tr.nullable(),priceId:i.uuid().optional(),quantity:i.number().int().min(0).max(1e4)}),Cc=i.strictObject({provider:i.literal("stripe"),invoiceMode:zt.optional(),executor:i.enum(["indiana","merchant"]),accountId:i.string().regex(/^acct_[A-Za-z0-9]+$/),subscriptionId:i.string().regex(/^sub_[A-Za-z0-9]+$/),action:i.enum(["update","cancel","schedule","release"]),update:i.strictObject({items:i.array(jc).max(20),remove:i.array(Tr).max(20),restoreItems:i.array(i.strictObject({price:Tr,quantity:i.number().int().min(0).max(1e4)})).min(1).max(20).optional(),prorationBehavior:i.enum(["always_invoice","create_prorations","none"]).optional(),prorationDate:i.number().int().positive().optional(),paymentBehavior:i.literal("error_if_incomplete").optional(),cancelAtPeriodEnd:i.boolean().optional(),clearCancelAt:i.literal(!0).optional(),billingCycleAnchorNow:i.literal(!0).optional(),metadata:Oc}).nullable(),cancel:i.strictObject({prorate:i.literal(!1),invoiceNow:i.literal(!1)}).nullable(),schedule:i.strictObject({currentItems:i.array(i.strictObject({price:Tr,quantity:i.number().int().min(0).max(1e4)})).max(20),nextItems:i.array(jc).min(1).max(20),switchAt:i.number().int().positive(),interval:i.enum(["week","month","year"]),intervalCount:i.number().int().min(1).max(52),resetBillingCycleAnchor:i.literal(!0).optional(),metadata:Oc}).nullable(),release:i.strictObject({schedule:i.string().regex(/^sub_sched_[A-Za-z0-9]+$/)}).nullable(),expiresAt:i.iso.datetime({offset:!0})}).refine(e=>["update","cancel","schedule","release"].every(t=>e[t]!==null==(e.action===t))&&(e.executor==="indiana"||[...e.update?.items??[],...e.schedule?.nextItems??[]].every(t=>t.price!==null)),"Stripe update execution carries exactly its action, with bound Prices for the merchant"),Br=i.strictObject({carryOverBalances:Dr.optional(),carryOverUsages:Dr.optional(),operationId:i.uuid(),membershipId:i.uuid(),productVersionId:i.uuid(),timing:i.enum(["immediate","renewal"]),effectiveAt:i.iso.datetime({offset:!0}),expiresAt:i.iso.datetime({offset:!0}),currency:ie,creditMinor:Re,debitMinor:Re,discountMinor:Re,taxMinor:Re,totalMinor:Re,retainedProductVersionIds:i.array(i.uuid()).max(19),execution:i.union([Cc,dr])}),rd=i.strictObject({operationId:i.uuid(),invoiceMode:i.boolean().optional(),membershipId:i.uuid(),productVersionId:i.uuid(),status:i.enum(["prepared","quoted","confirmed","pending","scheduled","effective","cancelled","failed"]),timing:i.enum(["immediate","renewal"]),effectiveAt:i.iso.datetime({offset:!0}),checkoutUrl:i.url().refine(e=>new URL(e).protocol==="https:").nullable(),executor:i.enum(["indiana","merchant"]),execution:i.union([Cc,dr]).nullable(),confirmedAt:i.iso.datetime({offset:!0}).nullable().optional(),merchantExecution:Et.nullable().optional(),problem:kn.nullable().optional(),quote:Br.optional(),authority:br.optional()}).refine(e=>e.execution===null||e.executor==="merchant","Only record-only changes carry execution instructions"),id=i.strictObject({operationId:i.uuid(),membershipId:i.uuid(),productVersionId:i.uuid(),timing:i.literal("store"),effectiveAt:i.null(),expiresAt:i.iso.datetime({offset:!0}),currency:ie,creditMinor:i.null(),debitMinor:i.null(),discountMinor:i.null(),taxMinor:i.null(),totalMinor:i.null(),retainedProductVersionIds:i.array(i.uuid()).max(19),store:i.strictObject({provider:i.enum(["apple","google"]),productId:i.string().min(1).max(255),catalogAmountMinor:Re,policy:i.enum(["apple_store","google_full_price"])})}),od=i.strictObject({operationId:i.uuid(),membershipId:i.uuid(),productVersionId:i.uuid(),status:i.enum(["prepared","pending","effective","cancelled","failed"]),timing:i.literal("store"),effectiveAt:i.iso.datetime({offset:!0}).nullable(),checkoutUrl:i.null(),nativePurchase:Li.nullable()}),kc=i.union([Br,id]),Hi=i.union([rd,od]),Un=i.number().int().positive().max(2e8),qt=i.number().int().min(0).max(2e8),Rc=i.strictObject({requestId:i.uuid(),invoiceId:i.uuid(),mode:i.enum(["full","partial"]),amountMinor:Un.optional(),entitlementAction:i.enum(["retain","revoke"])}).refine(e=>e.mode==="partial"==(e.amountMinor!==void 0),"A partial refund states amountMinor; a full refund refunds the remaining amount"),Ec=i.strictObject({provider:i.literal("stripe"),executor:i.enum(["indiana","merchant"]),accountId:i.string().regex(/^acct_[A-Za-z0-9]+$/),invoice:i.string().regex(/^in_[A-Za-z0-9]+$/),amountMinor:Un,currency:i.string().regex(/^[a-z]{3}$/),metadata:i.strictObject({indianaRefundId:i.uuid()}),idempotencyKey:i.string().regex(/^indiana-refund-[0-9a-f-]{36}$/),cancelSubscriptions:i.array(i.string().regex(/^sub_[A-Za-z0-9]+$/)).max(20)}),Ji=i.strictObject({operationId:i.uuid(),invoiceId:i.uuid(),providerInvoiceId:i.string().min(1).max(200),currency:ie,paidMinor:qt,refundedMinor:qt,pendingMinor:qt,amountMinor:Un,mode:i.enum(["full","partial"]),entitlementAction:i.enum(["retain","revoke"]),revokes:i.strictObject({customerProductIds:i.array(i.uuid()).max(100),subscriptionIds:i.array(i.string().min(1).max(200)).max(20)}),execution:i.union([Ec,fr]),expiresAt:i.iso.datetime({offset:!0})}).refine(e=>e.amountMinor<=e.paidMinor-e.refundedMinor-e.pendingMinor&&e.execution.amountMinor===e.amountMinor&&(e.execution.provider==="merchant"?e.execution.merchantInvoiceId===e.providerInvoiceId&&e.execution.operationId===e.operationId&&e.execution.currency===e.currency:e.execution.invoice===e.providerInvoiceId&&e.execution.metadata.indianaRefundId===e.operationId&&e.execution.currency===e.currency.toLowerCase())&&(e.entitlementAction==="revoke"||e.revokes.customerProductIds.length===0&&e.revokes.subscriptionIds.length===0),"Refund quote must stay within the refundable amount and match its execution"),zr=i.strictObject({operationId:i.uuid(),invoiceId:i.uuid(),providerInvoiceId:i.string().min(1).max(200),status:i.enum(["quoted","pending","succeeded","failed","expired"]),executor:i.enum(["indiana","merchant"]),currency:ie,amountMinor:Un,mode:i.enum(["full","partial"]),entitlementAction:i.enum(["retain","revoke"]),refundId:i.string().min(1).max(200).nullable(),quote:Ji.optional(),execution:i.union([Ec,fr]).nullable(),confirmedAt:i.iso.datetime({offset:!0}).nullable().optional(),merchantExecution:Et.nullable().optional(),problem:kn.nullable().optional(),authority:br.optional(),failureReason:i.string().min(1).max(200).nullable(),createdAt:i.iso.datetime({offset:!0}),completedAt:i.iso.datetime({offset:!0}).nullable()}).refine(e=>(e.execution===null||e.executor==="merchant"&&e.status==="quoted")&&(e.status!=="succeeded"||e.refundId!==null),"Only quoted record-only refunds carry instructions; a succeeded refund names its Stripe refund"),dy=i.strictObject({invoiceId:i.uuid(),currency:ie,paidMinor:qt,refundedMinor:qt,pendingMinor:qt,refundableMinor:qt,executor:i.enum(["indiana","merchant"]).nullable(),canRefund:i.boolean(),operations:i.array(zr).max(50)}).refine(e=>e.operations.every(t=>t.invoiceId===e.invoiceId),"Refund operations belong to the invoice"),fy=i.strictObject({requestId:i.uuid(),mode:i.enum(["full","partial"]),amountMinor:Un.optional(),entitlementAction:i.enum(["retain","revoke"])}).refine(e=>e.mode==="partial"==(e.amountMinor!==void 0),"A partial refund states amountMinor; a full refund refunds the remaining amount");var Mc=ye.strictObject({requestId:ye.uuid(),targets:ye.array(ye.strictObject({membershipId:ye.uuid(),action:ye.enum(["cancel","uncancel"]),timing:ye.enum(["immediate","renewal"])}).refine(e=>e.action!=="uncancel"||e.timing==="immediate","Restoration is immediate")).min(1).max(100)}).refine(e=>new Set(e.targets.map(t=>t.membershipId)).size===e.targets.length,"Duplicate batch target"),qr=ye.strictObject({batchId:ye.uuid()}),ad=ye.strictObject({operationId:ye.uuid(),membershipIds:ye.array(ye.uuid()).min(1).max(20),provider:ye.enum(["stripe","apple","google"]),action:ye.enum(["cancel","uncancel"]),timing:ye.enum(["immediate","renewal"]),status:ye.enum(["prepared","confirmed","pending","scheduled","effective","cancelled","failed","store_action_required"]),quote:Br.nullable(),managementUrl:ye.url().nullable(),failureCode:ye.enum(["provider_unavailable","invalid_evidence","pending_payment"]).nullable()}),Vn=ye.strictObject({batchId:ye.uuid(),ready:ye.boolean(),status:ye.enum(["prepared","cancelled","expired","pending","partial","effective","action_required"]),createdAt:ye.iso.datetime({offset:!0}),acceptedAt:ye.iso.datetime({offset:!0}).nullable(),groups:ye.array(ad).min(1).max(100)});import{z as te}from"zod";var sd=te.string().trim().min(1).max(240),Wi={requestId:te.uuid(),reason:sd},Fr=te.discriminatedUnion("action",[te.strictObject({...Wi,action:te.literal("start"),productVersionId:te.uuid(),entityId:te.uuid().optional(),days:te.number().int().min(1).max(730).optional()}),te.strictObject({...Wi,action:te.literal("extend"),membershipId:te.uuid(),days:te.number().int().min(1).max(730)}),te.strictObject({...Wi,action:te.literal("end"),membershipId:te.uuid()})]),Tc=te.strictObject({operationId:te.uuid()}),Dc=te.iso.datetime({offset:!0}),cd=te.strictObject({provider:te.literal("stripe"),executor:te.enum(["indiana","merchant"]),accountId:te.string().regex(/^acct_[A-Za-z0-9]+$/),subscriptionId:te.string().regex(/^sub_[A-Za-z0-9]+$/),trialEnd:te.union([te.literal("now"),Dc]),prorationBehavior:te.literal("none")}),Qi=te.strictObject({operationId:te.uuid(),action:te.enum(["start","extend","end"]),status:te.enum(["pending","effective"]),managedBy:te.enum(["indiana","stripe"]),membershipIds:te.array(te.uuid()).min(1).max(20),endsAt:Dc.nullable(),execution:cd.nullable()}).refine(e=>e.execution!==null==(e.managedBy==="stripe"&&e.status==="pending")&&e.action==="end"==(e.endsAt===null)&&(e.action!=="start"||e.managedBy==="indiana")&&(e.execution===null||e.execution.trialEnd==="now"==(e.action==="end")),"Only a pending Stripe trial change carries execution instructions"),Sy=te.strictObject({groupId:te.uuid(),productVersionId:te.uuid(),enabled:te.boolean()});import{z as me}from"zod";var Bc=me.strictObject({requestId:me.uuid(),currency:ie,makeDefault:me.boolean()}),zc=me.strictObject({setupId:me.uuid()}),ud=me.strictObject({provider:me.literal("stripe"),executor:me.literal("merchant"),accountId:me.string().regex(/^acct_[A-Za-z0-9]+$/),mode:me.literal("setup"),currency:me.string().regex(/^[a-z]{3}$/),customer:me.string().regex(/^cus_[A-Za-z0-9]+$/).nullable(),clientReferenceId:me.uuid(),metadata:me.strictObject({grooveProjectId:me.uuid(),grooveEnvironmentId:me.uuid(),grooveCustomerId:me.uuid(),groovePaymentSetupId:me.uuid()}),setDefaultPaymentMethod:me.boolean(),expiresAt:me.iso.datetime({offset:!0})}),Xi=me.strictObject({id:me.uuid(),provider:me.literal("stripe"),status:me.enum(["prepared","complete","expired"]),currency:ie,makeDefault:me.boolean(),url:me.url().nullable(),createdAt:me.iso.datetime({offset:!0}),expiresAt:me.iso.datetime({offset:!0}),completedAt:me.iso.datetime({offset:!0}).nullable(),execution:ud.nullable()});import{z as Ee}from"zod";var qc=Ee.union([Ee.string(),Ee.number(),Ee.boolean(),Ee.null()]),Fc=Ee.strictObject({customerId:Ee.uuid()}),Nc=Ee.strictObject({customerId:Ee.uuid(),provider:Ee.literal("stripe"),checkedAt:Ee.iso.datetime({offset:!0}),status:Ee.enum(["consistent","drifted","incomplete"]),checkedSubscriptions:Ee.number().int().nonnegative(),differences:Ee.array(Ee.strictObject({subscriptionId:Ee.string().startsWith("sub_"),itemId:Ee.string().nullable(),field:Ee.enum(["subscription","status","currency","cancelAtPeriodEnd","item","price","product","quantity","periodStart","periodEnd","trialEnd","evidence"]),expected:qc,actual:qc})).max(1e4)});import{z as J}from"zod";var Nr=J.iso.datetime({offset:!0}),Ur=J.strictObject({createdAt:Nr,id:J.uuid()}),Vr=J.strictObject({customerId:J.uuid().optional(),entityId:J.uuid().optional(),productId:J.string().min(1).max(256).optional(),provider:J.enum(["stripe","apple","google","merchant","free"]).optional(),status:J.enum(["trial","active","past_due","ended","refunded"]).optional(),cursor:Ur.optional(),limit:J.number().int().min(1).max(100).optional()}),Yi={id:J.uuid(),customerId:J.uuid(),entityId:J.uuid().nullable(),productId:J.string().min(1).max(256),productVersionId:J.uuid(),name:J.string().min(1).max(120),provider:J.enum(["stripe","apple","google","merchant","free"]),createdAt:Nr},pd=J.strictObject({...Yi,status:J.enum(["trial","active","past_due","ended"]),cancelAtPeriodEnd:J.boolean(),billingSubscriptionId:J.uuid().nullable()}),ld=J.strictObject({...Yi,status:J.enum(["active","ended","refunded"]),orderId:J.uuid().nullable(),transactionId:J.uuid().nullable(),currency:ie.nullable(),amountMinor:J.string().regex(/^(0|[1-9]\d{0,17})$/).nullable()}),md=J.strictObject({...Yi,status:J.enum(["blocked","resolved"]),conflict:J.strictObject({detectedAt:Nr,blockingMembershipIds:J.array(J.uuid()).min(1).max(100),transactionId:J.uuid()}),resolvedAt:Nr.nullable()}),Uc=Vr.extend({status:J.enum(["blocked","resolved"]).optional()}),Vc=J.strictObject({customerId:J.uuid(),orderId:J.uuid()}),$c=J.strictObject({orderId:J.uuid(),status:J.enum(["blocked","resolved"])}),Gc=J.strictObject({items:J.array(pd).max(100),nextCursor:Ur.nullable()}),Kc=J.strictObject({items:J.array(ld).max(100),nextCursor:Ur.nullable()}),Lc=J.strictObject({items:J.array(md).max(100),nextCursor:Ur.nullable()});import{z as ge}from"zod";var Zc=ge.union([ge.strictObject({intent:ge.literal("read"),requestId:ge.uuid(),purchaseIntentId:ge.uuid()}),ge.strictObject({requestId:ge.uuid(),provider:ge.literal("apple"),purchaseIntentId:ge.uuid(),productId:ge.string().min(1).max(255).optional(),signedTransaction:ge.string().min(1).max(131072)}),ge.strictObject({requestId:ge.uuid(),provider:ge.literal("google"),purchaseIntentId:ge.uuid(),productId:ge.string().min(1).max(255).optional(),purchaseToken:ge.string().min(1).max(16384)})]),Hc=ge.strictObject({requestId:ge.uuid(),orderId:ge.uuid(),purchaseIntentId:ge.uuid(),status:ge.enum(["created","pending","trialing","paid","cancelled","failed"]),currency:ie,refunded:ge.boolean(),completion:ge.strictObject({transactionIds:ge.array(ge.string().min(1).max(255)).min(1).max(50).refine(e=>new Set(e).size===e.length),membership:ge.boolean()}).nullable()});import{z as j}from"zod";var to=j.uuid().refine(e=>e===e.toLowerCase(),"Product references require canonical lowercase UUIDs"),dd=j.record(j.string(),j.json()).refine(e=>Array.from(JSON.stringify(e)).length<=4e3,"Offering metadata exceeds 4000 characters"),fd=3,$n=20,gd=fd*$n,eo=j.strictObject({type:j.literal("product"),productId:to}),Jc={type:j.literal("group"),key:j.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),name:j.string().trim().min(1).max(80)},hd=j.discriminatedUnion("type",[eo,j.strictObject({...Jc,items:j.array(eo).max($n)})]),bd=j.discriminatedUnion("type",[eo,j.strictObject({...Jc,items:j.array(hd).max($n)})]),yd=j.array(bd).max($n).superRefine((e,t)=>{let n=new Set,r=new Set,o=0;function a(l){for(let p of l){o++;let d=p.type==="product"?n:r,v=p.type==="product"?p.productId:p.key;d.has(v)&&t.addIssue({code:"custom",message:p.type==="product"?"Duplicate Offering Product reference":"Duplicate Offering group key"}),d.add(v),p.type==="group"&&a(p.items)}}a(e),(n.size>$n||o>gd)&&t.addIssue({code:"custom",message:"Offering item limit exceeded"})});function no(e){return e.items.flatMap(t=>t.type==="product"?[t.productId]:no(t))}var dn=j.strictObject({lookupKey:j.string().trim().min(1).max(200),displayName:j.string().trim().min(1).max(1500),items:yd,metadata:dd}),xd=j.strictObject({product:j.record(j.string(),j.json()),prices:j.array(j.record(j.string(),j.json())),entitlements:j.array(j.record(j.string(),j.json())),freeTrials:j.array(j.record(j.string(),j.json())),licenses:j.array(j.record(j.string(),j.json()))}),Wc=dn.extend({id:j.uuid(),projectId:j.uuid(),environmentId:j.uuid(),state:j.enum(["active","archived"]),isCurrent:j.boolean(),revision:j.number().int().nonnegative(),publishedVersionId:j.uuid().nullable(),createdAt:j.iso.datetime({offset:!0})}).superRefine((e,t)=>{e.isCurrent&&(e.state!=="active"||!e.publishedVersionId)&&t.addIssue({code:"custom",message:"Current Offering must be active and published"})}),Qc=j.strictObject({id:j.uuid(),offeringId:j.uuid(),projectId:j.uuid(),environmentId:j.uuid(),version:j.number().int().positive(),document:dn,productEvidence:j.record(to,xd),createdAt:j.iso.datetime({offset:!0})}).superRefine((e,t)=>{let n=no(e.document);(!n.length||Id(e.document).length>0||Object.keys(e.productEvidence).length!==n.length||n.some(r=>!Object.hasOwn(e.productEvidence,r)))&&t.addIssue({code:"custom",message:"Published Offering requires evidence for every Product"})}),Sd=j.strictObject({rows:j.array(Wc).max(200),versions:j.array(Qc).max(500)}),Ty=j.discriminatedUnion("action",[j.strictObject({action:j.literal("create"),document:dn}),j.strictObject({action:j.literal("save"),id:j.uuid(),revision:j.number().int().nonnegative(),document:dn}),j.strictObject({action:j.enum(["publish","set_current","archive","restore"]),id:j.uuid(),revision:j.number().int().nonnegative()})]),Dy=j.strictObject({record:Wc,version:Qc.nullable()}),Xc=j.discriminatedUnion("type",[j.strictObject({type:j.literal("current")}),j.strictObject({type:j.literal("id"),id:j.uuid()}),j.strictObject({type:j.literal("lookup_key"),lookupKey:j.string().min(1).max(200)}),j.strictObject({type:j.literal("version"),versionId:j.uuid()})]),vd=j.strictObject({internalId:to,id:j.string(),name:j.string().nullable(),version:j.number().int().positive(),archived:j.boolean()}),By=Sd.extend({products:j.array(vd).max(500),pagination:j.strictObject({rows:j.string().nullable(),versions:j.string().nullable(),products:j.string().nullable()}).optional()});function Id(e){let t=[];no(e).length||t.push("Select at least one Product before publishing");function n(r){for(let o of r)o.type==="group"&&(o.items.length||t.push("Every published group requires a Product"),n(o.items))}return n(e.items),t}import{z as $r}from"zod";var Yc=$r.strictObject({id:$r.uuid(),offeringId:$r.uuid(),version:$r.number().int().positive(),document:dn});import{z as we}from"zod";import{z as V}from"zod";var ro=V.discriminatedUnion("type",[V.strictObject({type:V.literal("event"),event:V.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/)}),V.strictObject({type:V.literal("open_url"),url:V.url().refine(e=>new URL(e).protocol==="https:")})]),Od=Ke,jd=V.discriminatedUnion("type",[V.object({type:V.literal("checkout"),product:ur}).strict(),V.object({type:V.literal("close")}).strict(),V.object({type:V.literal("action"),action:ro}).strict()]),fn=V.object({schemaVersion:V.literal(3),kind:V.literal("paywall"),name:V.string().trim().min(1).max(80),presentation:ft,requirement:Wt.optional(),products:vr,offeringVersionId:V.uuid().nullable(),offeringId:V.uuid(),screen:Od,buttons:V.record(V.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),jd)}).strict(),Hy=fn.superRefine((e,t)=>{(e.screen.surface!=="paywall"||e.screen.actions.some(r=>!["event","navigate"].includes(r.type)||r.close))&&t.addIssue({code:"custom",message:"Paywall screen is incomplete"});for(let r of wd(e))t.addIssue({code:"custom",message:r});for(let r of Ad(e))t.addIssue({code:"custom",message:r});vt(e.screen).some(r=>!r.complete)&&t.addIssue({code:"custom",message:"Paywall needs complete local content"}),(Object.keys(e.buttons).length!==e.screen.actions.filter(r=>r.type!=="navigate").length||e.screen.actions.some(r=>r.type!=="navigate"&&!Object.hasOwn(e.buttons,r.id)))&&t.addIssue({code:"custom",message:"Paywall buttons require matching node policies"}),Object.values(e.buttons).some(r=>r.type==="checkout")||t.addIssue({code:"custom",message:"A paywall requires a purchase or membership change button"})});function Ad(e){let t=e.products.items.map(a=>a.productVersionId),n=ka(e.screen),r=new Set,o=[];(!t.length||!e.products.defaultProductVersionId||!t.includes(e.products.defaultProductVersionId))&&o.push("products"),e.offeringVersionId||o.push("offering"),e.products.grouping&&(!Ea(e.products.grouping,t)||e.products.grouping.tiers.some(a=>!e.products.grouping.assignments.some(l=>l.tierId===a.id)))&&o.push("grouping");for(let a of Object.values(e.buttons))if(a.type==="checkout"){let l=a.product;if(l.type==="fixed")r.add(l.productVersionId);else{l.allowedProductVersionIds.forEach(v=>r.add(v));let p=!1,d=n[l.pickerId];d&&(p=!0,(l.allowedProductVersionIds.some(v=>!d.ids.includes(v))||d.ids.some(v=>!l.allowedProductVersionIds.includes(v)))&&o.push("picker")),gt(e.screen,v=>{if(v.id!==l.pickerId||v.type!=="plan_picker")return;p=!0,(JSON.stringify(v.planIds)!==JSON.stringify(t)||JSON.stringify(l.allowedProductVersionIds)!==JSON.stringify(t)||v.defaultPlan!==e.products.defaultProductVersionId)&&o.push("picker");let h=v.grouping?{tiers:v.grouping.tiers,assignments:v.grouping.assignments}:void 0;JSON.stringify(h)!==JSON.stringify(e.products.grouping)&&o.push("grouping")}),p||o.push("picker")}}return(!r.size||[...r].some(a=>!t.includes(a)))&&o.push("purchase"),gt(e.screen,a=>{a.type==="stack"&&a.productSlot&&!a.bind?.plan&&o.push(`productBinding:${a.id}`),(a.type==="stack"||a.type==="button")&&a.bind?.plan&&!t.includes(a.bind.plan)&&o.push("binding"),a.type==="plan_picker"&&(!a.planIds?.length||a.planIds.some(l=>!t.includes(l)))&&o.push("binding")}),[...new Set(o)]}function wd(e){let t=[],n=e.screen.pages.at(-1),r=new Map;for(let p of e.screen.pages)r.set(p.id,[]),Xt(p.root,d=>{let v=d.type==="button"?d.action:d.type==="stack"?d.purchaseAction:void 0;if(v){let h=e.screen.actions.find($=>$.id===v);h?.type==="navigate"&&r.get(p.id).push(h.pageId);let T=e.buttons[v];p.id!==n.id&&T&&T.type!=="close"&&t.push(`purchaseScreen:${d.id}`)}p.id!==n.id&&(d.type==="plan_picker"||d.type==="stack"&&d.productSlot)&&t.push(`packageScreen:${d.id}`)});let o=new Set;function a(p){if(!o.has(p)){o.add(p);for(let d of r.get(p)??[])a(d)}}let l=e.screen.initialPageId??e.screen.pages[0]?.id;l?a(l):t.push("initialPage");for(let p of e.screen.pages)o.has(p.id)||t.push(`unreachableScreen:${p.id}`);return[...new Set(t)]}var eu=V.object({id:V.uuid(),projectId:V.uuid(),environmentId:V.uuid(),revision:V.number().int().nonnegative(),state:V.enum(["active","archived"]),publishedVersionId:V.uuid().nullable(),updatedAt:V.iso.datetime({offset:!0}),draft:fn}).strict(),Jy=V.object({rows:V.array(eu).max(200),nextCursor:V.uuid().nullable()}).strict(),Wy=eu.omit({draft:!0}).extend({name:V.string(),productCount:V.number().int().nonnegative()}).strict(),Qy=V.discriminatedUnion("action",[V.object({action:V.literal("save"),id:V.uuid().nullable(),revision:V.number().int().nonnegative(),document:fn}).strict(),V.object({action:V.enum(["publish","archive"]),id:V.uuid(),revision:V.number().int().nonnegative()}).strict()]),Xy=V.object({paywalls:V.array(V.object({id:V.uuid(),paywallId:V.uuid(),version:V.number().int().positive(),name:V.string().min(1).max(80),presentation:ft,buttons:fn.shape.buttons}).strict()).max(500),limited:V.boolean()}).strict();import{z as X}from"zod";import{z as Fe}from"zod";var gn=Fe.string().regex(/^[a-f0-9]{64}$/),_d=Pa.pick({text:!0,label:!0,alt:!0,html:!0,couponId:!0,countdownAt:!0,missing:!0}),tu=Fe.strictObject({couponDigests:Fe.record(Fe.uuid(),gn),variables:Fe.record(Ht,Fe.record(Fe.uuid(),Fe.partialRecord(Fe.enum(["offer.name","offer.description","offer.headline","offer.eligibility","offer.validity","offer.terms","offer.discount","offer.months","offer.ends_at"]),Fe.string()))),locales:Fe.record(Ht,Qt.extend({nodes:Fe.record(Fe.string(),Fe.strictObject({base:_d})),plans:Fe.object({}).strict(),pickers:Fe.object({}).strict()}).omit({paywall:!0}))});import{z as se}from"zod";import{z as Gr}from"zod";var io=Gr.strictObject({eventsEnabled:Gr.boolean(),experimentViewsEnabled:Gr.boolean(),featureUsageEnabled:Gr.boolean()}),ox=Object.freeze({eventsEnabled:!0,experimentViewsEnabled:!0,featureUsageEnabled:!0});function ax(e,t){return t==="Experiment Viewed"?e.experimentViewsEnabled:t==="Feature Evaluated"?e.featureUsageEnabled:e.eventsEnabled}import{z as w}from"zod";var oo=w.tuple([w.number().min(0).max(1),w.number().min(0).max(1)]).refine(([e,t])=>e<=t),Pd=w.strictObject({attribute:w.string().optional(),seed:w.string(),hashVersion:w.literal(2),ranges:w.array(oo).max(100)}),Cd=w.strictObject({id:w.string().min(1).max(255),condition:rt,gate:w.boolean().optional()}),kd=w.strictObject({key:w.string().optional(),name:w.string().optional(),passthrough:w.boolean().optional()}),nu={condition:rt.optional(),parentConditions:w.array(Cd).max(100).optional(),weights:w.array(w.number().min(0).max(1)).max(20).optional(),coverage:w.number().min(0).max(1).optional(),hashAttribute:w.string().optional(),fallbackAttribute:w.string().optional(),hashVersion:w.literal(2).optional(),disableStickyBucketing:w.boolean().optional(),bucketVersion:w.number().int().nonnegative().optional(),minBucketVersion:w.number().int().nonnegative().optional(),filters:w.array(Pd).max(100).optional(),ranges:w.array(oo).max(20).optional(),meta:w.array(kd).max(20).optional(),seed:w.string().optional(),name:w.string().optional(),phase:w.string().optional()},hn=w.strictObject({...nu,key:w.string().min(1).max(255),variations:w.tuple([ee,ee]).rest(ee).refine(e=>e.length<=20),urlPatterns:w.array(w.strictObject({include:w.boolean(),type:w.enum(["regex","simple"]),pattern:w.string()})).max(100).optional(),force:w.number().int().nonnegative().optional(),active:w.boolean().optional(),persistQueryString:w.boolean().optional()}),ao=w.strictObject({value:ee,variationId:w.number().int(),key:w.string(),name:w.string().optional(),bucket:w.number().optional(),passthrough:w.boolean().optional(),inExperiment:w.boolean(),hashUsed:w.boolean().optional(),hashAttribute:w.string(),hashValue:w.string(),featureId:w.string().nullable(),stickyBucketUsed:w.boolean().optional()}),Rd=w.strictObject({...nu,id:w.string().max(255).optional(),force:ee.optional(),variations:w.array(ee).min(2).max(20).optional(),key:w.string().optional(),range:oo.optional(),tracks:w.array(w.strictObject({experiment:hn,result:ao})).max(100).optional()}),Ed=w.strictObject({defaultValue:ee.optional(),rules:w.array(Rd).max(500).optional()}),Gn=w.record(w.string(),w.union([w.strictObject({type:w.literal("hashed"),attributeKey:w.string(),values:w.array(w.string().regex(/^[a-f0-9]{64}$/))}),w.strictObject({type:w.literal("list"),attributeKey:w.string(),values:w.array(w.union([w.string(),w.number()]))}),w.strictObject({type:w.literal("condition"),condition:rt})])),wt=w.strictObject({scope:le,generation:w.string().regex(/^[a-f0-9]{64}$/),evaluatedAt:w.iso.datetime({offset:!0}),expiresAt:w.iso.datetime({offset:!0}).nullable(),features:w.record(w.string(),Ed),savedGroups:Gn,experiments:w.record(w.uuid(),hn)});var so=wt.extend({analyticsConfig:io,remoteFeatures:se.array(se.string().min(1).max(255)).max(500)}),Md=so.omit({evaluatedAt:!0,expiresAt:!0}).superRefine((e,t)=>{for(let n of e.remoteFeatures)Object.hasOwn(e.features,n)&&t.addIssue({code:"custom",path:["features",n],message:"Remote Feature definitions cannot be public"});for(let[n,r]of Object.entries(e.savedGroups))r.type==="list"&&t.addIssue({code:"custom",path:["savedGroups",n],message:"Raw Saved Group lists cannot be public"})}),ru=se.strictObject({attributes:Ge,features:se.array(se.string().min(1).max(255)).max(500).optional(),customerId:se.uuid().optional()}),Td=se.strictObject({value:ee,source:se.enum(["unknownFeature","defaultValue","force","override","experiment","prerequisite","cyclicPrerequisite"]),on:se.boolean(),off:se.boolean(),ruleId:se.string(),experimentResult:ao.optional()}),iu=se.strictObject({generation:wt.shape.generation,evaluatedAt:wt.shape.evaluatedAt,expiresAt:wt.shape.expiresAt,features:se.record(se.string(),Td),merchandiseContext:se.strictObject({merchandiseId:se.uuid(),merchandise:Ge}).optional()}),ou=se.strictObject({customerId:se.uuid().optional(),events:se.array(se.strictObject({eventUuid:se.uuid(),timestamp:se.iso.datetime({offset:!0}),name:se.string().min(1).max(255),merchandise:bs.optional(),properties:se.record(se.string(),ee).default({}),deviceId:se.string().min(1).max(255).optional(),sessionId:se.string().min(1).max(255).optional()})).min(1).max(100)}),au=se.strictObject({inserted:se.number().int().nonnegative(),duplicates:se.number().int().nonnegative(),rejected:se.number().int().nonnegative(),skipped:se.number().int().nonnegative(),analyticsConfig:io});import{z as A}from"zod";import{z as Dd}from"zod";var co=Dd.enum(["funnel-run/1","funnel-process/1"]),uo="funnel-process/1";function po(e,t=[]){let n=[];gt(e,o=>{o.hidden&&n.push("Hidden components must not be delivered"),t.includes(o.type)&&n.push(`Node type ${o.type} cannot be delivered`)});let r=new Set(di(e).map(o=>o.key));for(let[o,a]of Object.entries(e.strings.locales))for(let l of Object.keys(a))r.has(l)||n.push(`Unused string ${l} must not be delivered (${o})`);return n}function su(e){return e.hidden?null:e.type!=="stack"?e:{...e,children:e.children.flatMap(t=>su(t)??[])}}function Bd(e){let t=e.pages.map(o=>{let a=su(o.root);return a?.type==="stack"?{...o,root:a}:{...o,root:{type:"stack",id:o.root.id,...o.root.name===void 0?{}:{name:o.root.name},direction:"vertical",align:"stretch",justify:"start",children:[]}}}),n=new Set(di({pages:t}).map(o=>o.key)),r=Object.fromEntries(Object.entries(e.strings.locales).map(([o,a])=>[o,Object.fromEntries(Object.entries(a).filter(([l])=>n.has(l)))]));return{...e,pages:t,strings:{...e.strings,locales:r}}}function cu(e,t=[]){let n=Ke.parse(structuredClone(Bd(e))),r=a=>a.type!=="stack"||a.interaction!==void 0||a.children.some(r);for(let a of n.pages)if(!r(a.root))throw new Error(`Page ${a.id} has no visible content`);let o=po(n,t);if(o.length)throw new Error(o.join("; "));return n}import{z as P}from"zod";import{z as x}from"zod";import{z as ve}from"zod";var Kr=ve.strictObject({schemaVersion:ve.literal(1),renderKey:ve.string().min(1).max(256),routeTemplate:ve.string().startsWith("/").max(2048),selectors:ve.array(ve.string().regex(/^[a-z][a-z0-9-]*\[(?:id|data-testid|data-test|data-qa|data-indiana-id)="(?:[^"\\\x00-\x1f\x7f]|\\["\\])*"\]$/).max(512)),present:ve.array(ve.number().int().min(0)).min(1),absent:ve.array(ve.number().int().min(0))}).superRefine((e,t)=>{let n=[...e.present,...e.absent];(new Set(e.selectors).size!==e.selectors.length||new Set(n).size!==n.length||n.length!==e.selectors.length||n.some(r=>r>=e.selectors.length))&&t.addIssue({code:"custom",message:"Incomplete or ambiguous render signature"})}),uu=ve.strictObject({renderKey:ve.string().min(1).max(256),routeKey:ve.string().min(1).max(256),stateKey:ve.string().min(1).max(256),documentKey:ve.string().min(1).max(256),documentHash:ve.string().regex(/^[a-f0-9]{64}$/),compositionKey:ve.string().min(1).max(256),entryMode:ve.enum(["hard","soft"]),match:ve.strictObject({present:ve.array(ve.number().int().min(0)),absent:ve.array(ve.number().int().min(0))})});import{z as Nt}from"zod";var zd=["enterprise-internal-indiana-test","tinkerland-indiana-prod"],lo="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",qd=Nt.string().regex(new RegExp(`^${lo}/${lo}/${lo}/manifest\\.json$`)),pu=Nt.strictObject({kind:Nt.literal("gcs-resumable"),url:Nt.url(),bucket:Nt.enum(zd),objectKey:qd,byteLength:Nt.number().int().positive(),expiresAt:Nt.iso.datetime()}).superRefine((e,t)=>{let n=new URL(e.url),r=n.searchParams,o=["uploadType","upload_id","name","upload_protocol","ifGenerationMatch"];(n.origin!=="https://storage.googleapis.com"||n.username||n.password||n.hash||n.pathname!==`/upload/storage/v1/b/${e.bucket}/o`||[...r.keys()].some(a=>!o.includes(a)||r.getAll(a).length!==1)||r.get("uploadType")!=="resumable"||!/^[A-Za-z0-9_-]{1,4096}$/.test(r.get("upload_id")??"")||r.has("name")&&r.get("name")!==`app-manifests/${e.objectKey}`||r.has("upload_protocol")&&r.get("upload_protocol")!=="resumable"||r.has("ifGenerationMatch")&&r.get("ifGenerationMatch")!=="0")&&t.addIssue({code:"custom",message:"Invalid IAM upload capability"})});var Ie=x.string().min(1).max(256),He=x.string().regex(/^[a-f0-9]{64}$/),Lr=x.strictObject({versionId:x.uuid(),manifestDigest:He,sourceGraphDigest:He,pageKey:Ie,stateKey:Ie,documentKey:Ie,documentHash:He,elementKey:Ie.optional(),nodeId:Ie.optional(),contentHash:He.optional(),renderKey:Ie.optional()}),lu=x.strictObject({pageKey:Ie,documentKey:Ie,expectedDocumentHash:He,renderKey:Ie.optional(),nodeId:Ie,elementKey:Ie,expectedContentHash:He,property:x.enum(["text","fontSize","color"]),value:x.union([x.string().max(4e3),x.number().finite()])}),mu=x.strictObject({versionId:x.uuid(),manifestDigest:He,sourceGraphDigest:He,pageKey:Ie,stateKey:Ie,documentKey:Ie,documentHash:He,renderKey:Ie.optional(),patches:x.array(lu.omit({pageKey:!0,documentKey:!0,expectedDocumentHash:!0,renderKey:!0})).min(1).max(200)}),Fd=/^[a-z][a-z0-9-]{0,39}$/,Kn=x.string().regex(Fd),fo=x.enum(["web","ios","android"]),Cx=x.discriminatedUnion("action",[x.strictObject({action:x.literal("register"),requestId:x.uuid(),client:Kn,platform:fo,label:x.string().trim().min(1).max(100),sha256:He,bytes:x.number().int().min(1),transferBytes:x.number().int().min(1)}),x.strictObject({action:x.literal("complete"),versionId:x.uuid()}),x.strictObject({action:x.literal("current"),versionId:x.uuid(),expectedCurrent:x.uuid().nullable()}),x.strictObject({action:x.literal("delivery"),enabled:x.boolean()}),x.strictObject({action:x.literal("changes"),versionId:x.uuid(),experimentId:x.uuid(),variationId:Ie,changesetId:x.uuid().nullable(),expectedRevision:He.nullable(),editorUrl:x.string().url().max(2048),patches:x.array(lu).max(200)})]),go=x.strictObject({id:x.uuid(),projectId:x.uuid(),environmentId:x.uuid(),clientKey:Kn,platform:fo,label:x.string(),sha256:He,bytes:x.number().int().positive(),objectKey:x.string(),state:x.enum(["uploading","ready","rejected"]),isCurrent:x.boolean(),revision:x.number().int().nonnegative(),createdAt:x.string(),expiresAt:x.string(),readyAt:x.string().nullable(),summary:x.record(x.string(),x.json()),routeTree:x.json().nullable(),validation:x.record(x.string(),x.json())}),Nd=x.strictObject({key:Kn,platform:fo,currentId:x.uuid().nullable()}),kx=x.strictObject({rows:x.array(go).max(100),nextCursor:x.uuid().nullable(),clients:x.array(Nd).max(20)}),mo=x.strictObject({storedBytes:x.number().int().nonnegative(),reservedBytes:x.number().int().nonnegative(),chargedBytes:x.number().int().nonnegative(),versions:x.number().int().nonnegative(),objects:x.number().int().nonnegative(),orphanObjects:x.number().int().nonnegative(),missingReadyObjects:x.number().int().nonnegative(),unknownObjectSizes:x.number().int().nonnegative(),byteLimit:x.number().int().positive(),versionLimit:x.number().int().positive(),remainingBytes:x.number().int().nonnegative()}),Rx=x.strictObject({asOf:x.iso.datetime({offset:!0}),reclamation:x.literal("manual-review-required"),buckets:x.strictObject({source:mo,runtime:mo,previews:mo})}),Ex=x.strictObject({version:go,actorId:x.uuid(),claims:x.record(x.string(),x.json())}),Mx=x.strictObject({version:go,upload:pu.nullable()}),Tx=x.object({format:x.literal("indiana-route-state-index"),schemaVersion:x.literal(3),routes:x.array(x.object({routeKey:Ie,path:x.string(),documentKey:Ie,documentHash:He,initialStateKey:Ie,initialRenderKey:Ie})),renders:x.array(uu)}).loose().superRefine((e,t)=>{(!e.renders||e.routes.some(n=>!e.renders?.some(r=>r.renderKey===n.initialRenderKey&&r.routeKey===n.routeKey&&r.documentKey===n.documentKey&&r.stateKey===n.initialStateKey&&r.documentHash===n.documentHash&&r.entryMode==="hard")))&&t.addIssue({code:"custom",message:"Incomplete render catalog"})}),Dx=x.strictObject({rows:x.array(x.object({id:x.uuid(),name:x.string(),status:x.string(),variations:x.array(x.object({id:Ie,key:Ie,name:x.string().optional()}).loose())}).loose()),limited:x.boolean()}),Bx=x.strictObject({enabled:x.boolean(),allowedOrigins:x.array(x.string())});import{z as bn}from"zod";var du=bn.strictObject({id:bn.uuid(),name:bn.string().trim().min(1).max(80),client:Kn,source:Lr,event:bn.enum(["screen_enter","button_click"]),cooldownSeconds:bn.number().int().min(0).max(2592e3),behavior:bn.literal("observe")}).superRefine((e,t)=>{e.event==="button_click"&&(!e.source.nodeId||!e.source.elementKey)&&t.addIssue({code:"custom",path:["source"],message:"Choose a uniquely bound button"})});import{z as ue}from"zod";var ho=ee,Ud=["parameters","answers","results","variables"];function bo(e){return Ud.some(t=>e===t||e.startsWith(t+"."))}function yo(e){let t={};for(let[r,o]of Object.entries(En(e.declarations,e))){let a=r.split(".");if(a.some(d=>["__proto__","constructor","prototype"].includes(d)))throw new Error("Reserved result path");let l=t;for(let d of a.slice(0,-1)){Object.hasOwn(l,d)||(l[d]={});let v=l[d];if(!v||typeof v!="object"||Array.isArray(v))throw new Error("Ambiguous result path");l=v}let p=a.at(-1);if(p===void 0)throw new Error("Empty result path");l[p]=o}return{...Object.fromEntries(Object.entries(e.attributes).filter(([r])=>!bo(r))),variables:t}}import{z as Vd}from"zod";var Zr=Vd.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/);var xo=ue.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),fu=ue.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,128}$/),gu=ct.refine(e=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=8192,"Task data exceeds 8 KiB"),So=ue.record(xo,ue.enum(["string","number","boolean","strings"])).refine(e=>Object.keys(e).length<=20,"Too many output fields"),$d=pt,hu=ue.strictObject({type:ue.literal("external_task"),endpointId:ue.uuid(),taskKey:xo,inputs:ue.record(xo,$d).refine(e=>Object.keys(e).length<=20),outputs:So}),bu=ue.strictObject({maxAttempts:ue.number().int().min(1).max(5),retryDelaySeconds:ue.number().int().min(1).max(30),backoff:ue.enum(["fixed","exponential"]),requestTimeoutSeconds:ue.number().int().min(1).max(10),timeoutSeconds:ue.number().int().min(1).max(300)}).refine(e=>e.requestTimeoutSeconds<=e.timeoutSeconds,"Request timeout exceeds action deadline");var Yx=ue.strictObject({outcome:ue.enum(["success","failure"]),data:gu});var eS=ue.discriminatedUnion("operation",[ue.strictObject({operation:ue.literal("signal"),runId:ue.uuid(),nodeId:fu,eventName:Zr,eventId:ue.uuid(),data:gu}),ue.strictObject({operation:ue.literal("read_results"),runId:ue.uuid()})]),tS=ue.strictObject({scope:le,runId:ue.uuid(),eventId:ue.uuid(),accepted:ue.boolean()}),Gd=ue.record(fu,ho),nS=ue.strictObject({scope:le,runId:ue.uuid(),results:Gd});var ot={flowNodes:500,logicNodes:480,pages:100,components:1500,actions:250,questions:40,documentBytes:1e6,conditionDepth:3,conditionChildren:20,conditionPredicates:100},yu="00000000-0000-0000-0000-000000000000";import{z as k}from"zod";import{z as de}from"zod";var cS=de.enum(["local","remote"]),vo=de.strictObject({port:de.string().regex(/^[a-zA-Z0-9_.:-]{1,128}$/),value:ee.optional(),sticky:de.array(de.strictObject({expected:sr.nullable(),next:sr})).max(100),exposures:de.array(ee).max(100),features:de.array(ee).max(100)}),xu=de.strictObject({type:de.literal("evaluate"),receiptId:de.uuid(),environmentId:de.uuid(),policyRevision:de.number().int().nonnegative(),attributes:Ge,sticky:de.record(de.string(),sr)}),Su=xu.extend({runId:de.uuid(),versionId:de.uuid(),nodeId:de.string().min(1).max(64),visit:de.number().int().nonnegative(),revision:de.number().int().nonnegative()}),Io=xu.omit({type:!0,receiptId:!0}).extend({type:de.literal("evaluate_segment")}),vu=de.strictObject({nodeId:de.string().min(1).max(64),result:vo}),Iu=Io.extend({runId:de.uuid(),versionId:de.uuid(),nodeId:de.string().min(1).max(64),visit:de.number().int().nonnegative(),revision:de.number().int().nonnegative(),parameters:ct,answers:Rt,variables:de.record(de.string(),ee)});import{z as F}from"zod";var Oo=F.array(F.string().trim().min(1).max(40).refine(e=>!e.includes(","),"\u6807\u7B7E\u4E0D\u80FD\u5305\u542B\u9017\u53F7")).max(20).refine(e=>new Set(e).size===e.length,"\u6807\u7B7E\u4E0D\u80FD\u91CD\u590D"),Hr=F.intersection(Ge,F.looseObject({tags:Oo.optional()})).refine(e=>!["id","externalUserId","createdAt","ageDays","subscription","parameters","answers","results"].some(t=>Object.hasOwn(e,t)),"Reserved customer attribute"),Jr=F.string().trim().max(80),Wr=F.string().regex(/^\+[1-9]\d{1,14}$/).nullable(),Qr=F.union([F.email().max(254),F.literal("")]),Xr=F.string().trim().min(1).max(255).refine(e=>!/\p{Cc}/u.test(e),"Fingerprint must not contain control characters"),Ou=F.string().trim().min(1).max(255).refine(e=>!e.startsWith("gg_guest_"),"Reserved guest identity namespace"),ju=F.object({externalUserId:Ou.optional(),name:Jr.default(""),email:Qr.default(""),phone:Wr.optional(),attributes:Hr.default({})}).strict().refine(e=>e.externalUserId!==void 0||e.email!=="","\u8BF7\u63D0\u4F9B\u4E1A\u52A1\u7528\u6237 ID \u6216\u90AE\u7BB1"),yt=F.discriminatedUnion("type",[F.strictObject({type:F.literal("id"),value:F.uuid()}),F.strictObject({type:F.literal("externalUserId"),value:Ou})]),_t=F.strictObject({name:Jr.optional(),email:Qr.optional(),phone:Wr.optional(),attributes:Hr.optional(),fingerprint:Xr.optional()}),Ut=e=>!e.customerData||e.customer?.type==="externalUserId",Vt="customerData requires an externalUserId customer",yn=F.object({id:F.uuid(),externalUserId:F.string().min(1).max(255).nullable(),name:Jr,email:Qr,phone:Wr.optional(),attributes:Hr,createdAt:F.iso.datetime()}).strict(),Au=F.object({customer:yn,changed:F.boolean(),replayed:F.boolean()}).strict(),Kd=F.discriminatedUnion("type",[F.object({type:F.literal("id"),value:F.uuid()}).strict(),F.object({type:F.literal("externalUserId"),value:F.string().trim().min(1).max(255)}).strict()]),Ld=F.object({name:Jr.optional(),email:Qr.optional(),phone:Wr.optional(),attributes:Hr.refine(e=>!Object.hasOwn(e,"tags"),"Use incremental tagChanges").optional(),removeAttributes:F.array(F.string().regex(/^[a-zA-Z][a-zA-Z0-9_]{0,127}$/)).max(128).refine(e=>!e.includes("tags")).optional(),tagChanges:F.strictObject({add:Oo,remove:Oo}).optional()}).strict().refine(e=>Object.keys(e).length>0,"\u8BF7\u63D0\u4F9B\u9700\u8981\u4FEE\u6539\u7684\u5B57\u6BB5"),jo=F.object({lookup:Kd}).strict(),wu=jo.extend({requestId:F.uuid(),patch:Ld}).strict(),_u=F.object({search:F.string().trim().max(200).default(""),tag:F.string().trim().max(40).default(""),planId:F.string().max(200).default(""),versionId:F.string().max(200).default(""),holdingStatus:F.enum(["","active","scheduled","expired","unavailable","none"]).default(""),membershipStatus:F.enum(["","active","trial","past_due","ended"]).default(""),createdFrom:F.union([F.iso.datetime(),F.literal("")]).default(""),createdUntil:F.union([F.iso.datetime(),F.literal("")]).default(""),offset:F.coerce.number().int().min(0).max(1e5).default(0),limit:F.coerce.number().int().min(1).max(100).default(50)}).strict(),Pu=F.object({customers:yn.array(),hasMore:F.boolean(),total:F.number().int().nonnegative().nullable(),evaluatedAt:F.iso.datetime()}).strict();var Ln=k.discriminatedUnion("type",[k.strictObject({type:k.literal("literal"),value:ee}),k.strictObject({type:k.literal("variable"),key:Ae,path:it.optional()}),k.strictObject({type:k.literal("feature"),featureKey:k.string().min(1).max(128)})]),Zd=k.strictObject({requestId:k.uuid(),decisionId:k.uuid(),customerId:k.uuid(),externalUserId:k.string().min(1).max(255).nullable(),versionId:k.uuid(),receiptId:k.uuid(),value:ee}),Ao={funnelId:k.uuid(),requestId:k.uuid(),customer:yt,customerData:_t.optional(),attributes:Ge.refine(e=>!["parameters","answers","results","variables"].some(t=>Object.hasOwn(e,t)),"parameters, answers, results and variables are reserved flow namespaces")},SS=k.discriminatedUnion("operation",[k.strictObject({operation:k.literal("decide"),...Ao}).refine(Ut,Vt),k.strictObject({operation:k.literal("read_decision"),decisionId:k.uuid()}),k.strictObject({operation:k.literal("evaluate_decision"),decisionId:k.uuid(),requestId:k.uuid(),nodeId:k.string().min(1).max(64),visit:k.number().int().nonnegative(),revision:k.number().int().nonnegative(),receiptId:k.uuid(),policyRevision:k.number().int().nonnegative(),generation:k.string().min(1).max(256),result:vo}),k.strictObject({operation:k.literal("feature_config"),funnelId:k.uuid()}),k.strictObject({operation:k.literal("commit_decision_segment"),decisionId:k.uuid(),requestId:k.uuid(),nodeId:k.string().min(1).max(64),visit:k.number().int().nonnegative(),revision:k.number().int().nonnegative(),policyRevision:k.number().int().nonnegative(),generation:k.string().min(1).max(256),steps:k.array(vu).max(32),boundary:k.strictObject({nodeId:k.string().min(1).max(64),visit:k.number().int().nonnegative()}).optional()}),k.strictObject({operation:k.literal("segment_configuration"),funnelId:k.uuid(),versionId:k.uuid()}),k.strictObject({operation:k.literal("configuration"),funnelId:k.uuid(),versionId:k.uuid().optional()}),k.strictObject({operation:k.literal("local_configuration"),funnelId:k.uuid()}),k.strictObject({operation:k.literal("report_used"),decisionId:k.uuid(),eventId:k.uuid(),occurredAt:k.iso.datetime({offset:!0}),reference:k.string().min(1).max(128).optional()})]),vS=k.strictObject({scope:le,decisionId:k.uuid(),requestId:k.uuid(),status:k.enum(["pending","completed","failed"]),decision:Zd.nullable(),evaluation:k.discriminatedUnion("type",[Su,Iu]).optional()}).refine(e=>e.status==="completed"==(e.decision!==null)&&(!e.decision||e.decision.decisionId===e.decisionId&&e.decision.requestId===e.requestId),"Completed decisions carry their committed result"),IS=k.strictObject({scope:le,decisionId:k.uuid(),eventId:k.uuid(),source:k.literal("caller_reported")});import{z as Me}from"zod";var Cu=Me.strictObject({type:Me.literal("bundle"),paywall:pt.optional(),offering:pt.optional(),coupons:pt,data:pt}),Hd=e=>Me.strictObject({type:Me.literal(e),id:Me.uuid()}),PS=Me.strictObject({type:Me.literal("bundle"),paywallVersionId:Me.uuid().optional(),offeringVersionId:Me.uuid().optional(),couponIds:Me.array(Me.uuid()).max(20).refine(e=>new Set(e).size===e.length),data:ee});var CS=Me.strictObject({type:Me.literal("bundle"),offering:Hd("offering_version").nullable(),paywall:Me.strictObject({versionId:Me.uuid(),paywallId:Me.uuid(),offeringVersionId:Me.uuid()}).nullable(),coupons:Me.array(Tn).max(20),data:ee});import{z as at}from"zod";import{z as Xe}from"zod";var ku=Xe.union([Xe.string(),Xe.number().finite(),Xe.boolean(),Xe.null()]),Jd=Xe.union([ku,Xe.array(ku).min(1).max(20)]),Wd=Xe.record(it,Jd).refine(e=>Object.keys(e).length<=10),Ru=Xe.strictObject({path:it,type:Xe.enum(["string","number","boolean","strings"]),nullable:Xe.boolean().optional(),aggregation:Xe.enum(["count","exists"]).optional(),where:Wd.optional()}).superRefine((e,t)=>{(e.aggregation==="count"&&e.type!=="number"||e.aggregation==="exists"&&e.type!=="boolean"||!e.aggregation&&e.where)&&t.addIssue({code:"custom",message:"Collection summaries require their matching type"})});var Qd=["sendMessage","checkEntitlement","resolveOffering","readHoldings","readLedger","readBillingInvoice","readCreditStatement","previewAttach","attach","readSubscriptionOperation","previewUpdate","update","readSubscriptionUpdate","setupPayment","readPaymentSetup","verifySubscriptions","previewRefund","refund","readRefund","restoreNativePurchase","readBillingControls","prepareBillingAuthorization","confirmBillingAuthorization","setBillingCoupons","revokeBillingAuthorization","listBillingInvoices","confirmBillingAdjustment","manageBillingLimits","readSeats","manageSeat","quoteBalance","mutateBalance","trackUsage","readUsage","setUsage","adjustBalance","readBalanceSource","manageBalanceGrant","listBalanceGrants","manageUsageEntity","readUsageAnalytics","readCreditAnalytics","submitUsageBatch","readUsageBatch","redeemCoupon","listOffers","grantOffer","redeemReward","createReferralCode","claimRewardProduct"],Eu=at.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Xd=pt,Mu=at.discriminatedUnion("type",[hu,at.strictObject({type:at.literal("claim_offer"),coupon:pt}),at.strictObject({type:at.literal("event"),event:Eu}),at.strictObject({type:at.literal("api"),operation:at.enum(Qd),inputs:at.record(it,Xd).refine(e=>Object.keys(e).length<=40),outputs:at.record(Eu,Ru).refine(e=>Object.keys(e).length<=20)})]);var xe=Zr,Yd=P.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/),Je={id:xe,name:P.string().trim().min(1).max(80),position:P.strictObject({x:P.number().finite(),y:P.number().finite()}).optional()},ef={success:xe,cancel:xe,unavailable:xe,failure:xe},wo=P.url().max(2048).refine(e=>{try{return new URL(e).protocol==="https:"}catch{return!1}},{message:"External pages require HTTPS"}),_o=P.enum(["same_window","new_window"]),tf=P.discriminatedUnion("type",[P.strictObject({...Je,type:P.literal("entry"),next:xe,triggers:P.array(du).max(20).refine(e=>new Set(e.map(t=>t.id)).size===e.length,"Entry trigger IDs must be unique").optional()}),P.strictObject({...Je,type:P.literal("screen"),screenId:xe,presentation:ft,outputs:P.record(xe,xe),offering:P.discriminatedUnion("source",[P.strictObject({source:P.literal("variable"),key:Ae}),P.strictObject({source:P.literal("fixed"),versionId:P.uuid()})]).optional()}),P.strictObject({...Je,type:P.literal("offering"),configuration:P.discriminatedUnion("source",[P.strictObject({source:P.literal("fixed"),versionId:P.uuid()}),P.strictObject({source:P.literal("feature"),featureKey:P.string().min(1).max(128)})]),writes:P.strictObject({value:Ae}),next:xe}),P.strictObject({...Je,type:P.literal("coupon"),couponId:P.uuid(),writes:P.strictObject({value:Ae}),next:xe}),P.strictObject({...Je,type:P.literal("coupons"),couponIds:P.array(P.uuid()).max(20).refine(e=>new Set(e).size===e.length),writes:P.strictObject({value:Ae}),next:xe}),P.strictObject({...Je,type:P.literal("output"),value:P.discriminatedUnion("type",[...Ln.options,Cu,P.strictObject({type:P.literal("selection"),screenId:xe,offeringKey:Ae})])}),P.strictObject({...Je,type:P.literal("condition"),cases:P.array(P.strictObject({condition:rt,target:xe})).min(1).max(50),default:xe}),P.strictObject({...Je,type:P.literal("feature"),featureKey:P.string().min(1).max(128),writes:P.strictObject({value:Ae}),next:xe}),P.strictObject({...Je,type:P.literal("split"),experimentId:P.uuid(),applyPageExperiment:P.literal(!0).optional(),routes:P.record(Yd,xe).refine(e=>Object.keys(e).length>=2&&Object.keys(e).length<=20),notParticipating:xe}),P.strictObject({...Je,type:P.literal("action"),...ef,execution:bu,action:Mu,writes:yr.optional()}),P.strictObject({...Je,type:P.literal("external_page"),appManifest:Lr.optional(),url:wo,openIn:_o,opened:xe,failed:xe}),P.strictObject({...Je,type:P.literal("end"),outcome:P.enum(["completed","closed","ineligible","failed"]),output:Ln.optional()}),P.strictObject({...Je,type:P.literal("wait"),writes:yr.optional(),wait:P.discriminatedUnion("type",[P.strictObject({type:P.literal("duration"),delaySeconds:P.number().int().min(1).max(2592e3),elapsed:xe}),P.strictObject({type:P.literal("event"),eventName:xe,outputs:So,timeoutSeconds:P.number().int().min(1).max(2592e3),received:xe,timeout:xe})])})]),Po=P.strictObject({version:P.literal(5),entry:xe,nodes:P.array(tf).min(1).max(ot.flowNodes)}),Co=Po.superRefine((e,t)=>{nf(e,n=>t.addIssue({code:"custom",message:n.message,path:n.path,params:{reason:n.reason}}))});function Yr(e){switch(e.type){case"entry":case"feature":case"offering":case"coupon":case"coupons":return[e.next];case"screen":return Object.values(e.outputs);case"condition":return[...e.cases.map(t=>t.target),e.default];case"split":return[...Object.values(e.routes),e.notParticipating];case"action":return[e.success,e.cancel,e.unavailable,e.failure];case"external_page":return[e.opened,e.failed];case"end":case"output":return[];case"wait":return e.wait.type==="duration"?[e.wait.elapsed]:[e.wait.received,e.wait.timeout]}}function nf(e,t){let n=[],r=new Map(e.nodes.map(h=>[h.id,h])),o=(h,T,$)=>{n.push(h),t?.({message:h,reason:T,path:$?["nodes",e.nodes.indexOf($)]:[]})};r.size!==e.nodes.length&&o("Node identifiers must be unique","uniqueNodes"),(r.get(e.entry)?.type!=="entry"||e.nodes.filter(h=>h.type==="entry").length!==1)&&o("A flow has exactly one entry node","entry"),(e.nodes.filter(h=>h.type==="screen").length>ot.pages||e.nodes.filter(h=>!["screen","entry","end","output"].includes(h.type)).length>ot.logicNodes)&&o("Flow node limit exceeded","budget");let a=new Set;for(let h of e.nodes){for(let T of Yr(h))T===e.entry&&o("An entry cannot be a transition target","entryTarget",h),r.has(T)||o(`Missing target ${T}`,"missingTarget",h);h.type==="screen"&&(a.has(h.screenId)&&o("Every screen has exactly one node owner","screenOwner",h),a.add(h.screenId))}let l=new Set,p=new Set,d=new Set;function v(h){if(l.has(h)){o("Flow edges must not form a cycle","cycle",r.get(h));return}if(!(p.has(h)||!r.has(h))){l.add(h),d.add(h);for(let T of Yr(r.get(h)))v(T);l.delete(h),p.add(h)}}v(e.entry);for(let h of e.nodes)d.has(h.id)||o("Every node must be reachable from Entry","unreachable",h);return[...new Set(n)]}var ko={maxTransitions:1e4,runTimeoutSeconds:2592e3};function Tu(e,t,n){let r=[...t].sort((p,d)=>d.length-p.length),o=new Set,a=(p,d=!1)=>{let v=r.find(h=>p===h||d&&p.startsWith(h+"."));o.add(v??p)};if(e.type==="condition"){let p=n?.startsWith("case_")?Number(n.slice(5)):e.cases.length-1;for(let d of e.cases.slice(0,p+1))for(let v of Ot(d.condition))v.startsWith("variables.")&&a(v.slice(10),!0)}if(e.type==="screen"&&e.offering?.source==="variable"&&a(e.offering.key),e.type==="action"&&(e.action.type==="api"||e.action.type==="external_task"))for(let p of Object.values(e.action.inputs))p.source==="variable"&&a(p.key);e.type==="action"&&e.action.type==="claim_offer"&&e.action.coupon.source==="variable"&&a(e.action.coupon.key);let l=e.type==="output"?e.value:e.type==="end"?e.output:null;if(l?.type==="variable"&&a(l.key),l?.type==="bundle")for(let p of[l.paywall,l.offering,l.coupons,l.data])p?.source==="variable"&&a(p.key);return l?.type==="selection"&&a(l.offeringKey),[...o]}import{z as S}from"zod";var xn=S.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,127}$/),ei=e=>S.record(S.string(),ee).refine(t=>Le(t)<=e,"Funnel evidence exceeds its byte budget"),av=S.enum(["local_segment","evaluation","presentation","timer","event","operation"]),Eo=S.enum(["entry","presentation","decision","configuration","capability","wait","terminal"]),Mo=S.discriminatedUnion("type",[S.strictObject({type:S.literal("flag"),key:S.string().min(1).max(128)}),S.strictObject({type:S.literal("experiment"),id:S.uuid()}),S.strictObject({type:S.literal("saved_group"),id:S.uuid()}),S.strictObject({type:S.literal("config"),key:S.string().min(1).max(128)}),S.strictObject({type:S.literal("constant"),key:S.string().min(1).max(128)}),S.strictObject({type:S.literal("paywall_version"),id:S.uuid()}),S.strictObject({type:S.literal("offering_version"),id:S.uuid()}),S.strictObject({type:S.literal("reward"),id:S.uuid()})]),Zn=S.strictObject({schemaVersion:S.literal(1),kind:Eo,selector:Mo.nullable(),context:ei(131072),contract:S.strictObject({version:S.number().int().positive(),evaluator:S.string().min(1).max(128),policyRevision:S.number().int().nonnegative()})}).refine(e=>Le(e)<=131072,"Node input exceeds its byte budget"),Du=S.strictObject({schemaVersion:S.literal(1),kind:Eo,outcome:S.enum(["success","cancel","failure","unavailable","elapsed","received","timeout","not_participating"]),data:ei(131072),route:S.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/).nullable(),evidence:ei(131072)}).refine(e=>Le(e)<=131072,"Node result exceeds its byte budget"),sv=S.strictObject({schemaVersion:S.literal(1),operations:S.record(xn,S.strictObject({attempts:S.number().int().nonnegative(),maxAttempts:S.number().int().min(1).max(5),deadlineAt:S.iso.datetime({offset:!0}),retryAt:S.iso.datetime({offset:!0}).nullable(),error:S.string().regex(/^[a-z_]{1,64}$/).nullable(),reference:S.strictObject({type:xn,id:S.uuid()}).nullable()}))}).refine(e=>Le(e)<=65536,"Execution state exceeds its byte budget"),$t={receiptId:S.uuid()},Ro=S.iso.datetime({offset:!0}),cv=S.discriminatedUnion("type",[S.strictObject({type:S.literal("node_entered"),details:S.strictObject({kind:Eo})}),S.strictObject({type:S.literal("presentation_shown"),details:S.strictObject({...$t,source:S.literal("client"),occurredAt:Ro.optional()})}),S.strictObject({type:S.literal("decision_accepted"),details:S.strictObject($t)}),S.strictObject({type:S.literal("signal_received"),details:S.strictObject({signalId:S.uuid(),nodeId:xn,eventName:xn,data:ei(8192),source:S.literal("server"),occurredAt:Ro})}),S.strictObject({type:S.literal("signal_consumed"),details:S.strictObject({...$t,signalId:S.uuid()})}),S.strictObject({type:S.literal("wait_elapsed"),details:S.strictObject($t)}),S.strictObject({type:S.literal("wait_timeout"),details:S.strictObject($t)}),S.strictObject({type:S.literal("operation_completed"),details:S.strictObject({...$t,operation:xn,reference:S.strictObject({type:xn,id:S.uuid()}).nullable()})}),S.strictObject({type:S.literal("execution_recovered"),details:S.strictObject({generation:S.number().int().positive(),reason:S.enum(["interrupted","expired_lease","delivery_failed"])})}),S.strictObject({type:S.literal("execution_failed"),details:S.strictObject({generation:S.number().int().positive(),code:S.string().regex(/^[a-z_]{1,64}$/)})}),S.strictObject({type:S.literal("run_completed"),details:S.strictObject({outcome:S.enum(["completed","ineligible","failed"])})}),S.strictObject({type:S.literal("run_closed"),details:S.strictObject({source:S.enum(["client","server","expiry"])})}),S.strictObject({type:S.literal("treatment_used"),details:S.strictObject({...$t,source:S.enum(["client","server"]),occurredAt:Ro,reference:S.string().min(1).max(128).optional()})})]);var Ye=A.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),rf=A.discriminatedUnion("type",[A.strictObject({id:Ye,type:A.literal("owned"),publicData:tu.optional(),document:Ke.refine(e=>["page","popup","onboarding"].includes(e.surface)&&e.pages.length===1&&e.actions.every(t=>t.type==="event"&&!t.close),"A Funnel owns one Page or Popup per screen and emits outputs; Paywall owns its purchase policies")}),A.strictObject({id:Ye,type:A.literal("paywall"),paywallVersionId:A.uuid()})]),To={executionContract:co.optional(),kind:A.literal("funnel"),schemaVersion:A.literal(4),screens:A.array(rf).max(ot.pages),references:A.record(Ye,Mo).refine(e=>Object.keys(e).length<=500),inputs:A.array(A.strictObject({variable:Ye,screenId:Ye,componentId:Ye,required:A.boolean()})).max(ot.questions),variables:A.record(Ae,rn).refine(e=>Object.keys(e).length<=ot.logicNodes),outputSchema:nn,execution:A.strictObject({runTimeoutSeconds:A.number().int().min(1).max(ko.runTimeoutSeconds),maxTransitions:A.number().int().min(1).max(ko.maxTransitions)})},Pv=A.strictObject({...To,graph:Po});function of(e,t){let n=!1,r=(o,a)=>{let l=o.type==="stack"||o.type==="button"?o.bind?.coupon??a:a;o.type==="text"&&Object.values(e.strings.locales).some(p=>p[o.text]?.includes("{{offer."))&&!(l&&t(l))&&(n=!0),o.type==="stack"&&o.children.forEach(p=>r(p,l))};for(let o of e.pages)r(o.root);return n}function ni(e){return Array.isArray(e)?e.some(ni):!e||typeof e!="object"?!1:Object.entries(e).some(([t,n])=>t==="productVersionId"?n===yu:ni(n))}function af(e){let t=[],n=new Set(Object.values(e.references).flatMap(r=>r.type==="reward"?[r.id]:[]));for(let[r,o]of e.screens.entries()){if(o.type!=="owned")continue;let a;try{a=cu(o.document)}catch(l){t.push({message:l instanceof Error?l.message:"Screen cannot be delivered",reason:"screen",path:["screens",r,"document"]});continue}for(let[l,p]of e.inputs.entries())p.screenId===o.id&&!fi(a,p.componentId)&&t.push({message:`Local Funnel input ${p.variable} targets hidden component ${p.componentId} on screen ${p.screenId}`,reason:"inputBinding",path:["inputs",l]})}for(let[r,o]of e.graph.nodes.entries()){let a=["graph","nodes",r],l=o.type==="screen"?e.screens.find(p=>p.id===o.screenId):void 0;l?.type==="owned"&&(l.document.actions.some(p=>typeof p.properties.templateKey=="string"&&p.properties.templateKey.startsWith("popup-coupon-"))&&t.push({message:"Funnel screens claim Coupons through a Claim Coupon step",reason:"coupon",path:a}),of(l.document,p=>n.has(p))&&t.push({message:"Offer copy shows the Coupon of a Claim Coupon step",reason:"coupon",path:a})),(o.type==="output"&&o.value.type==="literal"&&ni(o.value.value)||o.type==="end"&&o.output?.type==="literal"&&ni(o.output.value))&&t.push({message:"Checkout outputs require a Product Version",reason:"product",path:a})}return t}function Bu(e,t){for(let{message:n,reason:r,path:o}of af(e))t.addIssue({code:"custom",message:n,path:o,params:{reason:r}})}function zu(e,t){let n=(C,u,b=[])=>t.addIssue({code:"custom",message:C,path:b,params:{reason:u}}),r=Object.values(e.references),o=new Map(e.screens.map(C=>[C.id,C])),a=(C,u)=>r.some(b=>b.type===C&&("id"in b?b.id:b.key)===u);o.size!==e.screens.length&&n("Screen identifiers must be unique","uniqueScreens");let l=e.graph.nodes.filter(C=>C.type==="screen");(l.length!==o.size||l.some(C=>!o.has(C.screenId)))&&n("Every screen belongs to exactly one presentation node","screenOwner");let p=new Map,d=Object.keys(e.variables);d.some(C=>d.some(u=>C!==u&&u.startsWith(C+".")))&&n("Variable paths must not overlap","variable");function v(C,u){Object.hasOwn(e.variables,C)||n("Every produced variable needs a declaration","variable",["graph","nodes",e.graph.nodes.indexOf(u)]);let b=p.get(C)??new Set;b.add(u.id),p.set(C,b)}for(let[C,u]of e.graph.nodes.entries()){let b=["graph","nodes",C],Z=u.type==="feature"?u.featureKey:u.type==="offering"&&u.configuration.source==="feature"?u.configuration.featureKey:u.type==="output"&&u.value.type==="feature"?u.value.featureKey:u.type==="end"&&u.output?.type==="feature"?u.output.featureKey:null;Z&&!a("flag",Z)&&n("Flag selectors require an explicit GB resource reference","feature",b);let E=u.type==="feature"||u.type==="offering"||u.type==="coupon"||u.type==="coupons"||u.type==="action"&&u.action.type==="api"?["value"]:u.type==="action"&&u.action.type==="external_task"?Object.keys(u.action.outputs):u.type==="wait"&&u.wait.type==="event"?Object.keys(u.wait.outputs):[],oe="writes"in u?u.writes??{}:{};(E.length!==Object.keys(oe).length||E.some(L=>!Object.hasOwn(oe,L))||new Set(Object.values(oe)).size!==Object.values(oe).length)&&n("Node writes must map every named output exactly once","variable",b);for(let[L,Y]of Object.entries(oe)){v(Y,u);let pe=e.variables[Y],H=u.type==="offering"?"offering_version":u.type==="coupon"?"reward":u.type==="action"&&u.action.type==="api"?"json":u.type==="action"&&u.action.type==="external_task"?u.action.outputs[L]:u.type==="wait"&&u.wait.type==="event"?u.wait.outputs[L]:void 0;(pe?.source.type!=="node"||H&&pe.type!==H)&&n("Node writer source or output type does not match declaration","variable",b)}if(u.type==="coupons"){let L=e.variables[u.writes.value];(L?.type!=="array"||L.items?.type!=="reward"||L.items.nullable||L.nullable)&&n("Coupons output requires a non-null Reward array","variable",b);for(let Y of u.couponIds)a("reward",Y)||n("Coupons require Reward references","coupon",b)}if(u.type==="split"&&!a("experiment",u.experimentId)&&n("Experiment selectors require a GB resource reference","experiment",b),u.type==="coupon"&&!a("reward",u.couponId)&&n("Coupon selectors require a Reward reference","coupon",b),u.type==="action"&&u.action.type==="claim_offer"&&u.action.coupon.source==="literal"){let L=u.action.coupon.value;(!L||typeof L!="object"||Array.isArray(L)||L.type!=="reward"||typeof L.id!="string"||Object.keys(L).length!==2||!a("reward",L.id))&&n("Coupon claims require a Reward reference","coupon",b)}if(u.type==="offering"&&u.configuration.source==="fixed"&&!a("offering_version",u.configuration.versionId)&&n("Offering selectors require an explicit Version reference","offering",b),u.type==="screen"&&u.offering?.source==="variable"&&e.variables[u.offering.key]?.type!=="offering_version"&&n("Screen Offering variable must be an Offering reference","offering",b),u.type==="action"&&u.action.type==="claim_offer"&&u.action.coupon.source==="variable"&&(e.variables[u.action.coupon.key]?.type!=="reward"||u.action.coupon.path)&&n("Coupon variable must be a complete Reward reference","coupon",b),u.type==="screen"){let L=o.get(u.screenId);if(u.offering?.source==="fixed"&&!a("offering_version",u.offering.versionId)&&n("Screen Offering requires an explicit Version reference","offering",b),L?.type==="paywall"&&u.offering&&n("Paywall owns its fixed Offering Version","offering",b),L?.type==="paywall"&&!a("paywall_version",L.paywallVersionId)&&n("Paywall screens require an explicit Version reference","paywall",b),L?.type==="owned"){let Y=L.document.pages[0];if(!Y){n("Owned screen requires a page","screen",b);continue}vt(L.document).some(H=>!H.complete)&&n("Owned screens require complete local content","translations",b);let pe=new Set(L.document.actions.map(H=>H.id));(pe.size!==Object.keys(u.outputs).length||Object.keys(u.outputs).some(H=>!pe.has(H)))&&n("Every screen action requires exactly one outcome route","buttonOutputs",b),Xt(Y.root,H=>{!u.offering&&(H.type==="plan_picker"||(H.type==="stack"||H.type==="button")&&H.bind?.plan||H.type==="customer_data"&&["customer_plans","credit_packs"].includes(H.data.source))&&n("Product presentation requires an Offering Version","offering",b),H.type==="customer_data"&&Object.values(H.data.outputs??{}).some(xt=>xt!==void 0&&!pe.has(xt))&&n("Customer components require declared screen outcomes","componentOutput",b)})}}u.type==="end"&&["completed","ineligible"].includes(u.outcome)&&!u.output&&n("Completed and ineligible ends require a declared output","output",b),u.type==="end"&&u.output?.type==="literal"&&!Qe(e.outputSchema,u.output.value)&&n("Terminal output does not match outputSchema","output",b),u.type==="output"&&u.value.type==="literal"&&!Qe(e.outputSchema,u.value.value)&&n("Terminal output does not match outputSchema","output",b);let Ce=u.type==="output"?u.value:u.type==="end"?u.output:void 0;if(Ce?.type==="variable"&&!Ce.path){let L=e.variables[Ce.key];L&&!ji(L,e.outputSchema)&&n("Variable output does not match outputSchema","output",b)}if(u.type==="screen"){let L=o.get(u.screenId);if(L?.type==="owned")for(let Y of Pi(L.document))(/^(input|params)\./.test(Y)||Y.startsWith("variables.")&&!_i(Y.slice(10),d))&&n("Screen values must reference registered variables","variable",b)}if(u.type==="condition")for(let L of u.cases){for(let Y of St(L.condition))a("saved_group",Y)||n("Conditions require explicit Saved Group references","savedGroup",b);for(let Y of Ot(L.condition))Y.startsWith("variables.")||n("Funnel conditions read registered variables only","variable",b)}if(u.type==="output"&&u.value.type==="bundle"){e.outputSchema.type!=="json"&&n("Bundle output requires a JSON outputSchema","output",b);for(let[L,Y]of[["paywall","paywall_version"],["offering","offering_version"],["coupons","reward"]]){let pe=u.value[L];if(pe)if(pe.source==="literal"){let H=L==="coupons"?pe.value:[pe.value];(!Array.isArray(H)||H.length>20||H.some(xt=>!Qe({type:Y,nullable:!1},xt)||!a(Y,xt.id))||L==="coupons"&&new Set(H.map(xt=>xt.id)).size!==H.length)&&n("Bundle requires distinct scoped resource references",L==="coupons"?"coupon":L==="paywall"?"paywall":"offering",[...b,"value",L])}else{let H=e.variables[pe.key];(pe.path||!H||H.nullable||(L==="coupons"?H.type!=="array"||H.items?.type!=="reward"||H.items.nullable:H.type!==Y))&&n("Bundle binding type does not match its slot","output",b)}}}}for(let[C,u]of e.graph.nodes.entries()){let b=u.type==="screen"?o.get(u.screenId):void 0,Z=[...Tu(u,d),...b?.type==="owned"?xr(b.document).map(E=>_i(E,d)?.key??E):[]];for(let E of new Set(Z)){let Y=function(pe){if(pe===u.id)return!0;if(L.has(pe))return!1;L.add(pe);let H=e.graph.nodes.find(tl=>tl.id===pe);return H?(Ce.has(pe)?H.type==="action"?[H.cancel,H.unavailable,H.failure]:H.type==="wait"&&H.wait.type==="event"?[H.wait.timeout]:[]:Yr(H)).some(Y):!1};var $=Y;if(!Object.hasOwn(e.variables,E)){n("Consumed variable is undeclared","variable",["graph","nodes",C]);continue}let oe=e.variables[E];if(u.type==="screen"&&oe.source.type==="input"&&e.inputs.some(pe=>pe.screenId===u.screenId&&pe.variable===E)||oe.source.type==="parameter"||oe.source.type==="attribute")continue;let Ce=oe.source.type==="input"?new Set(e.inputs.filter(pe=>pe.variable===E&&pe.required).flatMap(pe=>l.filter(H=>H.screenId===pe.screenId).map(H=>H.id))):p.get(E)??new Set,L=new Set;(!Ce.size||Y(e.graph.entry))&&n("Every path must produce the consumed variable","resultReference",["graph","nodes",C])}}(new Set(e.inputs.map(C=>C.variable)).size!==e.inputs.length||new Set(e.inputs.map(C=>`${C.screenId}:${C.componentId}`)).size!==e.inputs.length)&&n("Input keys and component bindings must be unique","inputKeys");for(let[C,u]of e.inputs.entries()){e.variables[u.variable]?.source.type!=="input"&&n("Input binding requires a registered input variable","inputBinding",["inputs",C]);let b=o.get(u.screenId),Z=b?.type==="owned"?fi(b.document,u.componentId):null;if((Z?.type!=="stack"||!Z.interaction||!["input","toggle","select","multiselect","tabs"].includes(Z.interaction.type))&&n("Input requires an interactive control on its owned screen","inputBinding",["inputs",C]),Z?.type==="stack"&&Z.interaction){let E=Z.interaction.type==="toggle"?"boolean":Z.interaction.type==="multiselect"?"strings":"string";e.variables[u.variable]?.type!==E&&n("Input variable type does not match component","inputBinding",["inputs",C]);let oe=e.variables[u.variable]?.enum;oe&&!Z.children.filter(Ce=>!Ce.hidden).every(Ce=>oe.includes(Ce.id))&&n("Input choices must match the variable enum","inputBinding",["inputs",C])}}for(let[C,u]of Object.entries(e.variables))u.enum&&u.type!=="string"&&n("Only string variables support enum","variable",["variables",C]),u.source.type==="input"&&!e.inputs.some(b=>b.variable===C)&&n("Input variable requires a component binding","inputBinding",["variables",C]);let h=0,T=0;for(let C of e.screens)if(C.type==="owned"){for(let u of C.document.pages)Xt(u.root,()=>{h++});T+=C.document.actions.length}(h>ot.components||T>ot.actions||Le(e)>ot.documentBytes)&&n("Funnel document exceeds its budget","budget")}var sf=A.strictObject({...To,graph:Co}).superRefine(zu),Pt=A.strictObject({...To,graph:Co,displayName:A.string().trim().min(1).max(80)}).superRefine(zu),Cv=Pt.superRefine(Bu),kv=sf.superRefine(Bu),ti=A.string().regex(ut),Hn={requestId:A.uuid(),nodeId:Ye,visit:A.number().int().nonnegative(),revision:A.number().int().nonnegative(),customerToken:ti.optional()},cf=A.discriminatedUnion("type",[A.strictObject({type:A.literal("screen"),output:Ye,answers:Rt,selection:A.record(Ye,A.union([A.string().max(200),A.boolean(),A.number().int().min(0).max(1e4)])).optional()}),A.strictObject({type:A.literal("paywall_quote"),featureQuantities:A.record(A.uuid(),A.number().int().min(0).max(1e4)).refine(e=>Object.keys(e).length<=100).optional(),actionId:Ye,productVersionId:A.uuid(),offerId:A.uuid().optional(),nativeOffer:un.optional(),predecessor:A.strictObject({operationId:A.uuid().nullable(),generation:A.number().int().positive()}).optional()}),A.strictObject({type:A.literal("paywall_confirm"),operationId:A.uuid()}),A.strictObject({type:A.literal("paywall_cancel"),operationId:A.uuid()}),A.strictObject({type:A.literal("client_action"),receiptId:A.uuid(),outcome:A.enum(["success","cancel","failure","opened","failed"])})]),uf=A.object({nodeId:Ye,visit:A.number().int().nonnegative(),revision:A.number().int().nonnegative(),components:A.record(Ye,A.object({resourceKey:A.string().regex(/^[a-z][a-z0-9_]{0,63}$/).optional(),page:A.number().int().min(1).max(1e5),after:pr.nullable(),filter:A.enum(["all","purchase","refund","source","usage","debt","settlement","issued","reserved","redeemed","expired","revoked"])}).strict()).refine(e=>Object.keys(e).length<=150)}).strict(),et=A.discriminatedUnion("operation",[A.strictObject({operation:A.literal("start"),funnelId:A.uuid(),requestId:A.uuid(),customer:yt.optional(),customerData:_t.optional(),locale:A.string().min(1).max(35),parameters:ct}).refine(Ut,Vt),A.strictObject({operation:A.literal("get"),settlementRequestId:A.uuid().optional(),data:uf.optional(),purchase:A.strictObject({receiptId:A.uuid(),operationId:A.uuid()}).optional(),customerToken:ti.optional()}),A.strictObject({operation:A.literal("resume"),requestId:A.uuid(),customerToken:ti.optional()}),A.strictObject({operation:A.literal("submit"),...Hn,input:cf}),A.strictObject({operation:A.literal("back"),...Hn}),A.strictObject({operation:A.literal("shown"),...Hn}),A.strictObject({operation:A.literal("close"),...Hn}),A.strictObject({operation:A.literal("commit_segment"),...Hn,policyRevision:A.number().int().nonnegative(),generation:A.string().min(1).max(256)}),A.strictObject({operation:A.literal("review"),receiptId:A.uuid().optional(),customerToken:ti.optional()})]);function ri(e,t){let n=new Set,r=new Set,o=new Set,a=[],l=new Map,p=new Map,d=new Map;function v(u){for(let b of St(u))h(b)}function h(u){if(o.has(u)||!Object.hasOwn(t.savedGroups,u))return;let b=t.savedGroups[u];b&&(o.add(u),d.set(u,b),a.push(()=>{!Array.isArray(b)&&b.type==="condition"&&v(b.condition)}))}function T(u){for(let b of["hashAttribute","fallbackAttribute"])if(u[b]!==void 0&&bo(u[b]))throw new Error(`Funnel GB ${b} uses a reserved flow namespace`);v(u.condition);for(let b of u.parentConditions??[])$(b.id),v(b.condition)}function $(u,b=!1){let Z=Object.hasOwn(t.features,u)?t.features[u]:void 0;if(!Z){if(b)throw new Error("Required GB Feature is unavailable");return}n.has(u)||(n.add(u),l.set(u,Z),a.push(()=>{for(let E of Z.rules??[]){T(E);for(let oe of E.tracks??[])T(oe.experiment)}}))}function C(u){let b=Object.hasOwn(t.experiments,u)?t.experiments[u]:void 0;if(!b)throw new Error("Required GB Experiment is unavailable");r.has(u)||(r.add(u),p.set(u,b),a.push(()=>T(b)))}for(let u of e.graph.nodes){u.type==="feature"&&$(u.featureKey,!0),u.type==="split"&&C(u.experimentId),u.type==="condition"&&u.cases.forEach(Z=>v(Z.condition)),u.type==="offering"&&u.configuration.source==="feature"&&$(u.configuration.featureKey,!0);let b=u.type==="output"?u.value:u.type==="end"?u.output:null;b?.type==="feature"&&$(b.featureKey,!0)}for(let u of a)u();return{...t,features:Object.fromEntries(l),experiments:Object.fromEntries(p),savedGroups:Object.fromEntries(d)}}import{z}from"zod";import{z as Jn}from"zod";var qu=Jn.object({defaultLocale:Ht,locales:Jn.record(Ht,Jn.object({name:Jn.string().max(80),description:Jn.string().max(500)}).strict())}).strict().superRefine((e,t)=>{let n=Object.keys(e.locales);(!n.length||n.length>20||!e.locales[e.defaultLocale])&&t.addIssue({code:"custom",message:"Invalid content languages"}),new TextEncoder().encode(JSON.stringify(e)).length>5e4&&t.addIssue({code:"custom",message:"Content exceeds 50 KB"})});var pf=["customer_data","coupon_code"],Fu=z.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/),lf=z.string().min(1).max(255).regex(/^[a-z0-9][a-z0-9-]*$/),ii=(e,t)=>new Set(e.map(t)).size===e.length,mf=z.strictObject({currency:ie,amountMinor:z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)}),df=z.strictObject({featureId:z.uuid(),name:z.string().trim().min(1).max(120),allowance:z.string().max(40).nullable(),access:z.boolean()}),ff=z.strictObject({stripe:z.strictObject({prices:z.array(mf).min(1).max(50)}).optional(),apple:z.strictObject({productIds:z.array(Fu).min(1).max(10)}).optional(),google:z.strictObject({products:z.array(z.strictObject({productId:Fu,basePlanId:lf.nullable()})).min(1).max(10)}).optional()}).superRefine((e,t)=>{(e.stripe&&!ii(e.stripe.prices,n=>n.currency)||e.apple&&!ii(e.apple.productIds,n=>n)||e.google&&!ii(e.google.products,n=>`${n.productId}:${n.basePlanId}`))&&t.addIssue({code:"custom",message:"Duplicate channel entry"})}),gf=z.strictObject({name:z.string().trim().min(1).max(80),interval:z.enum(["free","week","month","year","one_time"]),intervalCount:z.number().int().min(1).max(100),trial:z.strictObject({days:z.number().int().min(1).max(730),cardRequired:z.boolean()}).nullable(),benefits:z.array(df).max(50).refine(e=>ii(e,t=>t.featureId),"Duplicate benefit"),channels:ff,prepaid:z.array(ja).max(100).optional()}),hf=z.strictObject({digest:gn,content:z.strictObject({discount:jt,duration:Ze,appliesTo:qi,displayCopy:qu.nullable(),firstPurchaseOnly:z.boolean(),qualificationRequired:z.boolean(),startsAt:z.iso.datetime().nullable(),endsAt:z.iso.datetime().nullable(),grantWindowHours:z.number().int().positive(),perCustomerLimit:z.number().int().positive()})}),bf=z.discriminatedUnion("type",[z.strictObject({type:z.literal("checkout"),product:ur}),z.strictObject({type:z.literal("close")}),z.strictObject({type:z.literal("action"),action:ro})]),Nu=z.strictObject({kind:z.literal("paywall"),formatVersion:z.literal(1),name:z.string().trim().min(1).max(80),offeringVersionId:z.uuid(),presentation:ft,screen:Ke,products:vr,catalog:z.record(z.uuid(),gf),buttons:z.record(Cn,bf),coupons:z.record(z.uuid(),hf)}).superRefine((e,t)=>{let n=b=>t.addIssue({code:"custom",message:b}),{screen:r}=e;Ta(r,e.catalog).forEach(n),r.surface!=="paywall"&&n("Screen must be a Paywall"),po(r,pf).forEach(n),vt(r).some(b=>!b.complete)&&n("Every published locale must be complete");let o=new Set,a=new Set,l=new Set;gt(r,b=>{let Z="bind"in b?b.bind:void 0;Z?.promotionCode&&n("Promotion codes must not be published"),Z?.plan&&o.add(Z.plan),Z?.coupon&&a.add(Z.coupon),b.type==="plan_picker"&&(b.planIds?.forEach(E=>o.add(E)),b.defaultPlan&&o.add(b.defaultPlan)),b.type==="text"&&b.feature&&l.add(b.feature.id)});let p=e.products.items.map(b=>b.productVersionId),d=Object.keys(e.catalog);(p.length!==d.length||p.some(b=>!Object.hasOwn(e.catalog,b)))&&n("Catalog must contain exactly the displayed Products");let v=new Set(p);e.products.defaultProductVersionId!==null&&!v.has(e.products.defaultProductVersionId)&&n("Default Product must be displayed");for(let b of o)v.has(b)||n("Screen references a Product that is not displayed");for(let b of Object.values(e.catalog))!b.channels.stripe&&!b.channels.apple&&!b.channels.google&&n("A displayed Product needs at least one sales channel");let h=new Set(Object.values(e.catalog).flatMap(b=>b.benefits.map(Z=>Z.featureId)));for(let b of l)h.has(b)||n("Feature text must read a displayed benefit");let T=r.actions.filter(b=>b.type!=="navigate");r.actions.some(b=>b.type!=="event"&&b.type!=="navigate")&&n("Paywall actions are events or navigation"),(Object.keys(e.buttons).length!==T.length||T.some(b=>!Object.hasOwn(e.buttons,b.id)))&&n("Buttons must match the screen's actions");let C=!1;for(let b of Object.values(e.buttons)){if(b.type!=="checkout")continue;C=!0,(b.product.type==="fixed"?[b.product.productVersionId]:b.product.allowedProductVersionIds).some(E=>!v.has(E))&&n("Checkout may only sell displayed Products")}C||n("A Paywall needs a checkout button");let u=Object.keys(e.coupons);(u.length!==a.size||u.some(b=>!a.has(b)))&&n("Coupons must be exactly the bound Coupons")}),Uu=z.strictObject({state:z.enum(["published","archived"]),controlRevision:z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),currentVersionId:z.uuid(),versions:z.record(z.uuid(),z.strictObject({version:z.number().int().positive(),artifact:z.string().min(1),sourceDigest:z.string().regex(/^[a-f0-9]{64}$/)}))}).refine(e=>Object.keys(e.versions).length>0,"Reviewed Paywall Versions are required");var yf={manifestCdnSeconds:15,maxControlAgeMs:6e4,initializationMs:5e3,maxArtifactBytes:1048576,maxManifestBytes:524288,maxCacheBytes:32*1048576,retentionMs:7*864e5},Do=X.string().regex(/^[a-f0-9]{64}$/),Bo=X.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),xf=le.extend({environmentId:X.uuid()}),Vu=X.strictObject({features:X.array(X.string()).max(500),experiments:X.record(X.uuid(),X.array(X.string()).max(20)),savedGroups:X.array(X.string()).max(1e3)}),Fo=X.strictObject({kind:X.enum(["funnel","paywall","gb_features","gb_page_experiments"]),formatVersion:X.number().int().positive(),url:X.string().min(1).max(2048),sha256:Do,byteLength:X.number().int().positive().max(yf.maxArtifactBytes),generation:Do.optional()}),Sf=X.strictObject({state:X.enum(["active","paused","archived"]),controlRevision:Bo,evaluationMode:X.enum(["local","remote"]),evaluationRevision:Bo,currentVersionId:X.uuid(),versions:X.record(X.uuid(),X.strictObject({artifact:X.string(),dependencies:Vu,definitionDigest:gn.optional(),couponDigests:X.record(X.uuid(),gn).optional()}))}),sI=X.strictObject({kind:X.literal("sdk_configuration"),schemaVersion:X.literal(1),scope:xf,revision:Bo,generation:Do,policy:X.strictObject({refreshIntervalSeconds:X.number().positive().max(15),maxControlAgeSeconds:X.number().positive().max(60)}),gb:X.strictObject({features:X.string().nullable(),pageExperiments:X.string().nullable()}),artifacts:X.record(X.string(),Fo),funnels:X.record(X.uuid(),Sf),paywalls:X.record(X.uuid(),Uu).optional()}).superRefine((e,t)=>{let n=(r,o)=>{r!==null&&e.artifacts[r]?.kind!==o&&t.addIssue({code:"custom",message:"Missing or wrong-kind configuration artifact"})};n(e.gb.features,"gb_features"),n(e.gb.pageExperiments,"gb_page_experiments");for(let r of Object.values(e.paywalls??{}))for(let o of Object.values(r.versions))n(o.artifact,"paywall");for(let r of Object.values(e.funnels)){r.evaluationMode==="remote"&&Object.keys(r.versions).length&&t.addIssue({code:"custom",message:"Remote Funnel graphs cannot be public"}),r.evaluationMode==="local"&&!r.versions[r.currentVersionId]&&t.addIssue({code:"custom",message:"Current Funnel Version is not retained"});for(let o of Object.values(r.versions))n(o.artifact,"funnel")}});function zo(e){if(Array.isArray(e))return`[${e.map(zo).join(",")}]`;if(e!==null&&typeof e=="object")return`{${Object.entries(e).sort(([n],[r])=>n<r?-1:n>r?1:0).map(([n,r])=>`${JSON.stringify(n)}:${zo(r)}`).join(",")}}`;let t=JSON.stringify(e);if(t===void 0)throw new Error("Configuration must contain JSON values");return t}function vf(e){return or(ar(typeof e=="string"?new TextEncoder().encode(e):e))}function cI(e){return vf(zo(e))}var qo=class extends Error{constructor(n,r){super(n);this.dependency=r}dependency};function uI(e,t){let n=h=>h.type==="feature"?h.featureKey:h.type==="end"&&h.output?.type==="feature"?h.output.featureKey:h.type==="output"&&h.value.type==="feature"?h.value.featureKey:void 0,r=(h,T)=>e.graph.nodes.find($=>h==="experiment"?$.type==="split"&&$.experimentId===T:h==="feature"&&n($)===T)?.name,o=(h,T,$=r(T.type,T.resource))=>new qo(h,{...T,...$?{step:$}:{}});for(let h of Object.values(e.references)){let T=h.type==="flag"?!Object.hasOwn(t.features,h.key)||t.remoteFeatures.includes(h.key)?{type:"feature",resource:h.key}:null:h.type==="experiment"?Object.hasOwn(t.experiments,h.id)?null:{type:"experiment",resource:h.id}:h.type==="saved_group"&&!Object.hasOwn(t.savedGroups,h.id)?{type:"saved_group",resource:h.id}:null;if(T)throw o("Funnel dependency is absent from GB public delivery",{reason:"unavailable",...T})}let a=ri(e,{...t,evaluatedAt:new Date(0).toISOString(),expiresAt:null}),l=new Set(t.remoteFeatures);for(let h of e.graph.nodes){let T=n(h);if(!T)continue;let $=a.features[T],C=h.type==="feature"?e.variables[h.writes.value]:e.outputSchema,u={type:"feature",resource:T};if(!$||!C)throw o("Required public Feature declaration is unavailable",{reason:"unavailable",...u},h.name);if([$.defaultValue,...($.rules??[]).flatMap(Z=>[...Object.hasOwn(Z,"force")?[Z.force]:[],...Z.variations??[],...(Z.tracks??[]).flatMap(E=>E.experiment.variations)])].some(Z=>Z===void 0||!Qe(C,Z)))throw o("GB Feature values violate the Funnel type contract",{reason:"value_type",...u},h.name)}let p=new Set,d=(h,T)=>{for(let $ of St(h)){if(p.has($))continue;let C=t.savedGroups[$];if(!C)throw o("Required public Saved Group is unavailable",{reason:"unavailable",type:"saved_group",resource:$},T);p.add($),!Array.isArray(C)&&C.type==="condition"&&d(C.condition,T)}},v=(h,T)=>{if(l.has(h)||!t.features[h])throw o("Local Funnel requires public Local prerequisites",{reason:"unavailable",type:"feature",resource:h},T)};for(let h of e.graph.nodes)if(h.type==="condition")for(let T of h.cases)d(T.condition,h.name);for(let[h,T]of Object.entries(a.features)){let $=r("feature",h);for(let C of T.rules??[]){d(C.condition,$);for(let u of[...C.parentConditions??[],...(C.tracks??[]).flatMap(b=>b.experiment.parentConditions??[])])v(u.id,$),d(u.condition,$);for(let u of C.tracks??[])d(u.experiment.condition,$)}}for(let[h,T]of Object.entries(a.experiments)){let $=r("experiment",h);d(T.condition,$);for(let C of T.parentConditions??[])v(C.id,$),d(C.condition,$)}for(let h of e.graph.nodes)if(h.type==="split"){let T=a.experiments[h.experimentId],$={type:"experiment",resource:h.experimentId};if(!T)throw o("Local Funnel requires a public Experiment",{reason:"unavailable",...$},h.name);for(let C of T.variations)if(typeof C!="string"||!Object.hasOwn(h.routes,C))throw o("Experiment variation has no declared Funnel route",{reason:"variation_route",...$},h.name)}return Vu.parse({features:Object.keys(a.features).sort(),experiments:Object.fromEntries(Object.entries(a.experiments).map(([h,T])=>[h,T.variations.map(String)])),savedGroups:[...p].sort()})}function pI(e){return Pt.parse(e)}var $u=we.strictObject({processContext:Mr.optional(),...cn,selector:we.discriminatedUnion("type",[we.strictObject({type:we.literal("paywall"),paywallId:we.uuid()}),we.strictObject({type:we.literal("version"),versionId:we.uuid()})]),customerId:we.uuid().optional(),commerce:cr,locale:we.string().min(1).max(35),requirement:Wt.optional()}),Wn=we.strictObject({id:we.uuid(),paywallId:we.uuid(),version:we.number().int().positive(),document:fn.omit({requirement:!0,offeringId:!0}),offering:we.strictObject({id:we.uuid()}),content:we.strictObject({environmentId:we.uuid(),offeringVersionId:we.uuid(),artifact:Fo.refine(e=>e.kind==="paywall"&&e.formatVersion===1)}).optional(),capabilities:Qt,check:Pn.nullable()}).superRefine((e,t)=>{let n=new Set(e.document.products.items.map(r=>r.productVersionId));(e.document.offeringVersionId!==e.offering.id||Object.values(e.capabilities.plans).some(r=>!n.has(r.versionId)))&&t.addIssue({code:"custom",message:"Paywall resolution must preserve the exact Offering Version and displayed Product subset"})}),Qn=we.strictObject(Wn.shape).omit({document:!0,offering:!0}).extend({content:Wn.shape.content.unwrap()});function II(e,t){let n=Nu.parse(t);if(n.offeringVersionId!==e.content.offeringVersionId)throw new Error("Public Paywall Offering pin changed");let r=structuredClone(e.capabilities);for(let[o,a]of Object.entries(n.catalog)){let l=r.plans[o],p=a.channels.stripe?.prices.find(d=>d.currency===l?.currency);l&&p&&Object.assign(l,{amountMinor:p.amountMinor,interval:a.interval,intervalCount:a.intervalCount,...a.prepaid?.length?{prepaid:a.prepaid}:{}})}return Wn.parse({...e,capabilities:r,document:{schemaVersion:3,kind:n.kind,name:n.name,presentation:n.presentation,products:n.products,offeringVersionId:n.offeringVersionId,screen:n.screen,buttons:n.buttons},offering:{id:n.offeringVersionId}})}import{z as Ne}from"zod";var Gu={requestId:Ne.uuid(),sourceId:Ne.uuid(),expectedAvailable:Jt},Ku=Ne.discriminatedUnion("action",[Ne.strictObject({...Gu,action:Ne.enum(["add","subtract","set_remaining"]),amount:be}),Ne.strictObject({...Gu,action:Ne.literal("edit"),granted:be,expiresAt:Ne.iso.datetime({offset:!0}).nullable(),nextResetAt:Ne.iso.datetime({offset:!0}).nullable(),expectedRevision:Ne.number().int().nonnegative()})]),No=Ne.strictObject({sourceId:Ne.uuid(),available:Jt,held:Jt,spent:Jt,adjustmentGrantId:Ne.uuid().nullable()}),Lu=No.extend({granted:Jt,expiresAt:Ne.iso.datetime({offset:!0}).nullable(),nextResetAt:Ne.iso.datetime({offset:!0}).nullable(),revision:Ne.number().int().nonnegative()});import{z as We}from"zod";var Zu=We.discriminatedUnion("action",[We.object({action:We.literal("upsert"),externalId:We.string().min(1).max(128),name:We.string().trim().min(1).max(80)}).strict(),We.object({action:We.literal("archive"),entityId:We.uuid()}).strict()]),Hu=We.object({id:We.uuid(),externalId:We.string().min(1).max(128),name:We.string().min(1).max(80),archived:We.boolean()}).strict();import{z as Be}from"zod";import{z as Kt}from"zod";var Wu=["input","output","cache_read","cache_write","reasoning","input_audio","output_audio"],Ju=Kt.string().regex(/.+\/.+/),Uo=Kt.number().min(-100),Gt=Kt.string().regex(/^(0|[1-9]\d{0,5})(\.\d{1,12})?$/),If=Kt.strictObject({input:Gt,output:Gt,cache_read:Gt.optional(),cache_write:Gt.optional(),reasoning:Gt.optional(),input_audio:Gt.optional(),output_audio:Gt.optional()}),Vo=(e,t)=>Kt.record(e,t).refine(n=>Object.keys(n).length<=100,"At most 100 AI overrides"),RI=Kt.strictObject({defaultMarkup:Uo,providerMarkups:Vo(Kt.string().min(1),Uo),modelMarkups:Vo(Ju,Uo),customModels:Vo(Ju,If.partial())});import{z as K}from"zod";var Lt=K.iso.datetime({offset:!0}),Ct=K.string().regex(/^-?(0|[1-9]\d{0,23})(\.\d{1,12})?$/),Of=K.discriminatedUnion("kind",[K.object({kind:K.literal("absolute"),from:Lt,to:Lt}).strict(),K.object({kind:K.literal("last_days"),days:K.union([K.literal(1),K.literal(7),K.literal(30),K.literal(90)])}).strict(),K.object({kind:K.literal("billing_cycles"),membershipId:K.uuid(),count:K.number().int().min(1).max(12),includeCurrent:K.boolean()}).strict()]),Qu=K.string().max(100).refine(e=>{if(e!=="UTC"&&!/^[A-Za-z_]+(?:\/[A-Za-z0-9_+\-]+)+$/.test(e))return!1;try{return new Intl.DateTimeFormat("en",{timeZone:e}),!0}catch{return!1}},"Use an IANA timezone"),jf=K.object({key:K.string().regex(/^[a-z][a-z0-9_]{0,63}$/),values:K.array(K.string().max(120)).min(1).max(20).refine(e=>new Set(e).size===e.length)}).strict(),Zt=K.object({range:Of,timezone:Qu,filterBy:K.array(jf).max(5).refine(e=>new Set(e.map(t=>t.key)).size===e.length),interval:K.enum(["hour","day","week","month"]),internal_feature_id:K.uuid().nullable(),entityId:K.uuid().nullable(),topN:K.number().int().min(1).max(50).nullable(),groupBy:K.union([K.enum(["customer","entity","entitlement","source","resource","dimension","plan"]),K.string().regex(/^properties\.[a-z][a-z0-9_]{0,63}$/)]),after:K.object({bucket:Lt,group:K.string().max(240),isOther:K.boolean(),internal_feature_id:K.uuid(),resourceId:K.uuid()}).strict().nullable(),limit:K.number().int().min(1).max(100)}).strict().superRefine((e,t)=>{if(e.range.kind!=="absolute"){e.interval==="hour"&&e.range.kind==="last_days"&&e.range.days>31&&t.addIssue({code:"custom",message:"Hourly reports are bounded to 31 days"});return}let n=Date.parse(e.range.to)-Date.parse(e.range.from);(n<=0||n>366*864e5||e.interval==="hour"&&n>31*864e5)&&t.addIssue({code:"custom",message:"Reporting range must be positive and bounded (31 days hourly, 366 days otherwise)"})}),Xu=K.object({from:Lt,to:Lt,interval:K.enum(["hour","day","week","month"]),timezone:Qu,rows:K.array(K.object({bucket:Lt,group:K.string().max(240),isOther:K.boolean(),internal_feature_id:K.uuid(),resourceId:K.uuid(),consumedUnits:Ct,refundedUnits:Ct,reservedUnits:Ct,charged:Ct,refunded:Ct,reserved:Ct,netUnits:Ct,netCharged:Ct}).strict()).max(100),nextCursor:K.object({bucket:Lt,group:K.string().max(240),isOther:K.boolean(),internal_feature_id:K.uuid(),resourceId:K.uuid()}).strict().nullable()}).strict();var Sn=Be.string().regex(/^(0|[1-9]\d{0,29})$/),Yu=Be.string().regex(/^(0|[1-9]\d{0,29})(\.\d{1,18})?$/),$o=Be.strictObject({bucket:Be.iso.datetime({offset:!0}),group:Be.string().max(240),isOther:Be.boolean(),internal_feature_id:Be.uuid()}),ep=Be.strictObject({...Zt.shape,groupBy:Be.union([Be.enum(["customer","entity","entitlement"]),Be.string().regex(/^properties\.[a-z][a-z0-9_]{0,63}$/)]),after:$o.nullable()}).superRefine((e,t)=>{let n=Zt.safeParse({...e,after:null});if(!n.success)for(let r of n.error.issues)t.addIssue({code:"custom",path:r.path,message:r.message})}),tp=Be.strictObject({from:Be.iso.datetime({offset:!0}),to:Be.iso.datetime({offset:!0}),interval:Zt.shape.interval,timezone:Zt.shape.timezone,rows:Be.array(Be.strictObject({...$o.shape,eventCount:Sn,units:Yu,tokenEventCount:Sn,tokens:Be.strictObject(Object.fromEntries(Wu.map(e=>[e,Sn]))),totalTokens:Sn,providerCostEventCount:Sn,providerCostUsd:Yu,invalidTelemetryEventCount:Sn})).max(100),nextCursor:$o.nullable()});import{z as Oe}from"zod";var np=Oe.object({requestId:Oe.uuid(),items:Oe.array(Oe.object({customerId:Oe.uuid(),command:wn.options[1]}).strict()).min(1).max(1e3)}).strict().refine(e=>new Set(e.items.map(t=>t.customerId+":"+t.command.idempotencyKey)).size===e.items.length,"Each logical event must appear once in a batch"),rp=Oe.object({batchId:Oe.uuid(),after:Oe.number().int().min(-1).max(999),limit:Oe.number().int().min(1).max(100)}).strict(),ip=Oe.object({batchId:Oe.uuid(),status:Oe.enum(["queued","complete"]),total:Oe.number().int().min(1).max(1e3),processed:Oe.number().int().min(0).max(1e3),items:Oe.array(Oe.object({position:Oe.number().int().min(0).max(999),customerId:Oe.uuid(),idempotencyKey:Oe.string().min(1).max(120),status:Oe.enum(["queued","accepted","rejected","failed"]),receipt:_n.nullable(),errorCode:Oe.enum(["invalid_request","forbidden","conflict","internal_error"]).nullable()}).strict().refine(e=>e.status==="queued"?e.receipt===null&&e.errorCode===null:e.status==="failed"?e.receipt===null&&e.errorCode!==null:e.receipt!==null&&e.errorCode===null&&e.receipt.accepted===(e.status==="accepted"))).max(100),nextAfter:Oe.number().int().min(0).max(999).nullable()}).strict();import{z as f}from"zod";var Af=f.enum(["percentage_discount","fixed_discount","free_product","invoice_credits","feature_grant"]),op=f.enum(["draft","active","paused","archived"]),ap=f.string().min(1).max(256),sp=f.array(ap).max(50).refine(e=>new Set(e).size===e.length,"Duplicate products"),wf=f.strictObject({duration:f.enum(["day","week","month","year"]),length:f.number().int().min(1).max(3660)}),_f=f.strictObject({internal_feature_id:f.uuid(),allowance:f.number().nonnegative().max(1e15).nullable(),expiry:wf.nullable()}),Pf=f.discriminatedUnion("type",[f.strictObject({type:f.literal("feature_grant"),grants:f.array(_f).min(1).max(100).refine(e=>new Set(e.map(t=>t.internal_feature_id)).size===e.length,"Duplicate entitlement grants")}),f.strictObject({type:f.literal("free_product"),productId:ap,duration:Ze}),f.strictObject({type:f.literal("invoice_credits"),amount:f.number().positive().max(1e8),duration:Ze,rollover:f.boolean(),productIds:sp})]),Cf=f.string().regex(/^[a-zA-Z0-9_-]{1,64}$/),cp=f.object({key:Cf,name:f.string().trim().min(1).max(80),configuration:Pf}).strict(),up=f.string().regex(/^[A-Z0-9][A-Z0-9_-]{2,31}$/),Go=f.object({code:up,maxUses:f.number().int().min(1).max(1e6).nullable(),firstPurchaseOnly:f.boolean()}).strict(),pp=f.object({key:f.string().regex(/^[a-z][a-z0-9_]{0,63}$/),name:f.string().trim().min(1).max(80),rewardId:f.uuid(),redeemOn:f.enum(["customer_creation","checkout"]),receivedBy:f.enum(["referrer","all"]),maxRedemptions:f.number().int().min(1).max(1e6).nullable(),productIds:sp,excludeTrial:f.boolean()}).strict().refine(e=>e.redeemOn==="checkout"||e.productIds.length===0&&!e.excludeTrial,"Purchase restrictions require checkout trigger"),lp={id:f.uuid(),projectId:f.uuid(),environmentId:f.uuid(),revision:f.number().int().nonnegative(),status:op,createdAt:f.iso.datetime({offset:!0}),updatedAt:f.iso.datetime({offset:!0})},kf=cp.extend(lp).strict(),Rf=pp.safeExtend(lp).strict(),KI=f.strictObject({id:f.uuid(),key:f.string(),name:f.string(),type:Af,status:op}),LI=f.discriminatedUnion("action",[f.object({action:f.literal("save"),id:f.uuid().nullable(),revision:f.number().int().nonnegative(),input:cp}).strict(),f.object({action:f.enum(["activate","pause","resume","archive","delete"]),id:f.uuid(),revision:f.number().int().nonnegative()}).strict()]),ZI=f.discriminatedUnion("action",[f.object({action:f.literal("save"),id:f.uuid().nullable(),revision:f.number().int().nonnegative(),input:pp}).strict(),f.object({action:f.enum(["activate","pause","resume","archive","delete"]),id:f.uuid(),revision:f.number().int().nonnegative()}).strict()]),mp=f.object({id:f.uuid(),rewardId:f.uuid(),programId:f.uuid().nullable(),customerId:f.uuid(),referrerId:f.uuid().nullable(),status:f.enum(["pending","applied","unavailable"]),result:f.record(f.string(),f.unknown()).nullable(),createdAt:f.iso.datetime({offset:!0})}).strict(),dp=f.object({code:up,requestId:f.uuid()}).strict(),fp=f.strictObject({redemptionId:f.uuid(),currency:ie,requestId:f.uuid(),accepted:f.literal(!0)}),Ef=f.strictObject({type:f.literal("checkout"),orderId:f.uuid(),productVersionId:f.uuid(),currency:ie,duration:Ze,renewalAmountMinor:f.number().int().positive().max(1e8),status:f.enum(["created","pending","trialing","paid","cancelled","failed"]),url:f.url().nullable()}),gp=f.discriminatedUnion("type",[Ef,f.strictObject({type:f.literal("subscription"),operationId:f.uuid(),membershipId:f.uuid(),productVersionId:f.uuid(),currency:ie,duration:Ze,renewalAmountMinor:f.number().int().positive().max(1e8),status:f.enum(["pending","running","applied","failed"])})]),hp=f.object({programId:f.uuid(),requestId:f.uuid()}).strict(),bp=f.object({id:f.uuid(),programId:f.uuid(),code:Go.shape.code,createdAt:f.iso.datetime({offset:!0})}).strict(),HI=f.object({rows:f.array(kf).max(100),nextCursor:f.uuid().nullable()}).strict(),JI=f.object({rows:f.array(Rf).max(100),nextCursor:f.uuid().nullable()}).strict(),Mf=Go.extend({id:f.uuid(),redemptions:f.number().int().nonnegative()}).strict(),Tf=f.strictObject({id:f.uuid(),programId:f.uuid().nullable(),customerId:f.uuid().nullable(),referrerId:f.uuid().nullable(),code:f.string().nullable(),status:f.enum(["pending","triggered","applied"]),createdAt:f.iso.datetime({offset:!0})}),WI=f.object({codes:f.array(Mf).max(100),redemptions:f.array(Tf).max(100),customers:f.record(f.uuid(),f.string()),codesCursor:f.uuid().nullable(),redemptionsCursor:f.uuid().nullable()}).strict(),QI=f.discriminatedUnion("action",[f.object({action:f.literal("create"),rewardId:f.uuid(),revision:f.number().int().nonnegative(),input:Go}).strict(),f.object({action:f.literal("remove"),rewardId:f.uuid(),revision:f.number().int().nonnegative(),codeId:f.uuid()}).strict()]);import{z as c}from"zod";import{z as R}from"zod";var mt={repositories:20,branches:4,keys:2e3,references:1e4,referencesPerKey:2e3,reportBytes:1048576,files:1e4,sourceBytes:1e8},Xn=e=>new Set(e).size===e.length,Ko=R.string().regex(/^[a-zA-Z0-9_.:|-]{1,256}$/),Df=R.string().max(512).regex(/^[\w.-]+(?:\/[\w.-]+){1,5}$/).refine(e=>!e.split("/").some(t=>t==="."||t==="..")),Yn=R.string().min(1).max(200).regex(/^[a-zA-Z0-9_./-]+$/).refine(e=>!e.includes("..")&&!e.endsWith(".")&&!e.split("/").some(t=>!t||t.startsWith(".")||t.endsWith(".lock"))),Bf=R.string().min(1).max(512).refine(e=>!/[\\\u0000-\u001f\u007f]/.test(e)&&!e.startsWith("/")&&!e.split("/").some(t=>!t||t==="."||t==="..")),yp=R.string().min(1).max(256).regex(/^[a-zA-Z0-9_./*?-]+$/).refine(e=>!e.startsWith("/")&&!e.split("/").some(t=>!t||t==="."||t===".."));var xp=R.strictObject({id:R.uuid(),repo:Df,platform:R.enum(["github","gitlab","bitbucket"]),branches:R.array(Yn).min(1).max(4).refine(Xn),workflow:R.string().regex(/^\.github\/workflows\/[a-zA-Z0-9_-]+\.ya?ml$/),keyIds:R.array(R.uuid()).min(1).max(4).refine(Xn),include:R.array(yp).min(1).max(16),exclude:R.array(yp).max(16),methods:R.array(R.string().regex(/^[a-zA-Z_$][\w$]{0,63}$/)).min(1).max(32).refine(Xn),maxAgeHours:R.number().int().min(1).max(720)}),Sp=xp.extend({revision:R.number().int().positive()}),e0=R.strictObject({repository:xp,expectedRevision:R.number().int().min(0)}).refine(({repository:e})=>e.platform==="gitlab"||e.repo.split("/").length===2,{path:["repository","repo"]}),vp=R.strictObject({repositoryId:R.uuid(),branch:Yn}),zf=R.array(Ko).max(mt.keys).refine(Xn),Ip=R.strictObject({repository:Sp.omit({keyIds:!0}),branch:Yn,keys:zf,keySetHash:R.string().regex(/^[a-f0-9]{64}$/)}),qf=R.strictObject({filePath:Bf,startingLineNumber:R.number().int().min(1).max(1e7)}),Lo=R.strictObject({protocol:R.literal(1),repositoryId:R.uuid(),branch:Yn,workflow:R.string().max(200),configurationRevision:R.number().int().positive(),keySetHash:R.string().regex(/^[a-f0-9]{64}$/),commit:R.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/),scanId:R.uuid(),runNumber:R.number().int().min(1).max(Number.MAX_SAFE_INTEGER),runAttempt:R.number().int().min(1).max(1e4),scannerVersion:R.literal("1"),scannedAt:R.iso.datetime({offset:!0}),coverage:R.strictObject({complete:R.literal(!0),files:R.number().int().min(0).max(mt.files),sourceBytes:R.number().int().min(0).max(mt.sourceBytes),unresolvedCalls:R.number().int().min(0).max(1e6),unsupportedFiles:R.number().int().min(0).max(mt.files)}),features:R.array(R.strictObject({key:Ko,refs:R.array(qf).max(mt.referencesPerKey)})).max(mt.keys)}).superRefine((e,t)=>{Xn(e.features.map(n=>n.key))||t.addIssue({code:"custom",path:["features"],message:"Duplicate feature"}),e.features.reduce((n,r)=>n+r.refs.length,0)>mt.references&&t.addIssue({code:"custom",path:["features"],message:"Reference budget exceeded"})}),Zo=R.strictObject({scanId:R.uuid(),commit:R.string(),receivedAt:R.string(),references:R.number().int().nonnegative(),removedReferences:R.number().int().nonnegative()}),Ff=Zo.extend({repositoryId:R.uuid(),branch:Yn,workflow:R.string(),digest:R.string(),configurationRevision:R.number().int().positive(),runNumber:R.number().int().positive(),runAttempt:R.number().int().positive(),scannedAt:R.string(),keySetHash:R.string(),coverage:Lo.shape.coverage}),Nf=R.strictObject({repositories:R.array(Sp).max(mt.repositories),scans:R.array(Ff).max(mt.repositories*mt.branches)}),Uf=R.strictObject({key:Ko,references:R.number().int().nonnegative(),coveredTargets:R.number().int().nonnegative(),expiredTargets:R.number().int().nonnegative(),uncertainTargets:R.number().int().nonnegative()}),t0=R.strictObject({available:R.boolean().default(!0),settings:Nf,expectedTargets:R.number().int().min(0).max(80),features:R.array(Uf).max(2001),truncated:R.boolean()});import{z as _e}from"zod";var Vf=_e.enum(["checkout.session.completed","checkout.session.expired","checkout.session.async_payment_succeeded","checkout.session.async_payment_failed","customer.subscription.created","customer.subscription.updated","customer.subscription.deleted","customer.subscription.paused","customer.subscription.resumed","invoice.created","invoice.paid","customer.discount.created","customer.discount.updated","refund.created","refund.updated","refund.failed","charge.refunded"]),$f=_e.strictObject({provider:_e.literal("stripe"),accountId:_e.string().regex(/^acct_[A-Za-z0-9]+$/),eventId:_e.string().regex(/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,199}$/),type:Vf,occurredAt:_e.number().int().positive().max(Number.MAX_SAFE_INTEGER),data:_e.record(_e.string(),_e.unknown()).and(_e.object({id:_e.string().min(1).max(255),object:_e.enum(["checkout.session","subscription","invoice","discount","refund","charge"]),livemode:_e.boolean()}))}),Op=_e.union([$f,Na]),jp=_e.strictObject({id:_e.uuid(),eventId:_e.string().min(1).max(200),source:_e.literal("merchant"),providerVerified:_e.literal(!1),outcome:_e.string().min(1).max(100)});import{z as Ue}from"zod";var wp={customerId:Ue.uuid(),eventId:Ue.string().trim().min(1).max(200),grantId:Ue.uuid(),occurredAt:Ue.iso.datetime({offset:!0})},_p=Ue.strictObject({...wp,productVersionId:Ue.uuid(),subscriptionId:Ue.string().trim().min(1).max(255)}),Pp=Ue.strictObject({...wp,merchandiseId:Ue.uuid()}),Cp=Ue.union([_p,Pp]),Ap={id:Ue.uuid(),couponId:Ue.uuid(),status:Ue.literal("redeemed"),source:Ue.literal("merchant"),recordedAt:Ue.iso.datetime({offset:!0})},kp=Ue.union([_p.extend(Ap),Pp.extend(Ap)]);import{z as B}from"zod";var Rp=fc,Gf=Rp.extend({invoice_id:Rp.shape.invoice_id.meta({description:"The Indiana invoice ID to void and replace.",example:"9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"})}),Ho=B.strictObject({name:B.string().trim().min(1).max(255),memo:B.string().max(1e4).nullable().optional(),footer:B.string().max(1e4).nullable().optional(),net_terms_days:B.number().int().positive().nullable().optional()}),Kf=Ho.extend({id:B.string().min(1).max(255),created_at:B.number().nullable()}),Ep=B.strictObject({items:B.array(Kf).max(50),nextCursor:B.uuid().nullable()}),p0=B.discriminatedUnion("action",[B.strictObject({action:B.literal("create"),requestId:B.uuid(),values:Ho}),B.strictObject({action:B.literal("update"),id:B.string().min(1).max(255),values:Ho}),B.strictObject({action:B.literal("delete"),id:B.string().min(1).max(255)})]),Mp=B.discriminatedUnion("action",[B.strictObject({action:B.literal("create"),requestId:B.uuid(),params:pn}),B.strictObject({action:B.enum(["finalize","send","pay","void"]),requestId:B.uuid(),invoiceId:B.uuid()}),B.strictObject({action:B.literal("reissue"),requestId:B.uuid(),invoiceId:B.uuid(),params:Gf})]),Jo=B.strictObject({id:B.uuid(),customerId:B.uuid(),providerInvoiceId:B.string().nullable(),status:B.enum(["draft","open","paid","void","uncollectible"]),currency:B.string(),totalMinor:B.string().regex(/^-?\d+$/),paidMinor:B.string().regex(/^\d+$/),refundedMinor:B.string().regex(/^\d+$/),hostedInvoiceUrl:B.url().nullable(),createdAt:B.number(),collectionMethod:B.enum(["send_invoice","charge_automatically"]).nullable()}),Tp=Jo.extend({lines:B.array(B.strictObject({id:B.uuid(),description:B.string(),amountMinor:B.string().regex(/^-?\d+$/),netAmountMinor:B.string().regex(/^-?\d+$/),quantity:B.number().nullable(),periodStart:B.number().nullable(),periodEnd:B.number().nullable()})).max(1e3)}),vn=B.strictObject({taskId:B.uuid(),status:B.enum(["ready","running","done","dead"]),invoice:Jo.nullable(),errorCode:B.string().nullable()}),Dp=B.strictObject({items:B.array(Jo).max(50),nextCursor:B.uuid().nullable(),operations:B.array(vn).max(50),operationsLimited:B.boolean()});var Lf=c.enum(["customers:read","customers:write","entitlements:read","content:read","sessions:create","funnels:run","offers:resolve","offers:grant","billing:read","billing:write","credits:read","credits:consume","credits:manage","features:read","events:write","messaging:write","code-references:read","code-references:write","app-manifests:write"]),Bp={scope:le,permissions:c.array(Lf),expiresAt:c.iso.datetime().nullable()},nO=c.discriminatedUnion("kind",[c.object({...Bp,kind:c.literal("server"),keyId:c.string().min(1)}),c.object({...Bp,kind:c.literal("customer"),customerId:c.string().min(1),identityKind:c.enum(["identified","guest"]),expiresAt:c.iso.datetime()})]),O=c.object({requestId:c.uuid(),scope:le}).strict(),Zf=ju.safeExtend({fingerprint:Xr.optional()}).strict(),Hf=O.extend({customer:yn,created:c.boolean()});function zp(){return O.extend({offer:Tn.nullable(),reason:xs.nullable()})}var I={sendMessage:{method:"POST",path:"messaging/send",permission:"messaging:write",audience:"server",request:tc,response:O.extend({message:c.object({messageId:c.uuid(),channel:Nn,acceptedAt:c.iso.datetime({offset:!0}),status:c.enum(["accepted","sending","completed","canceled"]),replayed:c.boolean()})})},readMessage:{method:"POST",path:"messaging/read",permission:"messaging:write",audience:"server",request:c.strictObject({messageId:c.uuid()}),response:O.extend({message:c.object({id:c.uuid(),channel:Nn,status:c.enum(["accepted","sending","completed","canceled"]),deliveries:c.array(c.object({id:c.uuid(),status:rc,attempts:c.number().int().nonnegative(),receipts:c.array(c.object({kind:ic,occurredAt:c.iso.datetime({offset:!0}).nullable()}))}))})})},bindPushInstallation:{method:"POST",path:"push/installations/bind",permission:"messaging:write",audience:"customer",request:as,response:O.extend({installation:jr})},readPushInstallation:{method:"POST",path:"push/installations/read",permission:"messaging:write",audience:"customer",request:ss,response:O.extend({installation:jr})},updatePushAddress:{method:"POST",path:"push/installations/address",permission:"messaging:write",audience:"customer",request:Or,response:O.extend({installation:jr})},readMessagingPreference:{method:"POST",path:"messaging/preferences/read",permission:"messaging:write",audience:"customer",request:c.strictObject({channel:Nn}),response:O.extend({preference:Ei})},setMessagingPreference:{method:"POST",path:"messaging/preferences/set",permission:"messaging:write",audience:"customer",request:nc,response:O.extend({preference:Ei})},listInvoiceTemplates:{method:"POST",path:"invoices/templates",permission:"billing:read",audience:"server",request:c.strictObject({cursor:c.uuid().optional()}),response:O.extend({templates:Ep})},previewInvoice:{method:"POST",path:"invoices/preview",permission:"billing:write",audience:"server",request:c.strictObject({customerId:c.uuid(),params:pn}),response:O.extend({preview:Zi})},createInvoice:{method:"POST",path:"invoices/create",permission:"billing:write",audience:"server",request:c.strictObject({customerId:c.uuid(),requestId:c.uuid(),params:pn}).refine(e=>e.params.preview!==!0,"Use previewInvoice for a side-effect-free preview"),response:O.extend({operation:vn})},manageInvoice:{method:"POST",path:"invoices/manage",permission:"billing:write",audience:"server",request:c.strictObject({customerId:c.uuid(),command:Mp}).refine(e=>e.command.action!=="create"||e.command.params.preview!==!0,"Use previewInvoice for a side-effect-free preview"),response:O.extend({operation:vn})},readInvoiceOperation:{method:"POST",path:"invoices/operations/read",permission:"billing:read",audience:"server",request:c.strictObject({customerId:c.uuid(),taskId:c.uuid()}),response:O.extend({operation:vn})},listInvoices:{method:"POST",path:"invoices/list",permission:"billing:read",audience:"server",request:c.strictObject({customerId:c.uuid(),cursor:c.uuid().optional()}),response:O.extend({invoices:Dp})},getInvoice:{method:"POST",path:"invoices/read",permission:"billing:read",audience:"server",request:c.strictObject({customerId:c.uuid(),invoiceId:c.uuid()}),response:O.extend({invoice:Tp})},getCodeReferenceConfig:{method:"POST",path:"code-references/config",permission:"code-references:read",audience:"server",request:vp,response:O.extend({config:Ip})},submitCodeReferences:{method:"POST",path:"code-references",permission:"code-references:write",audience:"server",request:Lo,response:O.extend({receipt:Zo})},getFeatures:{method:"GET",path:"features",permission:"features:read",audience:"mixed",request:c.strictObject({}),response:O.extend({payload:so})},evaluateFeatures:{method:"POST",path:"features/evaluate",permission:"features:read",audience:"mixed",request:ru,response:O.merge(iu)},trackEvents:{method:"POST",path:"events",permission:"events:write",audience:"mixed",request:ou,response:O.merge(au)},readBalanceSource:{method:"POST",path:"balances/source/read",permission:"credits:read",audience:"server",request:c.strictObject({customerId:c.uuid(),sourceId:c.uuid()}),response:O.extend({balance:Lu})},adjustBalance:{method:"POST",path:"balances/source/adjust",permission:"credits:manage",audience:"server",request:c.strictObject({customerId:c.uuid(),command:Ku}),response:O.extend({balance:No})},readAiPricing:{method:"POST",path:"ai/pricing/read",permission:"credits:read",audience:"server",request:c.strictObject({internal_feature_id:c.uuid(),customerId:c.uuid().optional(),entityId:c.uuid().optional()}).refine(e=>!e.entityId||!!e.customerId,"Entity pricing requires a customer"),response:O.extend({internal_feature_id:c.uuid(),config:Di,model_markups:Pr})},readUsage:{method:"POST",path:"usage/read",permission:"credits:read",audience:"server",request:c.strictObject({customerId:c.uuid(),query:xa}),response:O.extend({usage:mi})},setUsage:{method:"POST",path:"usage/set",permission:"credits:manage",audience:"server",request:c.strictObject({customerId:c.uuid(),command:Sa}),response:O.extend({usage:mi})},manageBalanceGrant:{method:"POST",path:"balances/grants/manage",permission:"credits:manage",audience:"server",request:c.strictObject({customerId:c.uuid(),command:Ks}),response:O.extend({grant:Ui})},listBalanceGrants:{method:"POST",path:"balances/grants/list",permission:"credits:read",audience:"server",request:Ls,response:O.extend({grants:Zs})},restoreNativePurchase:{method:"POST",path:"subscriptions/native/restore",permission:"billing:write",audience:"mixed",request:c.union(Zc.options.map(e=>e.extend({customerId:c.uuid().optional(),customerToken:c.string().regex(ut).optional()}))),response:O.extend({operation:Hc})},setupPayment:{method:"POST",path:"billing/setup-payment",permission:"billing:write",audience:"mixed",request:Bc.extend({customerId:c.uuid().optional()}),response:O.extend({setup:Xi})},readPaymentSetup:{method:"POST",path:"billing/payment-setup",permission:"billing:read",audience:"mixed",request:zc.extend({customerId:c.uuid().optional()}),response:O.extend({setup:Xi})},previewSubscriptionBatch:{method:"POST",path:"subscriptions/batches/preview",permission:"billing:write",audience:"server",request:Mc.safeExtend({customerId:c.uuid()}),response:O.extend({batch:Vn})},confirmSubscriptionBatch:{method:"POST",path:"subscriptions/batches/confirm",permission:"billing:write",audience:"server",request:qr.extend({customerId:c.uuid()}),response:O.extend({batch:Vn})},readSubscriptionBatch:{method:"POST",path:"subscriptions/batches/read",permission:"billing:read",audience:"server",request:qr.extend({customerId:c.uuid()}),response:O.extend({batch:Vn})},abandonSubscriptionBatch:{method:"POST",path:"subscriptions/batches/abandon",permission:"billing:write",audience:"server",request:qr.extend({customerId:c.uuid()}),response:O.extend({batch:Vn})},manageSubscriptionTrial:{method:"POST",path:"subscriptions/trials/manage",permission:"billing:write",audience:"server",request:c.discriminatedUnion("action",[Fr.options[0].extend({customerId:c.uuid()}),Fr.options[1].extend({customerId:c.uuid()}),Fr.options[2].extend({customerId:c.uuid()})]),response:O.extend({trial:Qi})},readSubscriptionTrial:{method:"POST",path:"subscriptions/trials/read",permission:"billing:read",audience:"server",request:Tc.extend({customerId:c.uuid()}),response:O.extend({trial:Qi})},listSubscriptions:{method:"POST",path:"subscriptions/list",permission:"billing:read",audience:"server",request:Vr,response:O.extend({subscriptions:Gc})},listPurchases:{method:"POST",path:"purchases/list",permission:"billing:read",audience:"server",request:Vr,response:O.extend({purchases:Kc})},listSubscriptionConflicts:{method:"POST",path:"subscriptions/conflicts/list",permission:"billing:read",audience:"server",request:Uc,response:O.extend({conflicts:Lc})},retrySubscriptionConflict:{method:"POST",path:"subscriptions/conflicts/retry",permission:"billing:write",audience:"server",request:Vc,response:O.extend({resolution:$c})},verifySubscriptions:{method:"POST",path:"subscriptions/verify",permission:"billing:read",audience:"server",request:Fc,response:O.extend({verification:Nc})},previewAttach:{method:"POST",path:"subscriptions/preview-attach",permission:"billing:read",audience:"mixed",request:Ac.safeExtend({...cn,customerId:c.uuid().optional()}),response:O.extend({quote:ln})},recordBillingEvent:{method:"POST",path:"billing/events/record",permission:"billing:write",audience:"server",request:Op,response:O.extend({record:jp})},attach:{method:"POST",path:"subscriptions/attach",permission:"billing:write",audience:"mixed",request:Ft.extend({customerId:c.uuid().optional(),intent:c.enum(["confirm","cancel"]).optional()}),response:O.extend({operation:mn})},readSubscriptionOperation:{method:"POST",path:"subscriptions/operations/read",permission:"billing:read",audience:"mixed",request:Ft.extend({customerId:c.uuid().optional()}),response:O.extend({operation:mn})},previewUpdate:{method:"POST",path:"subscriptions/preview-update",permission:"billing:read",audience:"mixed",request:Pc.safeExtend({customerId:c.uuid().optional()}),response:O.extend({quote:kc})},update:{method:"POST",path:"subscriptions/update",permission:"billing:write",audience:"mixed",request:Ft.extend({customerId:c.uuid().optional(),intent:c.enum(["confirm","cancel"]).optional()}),response:O.extend({operation:Hi})},readSubscriptionUpdate:{method:"POST",path:"subscriptions/updates/read",permission:"billing:read",audience:"mixed",request:Ft.extend({customerId:c.uuid().optional()}),response:O.extend({operation:Hi})},previewRefund:{method:"POST",path:"subscriptions/refunds/preview",permission:"billing:read",audience:"server",request:Rc.safeExtend({customerId:c.uuid()}),response:O.extend({quote:Ji})},refund:{method:"POST",path:"subscriptions/refunds/confirm",permission:"billing:write",audience:"server",request:Ft.extend({customerId:c.uuid()}),response:O.extend({operation:zr})},readRefund:{method:"POST",path:"subscriptions/refunds/read",permission:"billing:read",audience:"server",request:Ft.extend({customerId:c.uuid()}),response:O.extend({operation:zr})},readBillingControls:{method:"POST",path:"billing/controls/read",permission:"billing:read",audience:"customer",request:Ms,response:O.extend({controls:Ni})},prepareBillingAuthorization:{method:"POST",path:"billing/authorizations/prepare",permission:"billing:write",audience:"customer",request:ws,response:O.extend({prepared:Ps})},confirmBillingAuthorization:{method:"POST",path:"billing/authorizations/confirm",permission:"billing:write",audience:"customer",request:Cs,response:O.extend({authorization:kr})},setBillingCoupons:{method:"POST",path:"billing/coupons",permission:"billing:write",audience:"customer",request:qs,response:O.extend({coupons:Fs})},revokeBillingAuthorization:{method:"POST",path:"billing/authorizations/revoke",permission:"billing:write",audience:"customer",request:ks,response:O.extend({authorization:kr})},listBillingInvoices:{method:"POST",path:"billing/invoices/read",permission:"billing:read",audience:"customer",request:Bs,response:O.extend({invoices:zs})},prepareBillingAdjustment:{method:"POST",path:"billing/invoices/prepare-adjustment",permission:"billing:write",audience:"server",request:Ds.extend({customerId:c.uuid()}),response:O.extend({operation:vn})},confirmBillingAdjustment:{method:"POST",path:"billing/invoices/confirm-adjustment",permission:"billing:write",audience:"customer",request:Ts,response:O.extend({invoice:zn})},manageBillingLimits:{method:"POST",path:"billing/controls/manage",permission:"billing:write",audience:"server",request:c.object({customerId:c.uuid(),command:Es}).strict(),response:O.extend({controls:Ni})},manageUsageEntity:{method:"POST",path:"usage/entities",permission:"credits:manage",audience:"server",request:c.object({customerId:c.uuid(),command:Zu}).strict(),response:O.extend({entity:Hu})},readUsageAnalytics:{method:"POST",path:"usage/analytics",permission:"credits:read",audience:"server",request:c.strictObject({customerId:c.uuid().nullable(),query:ep}),response:O.extend({analytics:tp})},readCreditAnalytics:{method:"POST",path:"credits/analytics",permission:"credits:read",audience:"server",request:c.object({customerId:c.uuid().nullable(),query:Zt}).strict(),response:O.extend({analytics:Xu})},submitUsageBatch:{method:"POST",path:"usage/batch",permission:"credits:consume",audience:"server",request:np,response:O.extend({batchId:c.uuid()})},readUsageBatch:{method:"POST",path:"usage/batch/read",permission:"credits:read",audience:"server",request:rp,response:O.extend({batch:ip})},checkEntitlement:{method:"POST",path:"entitlements/check",permission:"entitlements:read",audience:"mixed",request:wa.extend({customerId:c.string().min(1).optional()}),response:O.extend({check:Pn})},resolveContent:{method:"POST",path:"content/resolve",permission:"content:read",audience:"mixed",request:c.strictObject({kind:It,selector:c.discriminatedUnion("type",[c.strictObject({type:c.literal("resource"),id:c.uuid()}),c.strictObject({type:c.literal("version"),id:c.uuid()})]),customerId:c.string().min(1).optional()}),response:O.extend({content:Ci})},resolvePaywall:{method:"POST",path:"paywalls/resolve",permission:"entitlements:read",audience:"mixed",request:$u,response:O.extend({paywall:Qn})},resolveOffering:{method:"POST",path:"offerings/resolve",permission:"entitlements:read",audience:"mixed",request:c.strictObject({processContext:Mr.optional(),...cn,selector:Xc,customerId:c.string().min(1).optional(),commerce:cr,requirement:Wt.optional()}),response:O.extend({offering:Yc,candidates:c.array(_a).max(20),availability:c.array(c.strictObject({productVersionId:c.uuid(),available:c.boolean(),reason:c.enum(["platform_binding_missing","commercial_runtime_pending","commerce_not_configured","currency_mismatch","product_unavailable","already_attached","attach_in_progress","already_scheduled","subscription_change_required","purchase_conflict"]).nullable()})).max(20),check:Pn.nullable()})},readHoldings:{method:"POST",path:"customer-holdings",permission:"entitlements:read",audience:"mixed",request:c.object({customerId:c.uuid().optional(),entityId:c.uuid().optional()}).strict(),response:O.extend({holdings:va})},readLedger:{method:"POST",path:"customer-ledger",permission:"credits:read",audience:"mixed",request:c.object({customerId:c.uuid().optional(),query:Ia}).strict(),response:O.extend({ledger:Oa})},readBillingInvoice:{method:"POST",path:"billing/invoices/detail",permission:"billing:read",audience:"mixed",request:Hs.extend({customerId:c.uuid().optional()}),response:O.extend({detail:Js})},readCreditStatement:{method:"POST",path:"credit-statements/read",permission:"credits:read",audience:"mixed",request:Vi.safeExtend({customerId:c.uuid().optional()}),response:O.extend({statement:Ws})},quoteBalance:{method:"POST",path:"balances/quote",permission:"credits:read",audience:"mixed",request:c.object({customerId:c.uuid().optional(),command:wn.options[0]}).strict(),response:O.extend({quote:ya})},trackUsage:{method:"POST",path:"usage/track",permission:"credits:consume",audience:"server",request:c.strictObject({customerId:c.uuid(),command:c.union([c.strictObject({eventName:c.string().min(1),quantity:be.optional(),properties:dt.optional(),entityId:c.uuid().optional(),idempotencyKey:c.string().min(1).max(120)}),c.strictObject({internal_feature_id:c.uuid(),quantity:be.optional(),properties:dt.optional(),entityId:c.uuid().optional(),idempotencyKey:c.string().min(1).max(120)})])}),response:O.extend({receipts:c.array(_n).min(1)})},mutateBalance:{method:"POST",path:"balances/execute",permission:"credits:consume",audience:"server",request:c.object({customerId:c.uuid(),command:wn.refine(e=>e.operation!=="quote","Use the quote endpoint for a read")}).strict(),response:O.extend({receipt:_n})},redeemReward:{method:"POST",path:"rewards/redeem",permission:"offers:resolve",audience:"customer",request:dp,response:O.extend({redemption:mp})},createReferralCode:{method:"POST",path:"rewards/referral-code",permission:"offers:resolve",audience:"customer",request:hp,response:O.extend({referralCode:bp})},claimRewardProduct:{method:"POST",path:"rewards/product/claim",permission:"offers:resolve",audience:"customer",request:fp,response:O.extend({checkout:gp})},readSeats:{method:"POST",path:"seats/list",permission:"customers:read",audience:"server",request:Xs,response:O.extend({seats:Ki})},manageSeat:{method:"POST",path:"seats/manage",permission:"billing:write",audience:"server",request:Ys,response:O.extend({seats:Ki})},createCustomer:{method:"POST",path:"customers",permission:"customers:write",audience:"server",request:Zf,response:Hf},getCustomer:{method:"POST",path:"customers/get",permission:"customers:read",audience:"server",request:jo,response:O.extend({customer:yn})},listCustomers:{method:"POST",path:"customers/list",permission:"customers:read",audience:"server",request:_u,response:O.extend(Pu.shape)},updateCustomer:{method:"POST",path:"customers/update",permission:"customers:write",audience:"server",request:wu,response:O.extend(Au.shape)},createSession:{method:"POST",path:"customer-sessions",permission:"sessions:create",audience:"server",request:c.object({customerId:c.uuid()}).strict(),response:O.extend(en.shape)},refreshSession:{method:"POST",path:"customer-sessions/refresh",permission:"sessions:create",audience:"refresh",request:c.strictObject({}),response:O.extend(en.shape)},revokeSessions:{method:"POST",path:"customer-sessions/revoke",permission:"sessions:create",audience:"server",request:c.strictObject({customerId:c.uuid(),sessionId:c.uuid().optional()}),response:O.extend({revoked:c.number().int().nonnegative()})},createGuestCustomer:{method:"POST",path:"customers/guests",permission:"sessions:create",audience:"server",request:c.strictObject({guestToken:c.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/),fingerprint:Xr.optional()}),response:O.extend({customerId:c.uuid(),guestToken:c.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/),guestExpiresAt:c.iso.datetime()})},resumeGuestSession:{method:"POST",path:"customers/guests/session",permission:"sessions:create",audience:"server",request:c.strictObject({guestToken:c.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/)}),response:O.extend(en.shape)},claimGuestCustomer:{method:"POST",path:"customers/guests/claim",permission:"customers:write",audience:"server",request:c.strictObject({guestToken:c.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/),externalUserId:c.string().trim().min(1).max(255).refine(e=>!e.startsWith("gg_guest_")),requestId:c.uuid()}),response:O.extend({customer:yn,switched:c.boolean(),replayed:c.boolean()})},redeemCoupon:{method:"POST",path:"offers/redeem",permission:"offers:resolve",audience:"customer",request:c.strictObject({code:c.string().regex(/^[A-Z0-9][A-Z0-9_-]{2,31}$/),requestId:c.uuid()}),response:zp()},listOffers:{method:"GET",path:"offers",permission:"offers:resolve",audience:"customer",request:c.object({}).strict(),response:O.extend({offers:c.array(Tn)})},grantOffer:{method:"POST",path:"offers/grant",permission:"offers:grant",audience:"mixed",customerPermission:"offers:resolve",request:c.object({customerId:c.string().min(1).max(255).optional(),couponId:c.uuid(),...cn,requestId:c.uuid(),couponContentDigest:c.string().regex(/^[a-f0-9]{64}$/).optional()}).strict(),response:zp()},recordCouponRedemption:{method:"POST",path:"offers/redemptions",permission:"billing:write",audience:"server",request:Cp,response:O.extend({receipt:kp})}},rO={recordBillingEvent:I.recordBillingEvent,sendMessage:I.sendMessage,readMessage:I.readMessage,bindPushInstallation:I.bindPushInstallation,readPushInstallation:I.readPushInstallation,updatePushAddress:I.updatePushAddress,readMessagingPreference:I.readMessagingPreference,setMessagingPreference:I.setMessagingPreference,listInvoiceTemplates:I.listInvoiceTemplates,previewInvoice:I.previewInvoice,createInvoice:I.createInvoice,manageInvoice:I.manageInvoice,readInvoiceOperation:I.readInvoiceOperation,listInvoices:I.listInvoices,getInvoice:I.getInvoice,getCodeReferenceConfig:I.getCodeReferenceConfig,submitCodeReferences:I.submitCodeReferences,getFeatures:I.getFeatures,evaluateFeatures:I.evaluateFeatures,trackEvents:I.trackEvents,setupPayment:I.setupPayment,readPaymentSetup:I.readPaymentSetup,previewSubscriptionBatch:I.previewSubscriptionBatch,confirmSubscriptionBatch:I.confirmSubscriptionBatch,readSubscriptionBatch:I.readSubscriptionBatch,abandonSubscriptionBatch:I.abandonSubscriptionBatch,manageSubscriptionTrial:I.manageSubscriptionTrial,readSubscriptionTrial:I.readSubscriptionTrial,listSubscriptions:I.listSubscriptions,listPurchases:I.listPurchases,listSubscriptionConflicts:I.listSubscriptionConflicts,retrySubscriptionConflict:I.retrySubscriptionConflict,readAiPricing:I.readAiPricing,readUsage:I.readUsage,setUsage:I.setUsage,previewRefund:I.previewRefund,refund:I.refund,readRefund:I.readRefund,previewUpdate:I.previewUpdate,update:I.update,readSubscriptionUpdate:I.readSubscriptionUpdate,restoreNativePurchase:I.restoreNativePurchase,verifySubscriptions:I.verifySubscriptions,previewAttach:I.previewAttach,attach:I.attach,readSubscriptionOperation:I.readSubscriptionOperation,manageBalanceGrant:I.manageBalanceGrant,readBalanceSource:I.readBalanceSource,adjustBalance:I.adjustBalance,listBalanceGrants:I.listBalanceGrants,readBillingControls:I.readBillingControls,prepareBillingAuthorization:I.prepareBillingAuthorization,confirmBillingAuthorization:I.confirmBillingAuthorization,setBillingCoupons:I.setBillingCoupons,revokeBillingAuthorization:I.revokeBillingAuthorization,listBillingInvoices:I.listBillingInvoices,confirmBillingAdjustment:I.confirmBillingAdjustment,prepareBillingAdjustment:I.prepareBillingAdjustment,manageBillingLimits:I.manageBillingLimits,createCustomer:I.createCustomer,getCustomer:I.getCustomer,listCustomers:I.listCustomers,updateCustomer:I.updateCustomer,createSession:I.createSession,refreshSession:I.refreshSession,revokeSessions:I.revokeSessions,createGuestCustomer:I.createGuestCustomer,resumeGuestSession:I.resumeGuestSession,claimGuestCustomer:I.claimGuestCustomer,checkEntitlement:I.checkEntitlement,resolveOffering:I.resolveOffering,resolveContent:I.resolveContent,resolvePaywall:I.resolvePaywall,readHoldings:I.readHoldings,readLedger:I.readLedger,readBillingInvoice:I.readBillingInvoice,readCreditStatement:I.readCreditStatement,quoteBalance:I.quoteBalance,trackUsage:I.trackUsage,mutateBalance:I.mutateBalance,manageUsageEntity:I.manageUsageEntity,readUsageAnalytics:I.readUsageAnalytics,readCreditAnalytics:I.readCreditAnalytics,submitUsageBatch:I.submitUsageBatch,readUsageBatch:I.readUsageBatch,listOffers:I.listOffers,grantOffer:I.grantOffer,recordCouponRedemption:I.recordCouponRedemption,redeemCoupon:I.redeemCoupon,redeemReward:I.redeemReward,createReferralCode:I.createReferralCode,claimRewardProduct:I.claimRewardProduct,readSeats:I.readSeats,manageSeat:I.manageSeat};import{z as Wo}from"zod";var er=class extends Error{constructor(t){super(t),this.name="FunnelCalculationError"}};function Qo(e,t,n){let r={},o,a,l,p="next",d;switch(e.type){case"entry":d=e.next;break;case"condition":{let v=e.cases.findIndex(h=>li(t.attributes??{},h.condition,t.savedGroups??{}));p=v<0?"default":`case:${v}`,d=v<0?e.default:e.cases[v].target;break}case"feature":if(!Object.hasOwn(t.features??{},e.featureKey))throw new er("Required GB Feature is unavailable");o=An(e.featureKey,t),l=o.value,Object.assign(r,Tt(e,{value:l})),d=e.next;break;case"split":{let v=n[e.experimentId];if(!v)throw new er("Required GB Experiment is unavailable");if(a=fa(v,t),l=a.value,p=a.inExperiment&&!a.passthrough&&typeof l=="string"?l:"notParticipating",d=p==="notParticipating"?e.notParticipating:e.routes[p],!d)throw new er("Experiment Variation has no published route");break}case"offering":{let v=e.configuration.source==="fixed"?e.configuration.versionId:An(e.configuration.featureKey,t).value;l={type:"offering_version",id:Wo.uuid().parse(v)},Object.assign(r,Tt(e,{value:l})),d=e.next;break}case"coupon":case"coupons":l=e.type==="coupons"?e.couponIds.map(v=>({type:"reward",id:v})):{type:"reward",id:e.couponId},Object.assign(r,Tt(e,{value:l})),d=e.next;break}return{port:p,target:d,projections:r,...l===void 0?{}:{value:l},...o?{feature:o}:{},...a?{experiment:a}:{}}}function lO(e,t,n){Wo.uuid().parse(e),Wo.number().int().nonnegative().parse(t);let r=or(ar(new TextEncoder().encode(JSON.stringify([e,t,n])))).slice(0,32);return`${r.slice(0,8)}-${r.slice(8,12)}-5${r.slice(13,16)}-a${r.slice(17,20)}-${r.slice(20)}`}import{z as _}from"zod";var kt=_.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Jf=_.enum(["running","waiting","completed","closed","ineligible","failed"]),Xo=_.discriminatedUnion("type",[Io,_.strictObject({type:_.literal("wait"),receiptId:_.uuid(),kind:_.enum(["timer","event","operation"]),deadline:_.iso.datetime({offset:!0}).nullable(),eventName:kt.optional()}),_.strictObject({type:_.literal("open_url"),receiptId:_.uuid(),url:wo,openIn:_o}),_.strictObject({type:_.literal("event"),receiptId:_.uuid(),event:kt})]),Wf=_.strictObject({type:_.literal("funnel"),id:_.uuid(),versionId:_.uuid()}),Qf={id:kt,presentation:ft,outputs:_.array(kt).max(250),inputs:gi,values:_.record(_.string(),ee).optional(),offeringKey:Ae.optional(),capabilities:Qt,customerData:Ma,dataCursors:_.record(kt,pr.nullable())},Xf=_.strictObject({...Qf,content:_.strictObject({type:_.literal("document"),document:Ke})}),tr=_.strictObject({id:_.uuid(),source:Wf,revision:_.number().int().nonnegative(),visit:_.number().int().nonnegative(),nodeId:kt,nodeType:_.enum(["entry","screen","condition","split","feature","action","external_page","wait","end","offering","coupon","coupons","output"]),status:Jf,stopped:_.boolean(),canBack:_.boolean(),authenticated:_.boolean(),locale:_.string().min(1).max(35),answers:Rt,parameters:ct,variables:_.record(_.string(),ee),output:ee.nullable(),screen:Xf.nullable(),paywall:_.strictObject({receiptId:_.uuid(),resolution:_.union([Wn,Qn]),quote:ln.nullable(),operation:mn.nullable(),purchaseRequestId:_.uuid().nullable(),selectionGeneration:_.number().int().nonnegative().optional(),canReselect:_.boolean().optional()}).nullable(),instruction:Xo.nullable(),pendingRequest:_.strictObject({requestId:_.uuid(),authenticationRequired:_.boolean()}).nullable(),runExpiresAt:_.iso.datetime({offset:!0}),credentialExpiresAt:_.iso.datetime({offset:!0}).nullable()}),In=_.strictObject({scope:le,run:tr,settlement:_.strictObject({requestId:_.uuid(),state:_.enum(["pending","unknown","settled"]),operationId:_.uuid().nullable(),receiptId:_.uuid().nullable().optional()}).optional(),purchase:_.strictObject({receiptId:_.uuid(),quote:ln.nullable(),operation:mn.nullable(),canReselect:_.boolean().optional()}).optional(),review:_.strictObject({activeOperationId:_.uuid().nullable(),pages:_.array(_.strictObject({receiptId:_.uuid(),nodeId:kt,visit:_.number().int().nonnegative()})).max(100),page:_.strictObject({receiptId:_.uuid(),nodeId:kt,visit:_.number().int().nonnegative(),document:Ke,answers:Rt,inputs:gi,values:_.record(_.string(),ee).optional()}).nullable(),coupons:_.array(_.strictObject({grantId:_.uuid(),status:_.enum(["issued","reserved","redeemed","expired","revoked","unknown"]),expiresAt:_.string().nullable()})).max(100),purchases:_.array(_.strictObject({receiptId:_.uuid(),operationId:_.uuid(),status:_.enum(["pending","complete","cancelled","failed","unknown"])})).max(100)}).optional(),runToken:_.string().regex(/^gg_fr_[A-Za-z0-9_-]{43}$/).optional(),customerId:_.uuid().optional()}),qp=In.extend({run:tr.extend({paywall:tr.shape.paywall.unwrap().extend({resolution:Qn}).nullable()})});var _O="X-Indiana-Server-Key";import{z as q}from"zod";import{z as G}from"zod";import{z as Pe}from"zod";var Yf=Pe.strictObject({selector:Pe.string().min(1).max(2048),action:Pe.enum(["set","append","remove"]),attribute:Pe.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:Pe.string().max(5e4).optional(),parentSelector:Pe.string().max(2048).optional(),insertBeforeSelector:Pe.string().max(2048).optional()}),eg=Pe.strictObject({variation:Pe.string().min(1).max(128),description:Pe.string().max(2e3).default(""),css:Pe.string().max(1e5).default(""),js:Pe.string().max(1e5).default(""),domMutations:Pe.array(Yf).max(200).default([]),iam:mu.optional(),renderGuard:Kr.optional()}),Yo=eg.omit({variation:!0,description:!0,iam:!0}),tg=hn.omit({variations:!0,active:!0}).extend({changeId:Pe.string().regex(/^[a-f0-9]{64}$/),variations:Pe.tuple([Yo,Yo]).rest(Yo).refine(e=>e.length<=20)}),Fp=Pe.strictObject({trackExposures:Pe.boolean(),environmentId:Pe.uuid(),generation:Pe.string().regex(/^[a-f0-9]{64}$/),experiments:Pe.array(tg).max(100),savedGroups:Gn});var nr=G.string().regex(/^[a-f0-9]{64}$/),FO=G.strictObject({iam:nr,executionContracts:G.union([G.tuple([G.literal("funnel-run/1")]),G.tuple([G.literal("funnel-process/1")])]).default(["funnel-run/1"])}),ng=G.strictObject({release:nr,render:Kr,button:G.strictObject({selector:G.string().min(1).max(512),elementKey:G.string().min(1).max(256),tag:G.enum(["button","a","input"])}).nullable()}),NO=G.strictObject({scope:le.extend({environmentId:G.uuid()}),release:nr,validatedAt:G.iso.datetime({offset:!0}),validUntil:G.iso.datetime({offset:!0}),entries:G.array(G.strictObject({id:G.uuid(),funnelId:G.uuid(),versionId:G.uuid(),event:G.enum(["screen_enter","button_click"]),target:ng})).max(4e3)}),Np=G.strictObject({operation:G.literal("entry_start"),funnelId:G.uuid(),versionId:G.uuid(),entryId:G.uuid(),release:nr,requestId:G.uuid(),locale:G.string().min(1).max(35).default("en")}),Up=G.strictObject({scope:le,suppressed:G.literal(!0),reason:G.enum(["frequency","in_progress"]),retryAt:G.iso.datetime({offset:!0}).nullable()}),UO=G.strictObject({experimentId:G.uuid(),splitNodeId:G.string().min(1).max(128)}),rg=G.strictObject({experimentId:G.uuid(),experimentKey:G.string().min(1).max(128),variationKey:G.string().min(1).max(128),inExperiment:G.boolean(),generation:G.string().min(1).max(256)}),Vp=G.strictObject({operation:G.literal("page_experiments"),release:nr,usedReceiptIds:G.array(G.uuid()).max(20).default([]),customerToken:G.string().regex(ut).optional()}),VO=G.strictObject({scope:le,runId:G.uuid(),assignments:G.array(rg.extend({receiptId:G.uuid()})).max(100),payload:Fp});var st=q.literal(uo),ig=q.string().regex(/^gg_fr_[A-Za-z0-9_-]{43}$/),ea=q.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/),$p=q.discriminatedUnion("type",[q.strictObject({type:q.literal("guest"),guestToken:ea}),q.strictObject({type:q.literal("customer"),customer:yt,customerData:_t.optional()})]),ta=q.strictObject({id:q.uuid(),runId:q.uuid(),customerId:q.uuid(),requestId:q.uuid(),acceptedAt:q.iso.datetime({offset:!0})}),og=q.strictObject({participantId:q.uuid(),startedAs:q.enum(["guest","identified"]),binding:ta.omit({runId:!0,requestId:!0}).nullable()}),ag=q.union([Xo,q.strictObject({type:q.literal("authentication_required"),reason:q.enum(["customer_required","customer_experiment_required"]),nodeId:q.string().min(1).max(64),visit:q.number().int().nonnegative()})]),sg=tr.omit({authenticated:!0}).extend({identity:og,instruction:ag.nullable()}),cg=q.discriminatedUnion("operation",[et.options[2].omit({customerToken:!0}),et.options[3].omit({customerToken:!0}),et.options[4].omit({customerToken:!0}),et.options[5].omit({customerToken:!0}),et.options[6].omit({customerToken:!0}),et.options[7].omit({customerToken:!0})]),oi={contract:st,customerToken:q.string().regex(ut)},Gp={contract:st,requestId:q.uuid(),runToken:ig,externalUserId:yt.options[1].shape.value},Kp=q.discriminatedUnion("operation",[q.strictObject({contract:st,operation:q.literal("describe")}),q.strictObject({contract:st,operation:q.literal("start"),source:$p,funnelId:et.options[0].shape.funnelId,requestId:q.uuid(),locale:et.options[0].shape.locale,parameters:et.options[0].shape.parameters}),Np.omit({operation:!0}).extend({contract:st,operation:q.literal("entry_start"),source:$p}),q.strictObject({...Gp,operation:q.literal("bind_customer"),guestToken:ea,claimRequestId:q.uuid(),expectedBindingId:q.null()}),q.strictObject({...Gp,operation:q.literal("binding_status"),guestToken:ea.optional()}),et.options[1].omit({operation:!0,customerToken:!0}).extend({...oi,operation:q.literal("get"),settlementBindingId:q.uuid().nullable().optional()}),et.options[8].omit({operation:!0,customerToken:!0}).extend({...oi,operation:q.literal("review")}),Vp.omit({customerToken:!0}).extend(oi),q.strictObject({...oi,operation:q.literal("command"),identity:q.strictObject({bindingId:q.uuid().nullable()}),command:cg})]),ug=In.omit({run:!0}).extend({contract:st,run:sg,settlement:In.shape.settlement.unwrap().extend({accepted:q.boolean().nullable().optional()}).optional()}),XO=Up.extend({contract:st}),YO=q.discriminatedUnion("operation",[Kp.options[1].omit({contract:!0,source:!0,requestId:!0}),Kp.options[2].omit({contract:!0,source:!0,requestId:!0})]),ej=ug.extend({binding:ta,outcome:q.enum(["bound","already_bound"]),replayed:q.boolean()}),tj=q.discriminatedUnion("state",[q.strictObject({contract:st,scope:le,state:q.literal("not_accepted")}),q.strictObject({contract:st,scope:le,state:q.literal("conflict")}),q.strictObject({contract:st,scope:le,state:q.literal("bound"),binding:ta})]),nj=q.strictObject({contract:st,scope:le,keyId:q.uuid(),operations:q.array(q.string()).max(20)});import{z as $e}from"zod";import{z as ai}from"zod";var sj=ai.strictObject({operation:ai.literal("renew_run"),runId:ai.uuid(),customerId:ai.uuid()}),Lp=In.refine(e=>!!e.runToken,"Renewal returns a credential"),Zp=qp.refine(e=>!!e.runToken,"Renewal returns a credential");var gj=$e.discriminatedUnion("operation",[$e.strictObject({operation:$e.literal("campaign_decide"),...Ao}).refine(Ut,Vt),$e.strictObject({operation:$e.literal("campaign_start"),funnelId:$e.uuid(),requestId:$e.uuid(),customer:yt,customerData:_t.optional(),locale:$e.string().min(1).max(35),parameters:ct,cooldownSeconds:$e.number().int().min(1).max(2592e3)}).refine(Ut,Vt)]),pg=$e.union([$e.strictObject({scope:le,suppressed:$e.literal(!0),reason:$e.enum(["frequency","in_progress"]),retryAt:$e.iso.datetime({offset:!0})}),Lp]),hj=$e.union([pg.options[0],Zp]);import{z as re}from"zod";var On=re.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Jp=re.strictObject({entry:On,nodes:re.array(re.strictObject({id:On,type:re.enum(["entry","screen","condition","split","feature","action","external_page","wait","end","offering","coupon","coupons","output"]),outputs:re.record(re.string(),On),writes:re.record(Ae,Ae),resources:re.strictObject({screenId:On.optional(),paywallVersionId:re.uuid().optional(),couponId:re.uuid().optional(),couponIds:re.array(re.uuid()).max(20).optional(),experimentId:re.uuid().optional(),featureKey:re.string().optional(),offeringVersionId:re.uuid().optional()})})).min(1).max(500)}),Hp={scope:le,funnelId:re.uuid(),versionId:re.uuid(),evaluationRevision:re.number().int().nonnegative(),expiresAt:re.iso.datetime({offset:!0}).nullable(),topology:Jp},jn=re.discriminatedUnion("evaluationMode",[re.strictObject({...Hp,evaluationMode:re.literal("local"),growth:wt,conditions:re.record(On,re.array(re.strictObject({condition:rt,port:re.string()})))}),re.strictObject({...Hp,evaluationMode:re.literal("remote")})]),lg=jn.options[0].extend({evaluation:re.strictObject({maxTransitions:re.number().int().min(1).max(1e4),variables:re.record(Ae,rn),outputSchema:nn,terminals:re.record(On,re.strictObject({outcome:re.enum(["completed","closed","ineligible","failed"]),output:Ln.nullable()}))})});function mg(e){return Jp.parse({entry:e.graph.entry,nodes:e.graph.nodes.map(t=>{let n={},r={};switch(t.type){case"entry":case"feature":case"offering":case"coupon":case"coupons":n.next=t.next;break;case"screen":Object.assign(n,t.outputs),r.screenId=t.screenId;{let a=e.screens.find(l=>l.id===t.screenId);a?.type==="paywall"&&(r.paywallVersionId=a.paywallVersionId)}break;case"condition":t.cases.forEach((a,l)=>{n[`case:${l}`]=a.target}),n.default=t.default;break;case"split":Object.assign(n,t.routes),n.notParticipating=t.notParticipating,r.experimentId=t.experimentId;break;case"action":for(let a of["success","cancel","unavailable","failure"])n[a]=t[a];t.action.type==="claim_offer"&&t.action.coupon.source==="literal"&&t.action.coupon.value&&typeof t.action.coupon.value=="object"&&!Array.isArray(t.action.coupon.value)&&(r.couponId=re.uuid().parse(t.action.coupon.value.id));break;case"external_page":n.opened=t.opened,n.failed=t.failed;break;case"wait":t.wait.type==="duration"?n.elapsed=t.wait.elapsed:(n.received=t.wait.received,n.timeout=t.wait.timeout);break;case"end":case"output":break}t.type==="feature"&&(r.featureKey=t.featureKey),t.type==="offering"&&t.configuration.source==="feature"&&(r.featureKey=t.configuration.featureKey);let o=t.type==="output"?t.value:t.type==="end"?t.output:void 0;return o?.type==="feature"&&(r.featureKey=o.featureKey),t.type==="coupon"&&(r.couponId=t.couponId),t.type==="coupons"&&(r.couponIds=t.couponIds),t.type==="offering"&&t.configuration.source==="fixed"&&(r.offeringVersionId=t.configuration.versionId),{id:t.id,type:t.type,outputs:n,resources:r,writes:"writes"in t?t.writes??{}:{}}})})}function dg(e){let t=Pt.parse(e.document),n=e.evaluationMode==="local"?wt.parse(e.payload):null;if(n&&(n.scope.projectId!==e.scope.projectId||n.scope.environment!==e.scope.environment))throw new Error("GB payload belongs to another App or environment");let r={scope:e.scope,funnelId:e.funnelId,versionId:e.versionId,evaluationRevision:e.evaluationRevision,evaluationMode:e.evaluationMode,expiresAt:n?.expiresAt??null,topology:mg(t)};return jn.parse(e.evaluationMode==="remote"?r:{...r,growth:ri(t,n),conditions:Object.fromEntries(t.graph.nodes.filter(o=>o.type==="condition").map(o=>[o.id,o.cases.map((a,l)=>({condition:a.condition,port:`case:${l}`}))]))})}function wj(e){let t=dg(e);if(t.evaluationMode!=="local")throw new Error("Remote Funnel cannot disclose local rules");let n=Pt.parse(e.document);return lg.parse({...t,evaluation:{maxTransitions:n.execution.maxTransitions,variables:n.variables,outputSchema:n.outputSchema,terminals:Object.fromEntries(n.graph.nodes.flatMap(r=>{let o=r.type==="end"?r.output:r.type==="output"?r.value:void 0;return r.type!=="end"&&r.type!=="output"?[]:o&&o.type!=="literal"&&o.type!=="feature"&&o.type!=="variable"?[]:[[r.id,{outcome:r.type==="end"?r.outcome:"completed",output:o??null}]]}))}})}import{z as tt}from"zod";import{z as ze}from"zod";var Wp=ze.discriminatedUnion("provider",[ze.strictObject({provider:ze.literal("apple"),orderId:ze.uuid(),receiptId:ze.uuid(),signedTransaction:ze.string().min(1).max(131072)}),ze.strictObject({provider:ze.literal("google"),orderId:ze.uuid(),receiptId:ze.uuid(),purchaseToken:ze.string().min(1).max(16384)})]),Qp=ze.strictObject({orderId:ze.uuid(),receiptId:ze.uuid(),transactionIds:ze.array(ze.string().min(1).max(255)).min(1).max(50),membership:ze.boolean()});var Tj=tt.strictObject({operation:tt.literal("native_receipt"),requestId:tt.uuid(),customerToken:tt.string().regex(ut),orderId:tt.uuid(),receiptId:tt.uuid(),nativeEvidence:Wp.nullable()}).refine(e=>e.nativeEvidence===null||e.nativeEvidence.orderId===e.orderId&&e.nativeEvidence.receiptId===e.receiptId,"Evidence must use this current order receipt"),Dj=tt.strictObject({scope:le,requestId:tt.uuid(),orderId:tt.uuid(),receiptId:tt.uuid(),orderStatus:tt.enum(["created","pending","trialing","paid","cancelled","failed"]),refunded:tt.boolean(),nativeCompletion:Qp.optional()});import{z as he}from"zod";var Xp=he.string().regex(/^[a-f0-9]{64}$/),fg=hn.omit({variations:!0,active:!0}).extend({changeId:Xp,variations:he.array(he.strictObject({urlRedirect:he.string().max(2048)})).min(2).max(20)}),Fj=he.strictObject({environmentId:he.uuid(),trackExposures:he.boolean(),generation:Xp,experiments:he.array(fg).max(100),savedGroups:Gn}),gg=he.strictObject({eventUuid:he.uuid(),timestamp:he.iso.datetime({offset:!0}).optional(),deviceId:he.string().min(1).max(128),sessionId:he.string().min(1).max(128).optional(),url:he.url().max(2048),pageTitle:he.string().max(512).optional(),experimentKey:he.string().min(1).max(255),variationKey:he.string().min(1).max(64)}),Nj=he.strictObject({events:he.array(gg).min(1).max(20)}),Uj=he.strictObject({inserted:he.number().int().nonnegative(),duplicates:he.number().int().nonnegative(),skipped:he.number().int().nonnegative(),rejected:he.array(he.strictObject({index:he.number().int().nonnegative(),reason:he.string()}))});import{z as Se}from"zod";var ra=32,hg=522240;function ia(e){if(["entry","condition","feature","split","offering","coupon","coupons"].includes(e.type))return!0;if(e.type!=="end"&&e.type!=="output")return!1;let t=e.type==="end"?e.output:e.value;return t?.type!=="bundle"&&t?.type!=="selection"}var bg=Se.strictObject({nodeId:Se.string().min(1).max(64),visit:Se.number().int().nonnegative(),revision:Se.number().int().nonnegative()}),na=Se.record(Se.string(),ee),yg=Se.strictObject({id:Se.uuid(),nodeId:Se.string().min(1).max(64),visit:Se.number().int().nonnegative(),input:Se.strictObject({schemaVersion:Zn.shape.schemaVersion,kind:Zn.shape.kind,selector:Zn.shape.selector,contract:Zn.shape.contract}),context:na,removed:Se.array(Se.string()).max(100),attributes:na,removedAttributes:Se.array(Se.string()).max(100),result:Du,offeringVersionId:Se.uuid().nullable(),events:Se.strictObject({entered:Se.string().regex(/^[1-9][0-9]{0,18}$/),decision:Se.string().regex(/^[1-9][0-9]{0,18}$/).nullable()})}),Zj=Se.strictObject({schemaVersion:Se.literal(1),mode:Se.enum(["local","remote"]),versionId:Se.uuid(),generation:Se.number().int().positive(),base:bg,context:na,steps:Se.array(yg).min(1).max(ra)}).refine(e=>Le(e)<=hg,"Segment exceeds its byte budget");var xg=/^(parameters(?:\.|$)|answers(?:\.|$)|results(?:\.|$)|variables(?:\.|$)|funnelParticipantId$)/;function rr(e){return Array.isArray(e)?e.some(rr):!e||typeof e!="object"?!1:Object.entries(e).some(([t,n])=>t.startsWith("$")?["$and","$or","$nor","$not"].includes(t)&&rr(n):!xg.test(t))}function Yp(e,t,n,r){if(e.executionContract!=="funnel-process/1"||r)return null;if(["offering","coupon","coupons"].includes(t.type)||t.type==="action"&&t.action.type!=="event"||t.type==="screen"&&(t.offering||e.screens.some(p=>p.id===t.screenId&&p.type==="paywall")))return"customer_required";let o=t.type==="end"?t.output:t.type==="output"?t.value:void 0;if(o&&["bundle","selection","offering"].includes(o.type)||t.type==="condition"&&t.cases.some(p=>rr(p.condition)))return"customer_required";let a=JSON.stringify([t,t.type==="screen"?e.screens.find(p=>p.id===t.screenId):null]);for(let[p,d]of Object.entries(e.variables))if(d.source.type==="attribute"&&d.source.key!=="funnelParticipantId"&&(a.includes(`variables.${p}`)||a.includes(JSON.stringify(p))))return"customer_required";if(t.type==="split"){let p=n.experiments?.[t.experimentId];if((p?.hashAttribute??"id")!=="funnelParticipantId"||rr(p?.condition)||p?.parentConditions?.length)return"customer_experiment_required"}let l=t.type==="feature"?t.featureKey:o?.type==="feature"?o.featureKey:void 0;return l&&n.features?.[l]?.rules?.some(p=>(p.hashAttribute??"id")!=="funnelParticipantId"||rr(p.condition)||p.parentConditions?.length)?"customer_experiment_required":null}var oa=class extends Error{constructor(n,r){super(r);this.code=n;this.name="FunnelLocalCalculationError"}code},si=(e,t)=>new oa(e,t),Sg=e=>({experiments:e.experiments,features:e.features});function vg(e,t=si){let n=new Map(e.topology.nodes.map(l=>[l.id,l])),r=da(e.growth.savedGroups),o=Sg(e.growth);function a(l,p){if(!Object.hasOwn(e.growth.features,l))throw t("INVALID_RESPONSE","Required GB Feature is unavailable");return An(l,p).value}return{nodes:n,savedGroups:r,features:o.features,feature:a,evaluate(l,p){let d=n.get(l);if(!d)throw t("NOT_FOUND","Funnel node is unavailable");let v,h;if(d.type==="condition"){let $=e.conditions[d.id];if(!$)throw t("INVALID_RESPONSE","Local condition rules are unavailable");v=Qo({id:d.id,name:d.id,type:"condition",cases:$.map(C=>({condition:C.condition,target:d.outputs[C.port]})),default:d.outputs.default},p,o.experiments).port}else if(d.type==="feature"){if(!d.resources.featureKey)throw t("INVALID_RESPONSE","Feature reference is unavailable");h=a(d.resources.featureKey,p),v="next"}else if(d.type==="split"){if(!(d.resources.experimentId?e.growth.experiments[d.resources.experimentId]:void 0))throw t("INVALID_RESPONSE","Experiment reference is unavailable");let C=Qo({id:d.id,name:d.id,type:"split",experimentId:d.resources.experimentId,routes:d.outputs,notParticipating:d.outputs.notParticipating},p,o.experiments);h=C.value,v=C.port}else if(["offering","end","output"].includes(d.type)&&d.resources.featureKey)h=a(d.resources.featureKey,p),v=d.type==="offering"?"next":"value";else throw t("SERVER_REQUIRED","This node is driven by the authoritative Funnel runtime");let T=d.outputs[v]??(v==="value"?d.id:void 0);if(!T)throw t("INVALID_RESPONSE","Evaluated node exit is unavailable");return{nodeId:l,port:v,target:T,...h===void 0?{}:{value:h}}}}}function aA(e,t,n,r=si){return aa(e,r)(t,n)}function aa(e,t){let n=jn.parse(e);if(n.evaluationMode!=="local")throw t("EVALUATION_MODE","Remote nodes are evaluated by Grow");let r=n.expiresAt?Date.parse(n.expiresAt):null,o=()=>{if(r!==null&&r<=Date.now())throw t("CONFIGURATION_EXPIRED","Refresh local rules at the scheduled transition")};o();let a=vg(n,t);return(l,p)=>(o(),Ig(a,l,p))}function Ig(e,t,n){let r=Ge.parse(n.attributes??{}),{saveStickyBucketAssignmentDoc:o,onFeatureUsage:a,onExperimentViewed:l}=n,p={attributes:r,...o?{saveStickyBucketAssignmentDoc:d=>o(structuredClone(d))}:{},...a?{onFeatureUsage:(d,v)=>a(d,structuredClone(v))}:{},...l?{onExperimentViewed:(d,v)=>l(structuredClone(d),structuredClone(v))}:{},features:e.features,savedGroups:e.savedGroups,...n.stickyBucketAssignmentDocs?{stickyBucketAssignmentDocs:structuredClone(n.stickyBucketAssignmentDocs)}:{}};return e.evaluate(t,p)}function sA(e,t,n,r=si){return el(aa(e,r),t,n)}function el(e,t,n){let r=[],o=[],a=[],l=e(t,{...n.attributes?{attributes:n.attributes}:{},stickyBucketAssignmentDocs:n.sticky,saveStickyBucketAssignmentDoc(p){let d=r.findIndex(T=>T.next.attributeName===p.attributeName&&T.next.attributeValue===p.attributeValue),v=p.attributeName+"||"+p.attributeValue,h={expected:n.sticky[v]??null,next:p};d<0?r.push(h):r[d]=h},onExperimentViewed(p,d){d.inExperiment&&d.hashUsed&&!d.passthrough&&o.push(ee.parse({key:p.key,variationId:d.variationId,keyUsed:d.key,hashAttribute:d.hashAttribute,hashValue:d.hashValue}))},onFeatureUsage(p,d){a.push(ee.parse({feature:p,value:d.value,source:d.source,...d.ruleId?{ruleId:d.ruleId}:{}}))}});return{port:l.port,...l.value===void 0?{}:{value:l.value},sticky:r,exposures:o,features:a}}function cA(e,t,n,r=si){let o=n,a=new Map(t.graph.nodes.map(Z=>[Z.id,Z])),l=structuredClone(n.variables),p=structuredClone(o.sticky),d=[],v=n.nodeId,h=n.visit,T=!1,$,C=Z=>Yp(t,Z,e.evaluationMode==="local"?e.growth:{features:{},experiments:{}},o.attributes.funnelCustomerBound===!0),u=Z=>($??=aa(e,r),el($,Z,{attributes:yo({declarations:t.variables,attributes:o.attributes,parameters:n.parameters,answers:n.answers,results:l,savedGroups:{}}),sticky:p}));for(let Z=0;Z<ra;Z++){let E=a.get(v);if(!E||!ia(E)||C(E))break;if(h>=t.execution.maxTransitions&&(h>t.execution.maxTransitions||E.type!=="end"&&E.type!=="output")){if(!d.length)throw r("TRANSITION_LIMIT","Local Funnel transition budget exceeded");break}let oe,Ce;if(["condition","feature","split"].includes(E.type)||E.type==="offering"&&E.configuration.source==="feature")oe=u(E.id),E.type==="offering"&&(oe.value={type:"offering_version",id:String(oe.value)}),E.type==="condition"?Ce=oe.port==="default"?E.default:E.cases[Number(oe.port.slice(5))]?.target:E.type==="split"?Ce=oe.port==="notParticipating"?E.notParticipating:E.routes[oe.port]:(E.type==="feature"||E.type==="offering")&&(Ce=E.next);else if(oe={port:"next",sticky:[],exposures:[],features:[]},(E.type==="entry"||E.type==="coupon"||E.type==="coupons")&&(Ce=E.next),E.type==="offering"&&E.configuration.source==="fixed"&&(oe.value={type:"offering_version",id:E.configuration.versionId},Ce=E.next),E.type==="end"||E.type==="output"){let Y=E.type==="end"?E.output:E.value;if(oe=Y?.type==="feature"?u(E.id):{...oe,port:"value",value:Y?.type==="literal"?Y.value:Y?.type==="variable"?wi({source:"variable",key:Y.key,...Y.path?{path:Y.path}:{}},{declarations:t.variables,answers:n.answers,results:l,parameters:n.parameters,attributes:o.attributes,savedGroups:{}}):null},Y&&(oe.value===void 0||!Qe(t.outputSchema,oe.value)))throw r("INVALID_RESPONSE","Local terminal violates its declared output")}let L=[...d,{nodeId:v,result:oe}];if(Le({steps:L})>6e4){if(!d.length)throw r("INVALID_REQUEST","Local step exceeds its command budget");break}if(d.push({nodeId:v,result:oe}),E.type==="feature"||E.type==="offering"||E.type==="coupon"||E.type==="coupons"){let Y=E.type==="coupons"?E.couponIds.map(H=>({type:"reward",id:H})):E.type==="coupon"?{type:"reward",id:E.couponId}:oe.value;if(Y===void 0)throw r("INVALID_RESPONSE","Node output is missing");let pe=Tt(E,{value:Y});Ai(t.variables,E,pe),Object.assign(l,pe)}for(let Y of oe.sticky)p[`${Y.next.attributeName}||${Y.next.attributeValue}`]=structuredClone(Y.next);if(E.type==="end"||E.type==="output"){T=!0;break}if(!Ce)throw r("INVALID_RESPONSE","Local pure exit is unavailable");v=Ce,h++}let b=a.get(v);return{steps:d,...!T&&b&&(!ia(b)||C(b))?{boundary:{nodeId:v,visit:h}}:{}}}import{z as Og}from"zod";var dA=Og.strictObject({document:Pt,configuration:jn.options[0]});var R_={name:"@tinkerlandai/longplay-sdk",version:"0.10.16",description:"Framework-independent Longplay SDK for customer identity, entitlements, credits, offers and growth surfaces.",license:"UNLICENSED",repository:{type:"git",url:"git+https://github.com/tinkerlandai/Indiana.git",directory:"packages/sdk"},engines:{node:">=22"},publishConfig:{access:"public",tag:"beta"},type:"module",sideEffects:!1,files:["dist","README.md","README.zh-CN.md","CHANGELOG.md","THIRD_PARTY_NOTICES.md"],exports:{"./react-native":{types:"./dist/react-native.d.ts","react-native":"./dist/react-native.js",import:"./dist/react-native.js",default:"./dist/react-native.js"},".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./popup":{types:"./dist/popup.d.ts",import:"./dist/popup.js"},"./server":{types:"./dist/server.d.ts",import:"./dist/server.js"},"./openrouter":{types:"./dist/openrouter.d.ts",import:"./dist/openrouter.js"},"./native-shell":{types:"./dist/native-shell.d.ts",import:"./dist/native-shell.js"},"./page":{types:"./dist/page.d.ts",import:"./dist/page.js"},"./visual":{types:"./dist/visual.d.ts",import:"./dist/visual.js"}},scripts:{build:"tsup",prepack:"pnpm run build",typecheck:"tsc --noEmit && tsc --noEmit -p tsconfig.test.json",lint:"node ../../scripts/ci/lint.mjs --workspace packages/sdk"},dependencies:{"@ai-sdk/provider":"4.0.26","@types/json-schema":"7.0.15","css-tree":"^3.2.1","dom-mutator":"0.7.0",dompurify:"^3.4.15",zod:"4.6.6"},devDependencies:{"@indiana/contracts":"workspace:*","@openrouter/sdk":"^1.4.25","@types/css-tree":"^3.2.0",ai:"7.0.136",tsup:"^8.5.1",typescript:"^5.9.3","whatwg-url-minimum":"0.2.0"},peerDependencies:{"@openrouter/sdk":"^1.4.25"},peerDependenciesMeta:{"@openrouter/sdk":{optional:!0}}};var E_="https://api.longplayai.com";export{le as a,wh as b,_h as c,Ph as d,Ch as e,jr as f,Rh as g,Mh as h,Th as i,Dh as j,_g as k,Pg as l,qa as m,ut as n,en as o,tn as p,Va as q,Dg as r,Bg as s,sl as t,La as u,Fg as v,ul as w,pl as x,ll as y,gr as z,br as A,Si as B,fl as C,Ng as D,gl as E,Ug as F,Vg as G,Ja as H,Kg as I,Lg as J,bl as K,yl as L,Wg as M,Qe as N,Ai as O,wi as P,Ci as Q,vh as R,ax as S,wt as T,so as U,Md as V,iu as W,uo as X,yo as Y,eS as Z,tS as _,nS as $,SS as aa,vS as ba,IS as ca,et as da,Nu as ea,yf as fa,xf as ga,sI as ha,zo as ia,vf as ja,cI as ka,uI as la,pI as ma,Qn as na,II as oa,Wu as pa,Ju as qa,Uo as ra,If as sa,RI as ta,I as ua,lO as va,Wf as wa,In as xa,qp as ya,_O as za,ng as Aa,NO as Ba,Np as Ca,Up as Da,Vp as Ea,VO as Fa,Kp as Ga,ug as Ha,XO as Ia,YO as Ja,ej as Ka,tj as La,nj as Ma,sj as Na,Lp as Oa,gj as Pa,hj as Qa,jn as Ra,lg as Sa,dg as Ta,wj as Ua,Tj as Va,Dj as Wa,Fj as Xa,vg as Ya,aA as Za,sA as _a,cA as $a,dA as ab,R_ as bb,E_ as cb};
|