@tinkerlandai/longplay-sdk 0.10.34 → 0.10.36
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 +7 -0
- package/README.md +83 -5
- package/README.zh-CN.md +26 -3
- package/dist/{ai-usage-T62xehqa.d.ts → ai-usage-DXwAGTxT.d.ts} +1 -1
- package/dist/{api-Do-6AyWa.d.ts → api-r6FfVQpg.d.ts} +6 -1
- package/dist/check-response-DHY6T5Z2.js +1 -0
- package/dist/{chunk-7MNJH5GB.js → chunk-2HSD2SEU.js} +1 -1
- package/dist/chunk-2KKLY323.js +1 -0
- package/dist/{chunk-BXPXJARS.js → chunk-35VG2IYD.js} +1 -1
- package/dist/chunk-3NCMYTNG.js +1 -0
- package/dist/{chunk-HQITRRHF.js → chunk-5XIKN35D.js} +1 -1
- package/dist/chunk-5XKFUFXK.js +1 -0
- package/dist/chunk-7ZEXY4GC.js +1 -0
- package/dist/chunk-BL7E4RZ2.js +1 -0
- package/dist/{chunk-FYQXSGRT.js → chunk-BTPEXSNY.js} +1 -1
- package/dist/chunk-C4GBV32U.js +10 -0
- package/dist/chunk-CGXNU5BC.js +1 -0
- package/dist/chunk-DB4EO3JG.js +1 -0
- package/dist/chunk-DHT3AWJQ.js +1 -0
- package/dist/chunk-GLYFT5WW.js +1 -0
- package/dist/chunk-HS56A4IK.js +1 -0
- package/dist/chunk-HVVJGLYZ.js +1 -0
- package/dist/chunk-HYE2YQYM.js +1 -0
- package/dist/chunk-I6D25FWU.js +1 -0
- package/dist/{chunk-TYY3MUTF.js → chunk-IOBB6KFK.js} +1 -1
- package/dist/chunk-JOIPLLHK.js +1 -0
- package/dist/{chunk-MIBRUDIS.js → chunk-LAGGWYH3.js} +1 -1
- package/dist/{chunk-6T575JKD.js → chunk-LVG5ED52.js} +1 -1
- package/dist/{chunk-I6TSQQ5N.js → chunk-M3GGR53D.js} +1 -1
- package/dist/chunk-MHWPEMX7.js +1 -0
- package/dist/chunk-MYBUQFTC.js +1 -0
- package/dist/{chunk-7QL4GF4C.js → chunk-O4KXODTJ.js} +1 -1
- package/dist/chunk-OL2AI6DA.js +1 -0
- package/dist/chunk-QHJWVLJC.js +1 -0
- package/dist/chunk-R3YVDRTB.js +1 -0
- package/dist/chunk-RHF4NFCZ.js +1 -0
- package/dist/{chunk-5HJYR6Z4.js → chunk-RHWZRHK7.js} +1 -1
- package/dist/{chunk-X4W22IH6.js → chunk-TIQS5DUF.js} +1 -1
- package/dist/chunk-U4WUX3WB.js +1 -0
- package/dist/chunk-UHTTCVSL.js +1 -0
- package/dist/{chunk-UWLEGMWX.js → chunk-UVUFJO2V.js} +1 -1
- package/dist/{chunk-7NELM6EH.js → chunk-VKG6BB3Z.js} +1 -1
- package/dist/chunk-VWMFR22O.js +1 -0
- package/dist/chunk-W32FI2A2.js +1 -0
- package/dist/chunk-W3K5ARMY.js +1 -0
- package/dist/chunk-WRLVPHPE.js +1 -0
- package/dist/chunk-XE7GU6FZ.js +1 -0
- package/dist/{chunk-EQPEUPMG.js → chunk-XQTCEQXI.js} +1 -1
- package/dist/chunk-YQX27SBG.js +1 -0
- package/dist/{chunk-VYFSRHXM.js → chunk-ZYF6TRJ3.js} +1 -1
- package/dist/{configuration-sync-DdTRUv7A.d.ts → configuration-sync-BHrAf-ql.d.ts} +10 -1
- package/dist/content-RGKTEV23.js +1 -0
- package/dist/funnel-host-purchase-M7MM33EC.js +1 -0
- package/dist/{funnel-local-client-BeGBvi3z.d.ts → funnel-local-client-DR8OpKGU.d.ts} +167 -25
- package/dist/funnel-paywall-prerender-OSBI4VMY.js +1 -0
- package/dist/{funnel-process-client-C6QKDZun.d.ts → funnel-process-client-C87U4r_G.d.ts} +17 -3
- package/dist/funnel-runtime-host-AMJXEASH.js +1 -0
- package/dist/index.d.ts +214 -63
- package/dist/index.js +1 -1
- package/dist/merchant-bridge-contracts-GJQVKEAG.js +1 -0
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.d.ts +3 -3
- package/dist/openrouter.js +1 -1
- package/dist/operation-contracts-MFK2KORK.js +1 -0
- package/dist/page.d.ts +2 -2
- package/dist/page.js +1 -1
- package/dist/paywall-ATZ2IZPS.js +1 -0
- package/dist/paywall-content-XERXGNND.js +1 -0
- package/dist/paywall-session-EMMF6IYS.js +1 -0
- package/dist/popup.d.ts +21 -3
- package/dist/popup.js +1 -1
- package/dist/{presentation-loading-CFSiS0VX.d.ts → presentation-loading-B_v5XZtM.d.ts} +11 -1
- package/dist/react-native.d.ts +7 -7
- package/dist/react-native.js +1 -1
- package/dist/{screen-CGCJ46b1.d.ts → screen-qUBRsUi9.d.ts} +26 -21
- package/dist/screen-renderer-B7LUTPTJ.js +1 -0
- package/dist/server.d.ts +37 -7
- package/dist/server.js +2 -2
- package/dist/{visual-dom-6DCUZGPB.js → visual-dom-5LUN4AHO.js} +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-3JJYWRA3.js +0 -1
- package/dist/chunk-4WZVC4TM.js +0 -1
- package/dist/chunk-5JWMP4YD.js +0 -1
- package/dist/chunk-7VRZYSTR.js +0 -1
- package/dist/chunk-EHDHWYVJ.js +0 -1
- package/dist/chunk-ERJP2GBD.js +0 -1
- package/dist/chunk-ILEDKSRQ.js +0 -1
- package/dist/chunk-ITGERPCJ.js +0 -1
- package/dist/chunk-N7YXDSQL.js +0 -1
- package/dist/chunk-NAZU3EEJ.js +0 -1
- package/dist/chunk-QBA3B4YK.js +0 -1
- package/dist/chunk-R23IGK5U.js +0 -1
- package/dist/chunk-R4FDIYMN.js +0 -1
- package/dist/chunk-RKPAIF6U.js +0 -1
- package/dist/chunk-SCC3O2RD.js +0 -1
- package/dist/chunk-TDSATEGE.js +0 -10
- package/dist/chunk-THMGTRXP.js +0 -1
- package/dist/chunk-U6UHASIB.js +0 -1
- package/dist/chunk-WKIR2EQG.js +0 -1
- package/dist/chunk-WTVLNUMS.js +0 -1
- package/dist/chunk-ZGCKQWQ5.js +0 -1
- package/dist/content-ORU4ODJQ.js +0 -1
- package/dist/funnel-host-purchase-BEFE3N3E.js +0 -1
- package/dist/funnel-runtime-host-V6TYIDX3.js +0 -1
- package/dist/merchant-bridge-contracts-ZUQ6SGXZ.js +0 -1
- package/dist/operation-contracts-443N2P3A.js +0 -1
- package/dist/paywall-HO4PS472.js +0 -1
- package/dist/paywall-session-MZXFOPTR.js +0 -1
- package/dist/screen-renderer-W7ZGBFIR.js +0 -1
- /package/dist/{chunk-BID4UGWB.js → chunk-CILM5XMH.js} +0 -0
- /package/dist/{chunk-UKMEW5I7.js → chunk-OJM6ORHE.js} +0 -0
- /package/dist/{chunk-VF6QMMEA.js → chunk-ZYN4CRHS.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as tt,b as it}from"./chunk-XQTCEQXI.js";import{a as Ut,b as Mt,d as Et,h as Z,i as fe}from"./chunk-2HSD2SEU.js";import{a as st,b as de,c as P,d as ot,e as I,f as ct,g as me,h as ut,i as dt,j as mt,k as pe,l as pt,m as lt,n as le}from"./chunk-5XKFUFXK.js";import{i as f,j as He,u as N}from"./chunk-2KKLY323.js";import{a as V,b as rt,c as Tt,e as kt}from"./chunk-U4WUX3WB.js";import{f as gt,h as ht,i as ft,j as bt,k as xt}from"./chunk-JOIPLLHK.js";import{G as he,H as Ct,M as Q,N as _t,O as Rt,P as wt,Q as Bt,R as qt,o as nt,p as y,r as ue,s as at}from"./chunk-GLYFT5WW.js";import{a as zt}from"./chunk-RHWZRHK7.js";import{a as We,b as F}from"./chunk-ZYF6TRJ3.js";import{M as B,N as St,O as yt,P as It,Q as q,R as vt,S as Ot,T as ge,U as j,V as At,W as Pt,X as jt}from"./chunk-QHJWVLJC.js";import{a as c,e as Xe,f as Je,g as Ye,h as et,j as ce}from"./chunk-XE7GU6FZ.js";import{b as se,c as p,d as s,e as oe,g as h}from"./chunk-DHT3AWJQ.js";import{b as e}from"./chunk-ZYN4CRHS.js";var be=e.strictObject({operationId:e.uuid(),customerId:e.uuid(),externalUserId:e.string().min(1).max(256),modelId:e.string().min(1).max(256),quantity:e.number().int().min(1).max(1e6),validForDays:e.number().int().min(1).max(3660)}),Dt=e.strictObject({operationId:e.uuid(),customerId:e.uuid(),status:e.literal("applied"),voucherId:e.uuid(),modelId:e.string().min(1).max(256),quantity:e.number().int().positive(),issuedAt:e.iso.datetime({offset:!0}),expiresAt:e.iso.datetime({offset:!0})}).refine(t=>Date.parse(t.expiresAt)>Date.parse(t.issuedAt),{message:"A benefit must expire after it is issued"}),Gt=e.strictObject({operationId:e.uuid(),customerId:e.uuid()}),xa=e.discriminatedUnion("lookup",[Gt.extend({lookup:e.literal("not_received")}),Gt.extend({lookup:e.literal("found"),result:Dt}).refine(t=>t.result.operationId===t.operationId&&t.result.customerId===t.customerId)]),$t=e.strictObject({customerId:e.string().min(1).max(256),modelId:e.string().min(1).max(256),quantity:be.shape.quantity,validForDays:be.shape.validForDays,requestId:e.uuid()}),Lt=e.strictObject({customerId:e.string().min(1).max(256),operationId:e.uuid()}),xe=e.strictObject({operationId:e.uuid(),customerId:e.uuid(),taskId:e.uuid(),status:e.enum(["pending","applied","rejected"]),terms:be,receipt:Dt.nullable(),failureCode:e.enum(["INVALID_REQUEST","CONNECTION_CHANGED"]).nullable()}).superRefine((t,n)=>{(t.terms.operationId!==t.operationId||t.terms.customerId!==t.customerId||t.status==="applied"!=(t.receipt!==null)||t.status==="rejected"!=(t.failureCode!==null)||t.receipt&&(t.receipt.operationId!==t.operationId||t.receipt.customerId!==t.customerId||t.receipt.modelId!==t.terms.modelId||t.receipt.quantity!==t.terms.quantity))&&n.addIssue({code:"custom",message:"Benefit result differs from the original accepted operation"})});var T=e.enum(["email","sms","voice","push"]),Ia=e.enum(["resend","twilio","fcm","apns"]);var va=e.string().regex(/^\+[1-9]\d{1,14}$/),Qr=e.enum(["email_recipient","sms_segment","voice_second","push_device"]);var Zr=e.string().trim().min(1).max(200).refine(t=>!/[\r\n\0]/.test(t),"Invalid email header"),Kr=e.strictObject({subject:Zr,html:e.string().min(1).max(131072).optional(),text:e.string().min(1).max(65536).optional()}).refine(t=>t.html!==void 0||t.text!==void 0,{message:"Email requires HTML or text content"}),Wr=e.strictObject({body:e.string().min(1).max(1600).refine(t=>t.trim().length>0)}),Hr=e.strictObject({text:e.string().trim().min(1).max(4e3),language:e.string().regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/).max(35),maxDurationSeconds:e.number().int().min(1).max(900)}),Xr=e.record(e.string().min(1).max(64),e.string().max(256)).refine(t=>Object.keys(t).length<=20&&Object.keys(t).every(n=>!/^(?:indiana_|google\.|gcm\.)/i.test(n)&&n!=="aps"),"Push data contains reserved fields or too many entries"),Jr=e.strictObject({title:e.string().trim().min(1).max(200),body:e.string().trim().min(1).max(2e3),url:e.url().max(2048).refine(t=>!/^(?:javascript|data|file|vbscript):/i.test(t)).optional(),data:Xr.optional()}).refine(t=>new TextEncoder().encode(JSON.stringify(t)).length<=3072,"Push content exceeds the provider payload budget"),Ft=e.discriminatedUnion("channel",[e.strictObject({channel:e.literal("email"),content:Kr}),e.strictObject({channel:e.literal("sms"),content:Wr}),e.strictObject({channel:e.literal("voice"),content:Hr}),e.strictObject({channel:e.literal("push"),content:Jr})]),Nt=e.strictObject({requestId:e.uuid(),customerId:e.uuid(),connectionId:e.uuid().optional(),message:Ft,expiresAt:e.iso.datetime({offset:!0})}),Yr=e.array(e.uuid()).min(1).max(1e4).refine(t=>new Set(t).size===t.length,"Duplicate Customer"),en=e.discriminatedUnion("kind",[e.strictObject({kind:e.literal("all")}),e.strictObject({kind:e.literal("customers"),customerIds:Yr})]),Oa=e.strictObject({name:e.string().trim().min(1).max(120),connectionId:e.uuid().optional(),message:Ft,audience:en,frequencyLimit:e.number().int().min(1).max(100)}),Vt=e.strictObject({requestId:e.uuid(),channel:T,state:e.enum(["allowed","denied"]),expectedRevision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER-1)}),Qt=e.enum(["queued","leased","dispatching","accepted","unknown","retry","skipped","failed","canceled"]),Zt=e.enum(["accepted","sent","delivered","delayed","bounced","complained","unsubscribed","opened","clicked","ringing","answered","completed","busy","no_answer","failed","cost_finalized"]),Aa=e.strictObject({meter:Qr,estimatedUnits:e.string().regex(/^(0|[1-9]\d{0,11})$/),observedUnits:e.string().regex(/^(0|[1-9]\d{0,11})$/).nullable()});var Kt=e.strictObject({requestId:e.uuid(),targets:e.array(e.strictObject({membershipId:e.uuid(),action:e.enum(["cancel","uncancel"]),timing:e.enum(["immediate","renewal"])}).refine(t=>t.action!=="uncancel"||t.timing==="immediate","Restoration is immediate")).min(1).max(100)}).refine(t=>new Set(t.targets.map(n=>n.membershipId)).size===t.targets.length,"Duplicate batch target"),K=e.strictObject({batchId:e.uuid()}),tn=e.strictObject({operationId:e.uuid(),membershipIds:e.array(e.uuid()).min(1).max(20),provider:e.enum(["stripe","apple","google"]),action:e.enum(["cancel","uncancel"]),timing:e.enum(["immediate","renewal"]),status:e.enum(["prepared","confirmed","pending","scheduled","effective","cancelled","failed","store_action_required"]),quote:dt.nullable(),managementUrl:e.url().nullable(),failureCode:e.enum(["provider_unavailable","invalid_evidence","pending_payment"]).nullable()}),k=e.strictObject({batchId:e.uuid(),ready:e.boolean(),status:e.enum(["prepared","cancelled","expired","pending","partial","effective","action_required"]),createdAt:e.iso.datetime({offset:!0}),acceptedAt:e.iso.datetime({offset:!0}).nullable(),groups:e.array(tn).min(1).max(100)});var rn=e.string().trim().min(1).max(240),Se={requestId:e.uuid(),reason:rn},W=e.discriminatedUnion("action",[e.strictObject({...Se,action:e.literal("start"),productVersionId:e.uuid(),entityId:e.uuid().optional(),days:e.number().int().min(1).max(730).optional()}),e.strictObject({...Se,action:e.literal("extend"),membershipId:e.uuid(),days:e.number().int().min(1).max(730)}),e.strictObject({...Se,action:e.literal("end"),membershipId:e.uuid()})]),Wt=e.strictObject({operationId:e.uuid()}),Ht=e.iso.datetime({offset:!0}),nn=e.strictObject({provider:e.literal("stripe"),executor:e.enum(["indiana","merchant"]),accountId:e.string().regex(/^acct_[A-Za-z0-9]+$/),subscriptionId:e.string().regex(/^sub_[A-Za-z0-9]+$/),trialEnd:e.union([e.literal("now"),Ht]),prorationBehavior:e.literal("none")}),ye=e.strictObject({operationId:e.uuid(),action:e.enum(["start","extend","end"]),status:e.enum(["pending","effective"]),managedBy:e.enum(["indiana","stripe"]),membershipIds:e.array(e.uuid()).min(1).max(20),endsAt:Ht.nullable(),execution:nn.nullable()}).refine(t=>t.execution!==null==(t.managedBy==="stripe"&&t.status==="pending")&&t.action==="end"==(t.endsAt===null)&&(t.action!=="start"||t.managedBy==="indiana")&&(t.execution===null||t.execution.trialEnd==="now"==(t.action==="end")),"Only a pending Stripe trial change carries execution instructions"),wa=e.strictObject({groupId:e.uuid(),productVersionId:e.uuid(),enabled:e.boolean()});var Xt=e.strictObject({requestId:e.uuid(),currency:c,makeDefault:e.boolean()}),Jt=e.strictObject({setupId:e.uuid()}),an=e.strictObject({provider:e.literal("stripe"),executor:e.literal("merchant"),accountId:e.string().regex(/^acct_[A-Za-z0-9]+$/),mode:e.literal("setup"),currency:e.string().regex(/^[a-z]{3}$/),customer:e.string().regex(/^cus_[A-Za-z0-9]+$/).nullable(),clientReferenceId:e.uuid(),metadata:e.strictObject({grooveProjectId:e.uuid(),grooveEnvironmentId:e.uuid(),grooveCustomerId:e.uuid(),groovePaymentSetupId:e.uuid()}),setDefaultPaymentMethod:e.boolean(),expiresAt:e.iso.datetime({offset:!0})}),Ie=e.strictObject({id:e.uuid(),provider:e.literal("stripe"),status:e.enum(["prepared","complete","expired"]),currency:c,makeDefault:e.boolean(),url:e.url().nullable(),createdAt:e.iso.datetime({offset:!0}),expiresAt:e.iso.datetime({offset:!0}),completedAt:e.iso.datetime({offset:!0}).nullable(),execution:an.nullable()});var Yt=e.union([e.string(),e.number(),e.boolean(),e.null()]),ei=e.strictObject({customerId:e.uuid()}),ti=e.strictObject({customerId:e.uuid(),provider:e.literal("stripe"),checkedAt:e.iso.datetime({offset:!0}),status:e.enum(["consistent","drifted","incomplete"]),checkedSubscriptions:e.number().int().nonnegative(),differences:e.array(e.strictObject({subscriptionId:e.string().startsWith("sub_"),itemId:e.string().nullable(),field:e.enum(["subscription","status","currency","cancelAtPeriodEnd","item","price","product","quantity","periodStart","periodEnd","trialEnd","evidence"]),expected:Yt,actual:Yt})).max(1e4)});var H=e.iso.datetime({offset:!0}),X=e.strictObject({createdAt:H,id:e.uuid()}),J=e.strictObject({customerId:e.uuid().optional(),entityId:e.uuid().optional(),productId:e.string().min(1).max(256).optional(),provider:e.enum(["stripe","apple","google","merchant","free"]).optional(),status:e.enum(["trial","active","past_due","ended","refunded"]).optional(),cursor:X.optional(),limit:e.number().int().min(1).max(100).optional()}),ve={id:e.uuid(),customerId:e.uuid(),entityId:e.uuid().nullable(),productId:e.string().min(1).max(256),productVersionId:e.uuid(),name:e.string().min(1).max(120),provider:e.enum(["stripe","apple","google","merchant","free"]),createdAt:H},sn=e.strictObject({...ve,status:e.enum(["trial","active","past_due","ended"]),cancelAtPeriodEnd:e.boolean(),billingSubscriptionId:e.uuid().nullable()}),on=e.strictObject({...ve,status:e.enum(["active","ended","refunded"]),orderId:e.uuid().nullable(),transactionId:e.uuid().nullable(),currency:c.nullable(),amountMinor:e.string().regex(/^(0|[1-9]\d{0,17})$/).nullable()}),cn=e.strictObject({...ve,status:e.enum(["blocked","resolved"]),conflict:e.strictObject({detectedAt:H,blockingMembershipIds:e.array(e.uuid()).min(1).max(100),transactionId:e.uuid()}),resolvedAt:H.nullable()}),ii=J.extend({status:e.enum(["blocked","resolved"]).optional()}),ri=e.strictObject({customerId:e.uuid(),orderId:e.uuid()}),ni=e.strictObject({orderId:e.uuid(),status:e.enum(["blocked","resolved"])}),ai=e.strictObject({items:e.array(sn).max(100),nextCursor:X.nullable()}),si=e.strictObject({items:e.array(on).max(100),nextCursor:X.nullable()}),oi=e.strictObject({items:e.array(cn).max(100),nextCursor:X.nullable()});var ci=e.union([e.strictObject({intent:e.literal("read"),requestId:e.uuid(),purchaseIntentId:e.uuid()}),e.strictObject({requestId:e.uuid(),provider:e.literal("apple"),purchaseIntentId:e.uuid(),productId:e.string().min(1).max(255).optional(),signedTransaction:e.string().min(1).max(131072)}),e.strictObject({requestId:e.uuid(),provider:e.literal("google"),purchaseIntentId:e.uuid(),productId:e.string().min(1).max(255).optional(),purchaseToken:e.string().min(1).max(16384)})]),ui=e.strictObject({requestId:e.uuid(),orderId:e.uuid(),purchaseIntentId:e.uuid(),status:e.enum(["created","pending","trialing","paid","cancelled","failed"]),currency:c,refunded:e.boolean(),completion:e.strictObject({transactionIds:e.array(e.string().min(1).max(255)).min(1).max(50).refine(t=>new Set(t).size===t.length),membership:e.boolean()}).nullable()});var un=e.string().min(1).regex(/^[a-zA-Z0-9_-]+$/),pi=e.enum(["single_use","continuous_use"]),Oe=e.record(e.string(),e.union([e.string(),e.number(),e.boolean()]).transform(String).pipe(e.string())),di=e.string().min(1).max(64).refine(t=>!t.includes("::")),li={credit_amount:e.number(),tier_behavior:e.never().optional(),tiers:e.never().optional()},gi={credit_amount:e.never().optional(),tier_behavior:e.literal("graduated"),tiers:e.array(e.strictObject({to:e.union([e.number(),e.literal("inf")]),credit_amount:e.number()}))},dn=e.union([e.strictObject({match:Oe,priority:e.number().int().optional(),...li}),e.strictObject({match:Oe,priority:e.number().int().optional(),...gi})]),mn=e.strictObject({match:Oe,factor:e.number().positive().optional(),add:e.number().optional()}).refine(t=>t.factor!==void 0||t.add!==void 0),mi={metered_feature_id:e.string(),feature_amount:e.number().optional(),dimensions:e.record(di,dn).optional(),multipliers:e.record(di,mn).optional()},Ae=e.union([e.strictObject({...mi,...li}),e.strictObject({...mi,...gi})]),ee=e.number().min(-100),hi=e.record(e.string(),e.strictObject({markup:ee})).nullish(),te=e.record(e.string().regex(/.+\/.+/),e.strictObject({markup:ee.optional(),input_cost:e.number().min(0).optional(),output_cost:e.number().min(0).optional()})).nullish(),pn=e.strictObject({default_markup:ee.optional(),provider_markups:hi,model_markups:te}),Na=e.strictObject({schema:e.array(Ae).optional(),markups:pn.optional()}),ln=e.strictObject({filters:e.array(e.strictObject({property:e.string(),operator:e.string(),value:e.array(e.string())})),aggregate:e.strictObject({type:e.string(),property:e.string().nullable()}),usage_type:pi}),fi=e.strictObject({schema:e.array(Ae).min(1).refine(t=>new Set(t.map(n=>n.metered_feature_id)).size===t.length,"Credit rates must name each metered feature once"),invoice_credit:e.boolean().optional(),usage_type:pi.default("single_use").overwrite(()=>"single_use"),default_markup:ee.optional(),provider_markups:hi}),Pe=fi.safeExtend({schema:e.array(Ae).length(0)}),Y={id:un,name:e.string().min(1),display:e.strictObject({singular:e.string().optional(),plural:e.string().optional()}).nullish(),event_names:e.array(e.string()).default([]),model_markups:te,stripe_meter:e.strictObject({id:e.string(),event_name:e.string()}).nullish(),stripe_product_id:e.string().nullish()},je=t=>e.discriminatedUnion("type",[e.strictObject({...Y,...t,type:e.literal("boolean"),config:e.null()}),e.strictObject({...Y,...t,type:e.literal("metered"),config:ln}),e.strictObject({...Y,...t,type:e.literal("credit_system"),config:fi}),e.strictObject({...Y,...t,type:e.literal("ai_credit_system"),config:Pe})]),Va=je({}),gn=e.strictObject({id:e.boolean(),type:e.boolean(),usage_type:e.boolean()}),hn={internal_id:e.uuid(),org_id:e.uuid(),created_at:e.number(),env:e.enum(["sandbox","live"]),archived:e.boolean(),project_id:e.uuid(),environment_id:e.uuid(),revision:e.number().int().nonnegative(),update_rules:gn},bi=je(hn),Qa=e.strictObject({rows:e.array(bi).max(200),nextCursor:e.uuid().nullable()}),Za=e.strictObject({features:e.array(bi).max(500),limited:e.boolean()}),Ka=e.union([je({action:e.literal("save"),internal_id:e.uuid().nullable(),revision:e.number().int().nonnegative()}),e.strictObject({action:e.enum(["archive","restore","delete"]),internal_id:e.uuid(),revision:e.number().int().nonnegative()})]);var _e=e.uuid().refine(t=>t===t.toLowerCase(),"Product references require canonical lowercase UUIDs"),fn=e.record(e.string(),e.json()).refine(t=>Array.from(JSON.stringify(t)).length<=4e3,"Offering metadata exceeds 4000 characters"),bn=3,z=20,xn=bn*z,Ce=e.strictObject({type:e.literal("product"),productId:_e}),xi={type:e.literal("group"),key:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),name:e.string().trim().min(1).max(80)},Sn=e.discriminatedUnion("type",[Ce,e.strictObject({...xi,items:e.array(Ce).max(z)})]),yn=e.discriminatedUnion("type",[Ce,e.strictObject({...xi,items:e.array(Sn).max(z)})]),In=e.array(yn).max(z).superRefine((t,n)=>{let a=new Set,o=new Set,m=0;function Qe(Vr){for(let S of Vr){m++;let Ze=S.type==="product"?a:o,Ke=S.type==="product"?S.productId:S.key;Ze.has(Ke)&&n.addIssue({code:"custom",message:S.type==="product"?"Duplicate Offering Product reference":"Duplicate Offering group key"}),Ze.add(Ke),S.type==="group"&&Qe(S.items)}}Qe(t),(a.size>z||m>xn)&&n.addIssue({code:"custom",message:"Offering item limit exceeded"})});function Re(t){return t.items.flatMap(n=>n.type==="product"?[n.productId]:Re(n))}var C=e.strictObject({lookupKey:e.string().trim().min(1).max(200),displayName:e.string().trim().min(1).max(1500),items:In,metadata:fn}),vn=e.strictObject({product:e.record(e.string(),e.json()),prices:e.array(e.record(e.string(),e.json())),entitlements:e.array(e.record(e.string(),e.json())),freeTrials:e.array(e.record(e.string(),e.json())),licenses:e.array(e.record(e.string(),e.json()))}),Si=C.extend({id:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),state:e.enum(["active","archived"]),isCurrent:e.boolean(),revision:e.number().int().nonnegative(),publishedVersionId:e.uuid().nullable(),createdAt:e.iso.datetime({offset:!0})}).superRefine((t,n)=>{t.isCurrent&&(t.state!=="active"||!t.publishedVersionId)&&n.addIssue({code:"custom",message:"Current Offering must be active and published"})}),yi=e.strictObject({id:e.uuid(),offeringId:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),version:e.number().int().positive(),document:C,productEvidence:e.record(_e,vn),createdAt:e.iso.datetime({offset:!0})}).superRefine((t,n)=>{let a=Re(t.document);(!a.length||Pn(t.document).length>0||Object.keys(t.productEvidence).length!==a.length||a.some(o=>!Object.hasOwn(t.productEvidence,o)))&&n.addIssue({code:"custom",message:"Published Offering requires evidence for every Product"})}),On=e.strictObject({rows:e.array(Si).max(200),versions:e.array(yi).max(500)}),Xa=e.discriminatedUnion("action",[e.strictObject({action:e.literal("create"),document:C}),e.strictObject({action:e.literal("save"),id:e.uuid(),revision:e.number().int().nonnegative(),document:C}),e.strictObject({action:e.enum(["publish","set_current","archive","restore"]),id:e.uuid(),revision:e.number().int().nonnegative()})]),Ja=e.strictObject({record:Si,version:yi.nullable()}),Ii=e.discriminatedUnion("type",[e.strictObject({type:e.literal("current")}),e.strictObject({type:e.literal("id"),id:e.uuid()}),e.strictObject({type:e.literal("lookup_key"),lookupKey:e.string().min(1).max(200)}),e.strictObject({type:e.literal("version"),versionId:e.uuid()})]),An=e.strictObject({internalId:_e,id:e.string(),name:e.string().nullable(),version:e.number().int().positive(),archived:e.boolean()}),Ya=On.extend({products:e.array(An).max(500),pagination:e.strictObject({rows:e.string().nullable(),versions:e.string().nullable(),products:e.string().nullable()}).optional()});function Pn(t){let n=[];Re(t).length||n.push("Select at least one Product before publishing");function a(o){for(let m of o)m.type==="group"&&(m.items.length||n.push("Every published group requires a Product"),a(m.items))}return a(t.items),n}var vi=e.strictObject({id:e.uuid(),offeringId:e.uuid(),version:e.number().int().positive(),document:C});var Oi={requestId:e.uuid(),sourceId:e.uuid(),expectedAvailable:j},Ai=e.discriminatedUnion("action",[e.strictObject({...Oi,action:e.enum(["add","subtract","set_remaining"]),amount:s}),e.strictObject({...Oi,action:e.literal("edit"),granted:s,expiresAt:e.iso.datetime({offset:!0}).nullable(),nextResetAt:e.iso.datetime({offset:!0}).nullable(),expectedRevision:e.number().int().nonnegative()})]),we=e.strictObject({sourceId:e.uuid(),available:j,held:j,spent:j,adjustmentGrantId:e.uuid().nullable()}),Pi=we.extend({granted:j,expiresAt:e.iso.datetime({offset:!0}).nullable(),nextResetAt:e.iso.datetime({offset:!0}).nullable(),revision:e.number().int().nonnegative()});var ji=e.discriminatedUnion("action",[e.object({action:e.literal("upsert"),externalId:e.string().min(1).max(128),name:e.string().trim().min(1).max(80)}).strict(),e.object({action:e.literal("archive"),entityId:e.uuid()}).strict()]),Ci=e.object({id:e.uuid(),externalId:e.string().min(1).max(128),name:e.string().min(1).max(80),archived:e.boolean()}).strict();var _i=e.enum(["minute","hour","day","week","month","quarter","semi_annual","year","lifetime"]),Ri=e.number().int().min(1).max(1e3),ie=e.object({cap:s.refine(t=>/[1-9]/.test(t)).nullable(),capPercentage:e.number().positive().max(1e4).nullable(),cycles:e.number().int().min(1).max(1200).nullable()}).strict().refine(t=>t.cap===null||t.capPercentage===null,"Choose a fixed or percentage cap");var v=e.iso.datetime({offset:!0}),wi=s.refine(t=>/[1-9]/.test(t)),Bi=e.strictObject({interval:_i.exclude(["lifetime"]),count:Ri}),jn=e.strictObject({action:e.literal("create"),requestId:e.uuid(),internal_feature_id:e.uuid(),entityId:e.uuid().nullable(),amount:wi.nullable(),expiresAt:v.nullable(),reset:Bi.nullable(),rollover:ie.nullable(),nextResetAt:v.nullable()}).refine(t=>t.amount!==null||t.reset===null&&t.rollover===null,"Unlimited grants cannot reset or roll over").refine(t=>!t.rollover||t.reset!==null,"Rollover requires a recurring grant").refine(t=>t.nextResetAt===null||t.reset!==null&&(t.expiresAt===null||Date.parse(t.nextResetAt)<Date.parse(t.expiresAt)),"The first reset needs a reset interval and must precede expiry"),qi=e.discriminatedUnion("action",[jn,e.strictObject({action:e.literal("update"),requestId:e.uuid(),grantId:e.uuid(),revision:e.number().int().nonnegative(),amount:wi.nullable(),expiresAt:v.nullable(),rollover:ie.nullable(),nextResetAt:v.nullable()}),e.strictObject({action:e.enum(["add","subtract","set_remaining"]),requestId:e.uuid(),grantId:e.uuid(),revision:e.number().int().nonnegative(),amount:s}),e.strictObject({action:e.literal("revoke"),requestId:e.uuid(),grantId:e.uuid(),revision:e.number().int().nonnegative()})]),Be=e.strictObject({id:e.uuid(),internal_feature_id:e.uuid(),entityId:e.uuid().nullable(),amount:s.nullable(),reset:Bi.nullable(),rollover:ie.nullable(),nextResetAt:v.nullable(),startsAt:v,expiresAt:v.nullable(),revision:e.number().int().nonnegative(),revoked:e.boolean(),available:p,held:p,spent:p}),Ti=e.strictObject({customerId:e.uuid(),after:e.uuid().nullable(),limit:e.number().int().min(1).max(100)}),ki=e.strictObject({rows:e.array(Be).max(100),nextCursor:e.uuid().nullable()});var O=e.iso.datetime({offset:!0}),x=e.string().regex(/^-?(0|[1-9]\d{0,23})(\.\d{1,12})?$/),Cn=e.discriminatedUnion("kind",[e.object({kind:e.literal("absolute"),from:O,to:O}).strict(),e.object({kind:e.literal("last_days"),days:e.union([e.literal(1),e.literal(7),e.literal(30),e.literal(90)])}).strict(),e.object({kind:e.literal("billing_cycles"),membershipId:e.uuid(),count:e.number().int().min(1).max(12),includeCurrent:e.boolean()}).strict()]),zi=e.string().max(100).refine(t=>{if(t!=="UTC"&&!/^[A-Za-z_]+(?:\/[A-Za-z0-9_+\-]+)+$/.test(t))return!1;try{return new Intl.DateTimeFormat("en",{timeZone:t}),!0}catch{return!1}},"Use an IANA timezone"),_n=e.object({key:e.string().regex(/^[a-z][a-z0-9_]{0,63}$/),values:e.array(e.string().max(120)).min(1).max(20).refine(t=>new Set(t).size===t.length)}).strict(),A=e.object({range:Cn,timezone:zi,filterBy:e.array(_n).max(5).refine(t=>new Set(t.map(n=>n.key)).size===t.length),interval:e.enum(["hour","day","week","month"]),internal_feature_id:e.uuid().nullable(),entityId:e.uuid().nullable(),topN:e.number().int().min(1).max(50).nullable(),groupBy:e.union([e.enum(["customer","entity","entitlement","source","resource","dimension","plan"]),e.string().regex(/^properties\.[a-z][a-z0-9_]{0,63}$/)]),after:e.object({bucket:O,group:e.string().max(240),isOther:e.boolean(),internal_feature_id:e.uuid(),resourceId:e.uuid()}).strict().nullable(),limit:e.number().int().min(1).max(100)}).strict().superRefine((t,n)=>{if(t.range.kind!=="absolute"){t.interval==="hour"&&t.range.kind==="last_days"&&t.range.days>31&&n.addIssue({code:"custom",message:"Hourly reports are bounded to 31 days"});return}let a=Date.parse(t.range.to)-Date.parse(t.range.from);(a<=0||a>366*864e5||t.interval==="hour"&&a>31*864e5)&&n.addIssue({code:"custom",message:"Reporting range must be positive and bounded (31 days hourly, 366 days otherwise)"})}),Ui=e.object({from:O,to:O,interval:e.enum(["hour","day","week","month"]),timezone:zi,rows:e.array(e.object({bucket:O,group:e.string().max(240),isOther:e.boolean(),internal_feature_id:e.uuid(),resourceId:e.uuid(),consumedUnits:x,refundedUnits:x,reservedUnits:x,charged:x,refunded:x,reserved:x,netUnits:x,netCharged:x}).strict()).max(100),nextCursor:e.object({bucket:O,group:e.string().max(240),isOther:e.boolean(),internal_feature_id:e.uuid(),resourceId:e.uuid()}).strict().nullable()}).strict();var _=e.string().regex(/^(0|[1-9]\d{0,29})$/),Mi=e.string().regex(/^(0|[1-9]\d{0,29})(\.\d{1,18})?$/),qe=e.strictObject({bucket:e.iso.datetime({offset:!0}),group:e.string().max(240),isOther:e.boolean(),internal_feature_id:e.uuid()}),Ei=e.strictObject({...A.shape,groupBy:e.union([e.enum(["customer","entity","entitlement"]),e.string().regex(/^properties\.[a-z][a-z0-9_]{0,63}$/)]),after:qe.nullable()}).superRefine((t,n)=>{let a=A.safeParse({...t,after:null});if(!a.success)for(let o of a.error.issues)n.addIssue({code:"custom",path:o.path,message:o.message})}),Gi=e.strictObject({from:e.iso.datetime({offset:!0}),to:e.iso.datetime({offset:!0}),interval:A.shape.interval,timezone:A.shape.timezone,rows:e.array(e.strictObject({...qe.shape,eventCount:_,units:Mi,tokenEventCount:_,tokens:e.strictObject(Object.fromEntries(zt.map(t=>[t,_]))),totalTokens:_,providerCostEventCount:_,providerCostUsd:Mi,invalidTelemetryEventCount:_})).max(100),nextCursor:qe.nullable()});var Di=e.object({requestId:e.uuid(),items:e.array(e.object({customerId:e.uuid(),command:B.options[1]}).strict()).min(1).max(1e3)}).strict().refine(t=>new Set(t.items.map(n=>n.customerId+":"+n.command.idempotencyKey)).size===t.items.length,"Each logical event must appear once in a batch"),$i=e.object({batchId:e.uuid(),after:e.number().int().min(-1).max(999),limit:e.number().int().min(1).max(100)}).strict(),Li=e.object({batchId:e.uuid(),status:e.enum(["queued","complete"]),total:e.number().int().min(1).max(1e3),processed:e.number().int().min(0).max(1e3),items:e.array(e.object({position:e.number().int().min(0).max(999),customerId:e.uuid(),idempotencyKey:e.string().min(1).max(120),status:e.enum(["queued","accepted","rejected","failed"]),receipt:q.nullable(),errorCode:e.enum(["invalid_request","forbidden","conflict","internal_error"]).nullable()}).strict().refine(t=>t.status==="queued"?t.receipt===null&&t.errorCode===null:t.status==="failed"?t.receipt===null&&t.errorCode!==null:t.receipt!==null&&t.errorCode===null&&t.receipt.accepted===(t.status==="accepted"))).max(100),nextAfter:e.number().int().min(0).max(999).nullable()}).strict();var Rn=e.enum(["percentage_discount","fixed_discount","free_product","invoice_credits","feature_grant"]),Fi=e.enum(["draft","active","paused","archived"]),Ni=e.string().min(1).max(256),Vi=e.array(Ni).max(50).refine(t=>new Set(t).size===t.length,"Duplicate products"),wn=e.strictObject({duration:e.enum(["day","week","month","year"]),length:e.number().int().min(1).max(3660)}),Bn=e.strictObject({internal_feature_id:e.uuid(),allowance:e.number().nonnegative().max(1e15).nullable(),expiry:wn.nullable()}),qn=e.discriminatedUnion("type",[e.strictObject({type:e.literal("feature_grant"),grants:e.array(Bn).min(1).max(100).refine(t=>new Set(t.map(n=>n.internal_feature_id)).size===t.length,"Duplicate entitlement grants")}),e.strictObject({type:e.literal("free_product"),productId:Ni,duration:y}),e.strictObject({type:e.literal("invoice_credits"),amount:e.number().positive().max(1e8),duration:y,rollover:e.boolean(),productIds:Vi})]),Tn=e.string().regex(/^[a-zA-Z0-9_-]{1,64}$/),Qi=e.object({key:Tn,name:e.string().trim().min(1).max(80),configuration:qn}).strict(),Zi=e.string().regex(/^[A-Z0-9][A-Z0-9_-]{2,31}$/),Te=e.object({code:Zi,maxUses:e.number().int().min(1).max(1e6).nullable(),firstPurchaseOnly:e.boolean()}).strict(),Ki=e.object({key:e.string().regex(/^[a-z][a-z0-9_]{0,63}$/),name:e.string().trim().min(1).max(80),rewardId:e.uuid(),redeemOn:e.enum(["customer_creation","checkout"]),receivedBy:e.enum(["referrer","all"]),maxRedemptions:e.number().int().min(1).max(1e6).nullable(),productIds:Vi,excludeTrial:e.boolean()}).strict().refine(t=>t.redeemOn==="checkout"||t.productIds.length===0&&!t.excludeTrial,"Purchase restrictions require checkout trigger"),Wi={id:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),revision:e.number().int().nonnegative(),status:Fi,createdAt:e.iso.datetime({offset:!0}),updatedAt:e.iso.datetime({offset:!0})},kn=Qi.extend(Wi).strict(),zn=Ki.safeExtend(Wi).strict(),Rs=e.strictObject({id:e.uuid(),key:e.string(),name:e.string(),type:Rn,status:Fi,ended:e.boolean()}),ws=e.discriminatedUnion("action",[e.object({action:e.literal("save"),id:e.uuid().nullable(),revision:e.number().int().nonnegative(),input:Qi}).strict(),e.object({action:e.enum(["activate","pause","resume","archive","delete"]),id:e.uuid(),revision:e.number().int().nonnegative()}).strict()]),Bs=e.discriminatedUnion("action",[e.object({action:e.literal("save"),id:e.uuid().nullable(),revision:e.number().int().nonnegative(),input:Ki}).strict(),e.object({action:e.enum(["activate","pause","resume","archive","delete"]),id:e.uuid(),revision:e.number().int().nonnegative()}).strict()]),Hi=e.object({id:e.uuid(),rewardId:e.uuid(),programId:e.uuid().nullable(),customerId:e.uuid(),referrerId:e.uuid().nullable(),status:e.enum(["pending","applied","unavailable"]),result:e.record(e.string(),e.unknown()).nullable(),createdAt:e.iso.datetime({offset:!0})}).strict(),Xi=e.object({code:Zi,requestId:e.uuid()}).strict(),Ji=e.strictObject({redemptionId:e.uuid(),currency:c,requestId:e.uuid(),accepted:e.literal(!0)}),Un=e.strictObject({type:e.literal("checkout"),orderId:e.uuid(),productVersionId:e.uuid(),currency:c,duration:y,renewalAmountMinor:e.number().int().positive().max(1e8),status:e.enum(["created","pending","trialing","paid","cancelled","failed"]),url:e.url().nullable()}),Yi=e.discriminatedUnion("type",[Un,e.strictObject({type:e.literal("subscription"),operationId:e.uuid(),membershipId:e.uuid(),productVersionId:e.uuid(),currency:c,duration:y,renewalAmountMinor:e.number().int().positive().max(1e8),status:e.enum(["pending","running","applied","failed"])})]),er=e.object({programId:e.uuid(),requestId:e.uuid()}).strict(),tr=e.object({id:e.uuid(),programId:e.uuid(),code:Te.shape.code,createdAt:e.iso.datetime({offset:!0})}).strict(),qs=e.object({rows:e.array(kn).max(100),nextCursor:e.uuid().nullable()}).strict(),Ts=e.object({rows:e.array(zn).max(100),nextCursor:e.uuid().nullable()}).strict(),Mn=Te.extend({id:e.uuid(),redemptions:e.number().int().nonnegative()}).strict(),En=e.strictObject({id:e.uuid(),programId:e.uuid().nullable(),customerId:e.uuid().nullable(),referrerId:e.uuid().nullable(),code:e.string().nullable(),status:e.enum(["pending","triggered","applied"]),createdAt:e.iso.datetime({offset:!0})}),ks=e.object({codes:e.array(Mn).max(100),redemptions:e.array(En).max(100),customers:e.record(e.uuid(),e.string()),codesCursor:e.uuid().nullable(),redemptionsCursor:e.uuid().nullable()}).strict(),zs=e.discriminatedUnion("action",[e.object({action:e.literal("create"),rewardId:e.uuid(),revision:e.number().int().nonnegative(),input:Te}).strict(),e.object({action:e.literal("remove"),rewardId:e.uuid(),revision:e.number().int().nonnegative(),codeId:e.uuid()}).strict()]);var rr=e.object({customerId:e.uuid()}).strict(),nr=e.discriminatedUnion("action",[e.object({customerId:e.uuid(),requestId:e.uuid(),action:e.literal("assign"),poolId:e.uuid(),memberCustomerId:e.uuid()}).strict(),e.strictObject({customerId:e.uuid(),requestId:e.uuid(),action:e.literal("assign_entity"),poolId:e.uuid(),entityId:e.uuid()}),e.object({customerId:e.uuid(),requestId:e.uuid(),action:e.literal("release"),poolId:e.uuid(),slotId:e.uuid()}).strict()]),U=e.number().int().nonnegative(),ke=e.iso.datetime({offset:!0}),ze=e.strictObject({internalId:e.uuid(),id:e.string(),name:e.string().nullable(),version:e.number().int().positive()}),ir=e.enum(["active","past_due"]),Ue=e.strictObject({customerId:e.uuid(),licenses:e.array(e.strictObject({id:e.uuid(),linkId:e.uuid(),parent:e.strictObject({customerProductId:e.uuid(),status:ir,product:ze}),product:ze,planLicense:e.strictObject({id:e.uuid(),prepaidOnly:e.boolean(),isCustom:e.boolean()}).nullable(),granted:U,included:U,paidQuantity:U,usage:U,remaining:U,createdAt:ke}).refine(t=>t.granted===t.included+t.paidQuantity&&t.granted===t.usage+t.remaining,"Granted seats are included plus paid, and usage plus remaining")).max(2e3),assignments:e.array(e.strictObject({id:e.uuid(),linkId:e.uuid(),status:ir,product:ze,entity:e.strictObject({internalId:e.uuid(),id:e.string().nullable(),name:e.string().nullable()}).nullable(),beneficiary:e.strictObject({internalId:e.uuid(),id:e.string().nullable(),name:e.string().nullable()}).nullable(),startedAt:ke.nullable(),endedAt:ke.nullable()}).refine(t=>t.entity!==null||t.beneficiary!==null,"A seat assignment has a holder")).max(1e4),limited:e.boolean()});var ur=e.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/),Me=e.string().regex(/^(0|[1-9]\d{0,14})$/),R=e.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,30})?$/),Gn=e.string().regex(/^(?:[1-9]\d{0,7}|1\d{8}|200000000)$/),M=Gn,b=s.refine(t=>/[1-9]/.test(t)),u=e.iso.datetime({offset:!0}),re=t=>{let[n,a=""]=t.split(".");if(n===void 0||n==="")throw new Error("Invalid decimal value");return BigInt(n)*1000000n+BigInt(a.padEnd(6,"0"))},Dn=e.array(e.object({upTo:b.nullable(),unitAmountMinor:ur,flatAmountMinor:e.number().int().min(0).max(1e8).optional()}).strict()).min(1).max(12).refine(t=>{try{return t.at(-1)?.upTo===null&&t.slice(0,-1).every((n,a)=>{let o=t[a-1]?.upTo;return n.upTo!==null&&(a===0||o!=null&&re(n.upTo)>re(o))})}catch{return!1}},"Tier ceilings must increase and the final tier must be unbounded"),$n=e.discriminatedUnion("kind",[e.object({kind:e.literal("flat"),units:b,unitAmountMinor:ur}).strict(),e.object({kind:e.enum(["graduated","volume"]),units:b,tiers:Dn}).strict()]).refine(t=>t.kind==="flat"||!t.tiers.some(n=>(n.flatAmountMinor??0)>0)||t.kind==="volume"&&t.tiers.length>1,"Tier flat fees require volume pricing with multiple tiers"),Ln=e.strictObject({interval:e.enum(["month","year"]),count:e.number().int().min(1).max(12),anchor:e.enum(["membership","calendar"])}),E=e.object({currency:c,pricing:$n,billingCycle:Ln.optional()}).strict().refine(t=>t.pricing.kind!=="volume"||t.pricing.tiers.length===1,"Multiple volume tiers require prepaid billing");var ar={requestId:e.uuid(),productVersionId:e.uuid(),internal_feature_id:e.uuid(),currency:c},dr=e.strictObject({interval:e.enum(["hour","day","week","month"]),intervalCount:e.number().int().min(1).max(12),limit:e.number().int().min(1).max(1e6)}),mr=e.discriminatedUnion("kind",[e.object({...ar,kind:e.literal("auto_topup"),threshold:oe,quantity:b.refine(t=>Number(t)>=1,"AutoTopup quantity must be at least 1"),purchaseLimit:dr.optional()}).strict(),e.object({...ar,kind:e.literal("postpaid"),maxAmountMinorPerPeriod:M,maxOutstandingMinor:M}).strict()]),sr={productVersionId:e.uuid(),internal_feature_id:e.uuid(),currency:c},pr=e.discriminatedUnion("kind",[e.object({...sr,kind:e.literal("auto_topup"),threshold:oe,quantity:b.refine(t=>Number(t)>=1,"AutoTopup quantity must be at least 1"),purchaseLimit:dr.optional(),purchaseAmountMinor:M,purchaseUnits:b}).strict(),e.object({...sr,kind:e.literal("postpaid"),maxAmountMinorPerPeriod:M,maxOutstandingMinor:M,cashPrice:E}).strict().refine(t=>t.cashPrice.currency===t.currency,"Currency must match")]),ne=e.object({id:e.uuid(),terms:pr,status:e.enum(["prepared","active","revoked","blocked"]),createdAt:u,acceptedAt:u.nullable(),effectiveAt:u.nullable(),revokedAt:u.nullable()}).strict().refine(t=>(t.status==="prepared"?t.acceptedAt===null:!0)&&(t.status==="active"?t.acceptedAt!==null&&t.effectiveAt!==null:!0)&&(t.status==="revoked"?t.revokedAt!==null:t.revokedAt===null),"Authorization consent and revocation must be explicit"),lr=e.object({authorizationId:e.uuid(),terms:pr,setupUrl:e.url().nullable()}).strict(),gr=e.object({authorizationId:e.uuid(),accepted:e.literal(!0)}).strict(),hr=e.object({authorizationId:e.uuid(),requestId:e.uuid()}).strict(),fr=e.object({internal_feature_id:e.uuid(),entityId:e.uuid().nullable(),interval:e.enum(["day","week","month","year"]),anchor:e.enum(["billing_cycle","utc"]).optional(),basis:e.enum(["usage","credits"]),filter:h.optional(),limit:s.nullable(),thresholds:e.array(e.number().positive().max(1)).max(8),includedThresholds:e.array(e.number().positive().max(1)).max(8).optional(),absoluteThresholds:e.array(b).max(8).optional()}).strict().refine(t=>t.thresholds.every((n,a)=>{let o=t.thresholds[a-1];return a===0||o!==void 0&&n>o})&&(t.includedThresholds??[]).every((n,a,o)=>{let m=o[a-1];return a===0||m!==void 0&&n>m})&&(t.absoluteThresholds??[]).every((n,a,o)=>{let m=o[a-1];return a===0||m!==void 0&&re(n)>re(m)}),"Notification thresholds must increase"),Fn=fr.safeExtend({requestId:e.uuid()}),or={control:e.literal("overage"),requestId:e.uuid(),internal_feature_id:e.uuid(),entityId:e.uuid().nullable()},Nn=e.discriminatedUnion("action",[e.strictObject({...or,action:e.literal("set"),allowed:e.boolean().nullable(),overageLimit:s.nullable(),skipOverageBilling:e.boolean()}),e.strictObject({...or,action:e.literal("remove")})]),br=e.union([Fn,Nn]),Vn=e.strictObject({internal_feature_id:e.uuid(),entityId:e.uuid().nullable(),allowed:e.boolean().nullable(),overageLimit:s.nullable(),skipOverageBilling:e.boolean(),interval:e.enum(["day","week","month","year"]),startsAt:u,endsAt:u,used:e.string().regex(/^(0|[1-9]\d{0,23})(\.\d{1,6})?$/),reserved:e.string().regex(/^(0|[1-9]\d{0,23})(\.\d{1,6})?$/),remaining:e.string().regex(/^-?(0|[1-9]\d{0,23})(\.\d{1,6})?$/).nullable()}),Qn=e.object({internal_feature_id:e.uuid(),entityId:e.uuid().nullable(),interval:e.enum(["day","week","month","year"]),anchor:e.enum(["billing_cycle","utc"]).optional(),basis:e.enum(["usage","credits"]),filter:h.optional(),startsAt:u,endsAt:u,used:p,reserved:p,limit:s.nullable(),thresholds:e.array(e.number().positive().max(1)).max(8),notifiedThresholds:e.array(e.number().positive().max(1)).max(1024),includedThresholds:e.array(e.number().positive().max(1)).max(8).optional(),includedAllowance:e.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,12})?$/).optional(),notifiedIncludedThresholds:e.array(e.number().positive().max(1)).max(1024).optional(),absoluteThresholds:e.array(b).max(8).optional(),notifiedAbsoluteThresholds:e.array(b).max(1024).optional()}).strict().refine(t=>t.basis!=="usage"||s.safeParse(t.used).success&&s.safeParse(t.reserved).success,"Usage counters retain six decimals; credit costs retain twelve"),Zn=e.object({authorizationId:e.uuid(),status:e.enum(["idle","pending","blocked"]),taskId:e.uuid().nullable(),invoiceId:e.uuid().nullable(),hostedInvoiceUrl:e.url().nullable(),purchaseCount:e.number().int().nonnegative(),purchaseWindowEndsAt:u.nullable(),attemptCount:e.number().int().nonnegative(),failedAttemptCount:e.number().int().nonnegative(),suspendedAt:u.nullable(),nextAttemptAt:u.nullable(),failureReason:e.string().min(1).max(240).nullable()}).strict(),xr=e.object({internal_feature_id:e.uuid().optional(),entityId:e.uuid().optional()}).strict(),Ee=e.object({authorizations:e.array(ne).max(100),limits:e.array(fr).max(100),overages:e.array(Vn).max(100).optional(),windows:e.array(Qn).max(200),autoTopups:e.array(Zn).max(100),limited:e.boolean()}).strict(),Kn=e.object({id:e.uuid(),internal_feature_id:e.uuid(),productVersionId:e.uuid(),authorizationId:e.uuid(),entityId:e.uuid().nullable(),units:s,amountMinor:R,cashPrice:E}).strict(),G=e.object({id:e.uuid(),sourceKind:e.enum(["product","usage","manual"]),providerInvoiceId:e.string().min(1).max(240).nullable(),status:e.enum(["accruing","open","pending","paid","failed","void"]),currency:c,startsAt:u.nullable(),endsAt:u.nullable(),amountMinor:e.string().regex(/^-?(0|[1-9]\d{0,14})$/),grossAmountMinor:e.string().regex(/^-?(0|[1-9]\d{0,14})$/),discountMinor:Me,paidAmountMinor:Me,refundedAmountMinor:Me,createdAt:u,hostedInvoiceUrl:e.url().nullable(),adjustment:e.object({originalInvoiceId:e.uuid(),amountMinor:e.string().regex(/^-?(0|[1-9]\d{0,8})$/).refine(t=>t!=="-0"&&/^-?(0|[1-9]\d{0,8})$/.test(t)&&BigInt(t)>=-200000000n&&BigInt(t)<=200000000n,"Invoice adjustment exceeds the bounded minor amount"),acceptedAt:u.nullable(),reason:e.string().min(1).max(500).optional()}).strict().nullable(),lines:e.array(Kn).max(100),linesLimited:e.boolean()}).strict(),Sr=e.object({invoiceId:e.uuid(),accepted:e.literal(!0)}).strict(),yr=e.strictObject({requestId:e.uuid(),originalInvoiceId:e.uuid(),amountMinor:e.string().regex(/^[1-9]\d{0,8}$/).refine(t=>/^[1-9]\d{0,8}$/.test(t)&&BigInt(t)<=200000000n,"Supplemental amount exceeds the bounded minor amount"),reason:e.string().trim().min(1).max(500)}),Ir=e.object({after:e.uuid().nullable(),limit:e.number().int().min(1).max(100)}).strict(),vr=e.object({rows:e.array(G).max(100),nextCursor:e.uuid().nullable()}).strict(),cr=e.strictObject({id:e.string(),coupon:e.string(),start:e.number().nonnegative(),end:e.number().nullable()}),Wn=e.strictObject({subscriptionId:e.string(),customerId:e.string(),accountId:e.string(),sourceItems:e.array(e.strictObject({id:e.string(),price_id:e.string(),quantity:e.number().int(),discounts:e.array(cr).optional()})).max(100),items:e.array(e.strictObject({id:e.string(),price:e.string(),quantity:e.number().int(),discounts:e.array(e.strictObject({coupon:e.string().optional(),terms:e.strictObject({id:e.string(),name:e.string().optional(),percent_off:e.number().optional(),amount_off:e.number().optional(),currency:e.string().optional(),duration:e.enum(["once","forever","repeating"]),duration_in_months:e.number().optional()}).optional(),discount:e.string().optional(),receipt:cr.optional()})).max(20)})).max(100)}),Or=e.strictObject({membershipId:e.uuid(),requestId:e.uuid(),grantIds:e.array(e.uuid()).max(20).refine(t=>new Set(t).size===t.length,"Duplicate Coupon grants")}),Ar=e.strictObject({membershipId:e.uuid(),operationId:e.uuid(),status:e.enum(["pending","effective"]),execution:Wn.nullable(),grants:e.array(e.strictObject({id:e.uuid(),couponId:e.uuid(),name:e.string(),discount:nt,duration:y,startedAt:u.nullable()})).max(20)});var l={repositories:20,branches:4,keys:2e3,references:1e4,referencesPerKey:2e3,reportBytes:1048576,files:1e4,sourceBytes:1e8},D=t=>new Set(t).size===t.length,Ge=e.string().regex(/^[a-zA-Z0-9_.:|-]{1,256}$/),Hn=e.string().max(512).regex(/^[\w.-]+(?:\/[\w.-]+){1,5}$/).refine(t=>!t.split("/").some(n=>n==="."||n==="..")),$=e.string().min(1).max(200).regex(/^[a-zA-Z0-9_./-]+$/).refine(t=>!t.includes("..")&&!t.endsWith(".")&&!t.split("/").some(n=>!n||n.startsWith(".")||n.endsWith(".lock"))),Xn=e.string().min(1).max(512).refine(t=>!/[\\\u0000-\u001f\u007f]/.test(t)&&!t.startsWith("/")&&!t.split("/").some(n=>!n||n==="."||n==="..")),Pr=e.string().min(1).max(256).regex(/^[a-zA-Z0-9_./*?-]+$/).refine(t=>!t.startsWith("/")&&!t.split("/").some(n=>!n||n==="."||n===".."));var jr=e.strictObject({id:e.uuid(),repo:Hn,platform:e.enum(["github","gitlab","bitbucket"]),branches:e.array($).min(1).max(4).refine(D),workflow:e.string().regex(/^\.github\/workflows\/[a-zA-Z0-9_-]+\.ya?ml$/),keyIds:e.array(e.uuid()).min(1).max(4).refine(D),include:e.array(Pr).min(1).max(16),exclude:e.array(Pr).max(16),methods:e.array(e.string().regex(/^[a-zA-Z_$][\w$]{0,63}$/)).min(1).max(32).refine(D),maxAgeHours:e.number().int().min(1).max(720)}),Cr=jr.extend({revision:e.number().int().positive()}),Qs=e.strictObject({repository:jr,expectedRevision:e.number().int().min(0)}).refine(({repository:t})=>t.platform==="gitlab"||t.repo.split("/").length===2,{path:["repository","repo"]}),_r=e.strictObject({repositoryId:e.uuid(),branch:$}),Jn=e.array(Ge).max(l.keys).refine(D),Rr=e.strictObject({repository:Cr.omit({keyIds:!0}),branch:$,keys:Jn,keySetHash:e.string().regex(/^[a-f0-9]{64}$/)}),Yn=e.strictObject({filePath:Xn,startingLineNumber:e.number().int().min(1).max(1e7)}),De=e.strictObject({protocol:e.literal(1),repositoryId:e.uuid(),branch:$,workflow:e.string().max(200),configurationRevision:e.number().int().positive(),keySetHash:e.string().regex(/^[a-f0-9]{64}$/),commit:e.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/),scanId:e.uuid(),runNumber:e.number().int().min(1).max(Number.MAX_SAFE_INTEGER),runAttempt:e.number().int().min(1).max(1e4),scannerVersion:e.literal("1"),scannedAt:e.iso.datetime({offset:!0}),coverage:e.strictObject({complete:e.literal(!0),files:e.number().int().min(0).max(l.files),sourceBytes:e.number().int().min(0).max(l.sourceBytes),unresolvedCalls:e.number().int().min(0).max(1e6),unsupportedFiles:e.number().int().min(0).max(l.files)}),features:e.array(e.strictObject({key:Ge,refs:e.array(Yn).max(l.referencesPerKey)})).max(l.keys)}).superRefine((t,n)=>{D(t.features.map(a=>a.key))||n.addIssue({code:"custom",path:["features"],message:"Duplicate feature"}),t.features.reduce((a,o)=>a+o.refs.length,0)>l.references&&n.addIssue({code:"custom",path:["features"],message:"Reference budget exceeded"})}),$e=e.strictObject({scanId:e.uuid(),commit:e.string(),receivedAt:e.string(),references:e.number().int().nonnegative(),removedReferences:e.number().int().nonnegative()}),ea=$e.extend({repositoryId:e.uuid(),branch:$,workflow:e.string(),digest:e.string(),configurationRevision:e.number().int().positive(),runNumber:e.number().int().positive(),runAttempt:e.number().int().positive(),scannedAt:e.string(),keySetHash:e.string(),coverage:De.shape.coverage}),ta=e.strictObject({repositories:e.array(Cr).max(l.repositories),scans:e.array(ea).max(l.repositories*l.branches)}),ia=e.strictObject({key:Ge,references:e.number().int().nonnegative(),coveredTargets:e.number().int().nonnegative(),expiredTargets:e.number().int().nonnegative(),uncertainTargets:e.number().int().nonnegative()}),Zs=e.strictObject({available:e.boolean().default(!0),settings:ta,expectedTargets:e.number().int().min(0).max(80),features:e.array(ia).max(2001),truncated:e.boolean()});var g=e.iso.datetime({offset:!0}),wr=e.strictObject({invoiceId:e.uuid(),after:e.string().min(1).max(180).nullable(),limit:e.number().int().min(1).max(100)}),ra=e.strictObject({kind:e.literal("product"),key:e.string(),productVersionId:e.uuid(),productName:e.string(),itemKey:e.string(),entityId:e.uuid().nullable(),quantity:e.number().positive(),subtotalMinor:e.string().regex(/^-?\d+$/),discountMinor:e.string().regex(/^\d+$/),taxMinor:e.string().regex(/^-?\d+$/).nullable(),totalMinor:e.string().regex(/^-?\d+$/),startsAt:g.nullable(),endsAt:g.nullable(),providerLineId:e.string().nullable(),providerItemId:e.string()}),Br=e.strictObject({invoice:G,items:e.array(e.discriminatedUnion("kind",[ra,e.strictObject({kind:e.literal("invoice_credit"),key:e.string(),internal_feature_id:e.uuid(),internal_credit_feature_id:e.uuid(),name:e.string(),units:s,reserved:s,amountMinor:R,grossAmountMinor:R,creditsAppliedMinor:R,properties:h,cashPrice:E,providerItemId:e.string().nullable(),creditProviderItemId:e.string().nullable()}),e.strictObject({kind:e.literal("usage"),key:e.string(),internal_feature_id:e.uuid(),name:e.string(),units:s,reserved:s,amountMinor:R,cashPrice:E})])).max(100),nextCursor:e.string().min(1).max(180).nullable()}),na=e.string().regex(/^-?(0|[1-9]\d{0,17})(\.\d{1,12})?$/).refine(t=>!/^\-0(?:\.0+)?$/.test(t)),Le=e.strictObject({from:g,to:g,entityId:e.uuid().optional(),snapshotAt:g.nullable(),after:e.strictObject({at:g,id:e.uuid(),position:e.number().int().nonnegative()}).nullable(),limit:e.number().int().min(1).max(100)}).refine(t=>Date.parse(t.from)<Date.parse(t.to)&&Date.parse(t.to)-Date.parse(t.from)<=366*864e5,"Statement range must be positive and at most 366 days").refine(t=>t.after===null||t.snapshotAt!==null,"A cursor requires the original snapshot time"),qr=e.strictObject({customerId:e.uuid(),entityId:e.uuid().nullable(),from:g,to:g,snapshotAt:g,totals:e.array(e.strictObject({internal_credit_feature_id:e.uuid(),name:e.string(),consumed:p,refunded:p,net:na})).max(1e3),rows:e.array(e.strictObject({operationId:e.uuid(),position:e.number().int().nonnegative(),kind:e.enum(["consume","confirm","refund"]),originalId:e.uuid().nullable(),occurredAt:g,internal_feature_id:e.uuid(),entitlementName:e.string(),sourceId:e.uuid(),internal_credit_feature_id:e.uuid(),creditName:e.string(),units:yt,amount:p,pricing:e.array(St).max(12),properties:h})).max(100),nextCursor:Le.shape.after});var d=e.string().min(1).max(200),ae=e.iso.datetime({offset:!0}),L=e.number().int().min(1).max(Number.MAX_SAFE_INTEGER),Fe=e.number().int().min(0).max(1e12),zr=e.number().int().min(1).max(1e12),Tr={...f,type:e.literal("coupon.redeemed"),grantId:e.uuid()},kr={...f,type:e.literal("usage.observed"),merchantTransactionId:d,resource:d,unit:d,quantity:zr},aa=e.strictObject({...f,type:e.literal("fulfillment.updated"),operationId:e.uuid(),merchantFulfillmentId:d,status:e.enum(["pending","applied","failed"])}),sa=e.strictObject({...f,type:e.literal("benefit.claimed"),merchantBenefitId:d,resource:d,unit:d,quantity:zr,expiresAt:ae.nullable(),revision:L}),oa=e.strictObject({...f,type:e.literal("benefit.closed"),merchantBenefitId:d,status:e.enum(["failed","expired","canceled"]),revision:L}),ca=e.strictObject({...f,type:e.literal("benefit.updated"),merchantBenefitId:d,status:e.enum(["active","expired","revoked"]),remainingQuantity:Fe.nullable(),expiresAt:ae.nullable(),revision:L}),ua=e.strictObject({...f,type:e.literal("authorization.updated"),merchantAuthorizationId:d,kind:e.literal("auto_topup"),status:e.enum(["pending","effective","revoked","failed"]),termsReference:d.nullable(),revision:L}),da=e.strictObject({...f,type:e.literal("balance.observed"),resource:d,unit:d,availableQuantity:Fe,reservedQuantity:Fe,periodStartsAt:ae.nullable(),periodEndsAt:ae.nullable(),revision:L}),Ur=e.union([e.discriminatedUnion("type",[...He,aa,sa,oa,ca,ua,da]),e.strictObject({...Tr,productVersionId:e.uuid(),subscriptionId:e.string().trim().min(1).max(255)}),e.strictObject({...Tr,merchandiseId:e.uuid()}),e.strictObject({...kr,operation:e.literal("consume")}),e.strictObject({...kr,operation:e.literal("reverse"),reversalOf:d})]),Mr=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)});var Er=st,pa=Er.extend({invoice_id:Er.shape.invoice_id.meta({description:"The Indiana invoice ID to void and replace.",example:"9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"})}),Ne=e.strictObject({name:e.string().trim().min(1).max(255),memo:e.string().max(1e4).nullable().optional(),footer:e.string().max(1e4).nullable().optional(),net_terms_days:e.number().int().positive().nullable().optional()}),la=Ne.extend({id:e.string().min(1).max(255),created_at:e.number().nullable()}),Gr=e.strictObject({items:e.array(la).max(50),nextCursor:e.uuid().nullable()}),so=e.discriminatedUnion("action",[e.strictObject({action:e.literal("create"),requestId:e.uuid(),values:Ne}),e.strictObject({action:e.literal("update"),id:e.string().min(1).max(255),values:Ne}),e.strictObject({action:e.literal("delete"),id:e.string().min(1).max(255)})]),Dr=e.discriminatedUnion("action",[e.strictObject({action:e.literal("create"),requestId:e.uuid(),params:P}),e.strictObject({action:e.enum(["finalize","send","pay","void"]),requestId:e.uuid(),invoiceId:e.uuid()}),e.strictObject({action:e.literal("reissue"),requestId:e.uuid(),invoiceId:e.uuid(),params:pa})]),Ve=e.strictObject({id:e.uuid(),customerId:e.uuid(),providerInvoiceId:e.string().nullable(),status:e.enum(["draft","open","paid","void","uncollectible"]),currency:e.string(),totalMinor:e.string().regex(/^-?\d+$/),paidMinor:e.string().regex(/^\d+$/),refundedMinor:e.string().regex(/^\d+$/),hostedInvoiceUrl:e.url().nullable(),createdAt:e.number(),collectionMethod:e.enum(["send_invoice","charge_automatically"]).nullable()}),$r=Ve.extend({lines:e.array(e.strictObject({id:e.uuid(),description:e.string(),amountMinor:e.string().regex(/^-?\d+$/),netAmountMinor:e.string().regex(/^-?\d+$/),quantity:e.number().nullable(),periodStart:e.number().nullable(),periodEnd:e.number().nullable()})).max(1e3)}),w=e.strictObject({taskId:e.uuid(),status:e.enum(["ready","running","done","dead"]),invoice:Ve.nullable(),errorCode:e.string().nullable()}),Lr=e.strictObject({items:e.array(Ve).max(50),nextCursor:e.uuid().nullable(),operations:e.array(w).max(50),operationsLimited:e.boolean()});var ga=e.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"]),Fr={scope:se,permissions:e.array(ga),expiresAt:e.iso.datetime().nullable()},ec=e.discriminatedUnion("kind",[e.object({...Fr,kind:e.literal("server"),keyId:e.string().min(1)}),e.object({...Fr,kind:e.literal("customer"),customerId:e.string().min(1),identityKind:e.enum(["identified","guest"]),expiresAt:e.iso.datetime()})]),r=e.object({requestId:e.uuid(),scope:se}).strict(),ha=Ct.safeExtend({fingerprint:he.optional()}).strict(),fa=r.extend({customer:Q,created:e.boolean()});function Nr(){return r.extend({offer:ue.nullable(),reason:at.nullable()})}var i={sendMessage:{method:"POST",path:"messaging/send",permission:"messaging:write",audience:"server",request:Nt,response:r.extend({message:e.object({messageId:e.uuid(),channel:T,acceptedAt:e.iso.datetime({offset:!0}),status:e.enum(["accepted","sending","completed","canceled"]),replayed:e.boolean()})})},readMessage:{method:"POST",path:"messaging/read",permission:"messaging:write",audience:"server",request:e.strictObject({messageId:e.uuid()}),response:r.extend({message:e.object({id:e.uuid(),channel:T,status:e.enum(["accepted","sending","completed","canceled"]),deliveries:e.array(e.object({id:e.uuid(),status:Qt,attempts:e.number().int().nonnegative(),receipts:e.array(e.object({kind:Zt,occurredAt:e.iso.datetime({offset:!0}).nullable()}))}))})})},bindPushInstallation:{method:"POST",path:"push/installations/bind",permission:"messaging:write",audience:"customer",request:Ut,response:r.extend({installation:Z})},readPushInstallation:{method:"POST",path:"push/installations/read",permission:"messaging:write",audience:"customer",request:Mt,response:r.extend({installation:Z})},updatePushAddress:{method:"POST",path:"push/installations/address",permission:"messaging:write",audience:"customer",request:Et,response:r.extend({installation:Z})},readMessagingPreference:{method:"POST",path:"messaging/preferences/read",permission:"messaging:write",audience:"customer",request:e.strictObject({channel:T}),response:r.extend({preference:fe})},setMessagingPreference:{method:"POST",path:"messaging/preferences/set",permission:"messaging:write",audience:"customer",request:Vt,response:r.extend({preference:fe})},listInvoiceTemplates:{method:"POST",path:"invoices/templates",permission:"billing:read",audience:"server",request:e.strictObject({cursor:e.uuid().optional()}),response:r.extend({templates:Gr})},previewInvoice:{method:"POST",path:"invoices/preview",permission:"billing:write",audience:"server",request:e.strictObject({customerId:e.uuid(),params:P}),response:r.extend({preview:de})},createInvoice:{method:"POST",path:"invoices/create",permission:"billing:write",audience:"server",request:e.strictObject({customerId:e.uuid(),requestId:e.uuid(),params:P}).refine(t=>t.params.preview!==!0,"Use previewInvoice for a side-effect-free preview"),response:r.extend({operation:w})},manageInvoice:{method:"POST",path:"invoices/manage",permission:"billing:write",audience:"server",request:e.strictObject({customerId:e.uuid(),command:Dr}).refine(t=>t.command.action!=="create"||t.command.params.preview!==!0,"Use previewInvoice for a side-effect-free preview"),response:r.extend({operation:w})},readInvoiceOperation:{method:"POST",path:"invoices/operations/read",permission:"billing:read",audience:"server",request:e.strictObject({customerId:e.uuid(),taskId:e.uuid()}),response:r.extend({operation:w})},listInvoices:{method:"POST",path:"invoices/list",permission:"billing:read",audience:"server",request:e.strictObject({customerId:e.uuid(),cursor:e.uuid().optional()}),response:r.extend({invoices:Lr})},getInvoice:{method:"POST",path:"invoices/read",permission:"billing:read",audience:"server",request:e.strictObject({customerId:e.uuid(),invoiceId:e.uuid()}),response:r.extend({invoice:$r})},getCodeReferenceConfig:{method:"POST",path:"code-references/config",permission:"code-references:read",audience:"server",request:_r,response:r.extend({config:Rr})},submitCodeReferences:{method:"POST",path:"code-references",permission:"code-references:write",audience:"server",request:De,response:r.extend({receipt:$e})},getFeatures:{method:"GET",path:"features",permission:"features:read",audience:"mixed",request:e.strictObject({}),response:r.extend({payload:gt})},evaluateFeatures:{method:"POST",path:"features/evaluate",permission:"features:read",audience:"mixed",request:ht,response:r.merge(ft)},trackEvents:{method:"POST",path:"events",permission:"events:write",audience:"mixed",request:bt,response:r.merge(xt)},readBalanceSource:{method:"POST",path:"balances/source/read",permission:"credits:read",audience:"server",request:e.strictObject({customerId:e.uuid(),sourceId:e.uuid()}),response:r.extend({balance:Pi})},adjustBalance:{method:"POST",path:"balances/source/adjust",permission:"credits:manage",audience:"server",request:e.strictObject({customerId:e.uuid(),command:Ai}),response:r.extend({balance:we})},readAiPricing:{method:"POST",path:"ai/pricing/read",permission:"credits:read",audience:"server",request:e.strictObject({internal_feature_id:e.uuid(),customerId:e.uuid().optional(),entityId:e.uuid().optional()}).refine(t=>!t.entityId||!!t.customerId,"Entity pricing requires a customer"),response:r.extend({internal_feature_id:e.uuid(),config:Pe,model_markups:te})},readUsage:{method:"POST",path:"usage/read",permission:"credits:read",audience:"server",request:e.strictObject({customerId:e.uuid(),query:vt}),response:r.extend({usage:ge})},setUsage:{method:"POST",path:"usage/set",permission:"credits:manage",audience:"server",request:e.strictObject({customerId:e.uuid(),command:Ot}),response:r.extend({usage:ge})},manageBalanceGrant:{method:"POST",path:"balances/grants/manage",permission:"credits:manage",audience:"server",request:e.strictObject({customerId:e.uuid(),command:qi}),response:r.extend({grant:Be})},listBalanceGrants:{method:"POST",path:"balances/grants/list",permission:"credits:read",audience:"server",request:Ti,response:r.extend({grants:ki})},restoreNativePurchase:{method:"POST",path:"subscriptions/native/restore",permission:"billing:write",audience:"mixed",request:e.union(ci.options.map(t=>t.extend({customerId:e.uuid().optional(),customerToken:e.string().regex(We).optional()}))),response:r.extend({operation:ui})},setupPayment:{method:"POST",path:"billing/setup-payment",permission:"billing:write",audience:"mixed",request:Xt.extend({customerId:e.uuid().optional()}),response:r.extend({setup:Ie})},readPaymentSetup:{method:"POST",path:"billing/payment-setup",permission:"billing:read",audience:"mixed",request:Jt.extend({customerId:e.uuid().optional()}),response:r.extend({setup:Ie})},previewSubscriptionBatch:{method:"POST",path:"subscriptions/batches/preview",permission:"billing:write",audience:"server",request:Kt.safeExtend({customerId:e.uuid()}),response:r.extend({batch:k})},confirmSubscriptionBatch:{method:"POST",path:"subscriptions/batches/confirm",permission:"billing:write",audience:"server",request:K.extend({customerId:e.uuid()}),response:r.extend({batch:k})},readSubscriptionBatch:{method:"POST",path:"subscriptions/batches/read",permission:"billing:read",audience:"server",request:K.extend({customerId:e.uuid()}),response:r.extend({batch:k})},abandonSubscriptionBatch:{method:"POST",path:"subscriptions/batches/abandon",permission:"billing:write",audience:"server",request:K.extend({customerId:e.uuid()}),response:r.extend({batch:k})},manageSubscriptionTrial:{method:"POST",path:"subscriptions/trials/manage",permission:"billing:write",audience:"server",request:e.discriminatedUnion("action",[W.options[0].extend({customerId:e.uuid()}),W.options[1].extend({customerId:e.uuid()}),W.options[2].extend({customerId:e.uuid()})]),response:r.extend({trial:ye})},readSubscriptionTrial:{method:"POST",path:"subscriptions/trials/read",permission:"billing:read",audience:"server",request:Wt.extend({customerId:e.uuid()}),response:r.extend({trial:ye})},listSubscriptions:{method:"POST",path:"subscriptions/list",permission:"billing:read",audience:"server",request:J,response:r.extend({subscriptions:ai})},listPurchases:{method:"POST",path:"purchases/list",permission:"billing:read",audience:"server",request:J,response:r.extend({purchases:si})},listSubscriptionConflicts:{method:"POST",path:"subscriptions/conflicts/list",permission:"billing:read",audience:"server",request:ii,response:r.extend({conflicts:oi})},retrySubscriptionConflict:{method:"POST",path:"subscriptions/conflicts/retry",permission:"billing:write",audience:"server",request:ri,response:r.extend({resolution:ni})},verifySubscriptions:{method:"POST",path:"subscriptions/verify",permission:"billing:read",audience:"server",request:ei,response:r.extend({verification:ti})},previewAttach:{method:"POST",path:"subscriptions/preview-attach",permission:"billing:read",audience:"mixed",request:ot.safeExtend({...V,customerId:e.uuid().optional()}),response:r.extend({quote:ct})},recordMerchantEvent:{replay:"immutable_event",method:"POST",path:"merchant/events/record",permission:"billing:write",audience:"server",request:Ur,response:r.extend({record:Mr})},attach:{method:"POST",path:"subscriptions/attach",permission:"billing:write",audience:"mixed",request:I.extend({customerId:e.uuid().optional(),intent:e.enum(["confirm","cancel"]).optional(),merchantConfirmation:N.optional()}),response:r.extend({operation:me})},readSubscriptionOperation:{replay:"read",method:"POST",path:"subscriptions/operations/read",permission:"billing:read",audience:"mixed",request:I.extend({customerId:e.uuid().optional()}),response:r.extend({operation:me})},previewUpdate:{method:"POST",path:"subscriptions/preview-update",permission:"billing:read",audience:"mixed",request:ut.safeExtend({customerId:e.uuid().optional()}),response:r.extend({quote:mt})},update:{method:"POST",path:"subscriptions/update",permission:"billing:write",audience:"mixed",request:I.extend({customerId:e.uuid().optional(),intent:e.enum(["confirm","cancel"]).optional(),merchantConfirmation:N.optional()}),response:r.extend({operation:pe})},readSubscriptionUpdate:{replay:"read",method:"POST",path:"subscriptions/updates/read",permission:"billing:read",audience:"mixed",request:I.extend({customerId:e.uuid().optional()}),response:r.extend({operation:pe})},previewRefund:{method:"POST",path:"subscriptions/refunds/preview",permission:"billing:read",audience:"server",request:pt.safeExtend({customerId:e.uuid()}),response:r.extend({quote:lt})},refund:{method:"POST",path:"subscriptions/refunds/confirm",permission:"billing:write",audience:"server",request:I.extend({customerId:e.uuid(),merchantConfirmation:N.optional()}),response:r.extend({operation:le})},readRefund:{replay:"read",method:"POST",path:"subscriptions/refunds/read",permission:"billing:read",audience:"server",request:I.extend({customerId:e.uuid()}),response:r.extend({operation:le})},readBillingControls:{method:"POST",path:"billing/controls/read",permission:"billing:read",audience:"customer",request:xr,response:r.extend({controls:Ee})},prepareBillingAuthorization:{method:"POST",path:"billing/authorizations/prepare",permission:"billing:write",audience:"customer",request:mr,response:r.extend({prepared:lr})},confirmBillingAuthorization:{method:"POST",path:"billing/authorizations/confirm",permission:"billing:write",audience:"customer",request:gr,response:r.extend({authorization:ne})},setBillingCoupons:{method:"POST",path:"billing/coupons",permission:"billing:write",audience:"customer",request:Or,response:r.extend({coupons:Ar})},revokeBillingAuthorization:{method:"POST",path:"billing/authorizations/revoke",permission:"billing:write",audience:"customer",request:hr,response:r.extend({authorization:ne})},listBillingInvoices:{method:"POST",path:"billing/invoices/read",permission:"billing:read",audience:"customer",request:Ir,response:r.extend({invoices:vr})},prepareBillingAdjustment:{method:"POST",path:"billing/invoices/prepare-adjustment",permission:"billing:write",audience:"server",request:yr.extend({customerId:e.uuid()}),response:r.extend({operation:w})},confirmBillingAdjustment:{method:"POST",path:"billing/invoices/confirm-adjustment",permission:"billing:write",audience:"customer",request:Sr,response:r.extend({invoice:G})},manageBillingLimits:{method:"POST",path:"billing/controls/manage",permission:"billing:write",audience:"server",request:e.object({customerId:e.uuid(),command:br}).strict(),response:r.extend({controls:Ee})},manageUsageEntity:{method:"POST",path:"usage/entities",permission:"credits:manage",audience:"server",request:e.object({customerId:e.uuid(),command:ji}).strict(),response:r.extend({entity:Ci})},readUsageAnalytics:{method:"POST",path:"usage/analytics",permission:"credits:read",audience:"server",request:e.strictObject({customerId:e.uuid().nullable(),query:Ei}),response:r.extend({analytics:Gi})},readCreditAnalytics:{method:"POST",path:"credits/analytics",permission:"credits:read",audience:"server",request:e.object({customerId:e.uuid().nullable(),query:A}).strict(),response:r.extend({analytics:Ui})},submitUsageBatch:{method:"POST",path:"usage/batch",permission:"credits:consume",audience:"server",request:Di,response:r.extend({batchId:e.uuid()})},readUsageBatch:{method:"POST",path:"usage/batch/read",permission:"credits:read",audience:"server",request:$i,response:r.extend({batch:Li})},checkEntitlement:{method:"POST",path:"entitlements/check",permission:"entitlements:read",audience:"mixed",request:Ye.extend({customerId:e.string().min(1).optional()}),response:r.extend({check:ce})},resolveContent:{method:"POST",path:"content/resolve",permission:"content:read",audience:"mixed",request:e.strictObject({kind:tt,selector:e.discriminatedUnion("type",[e.strictObject({type:e.literal("resource"),id:e.uuid()}),e.strictObject({type:e.literal("version"),id:e.uuid()})]),customerId:e.string().min(1).optional()}),response:r.extend({content:it})},resolvePaywall:{method:"POST",path:"paywalls/resolve",permission:"entitlements:read",audience:"mixed",request:Tt,response:r.extend({paywall:kt})},resolveOffering:{method:"POST",path:"offerings/resolve",permission:"entitlements:read",audience:"mixed",request:e.strictObject({processContext:rt.optional(),...V,selector:Ii,customerId:e.string().min(1).optional(),commerce:Xe,requirement:Je.optional()}),response:r.extend({offering:vi,candidates:e.array(et).max(20),availability:e.array(e.strictObject({productVersionId:e.uuid(),available:e.boolean(),reason:e.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:ce.nullable()})},readHoldings:{method:"POST",path:"customer-holdings",permission:"entitlements:read",audience:"mixed",request:e.object({customerId:e.uuid().optional(),entityId:e.uuid().optional()}).strict(),response:r.extend({holdings:At})},readLedger:{method:"POST",path:"customer-ledger",permission:"credits:read",audience:"mixed",request:e.object({customerId:e.uuid().optional(),query:Pt}).strict(),response:r.extend({ledger:jt})},readBillingInvoice:{method:"POST",path:"billing/invoices/detail",permission:"billing:read",audience:"mixed",request:wr.extend({customerId:e.uuid().optional()}),response:r.extend({detail:Br})},readCreditStatement:{method:"POST",path:"credit-statements/read",permission:"credits:read",audience:"mixed",request:Le.safeExtend({customerId:e.uuid().optional()}),response:r.extend({statement:qr})},quoteBalance:{method:"POST",path:"balances/quote",permission:"credits:read",audience:"mixed",request:e.object({customerId:e.uuid().optional(),command:B.options[0]}).strict(),response:r.extend({quote:It})},trackUsage:{method:"POST",path:"usage/track",permission:"credits:consume",audience:"server",request:e.strictObject({customerId:e.uuid(),command:e.union([e.strictObject({eventName:e.string().min(1),quantity:s.optional(),properties:h.optional(),entityId:e.uuid().optional(),idempotencyKey:e.string().min(1).max(120)}),e.strictObject({internal_feature_id:e.uuid(),quantity:s.optional(),properties:h.optional(),entityId:e.uuid().optional(),idempotencyKey:e.string().min(1).max(120)})])}),response:r.extend({receipts:e.array(q).min(1)})},mutateBalance:{method:"POST",path:"balances/execute",permission:"credits:consume",audience:"server",request:e.object({customerId:e.uuid(),command:B.refine(t=>t.operation!=="quote","Use the quote endpoint for a read")}).strict(),response:r.extend({receipt:q})},redeemReward:{method:"POST",path:"rewards/redeem",permission:"offers:resolve",audience:"customer",request:Xi,response:r.extend({redemption:Hi})},createReferralCode:{method:"POST",path:"rewards/referral-code",permission:"offers:resolve",audience:"customer",request:er,response:r.extend({referralCode:tr})},claimRewardProduct:{method:"POST",path:"rewards/product/claim",permission:"offers:resolve",audience:"customer",request:Ji,response:r.extend({checkout:Yi})},readSeats:{method:"POST",path:"seats/list",permission:"customers:read",audience:"server",request:rr,response:r.extend({seats:Ue})},manageSeat:{method:"POST",path:"seats/manage",permission:"billing:write",audience:"server",request:nr,response:r.extend({seats:Ue})},createCustomer:{method:"POST",path:"customers",permission:"customers:write",audience:"server",request:ha,response:fa},getCustomer:{replay:"read",method:"POST",path:"customers/get",permission:"customers:read",audience:"server",request:Rt,response:r.extend({customer:Q})},listCustomers:{method:"POST",path:"customers/list",permission:"customers:read",audience:"server",request:Bt,response:r.extend(qt.shape)},updateCustomer:{method:"POST",path:"customers/update",permission:"customers:write",audience:"server",request:wt,response:r.extend(_t.shape)},createSession:{method:"POST",path:"customer-sessions",permission:"sessions:create",audience:"server",request:e.object({customerId:e.uuid()}).strict(),response:r.extend(F.shape)},refreshSession:{method:"POST",path:"customer-sessions/refresh",permission:"sessions:create",audience:"refresh",request:e.strictObject({}),response:r.extend(F.shape)},revokeSessions:{method:"POST",path:"customer-sessions/revoke",permission:"sessions:create",audience:"server",request:e.strictObject({customerId:e.uuid(),sessionId:e.uuid().optional()}),response:r.extend({revoked:e.number().int().nonnegative()})},createGuestCustomer:{method:"POST",path:"customers/guests",permission:"sessions:create",audience:"server",request:e.strictObject({guestToken:e.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/),fingerprint:he.optional()}),response:r.extend({customerId:e.uuid(),guestToken:e.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/),guestExpiresAt:e.iso.datetime()})},resumeGuestSession:{method:"POST",path:"customers/guests/session",permission:"sessions:create",audience:"server",request:e.strictObject({guestToken:e.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/)}),response:r.extend(F.shape)},claimGuestCustomer:{method:"POST",path:"customers/guests/claim",permission:"customers:write",audience:"server",request:e.strictObject({guestToken:e.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/),externalUserId:e.string().trim().min(1).max(255).refine(t=>!t.startsWith("gg_guest_")),requestId:e.uuid()}),response:r.extend({customer:Q,switched:e.boolean(),replayed:e.boolean()})},redeemCoupon:{method:"POST",path:"offers/redeem",permission:"offers:resolve",audience:"customer",request:e.strictObject({code:e.string().regex(/^[A-Z0-9][A-Z0-9_-]{2,31}$/),requestId:e.uuid()}),response:Nr()},listOffers:{method:"GET",path:"offers",permission:"offers:resolve",audience:"customer",request:e.object({}).strict(),response:r.extend({offers:e.array(ue)})},grantModelBenefit:{method:"POST",path:"benefits/model-usage/grant",permission:"offers:grant",audience:"server",request:$t,response:r.extend({operation:xe})},readModelBenefit:{method:"POST",path:"benefits/model-usage/read",permission:"offers:grant",audience:"server",request:Lt,response:r.extend({operation:xe})},grantOffer:{method:"POST",path:"offers/grant",permission:"offers:grant",audience:"mixed",customerPermission:"offers:resolve",request:e.object({customerId:e.string().min(1).max(255).optional(),couponId:e.uuid(),...V,requestId:e.uuid(),couponContentDigest:e.string().regex(/^[a-f0-9]{64}$/).optional()}).strict(),response:Nr()}},tc={recordMerchantEvent:i.recordMerchantEvent,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,grantModelBenefit:i.grantModelBenefit,readModelBenefit:i.readModelBenefit,redeemCoupon:i.redeemCoupon,redeemReward:i.redeemReward,createReferralCode:i.createReferralCode,claimRewardProduct:i.claimRewardProduct,readSeats:i.readSeats,manageSeat:i.manageSeat};export{be as a,Dt as b,Gt as c,xa as d,i as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as n}from"./chunk-
|
|
1
|
+
import{a as n}from"./chunk-TIQS5DUF.js";function o(r,e){try{return r.parse(e)}catch{throw new n("INVALID_RESPONSE","Invalid gateway response")}}export{o as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as T,b as se}from"./chunk-I6TSQQ5N.js";import{b as re,h as ae,j as ce}from"./chunk-7VRZYSTR.js";import{a as oe,b as j}from"./chunk-FYQXSGRT.js";import{c as Z,e as ee,f as te,g as H,h as G,j as ne}from"./chunk-7MNJH5GB.js";import{F as M,b as J}from"./chunk-QBA3B4YK.js";import{a as b,b as f,c as m}from"./chunk-ITGERPCJ.js";import{b as W,j as X}from"./chunk-NAZU3EEJ.js";import{E as $}from"./chunk-R23IGK5U.js";import{b as ie}from"./chunk-WTVLNUMS.js";import{a as B}from"./chunk-VYFSRHXM.js";import{a as s}from"./chunk-X4W22IH6.js";import{h as Q}from"./chunk-R4FDIYMN.js";import{b as K}from"./chunk-VF6QMMEA.js";import{a as z}from"./chunk-DSPLGTQI.js";var U=t=>{if(!Number.isSafeInteger(t)||t<0||t>=Number.MAX_SAFE_INTEGER)throw new s("INVALID_STATE","Installation sequence exhausted");return t+1},Se=async t=>[...new Uint8Array(await crypto.subtle.digest("SHA-256",Uint8Array.from(t,e=>e.charCodeAt(0))))].map(e=>e.toString(16).padStart(2,"0")).join("");function _(t,e){return t.transaction(n=>{if(!Number.isSafeInteger(n.identitySeq)||n.identitySeq<0||!Number.isSafeInteger(n.addressSeq)||n.addressSeq<0||n.detachSeq!==null&&(!Number.isSafeInteger(n.detachSeq)||n.detachSeq<1||n.detachSeq>n.identitySeq))throw new s("INVALID_STATE","Installation journal is invalid");return e({...n})})}function ue(t,e,n){let r=null,o=0,a=0,d=0,y=Promise.resolve(),g=!1;if(t&&(!n||Q.parse(t.scope).projectId!==n.projectId||t.scope.environment!==n.environment))throw new s("SCOPE_MISMATCH","Push installation belongs to another scope");let l=()=>{if(g)throw new s("CLOSED","SDK client was destroyed");if(!t)throw new s("NOT_CONFIGURED","Configure this client's native Push host first");return t},O=i=>{if(i!==o)throw new s("IDENTITY_CHANGED","Identity changed during Push operation")};async function F(i){let c=l();if(!c.sha256&&!globalThis.crypto?.subtle)throw new s("NOT_CONFIGURED","Configure native SHA-256 for this Push host");let u=c.sha256?await c.sha256(Uint8Array.from(i,A=>A.charCodeAt(0))):await Se(i);if(!/^[a-f0-9]{64}$/.test(u))throw new s("INVALID_STATE","Push credential digest is invalid");return u}function p(i){let c=G.parse(i);if(c.installationId.toLowerCase()!==l().installationId.toLowerCase())throw new s("INVALID_RESPONSE","Push response belongs to another installation");return c}async function S(i,c){let u=l(),A={installationId:u.installationId,publicKey:u.publicKey,issuedAt:new Date().toISOString(),...c},w=await u.sign(ne(i,u.scope,A));return{...A,signature:w}}let I=(i,c,u)=>e.requestWithCredential?e.requestWithCredential(i,c,u):e.request(i,c);async function q(){let i=l(),c=o,u=r?await(e.session?.access()??r):null,A=_(i,v=>v),w;if(A.detachSeq!==null){let v=A.detachSeq,V=Z.parse(await S("detach",{sequence:v,platform:i.platform}));try{let k=await e.request("push/installations/detach",{...i.scope,...V},"POST",{installationDetach:!0});if(!k||typeof k!="object"||!("installation"in k))throw new s("INVALID_RESPONSE","Push detach acknowledgement is invalid");let x=p(k.installation);if(x.bound||x.identitySeq!==v)throw new s("INVALID_RESPONSE","Push detach acknowledgement does not match its intent")}catch(k){if(k instanceof s&&k.status===404)w=k;else if(!(k instanceof s)||k.status!==412)throw k}w||_(i,k=>({...k,detachSeq:k.detachSeq===v?null:k.detachSeq}))}if(O(c),!u){if(w)throw w;return null}let C=(await import("./operation-contracts-443N2P3A.js")).apiOperations.bindPushInstallation,D=C.request.parse(await S("bind",{sequence:d,platform:i.platform,credentialDigest:await F(u)}));O(c);let R=C.response.parse(await I(C.path,D,u));O(c);let N=p(R.installation);if(!N.bound||N.identitySeq!==d)throw new s("INVALID_RESPONSE","Push binding acknowledgement does not match its intent");return w&&A.detachSeq!==null&&d>A.detachSeq&&_(i,v=>({...v,detachSeq:v.detachSeq===A.detachSeq?null:v.detachSeq})),N}async function h(){l();let i=o,c=r?await(e.session?.access()??r):null;if(!c)throw new s("NOT_IDENTIFIED","Identify before reading this installation");let u=(await import("./operation-contracts-443N2P3A.js")).apiOperations.readPushInstallation,A=u.request.parse(await S("read",{credentialDigest:await F(c)}));O(i);let w=u.response.parse(await I(u.path,A,c));return O(i),p(w.installation)}function P(i=q){let c=y.catch(()=>{}).then(i);return y=c,c.catch(u=>{try{t?.onError?.(u instanceof Error?u:new Error("Push synchronization failed"))}catch{}}),c}async function E(i,c,u){let A=l(),w=c.identity,C=c.observation,D=r?await(e.session?.access()??r):null;if(O(w),C!==a)throw new s("INVALID_STATE","Push observation changed during recovery");if(!D)throw new s("NOT_IDENTIFIED","Identify before recovering a Push address");if(!i.connectionId||!i.kind||!i.token||!["granted","provisional"].includes(i.permission))throw new s("INVALID_REQUEST","Recovery needs a provider token and notification permission");return await P(async()=>{if(O(w),await q(),O(w),C!==a)throw new s("INVALID_STATE","Push observation changed during recovery");let R=_(A,x=>u?x:{...x,addressSeq:U(x.addressSeq)}),v=await S(u?"recovery_confirm":"recovery_request",{...i,sequence:R.addressSeq,credentialDigest:await F(D),...u?{challenge:u}:{}}),V=u?te.parse(v):ee.parse(v);if(O(w),C!==a)throw new s("INVALID_STATE","Push observation changed during recovery");let k=await I(`push/installations/recovery/${u?"confirm":"request"}`,V,D);if(O(w),C!==a||_(A,x=>x).addressSeq!==R.addressSeq)throw new s("INVALID_STATE","Push observation changed during recovery");if(u){let{apiOperations:x}=await import("./operation-contracts-443N2P3A.js");if(O(w),C!==a||_(A,Oe=>Oe).addressSeq!==R.addressSeq)throw new s("INVALID_STATE","Push observation changed during recovery");let Ae=x.updatePushAddress.response.parse(k),L=p(Ae.installation);if(!L.bound||L.identitySeq!==d||L.addressSeq!==R.addressSeq||L.connectionId!==i.connectionId||L.addressStatus!=="active")throw new s("INVALID_RESPONSE","Push recovery acknowledgement does not match its intent");return L}if(!k||typeof k!="object"||!("recovery"in k))throw new s("INVALID_RESPONSE","Push recovery acknowledgement is invalid");return H.parse(k.recovery)})}return{recoveryObserver(){l();let i={identity:o,observation:++a};return{async request(c){return H.parse(await E(c,i))},async confirm(c,u){return G.parse(await E(u,i,c))}}},identify(i){if(!t)return;d=_(t,u=>({...u,identitySeq:U(u.identitySeq)})).identitySeq,r=i,o++,a++},reset(){if(t)try{_(t,i=>{let c=U(i.identitySeq);return{...i,identitySeq:c,detachSeq:c}})}finally{r=null,o++,a++}},start(){t&&!g&&P()},destroy(){g=!0,r=null,o++,a++},async sync(){return await P()},read:h,async recover(){let i=l(),c=o,u=d;return a++,await P(async()=>{O(c);let A=await h();return O(c),d=_(i,C=>{if(C.identitySeq!==u)throw new s("IDENTITY_CHANGED","A newer installation intent exists");return{...C,identitySeq:U(Math.max(C.identitySeq,A.identitySeq)),addressSeq:Math.max(C.addressSeq,A.addressSeq)}}).identitySeq,await q()})},tokenObserver(){l();let i=++a,c=o;return async u=>{if(i!==a||c!==o)return null;let A=l(),w=r?await(e.session?.access()??r):null;if(!w)throw new s("NOT_IDENTIFIED","Identify before registering a Push token");if(await P(),O(c),i!==a)return null;let C=_(A,v=>({...v,addressSeq:U(v.addressSeq)})),D=(await import("./operation-contracts-443N2P3A.js")).apiOperations.updatePushAddress,R=D.request.parse(await S("address",{...u,sequence:C.addressSeq,credentialDigest:await F(w)}));if(O(c),i!==a)return null;let N=await I(D.path,R,w);return O(c),i!==a||_(A,v=>v).addressSeq!==C.addressSeq?null:p(D.response.parse(N).installation)}}}}function de(t,e){let n={async preference(r){let o=await f(t,"readMessagingPreference");return(await m(t,o,{channel:r})).preference},async setPreference(r){r=b(r);let o=await f(t,"setMessagingPreference");return(await m(t,o,r)).preference}};return{messaging:n,push:{sync:e.sync,read:e.read,recover:e.recover,tokenObserver:e.tokenObserver,recoveryObserver:e.recoveryObserver,async preference(){return n.preference("push")},async setPreference(r){return r=b(r),n.setPreference({...r,channel:"push"})}}}}function le(t,e,n={}){let r=!1;function o(){if(r)throw new s("CLOSED","SDK client was destroyed")}let a=new Set,d=g=>{for(let l of a)try{l(g)}catch{}},y=t.session.subscribeIdentity(()=>{d(!!t.session.peek()),n.afterChange?.()},()=>{e()});return{assertActive:o,isIdentified:()=>!r&&!!t.session.peek(),methods:{subscribeIdentity(g){return o(),a.add(g),()=>{a.delete(g)}},identify(g){o();let l=typeof g=="string"?g:g.accessToken;if(!B.test(l))throw new s("INVALID_TOKEN","Browser SDK requires a customer session");n.beforeIdentify?.(l),t.identify(g)},reset(){if(!r)try{n.beforeReset?.()}finally{t.reset()}},destroy(){if(!r){r=!0,y(),a.clear();try{n.beforeDestroy?.(),e()}finally{t.dispose()}}}}}}function pe(t){return{async checkEntitlement(e){e=b(e),T(e);let n=await f(t,"checkEntitlement"),r=n.request.parse(e),o=await m(t,n,r);return oe(r.requirement,o.check,void 0,o.scope),o},async readHoldings(e={}){e=b(e);let n=await f(t,"readHoldings"),r={...n,request:n.request.omit({customerId:!0})};return m(t,r,e)}}}function fe(t){return{async readLedger(e){e=b(e);let n=await f(t,"readLedger");return m(t,n,{query:e})},async readCreditStatement(e){e=b(e),T(e);let n=await f(t,"readCreditStatement");return m(t,n,e)},async quoteBalance(e){e=b(e),T(e);let n=await f(t,"quoteBalance");return m(t,n,{command:e})}}}function me(t){return{async setupPayment(e){e=b(e),T(e);let n=await f(t,"setupPayment");return m(t,n,e)},async readPaymentSetup(e){e=b(e),T(e);let n=await f(t,"readPaymentSetup");return m(t,n,e)},async readBillingInvoice(e){e=b(e),T(e);let n=await f(t,"readBillingInvoice");return m(t,n,e)},async readBillingControls(e={}){e=b(e),T(e);let n=await f(t,"readBillingControls");return m(t,n,e)},async prepareBillingAuthorization(e){e=b(e),T(e);let n=await f(t,"prepareBillingAuthorization");return m(t,n,e)},async confirmBillingAuthorization(e){e=b(e),T(e);let n=await f(t,"confirmBillingAuthorization");return m(t,n,e)},async setBillingCoupons(e){e=b(e),T(e);let n=await f(t,"setBillingCoupons");return m(t,n,e,{request:"Invalid billing coupon list",response:"Invalid billing coupon receipt"})},async revokeBillingAuthorization(e){e=b(e),T(e);let n=await f(t,"revokeBillingAuthorization");return m(t,n,e)},async listBillingInvoices(e={after:null,limit:25}){e=b(e),T(e);let n=await f(t,"listBillingInvoices");return m(t,n,e)},async confirmBillingAdjustment(e){e=b(e),T(e);let n=await f(t,"confirmBillingAdjustment");return m(t,n,e)}}}function ye(t){return{async redeemReward(e){return e=b(e),T(e),(await m(t,await f(t,"redeemReward"),{...e,requestId:e.requestId??crypto.randomUUID()},{request:"Invalid reward redemption",response:"Invalid reward receipt"})).redemption},async claimRewardProduct(e){return e=b(e),T(e),(await m(t,await f(t,"claimRewardProduct"),e,{request:"Invalid reward product claim",response:"Invalid reward product checkout"})).checkout},async createReferralCode(e){return e=b(e),T(e),(await m(t,await f(t,"createReferralCode"),{...e,requestId:e.requestId??crypto.randomUUID()},{request:"Invalid referral program",response:"Invalid referral code"})).referralCode},async redeemCoupon(e,n=crypto.randomUUID()){typeof e=="string"&&(e=e.trim().toUpperCase());let r=await m(t,await f(t,"redeemCoupon"),{code:e,requestId:n},{request:"Invalid coupon code",response:"Invalid Coupon receipt"});return{offer:r.offer,reason:r.reason}},async claimCoupon(e,n=crypto.randomUUID()){let r=await m(t,await f(t,"grantOffer"),{couponId:e,requestId:n},{request:"Invalid Coupon claim",response:"Invalid Coupon receipt"});return{offer:r.offer,reason:r.reason}},async listOffers(){return(await m(t,await f(t,"listOffers"),{},{response:"Invalid offers response"})).offers}}}function Ie(t){return{...pe(t),...fe(t),...me(t),...se(t),...ye(t)}}function he(t){return{async resolveContent(e){e=b(e),T(e);let n=await f(t,"resolveContent");return m(t,n,e)},async resolvePaywall(e){e=b(e),T(e);let n=await f(t,"resolvePaywall"),r=n.request.parse(e),o=await m(t,n,r);return j(r,o.paywall.check,o.scope),o},async resolveOffering(e){e=b(e),T(e);let n=await f(t,"resolveOffering"),r=n.request.parse(e),o=await m(t,n,r);return j(r,o.check,o.scope),o}}}var Y=t=>new TextEncoder().encode(JSON.stringify(t)).length,we=16384,Pe=5e3,Ce=6e4,Re=5;function Te(t){return t instanceof s&&t.status!==void 0&&t.status>=400&&t.status<500&&!t.retryable}function ge(t,e){let n=0,r,o=h=>{r={config:structuredClone(h),until:Date.now()+3e4}},a=[],d=null,y,g=0;function l(){if(!e())throw new s("NOT_IDENTIFIED","Call identify before using Features or events")}function O(){y||!a.length||!e()||(y=setTimeout(()=>{y=void 0,S().catch(()=>{}).finally(O)},Math.min(Pe*2**g,Ce)),typeof y=="object"&&"unref"in y&&y.unref())}function F(h){if(l(),r&&Date.now()<r.until&&!W(r.config,h.kind))return;q();let P=X.parse({events:[{...h,eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString()}]}).events[0];if(Y({events:[P]})>we)throw new s("INVALID_REQUEST","Event exceeds the delivery size limit");if(a.length>=500)throw new s("EVENT_QUEUE_FULL","Flush pending events before tracking more");a.push(structuredClone(P)),O()}function p(h,P={},E={}){F({kind:"custom",name:h,properties:P,...E})}async function S(h=!1){if(l(),d)return d;let P=n,E=(async()=>{let i={inserted:0,duplicates:0,rejected:0,skipped:0,rejections:[]},c=a.length;for(;c&&P===n;){let u=[],A=Y({events:[]});for(let C of a.slice(0,Math.min(c,100))){let D=Y(C)+(u.length?1:0);if(u.length&&A+D>we)break;u.push(C),A+=D}let w;try{let C=await f(t,"trackEvents");if(w=await m(t,C,{events:u},void 0,{keepalive:h}),P!==n)throw new s("IDENTITY_CHANGED","Event identity changed during delivery");if(w.inserted+w.duplicates+w.rejected+w.skipped!==u.length||w.rejections.length!==w.rejected)throw new s("INVALID_RESPONSE","Incomplete event acknowledgement")}catch(C){throw P===n&&(g++,(Te(C)||g>=Re)&&(a.splice(0,u.length),g=0)),C}g=0,o(w.analyticsConfig),a.splice(0,u.length),c-=u.length,i.inserted+=w.inserted,i.duplicates+=w.duplicates,i.rejected+=w.rejected,i.skipped+=w.skipped,i.rejections.push(...w.rejections)}return i})();d=E;try{return await E}finally{d===E&&(d=null)}}let I;function q(){if(I||typeof document>"u")return;let h=()=>{document.visibilityState==="hidden"&&e()&&a.length&&S(!0).catch(()=>{})};document.addEventListener("visibilitychange",h),I=()=>document.removeEventListener("visibilitychange",h)}return{rememberConfiguration:o,track:p,observe:F,flush:S,reset(){n++,r=void 0,clearTimeout(y),y=void 0,a=[],g=0,d=null},detachVisibility(){I?.(),I=void 0}}}function ve(t){let e=t.merchandise;if(typeof t.merchandiseId=="string")return{internalId:t.merchandiseId};if(!(!e||typeof e!="object"||Array.isArray(e))){if(typeof e.internalId=="string")return{internalId:e.internalId};if(typeof e.externalId=="string")return{id:e.externalId};if(typeof e.id=="string")return{id:e.id}}}var qe=new Set([...$,"merchandiseId","merchandise"]);function ke(t){let e=ve(t);return{...Object.fromEntries(Object.entries(t).filter(([r])=>!qe.has(r))),...e?{merchandise:e}:{}}}function Ee(t,e,n,r,o){if(o&&r&&(o.scope.projectId!==r.projectId||o.scope.environment!==r.environment))throw new s("SCOPE_MISMATCH","Configuration belongs to another App/environment");let a=0,d=new Set;function y(){if(!e())throw new s("NOT_IDENTIFIED","Call identify before using Features or events")}async function g(l={}){o||y();let O=a,F=!1,p=async()=>{if(F||O!==a)throw new s("IDENTITY_CHANGED","Feature identity changed");let R=o?{scope:{projectId:o.scope.projectId,environment:o.scope.environment},payload:await o.features()}:await m(t,await f(t,"getFeatures"),{});if(O!==a)throw new s("IDENTITY_CHANGED","Feature identity changed");if(r&&(R.scope.projectId!==r.projectId||R.scope.environment!==r.environment))throw new s("INVALID_RESPONSE","Feature response scope changed");return n.rememberConfiguration(R.payload.analyticsConfig),R},S=await p(),I=!0,q,h=R=>{try{l.onError?.(R)}catch{}},P=(R,N)=>{try{let v=ve(N);n.observe({...R,...v?{merchandise:v}:{}})}catch(v){h(v)}},E=ae({assertUsable:o?.assertFeatures,scope:S.scope,attributes:l.attributes,onError:l.onError,load:async()=>I?(I=!1,S.payload):(await p()).payload,evaluateRemote:async R=>{if(O!==a)throw new s("IDENTITY_CHANGED","Feature identity changed");let N=await f(t,"evaluateFeatures"),v=await m(t,N,{...R,attributes:ke(R.attributes)});if(v.scope.projectId!==S.scope.projectId||v.scope.environment!==S.scope.environment)throw new s("INVALID_RESPONSE","Remote Feature response scope changed");return{generation:v.generation,evaluatedAt:v.evaluatedAt,expiresAt:v.expiresAt,features:v.features,...v.merchandiseContext?{merchandiseContext:v.merchandiseContext}:{}}},onExperimentViewed:(R,N,v,V)=>P({kind:"experiment_exposure",generation:V,experimentId:R.key,variationId:N.key},v),onFeatureUsage:(R,N,v,V)=>P({kind:"feature_usage",generation:V,feature:R,value:N.value??null,source:N.source,ruleId:N.ruleId,...N.experimentResult?{variationId:N.experimentResult.key}:{}},v)}),i=E.refresh;function c(){clearTimeout(q),!o&&(F||O!==a||!E.expiresAt||(q=setTimeout(()=>{u().catch(h)},Math.min(2147483647,Math.max(1e3,Date.parse(E.expiresAt)-Date.now()))),typeof q=="object"&&"unref"in q&&q.unref()))}async function u(){try{return await i()}finally{c()}}let A=()=>{F||u().catch(h)},w=E.subscribe(c),C=o?.subscribe(()=>{!F&&o.fresh&&u().catch(h)});function D(){F||(F=!0,clearTimeout(q),typeof window<"u"&&window.removeEventListener("focus",A),w(),C?.(),E.reset(),d.delete(D))}d.add(D);try{await E.init(),(l.attributes?.merchandise||l.attributes?.merchandiseId)&&await E.refreshRemote()}catch(R){throw D(),R}return c(),!o&&typeof window<"u"&&window.addEventListener("focus",A),Object.assign(E,{refresh:u,destroy:D})}return{features:g,reset(l){a++,l();for(let O of d)O()}}}function be(t,e){let n="source"in e?{funnelId:e.source.id,funnelVersionId:e.source.versionId}:"versionId"in e?{funnelId:e.funnelId,funnelVersionId:e.versionId}:e,r=K.object({funnelId:J.shape.id,funnelVersionId:J.shape.versionId.optional()}).safeParse(n);if(!r.success)throw new s("INVALID_REQUEST","A valid Funnel source is required");let o=Object.freeze(r.data);function a(d){if("customerId"in d)throw new s("INVALID_REQUEST","Customer identity cannot be overridden");if("funnelId"in d&&d.funnelId!==void 0&&d.funnelId!==o.funnelId||"funnelVersionId"in d&&d.funnelVersionId!==void 0&&d.funnelVersionId!==o.funnelVersionId)throw new s("SCOPE_MISMATCH","The original Funnel source cannot change");return{...d,...o}}return{async claimCoupon(d,y=crypto.randomUUID()){let g=await f(t,"grantOffer"),l=await m(t,g,a({couponId:d,requestId:y}));return{offer:l.offer,reason:l.reason}},async resolveOffering(d){d=b(d);let y=await f(t,"resolveOffering"),g=y.request.parse(a(d)),l=await m(t,y,g);return j(g,l.check,l.scope),l},async resolvePaywall(d){d=b(d);let y=await f(t,"resolvePaywall"),g=y.request.parse(a(d)),l=await m(t,y,g);return j(g,l.paywall.check,l.scope),l},async previewAttach(d){d=b(d);let y=await f(t,"previewAttach");return m(t,y,a(d))}}}function xt(t){return Ne(t)}function Ne(t){let e=ie(t),n=e.request,r;try{r=ue(t.push,e,t.scope??t.configuration?.scope)}catch(y){throw e.dispose(),y}let o=le(e,()=>{d.reset(a.reset),a.detachVisibility()},{beforeIdentify:r.identify,beforeReset:r.reset,afterChange:r.start,beforeDestroy:r.destroy}),a=ge(n,o.isIdentified),d=Ee(n,o.isIdentified,a,t.scope,t.configuration);return{session:e.session,...de(n,r),...Ie(n),...he(n),forFunnel(y){return o.assertActive(),be(n,y)},async features(y={}){return o.assertActive(),d.features(y)},track(y,g,l={}){return a.track(y,g,l)},flush(){return a.flush()},...o.methods}}function Mt(t){if(!B.test(t.customerToken))throw new s("INVALID_TOKEN","A customer credential is required");if(!t.scope)throw new s("INVALID_REQUEST","An explicit App and environment scope is required");let e=ce({...t,scope:t.scope,apiKey:t.customerToken});return{async start(n){let r=await e.start(n),o=M({...t,runToken:r.runToken,initialResponse:r});o.identify(t.customerToken);let a=await o.get();return{...r,...a,controller:o}}}}function Kt(t){if(!t.scope)throw new s("INVALID_CONFIGURATION","An explicit process App/environment scope is required");if(t.session!==void 0)throw new s("INVALID_CONFIGURATION","The merchant process adapter owns the session");let e=null,n,r=0,o=new Set,a=new Map,d=new Map;async function y(p){let S,I=new Promise((q,h)=>{S=setTimeout(()=>h(new s("TIMEOUT","Process bridge request timed out")),t.timeoutMs??35e3)});try{return await Promise.race([Promise.resolve().then(p),I])}finally{clearTimeout(S)}}function g(p){throw p instanceof s&&(p.status===401||p.reason==="CUSTOMER_BINDING_CONFLICT")&&(r++,n?.reset(),n=void 0,e=null,a.clear(),d.clear()),p}function l(p,S){if(S!==r)throw new s("IDENTITY_CHANGED","Process was detached during a request");let I=re.parse(p);if(I.scope.projectId!==t.scope.projectId||I.scope.environment!==t.scope.environment)throw new s("SCOPE_MISMATCH","Process response belongs to another App/environment");if(e&&(e.run.id!==I.run.id||e.run.source.versionId!==I.run.source.versionId||e.run.source.id!==I.run.source.id||e.run.runExpiresAt!==I.run.runExpiresAt||e.run.identity.startedAs!==I.run.identity.startedAs||e.run.identity.participantId!==I.run.identity.participantId||e.run.identity.binding&&I.run.identity.binding&&e.run.identity.binding.id!==I.run.identity.binding.id))throw new s("INVALID_RESPONSE","The process changed its Run or Customer binding");if(!e||I.run.revision>=e.run.revision){if(e?.run.identity.binding&&!I.run.identity.binding)throw new s("INVALID_RESPONSE","The process lost its Customer binding");e=I;for(let A of o)z(A,I.run);I.run.instruction?.type==="authentication_required"&&z(t.onAuthenticationRequired,I.run)}I.settlement?.accepted!==void 0&&d.set(I.settlement.requestId,I.settlement.accepted);let{identity:q,instruction:h,...P}=I.run,{contract:E,settlement:i,...c}=I,u=i&&(({accepted:A,...w})=>w)(i);return{...c,run:{...P,authenticated:q.binding!==null,instruction:h?.type==="authentication_required"?null:h},...u?{settlement:u}:{}}}let O=p=>(a.has(p)||a.set(p,e?.run.identity.binding?.id??null),a.get(p));async function F(p){let S=r,I=e?.run.identity.binding?.id??null,q=P=>{if(I!==(e?.run.identity.binding?.id??null))throw P;return g(P)};if(p.operation==="page_experiments"){if(!t.adapter.pageExperiments)throw new s("CAPABILITY_UNAVAILABLE","Process page experiments are unavailable",501);return y(()=>t.adapter.pageExperiments(p.release,p.usedReceiptIds)).catch(q)}let h;if(p.operation==="get"){let{operation:P,customerToken:E,...i}=p;h=await y(()=>t.adapter.get({...i,...i.settlementRequestId?{settlementBindingId:O(i.settlementRequestId)}:{}})).catch(q)}else if(p.operation==="review")h=await y(()=>t.adapter.review(p.receiptId)).catch(q);else{if(p.operation==="start")throw new s("INVALID_REQUEST","Use process.open for entry");{let{customerToken:P,...E}=p;h=await y(()=>t.adapter.command(E,O(E.requestId))).catch(q)}}return l(h,S)}return{get view(){return e?.run??null},get controller(){return n},async open(p){let S=r,I=await y(()=>t.adapter.open(p)).catch(g),q=l(I,S);if(!n){n=M({...t,runToken:I.runToken,initialResponse:q,process:{request:F,binding:O,restore(E){for(let[i,c]of Object.entries(E))a.set(i,c)}}});let h=n,P=h.submit;h.submit=async E=>{try{return await P(E)}catch(i){if(!(i instanceof s)||i.reason!=="IDENTITY_CONTEXT_CHANGED"||E.operation!=="submit"||E.input.type!=="screen"||a.get(E.requestId)!==null)throw i;await h.settle?.(E.requestId),await h.get();let c=h.view;if(d.get(E.requestId)!==!1||!c||c.id!==e?.run.id||c.nodeId!==E.nodeId||c.visit!==E.visit||!e?.run.identity.binding)throw i;return P({...E,requestId:crypto.randomUUID(),revision:c.revision})}}}await n.get();for(let h of n.pendingCommands??[])a.has(h.requestId)&&a.get(h.requestId)!==(e?.run.identity.binding?.id??null)&&await n.settle?.(h.requestId);return{run:e.run,controller:n}},async syncIdentity(){let p=r;l(await y(()=>t.adapter.syncIdentity()).catch(g),p),await n?.get();for(let S of n?.pendingCommands??[])a.has(S.requestId)&&a.get(S.requestId)!==(e?.run.identity.binding?.id??null)&&await n?.settle?.(S.requestId);return e.run},async detach(){r++,n?.reset(),n=void 0,e=null,a.clear(),d.clear(),await y(()=>t.adapter.detach())},forProcess(p){if(!e?.run.identity.binding)throw new s("UNAUTHENTICATED","Sign in before a commercial operation",401);return{runId:e.run.id,bindingId:e.run.identity.binding.id,receiptId:p}},subscribe(p){return o.add(p),()=>{o.delete(p)}},destroy(){r++,n?.reset(),n=void 0,e=null,a.clear(),d.clear(),o.clear()}}}export{xt as a,Ne as b,Mt as c,Kt as d};
|
|
1
|
+
import{a as T,b as se}from"./chunk-M3GGR53D.js";import{b as re,h as ae,j as ce}from"./chunk-HS56A4IK.js";import{F as M,b as J}from"./chunk-HYE2YQYM.js";import{a as b,b as f,c as m}from"./chunk-MHWPEMX7.js";import{c as Z,e as ee,f as te,g as H,h as G,j as ne}from"./chunk-2HSD2SEU.js";import{a as oe,b as j}from"./chunk-BTPEXSNY.js";import{b as W,j as X}from"./chunk-JOIPLLHK.js";import{F as $}from"./chunk-GLYFT5WW.js";import{b as ie}from"./chunk-HVVJGLYZ.js";import{a as B}from"./chunk-ZYF6TRJ3.js";import{b as Q}from"./chunk-DHT3AWJQ.js";import{a as s}from"./chunk-TIQS5DUF.js";import{b as K}from"./chunk-ZYN4CRHS.js";import{a as z}from"./chunk-DSPLGTQI.js";var U=t=>{if(!Number.isSafeInteger(t)||t<0||t>=Number.MAX_SAFE_INTEGER)throw new s("INVALID_STATE","Installation sequence exhausted");return t+1},Se=async t=>[...new Uint8Array(await crypto.subtle.digest("SHA-256",Uint8Array.from(t,e=>e.charCodeAt(0))))].map(e=>e.toString(16).padStart(2,"0")).join("");function _(t,e){return t.transaction(n=>{if(!Number.isSafeInteger(n.identitySeq)||n.identitySeq<0||!Number.isSafeInteger(n.addressSeq)||n.addressSeq<0||n.detachSeq!==null&&(!Number.isSafeInteger(n.detachSeq)||n.detachSeq<1||n.detachSeq>n.identitySeq))throw new s("INVALID_STATE","Installation journal is invalid");return e({...n})})}function ue(t,e,n){let r=null,o=0,a=0,d=0,y=Promise.resolve(),g=!1;if(t&&(!n||Q.parse(t.scope).projectId!==n.projectId||t.scope.environment!==n.environment))throw new s("SCOPE_MISMATCH","Push installation belongs to another scope");let l=()=>{if(g)throw new s("CLOSED","SDK client was destroyed");if(!t)throw new s("NOT_CONFIGURED","Configure this client's native Push host first");return t},O=i=>{if(i!==o)throw new s("IDENTITY_CHANGED","Identity changed during Push operation")};async function F(i){let c=l();if(!c.sha256&&!globalThis.crypto?.subtle)throw new s("NOT_CONFIGURED","Configure native SHA-256 for this Push host");let u=c.sha256?await c.sha256(Uint8Array.from(i,A=>A.charCodeAt(0))):await Se(i);if(!/^[a-f0-9]{64}$/.test(u))throw new s("INVALID_STATE","Push credential digest is invalid");return u}function p(i){let c=G.parse(i);if(c.installationId.toLowerCase()!==l().installationId.toLowerCase())throw new s("INVALID_RESPONSE","Push response belongs to another installation");return c}async function S(i,c){let u=l(),A={installationId:u.installationId,publicKey:u.publicKey,issuedAt:new Date().toISOString(),...c},w=await u.sign(ne(i,u.scope,A));return{...A,signature:w}}let I=(i,c,u)=>e.requestWithCredential?e.requestWithCredential(i,c,u):e.request(i,c);async function q(){let i=l(),c=o,u=r?await(e.session?.access()??r):null,A=_(i,v=>v),w;if(A.detachSeq!==null){let v=A.detachSeq,V=Z.parse(await S("detach",{sequence:v,platform:i.platform}));try{let k=await e.request("push/installations/detach",{...i.scope,...V},"POST",{installationDetach:!0});if(!k||typeof k!="object"||!("installation"in k))throw new s("INVALID_RESPONSE","Push detach acknowledgement is invalid");let x=p(k.installation);if(x.bound||x.identitySeq!==v)throw new s("INVALID_RESPONSE","Push detach acknowledgement does not match its intent")}catch(k){if(k instanceof s&&k.status===404)w=k;else if(!(k instanceof s)||k.status!==412)throw k}w||_(i,k=>({...k,detachSeq:k.detachSeq===v?null:k.detachSeq}))}if(O(c),!u){if(w)throw w;return null}let C=(await import("./operation-contracts-MFK2KORK.js")).apiOperations.bindPushInstallation,D=C.request.parse(await S("bind",{sequence:d,platform:i.platform,credentialDigest:await F(u)}));O(c);let R=C.response.parse(await I(C.path,D,u));O(c);let N=p(R.installation);if(!N.bound||N.identitySeq!==d)throw new s("INVALID_RESPONSE","Push binding acknowledgement does not match its intent");return w&&A.detachSeq!==null&&d>A.detachSeq&&_(i,v=>({...v,detachSeq:v.detachSeq===A.detachSeq?null:v.detachSeq})),N}async function h(){l();let i=o,c=r?await(e.session?.access()??r):null;if(!c)throw new s("NOT_IDENTIFIED","Identify before reading this installation");let u=(await import("./operation-contracts-MFK2KORK.js")).apiOperations.readPushInstallation,A=u.request.parse(await S("read",{credentialDigest:await F(c)}));O(i);let w=u.response.parse(await I(u.path,A,c));return O(i),p(w.installation)}function P(i=q){let c=y.catch(()=>{}).then(i);return y=c,c.catch(u=>{try{t?.onError?.(u instanceof Error?u:new Error("Push synchronization failed"))}catch{}}),c}async function E(i,c,u){let A=l(),w=c.identity,C=c.observation,D=r?await(e.session?.access()??r):null;if(O(w),C!==a)throw new s("INVALID_STATE","Push observation changed during recovery");if(!D)throw new s("NOT_IDENTIFIED","Identify before recovering a Push address");if(!i.connectionId||!i.kind||!i.token||!["granted","provisional"].includes(i.permission))throw new s("INVALID_REQUEST","Recovery needs a provider token and notification permission");return await P(async()=>{if(O(w),await q(),O(w),C!==a)throw new s("INVALID_STATE","Push observation changed during recovery");let R=_(A,x=>u?x:{...x,addressSeq:U(x.addressSeq)}),v=await S(u?"recovery_confirm":"recovery_request",{...i,sequence:R.addressSeq,credentialDigest:await F(D),...u?{challenge:u}:{}}),V=u?te.parse(v):ee.parse(v);if(O(w),C!==a)throw new s("INVALID_STATE","Push observation changed during recovery");let k=await I(`push/installations/recovery/${u?"confirm":"request"}`,V,D);if(O(w),C!==a||_(A,x=>x).addressSeq!==R.addressSeq)throw new s("INVALID_STATE","Push observation changed during recovery");if(u){let{apiOperations:x}=await import("./operation-contracts-MFK2KORK.js");if(O(w),C!==a||_(A,Oe=>Oe).addressSeq!==R.addressSeq)throw new s("INVALID_STATE","Push observation changed during recovery");let Ae=x.updatePushAddress.response.parse(k),L=p(Ae.installation);if(!L.bound||L.identitySeq!==d||L.addressSeq!==R.addressSeq||L.connectionId!==i.connectionId||L.addressStatus!=="active")throw new s("INVALID_RESPONSE","Push recovery acknowledgement does not match its intent");return L}if(!k||typeof k!="object"||!("recovery"in k))throw new s("INVALID_RESPONSE","Push recovery acknowledgement is invalid");return H.parse(k.recovery)})}return{recoveryObserver(){l();let i={identity:o,observation:++a};return{async request(c){return H.parse(await E(c,i))},async confirm(c,u){return G.parse(await E(u,i,c))}}},identify(i){if(!t)return;d=_(t,u=>({...u,identitySeq:U(u.identitySeq)})).identitySeq,r=i,o++,a++},reset(){if(t)try{_(t,i=>{let c=U(i.identitySeq);return{...i,identitySeq:c,detachSeq:c}})}finally{r=null,o++,a++}},start(){t&&!g&&P()},destroy(){g=!0,r=null,o++,a++},async sync(){return await P()},read:h,async recover(){let i=l(),c=o,u=d;return a++,await P(async()=>{O(c);let A=await h();return O(c),d=_(i,C=>{if(C.identitySeq!==u)throw new s("IDENTITY_CHANGED","A newer installation intent exists");return{...C,identitySeq:U(Math.max(C.identitySeq,A.identitySeq)),addressSeq:Math.max(C.addressSeq,A.addressSeq)}}).identitySeq,await q()})},tokenObserver(){l();let i=++a,c=o;return async u=>{if(i!==a||c!==o)return null;let A=l(),w=r?await(e.session?.access()??r):null;if(!w)throw new s("NOT_IDENTIFIED","Identify before registering a Push token");if(await P(),O(c),i!==a)return null;let C=_(A,v=>({...v,addressSeq:U(v.addressSeq)})),D=(await import("./operation-contracts-MFK2KORK.js")).apiOperations.updatePushAddress,R=D.request.parse(await S("address",{...u,sequence:C.addressSeq,credentialDigest:await F(w)}));if(O(c),i!==a)return null;let N=await I(D.path,R,w);return O(c),i!==a||_(A,v=>v).addressSeq!==C.addressSeq?null:p(D.response.parse(N).installation)}}}}function de(t,e){let n={async preference(r){let o=await f(t,"readMessagingPreference");return(await m(t,o,{channel:r})).preference},async setPreference(r){r=b(r);let o=await f(t,"setMessagingPreference");return(await m(t,o,r)).preference}};return{messaging:n,push:{sync:e.sync,read:e.read,recover:e.recover,tokenObserver:e.tokenObserver,recoveryObserver:e.recoveryObserver,async preference(){return n.preference("push")},async setPreference(r){return r=b(r),n.setPreference({...r,channel:"push"})}}}}function le(t,e,n={}){let r=!1;function o(){if(r)throw new s("CLOSED","SDK client was destroyed")}let a=new Set,d=g=>{for(let l of a)try{l(g)}catch{}},y=t.session.subscribeIdentity(()=>{d(!!t.session.peek()),n.afterChange?.()},()=>{e()});return{assertActive:o,isIdentified:()=>!r&&!!t.session.peek(),methods:{subscribeIdentity(g){return o(),a.add(g),()=>{a.delete(g)}},identify(g){o();let l=typeof g=="string"?g:g.accessToken;if(!B.test(l))throw new s("INVALID_TOKEN","Browser SDK requires a customer session");n.beforeIdentify?.(l),t.identify(g)},reset(){if(!r)try{n.beforeReset?.()}finally{t.reset()}},destroy(){if(!r){r=!0,y(),a.clear();try{n.beforeDestroy?.(),e()}finally{t.dispose()}}}}}}function pe(t){return{async checkEntitlement(e){e=b(e),T(e);let n=await f(t,"checkEntitlement"),r=n.request.parse(e),o=await m(t,n,r);return oe(r.requirement,o.check,void 0,o.scope),o},async readHoldings(e={}){e=b(e);let n=await f(t,"readHoldings"),r={...n,request:n.request.omit({customerId:!0})};return m(t,r,e)}}}function fe(t){return{async readLedger(e){e=b(e);let n=await f(t,"readLedger");return m(t,n,{query:e})},async readCreditStatement(e){e=b(e),T(e);let n=await f(t,"readCreditStatement");return m(t,n,e)},async quoteBalance(e){e=b(e),T(e);let n=await f(t,"quoteBalance");return m(t,n,{command:e})}}}function me(t){return{async setupPayment(e){e=b(e),T(e);let n=await f(t,"setupPayment");return m(t,n,e)},async readPaymentSetup(e){e=b(e),T(e);let n=await f(t,"readPaymentSetup");return m(t,n,e)},async readBillingInvoice(e){e=b(e),T(e);let n=await f(t,"readBillingInvoice");return m(t,n,e)},async readBillingControls(e={}){e=b(e),T(e);let n=await f(t,"readBillingControls");return m(t,n,e)},async prepareBillingAuthorization(e){e=b(e),T(e);let n=await f(t,"prepareBillingAuthorization");return m(t,n,e)},async confirmBillingAuthorization(e){e=b(e),T(e);let n=await f(t,"confirmBillingAuthorization");return m(t,n,e)},async setBillingCoupons(e){e=b(e),T(e);let n=await f(t,"setBillingCoupons");return m(t,n,e,{request:"Invalid billing coupon list",response:"Invalid billing coupon receipt"})},async revokeBillingAuthorization(e){e=b(e),T(e);let n=await f(t,"revokeBillingAuthorization");return m(t,n,e)},async listBillingInvoices(e={after:null,limit:25}){e=b(e),T(e);let n=await f(t,"listBillingInvoices");return m(t,n,e)},async confirmBillingAdjustment(e){e=b(e),T(e);let n=await f(t,"confirmBillingAdjustment");return m(t,n,e)}}}function ye(t){return{async redeemReward(e){return e=b(e),T(e),(await m(t,await f(t,"redeemReward"),{...e,requestId:e.requestId??crypto.randomUUID()},{request:"Invalid reward redemption",response:"Invalid reward receipt"})).redemption},async claimRewardProduct(e){return e=b(e),T(e),(await m(t,await f(t,"claimRewardProduct"),e,{request:"Invalid reward product claim",response:"Invalid reward product checkout"})).checkout},async createReferralCode(e){return e=b(e),T(e),(await m(t,await f(t,"createReferralCode"),{...e,requestId:e.requestId??crypto.randomUUID()},{request:"Invalid referral program",response:"Invalid referral code"})).referralCode},async redeemCoupon(e,n=crypto.randomUUID()){typeof e=="string"&&(e=e.trim().toUpperCase());let r=await m(t,await f(t,"redeemCoupon"),{code:e,requestId:n},{request:"Invalid coupon code",response:"Invalid Coupon receipt"});return{offer:r.offer,reason:r.reason}},async claimCoupon(e,n=crypto.randomUUID()){let r=await m(t,await f(t,"grantOffer"),{couponId:e,requestId:n},{request:"Invalid Coupon claim",response:"Invalid Coupon receipt"});return{offer:r.offer,reason:r.reason}},async listOffers(){return(await m(t,await f(t,"listOffers"),{},{response:"Invalid offers response"})).offers}}}function Ie(t){return{...pe(t),...fe(t),...me(t),...se(t),...ye(t)}}function he(t){return{async resolveContent(e){e=b(e),T(e);let n=await f(t,"resolveContent");return m(t,n,e)},async resolvePaywall(e){e=b(e),T(e);let n=await f(t,"resolvePaywall"),r=n.request.parse(e),o=await m(t,n,r);return j(r,o.paywall.check,o.scope),o},async resolveOffering(e){e=b(e),T(e);let n=await f(t,"resolveOffering"),r=n.request.parse(e),o=await m(t,n,r);return j(r,o.check,o.scope),o}}}var Y=t=>new TextEncoder().encode(JSON.stringify(t)).length,we=16384,Pe=5e3,Ce=6e4,Re=5;function Te(t){return t instanceof s&&t.status!==void 0&&t.status>=400&&t.status<500&&!t.retryable}function ge(t,e){let n=0,r,o=h=>{r={config:structuredClone(h),until:Date.now()+3e4}},a=[],d=null,y,g=0;function l(){if(!e())throw new s("NOT_IDENTIFIED","Call identify before using Features or events")}function O(){y||!a.length||!e()||(y=setTimeout(()=>{y=void 0,S().catch(()=>{}).finally(O)},Math.min(Pe*2**g,Ce)),typeof y=="object"&&"unref"in y&&y.unref())}function F(h){if(l(),r&&Date.now()<r.until&&!W(r.config,h.kind))return;q();let P=X.parse({events:[{...h,eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString()}]}).events[0];if(Y({events:[P]})>we)throw new s("INVALID_REQUEST","Event exceeds the delivery size limit");if(a.length>=500)throw new s("EVENT_QUEUE_FULL","Flush pending events before tracking more");a.push(structuredClone(P)),O()}function p(h,P={},E={}){F({kind:"custom",name:h,properties:P,...E})}async function S(h=!1){if(l(),d)return d;let P=n,E=(async()=>{let i={inserted:0,duplicates:0,rejected:0,skipped:0,rejections:[]},c=a.length;for(;c&&P===n;){let u=[],A=Y({events:[]});for(let C of a.slice(0,Math.min(c,100))){let D=Y(C)+(u.length?1:0);if(u.length&&A+D>we)break;u.push(C),A+=D}let w;try{let C=await f(t,"trackEvents");if(w=await m(t,C,{events:u},void 0,{keepalive:h}),P!==n)throw new s("IDENTITY_CHANGED","Event identity changed during delivery");if(w.inserted+w.duplicates+w.rejected+w.skipped!==u.length||w.rejections.length!==w.rejected)throw new s("INVALID_RESPONSE","Incomplete event acknowledgement")}catch(C){throw P===n&&(g++,(Te(C)||g>=Re)&&(a.splice(0,u.length),g=0)),C}g=0,o(w.analyticsConfig),a.splice(0,u.length),c-=u.length,i.inserted+=w.inserted,i.duplicates+=w.duplicates,i.rejected+=w.rejected,i.skipped+=w.skipped,i.rejections.push(...w.rejections)}return i})();d=E;try{return await E}finally{d===E&&(d=null)}}let I;function q(){if(I||typeof document>"u")return;let h=()=>{document.visibilityState==="hidden"&&e()&&a.length&&S(!0).catch(()=>{})};document.addEventListener("visibilitychange",h),I=()=>document.removeEventListener("visibilitychange",h)}return{rememberConfiguration:o,track:p,observe:F,flush:S,reset(){n++,r=void 0,clearTimeout(y),y=void 0,a=[],g=0,d=null},detachVisibility(){I?.(),I=void 0}}}function ve(t){let e=t.merchandise;if(typeof t.merchandiseId=="string")return{internalId:t.merchandiseId};if(!(!e||typeof e!="object"||Array.isArray(e))){if(typeof e.internalId=="string")return{internalId:e.internalId};if(typeof e.externalId=="string")return{id:e.externalId};if(typeof e.id=="string")return{id:e.id}}}var qe=new Set([...$,"merchandiseId","merchandise"]);function ke(t){let e=ve(t);return{...Object.fromEntries(Object.entries(t).filter(([r])=>!qe.has(r))),...e?{merchandise:e}:{}}}function Ee(t,e,n,r,o){if(o&&r&&(o.scope.projectId!==r.projectId||o.scope.environment!==r.environment))throw new s("SCOPE_MISMATCH","Configuration belongs to another App/environment");let a=0,d=new Set;function y(){if(!e())throw new s("NOT_IDENTIFIED","Call identify before using Features or events")}async function g(l={}){o||y();let O=a,F=!1,p=async()=>{if(F||O!==a)throw new s("IDENTITY_CHANGED","Feature identity changed");let R=o?{scope:{projectId:o.scope.projectId,environment:o.scope.environment},payload:await o.features()}:await m(t,await f(t,"getFeatures"),{});if(O!==a)throw new s("IDENTITY_CHANGED","Feature identity changed");if(r&&(R.scope.projectId!==r.projectId||R.scope.environment!==r.environment))throw new s("INVALID_RESPONSE","Feature response scope changed");return n.rememberConfiguration(R.payload.analyticsConfig),R},S=await p(),I=!0,q,h=R=>{try{l.onError?.(R)}catch{}},P=(R,N)=>{try{let v=ve(N);n.observe({...R,...v?{merchandise:v}:{}})}catch(v){h(v)}},E=ae({assertUsable:o?.assertFeatures,scope:S.scope,attributes:l.attributes,onError:l.onError,load:async()=>I?(I=!1,S.payload):(await p()).payload,evaluateRemote:async R=>{if(O!==a)throw new s("IDENTITY_CHANGED","Feature identity changed");let N=await f(t,"evaluateFeatures"),v=await m(t,N,{...R,attributes:ke(R.attributes)});if(v.scope.projectId!==S.scope.projectId||v.scope.environment!==S.scope.environment)throw new s("INVALID_RESPONSE","Remote Feature response scope changed");return{generation:v.generation,evaluatedAt:v.evaluatedAt,expiresAt:v.expiresAt,features:v.features,...v.merchandiseContext?{merchandiseContext:v.merchandiseContext}:{}}},onExperimentViewed:(R,N,v,V)=>P({kind:"experiment_exposure",generation:V,experimentId:R.key,variationId:N.key},v),onFeatureUsage:(R,N,v,V)=>P({kind:"feature_usage",generation:V,feature:R,value:N.value??null,source:N.source,ruleId:N.ruleId,...N.experimentResult?{variationId:N.experimentResult.key}:{}},v)}),i=E.refresh;function c(){clearTimeout(q),!o&&(F||O!==a||!E.expiresAt||(q=setTimeout(()=>{u().catch(h)},Math.min(2147483647,Math.max(1e3,Date.parse(E.expiresAt)-Date.now()))),typeof q=="object"&&"unref"in q&&q.unref()))}async function u(){try{return await i()}finally{c()}}let A=()=>{F||u().catch(h)},w=E.subscribe(c),C=o?.subscribe(()=>{!F&&o.fresh&&u().catch(h)});function D(){F||(F=!0,clearTimeout(q),typeof window<"u"&&window.removeEventListener("focus",A),w(),C?.(),E.reset(),d.delete(D))}d.add(D);try{await E.init(),(l.attributes?.merchandise||l.attributes?.merchandiseId)&&await E.refreshRemote()}catch(R){throw D(),R}return c(),!o&&typeof window<"u"&&window.addEventListener("focus",A),Object.assign(E,{refresh:u,destroy:D})}return{features:g,reset(l){a++,l();for(let O of d)O()}}}function be(t,e){let n="source"in e?{funnelId:e.source.id,funnelVersionId:e.source.versionId}:"versionId"in e?{funnelId:e.funnelId,funnelVersionId:e.versionId}:e,r=K.object({funnelId:J.shape.id,funnelVersionId:J.shape.versionId.optional()}).safeParse(n);if(!r.success)throw new s("INVALID_REQUEST","A valid Funnel source is required");let o=Object.freeze(r.data);function a(d){if("customerId"in d)throw new s("INVALID_REQUEST","Customer identity cannot be overridden");if("funnelId"in d&&d.funnelId!==void 0&&d.funnelId!==o.funnelId||"funnelVersionId"in d&&d.funnelVersionId!==void 0&&d.funnelVersionId!==o.funnelVersionId)throw new s("SCOPE_MISMATCH","The original Funnel source cannot change");return{...d,...o}}return{async claimCoupon(d,y=crypto.randomUUID()){let g=await f(t,"grantOffer"),l=await m(t,g,a({couponId:d,requestId:y}));return{offer:l.offer,reason:l.reason}},async resolveOffering(d){d=b(d);let y=await f(t,"resolveOffering"),g=y.request.parse(a(d)),l=await m(t,y,g);return j(g,l.check,l.scope),l},async resolvePaywall(d){d=b(d);let y=await f(t,"resolvePaywall"),g=y.request.parse(a(d)),l=await m(t,y,g);return j(g,l.paywall.check,l.scope),l},async previewAttach(d){d=b(d);let y=await f(t,"previewAttach");return m(t,y,a(d))}}}function xt(t){return Ne(t)}function Ne(t){let e=ie(t),n=e.request,r;try{r=ue(t.push,e,t.scope??t.configuration?.scope)}catch(y){throw e.dispose(),y}let o=le(e,()=>{d.reset(a.reset),a.detachVisibility()},{beforeIdentify:r.identify,beforeReset:r.reset,afterChange:r.start,beforeDestroy:r.destroy}),a=ge(n,o.isIdentified),d=Ee(n,o.isIdentified,a,t.scope,t.configuration);return{session:e.session,...de(n,r),...Ie(n),...he(n),forFunnel(y){return o.assertActive(),be(n,y)},async features(y={}){return o.assertActive(),d.features(y)},track(y,g,l={}){return a.track(y,g,l)},flush(){return a.flush()},...o.methods}}function Mt(t){if(!B.test(t.customerToken))throw new s("INVALID_TOKEN","A customer credential is required");if(!t.scope)throw new s("INVALID_REQUEST","An explicit App and environment scope is required");let e=ce({...t,scope:t.scope,apiKey:t.customerToken});return{async start(n){let r=await e.start(n),o=M({...t,runToken:r.runToken,initialResponse:r});o.identify(t.customerToken);let a=await o.get();return{...r,...a,controller:o}}}}function Kt(t){if(!t.scope)throw new s("INVALID_CONFIGURATION","An explicit process App/environment scope is required");if(t.session!==void 0)throw new s("INVALID_CONFIGURATION","The merchant process adapter owns the session");let e=null,n,r=0,o=new Set,a=new Map,d=new Map;async function y(p){let S,I=new Promise((q,h)=>{S=setTimeout(()=>h(new s("TIMEOUT","Process bridge request timed out")),t.timeoutMs??35e3)});try{return await Promise.race([Promise.resolve().then(p),I])}finally{clearTimeout(S)}}function g(p){throw p instanceof s&&(p.status===401||p.reason==="CUSTOMER_BINDING_CONFLICT")&&(r++,n?.reset(),n=void 0,e=null,a.clear(),d.clear()),p}function l(p,S){if(S!==r)throw new s("IDENTITY_CHANGED","Process was detached during a request");let I=re.parse(p);if(I.scope.projectId!==t.scope.projectId||I.scope.environment!==t.scope.environment)throw new s("SCOPE_MISMATCH","Process response belongs to another App/environment");if(e&&(e.run.id!==I.run.id||e.run.source.versionId!==I.run.source.versionId||e.run.source.id!==I.run.source.id||e.run.runExpiresAt!==I.run.runExpiresAt||e.run.identity.startedAs!==I.run.identity.startedAs||e.run.identity.participantId!==I.run.identity.participantId||e.run.identity.binding&&I.run.identity.binding&&e.run.identity.binding.id!==I.run.identity.binding.id))throw new s("INVALID_RESPONSE","The process changed its Run or Customer binding");if(!e||I.run.revision>=e.run.revision){if(e?.run.identity.binding&&!I.run.identity.binding)throw new s("INVALID_RESPONSE","The process lost its Customer binding");e=I;for(let A of o)z(A,I.run);I.run.instruction?.type==="authentication_required"&&z(t.onAuthenticationRequired,I.run)}I.settlement?.accepted!==void 0&&d.set(I.settlement.requestId,I.settlement.accepted);let{identity:q,instruction:h,...P}=I.run,{contract:E,settlement:i,...c}=I,u=i&&(({accepted:A,...w})=>w)(i);return{...c,run:{...P,authenticated:q.binding!==null,instruction:h?.type==="authentication_required"?null:h},...u?{settlement:u}:{}}}let O=p=>(a.has(p)||a.set(p,e?.run.identity.binding?.id??null),a.get(p));async function F(p){let S=r,I=e?.run.identity.binding?.id??null,q=P=>{if(I!==(e?.run.identity.binding?.id??null))throw P;return g(P)};if(p.operation==="page_experiments"){if(!t.adapter.pageExperiments)throw new s("CAPABILITY_UNAVAILABLE","Process page experiments are unavailable",501);return y(()=>t.adapter.pageExperiments(p.release,p.usedReceiptIds)).catch(q)}let h;if(p.operation==="get"){let{operation:P,customerToken:E,...i}=p;h=await y(()=>t.adapter.get({...i,...i.settlementRequestId?{settlementBindingId:O(i.settlementRequestId)}:{}})).catch(q)}else if(p.operation==="review")h=await y(()=>t.adapter.review(p.receiptId)).catch(q);else{if(p.operation==="start")throw new s("INVALID_REQUEST","Use process.open for entry");{let{customerToken:P,...E}=p;h=await y(()=>t.adapter.command(E,O(E.requestId))).catch(q)}}return l(h,S)}return{get view(){return e?.run??null},get controller(){return n},async open(p){let S=r,I=await y(()=>t.adapter.open(p)).catch(g),q=l(I,S);if(!n){n=M({...t,runToken:I.runToken,initialResponse:q,process:{request:F,binding:O,restore(E){for(let[i,c]of Object.entries(E))a.set(i,c)}}});let h=n,P=h.submit;h.submit=async E=>{try{return await P(E)}catch(i){if(!(i instanceof s)||i.reason!=="IDENTITY_CONTEXT_CHANGED"||E.operation!=="submit"||E.input.type!=="screen"||a.get(E.requestId)!==null)throw i;await h.settle?.(E.requestId),await h.get();let c=h.view;if(d.get(E.requestId)!==!1||!c||c.id!==e?.run.id||c.nodeId!==E.nodeId||c.visit!==E.visit||!e?.run.identity.binding)throw i;return P({...E,requestId:crypto.randomUUID(),revision:c.revision})}}}await n.get();for(let h of n.pendingCommands??[])a.has(h.requestId)&&a.get(h.requestId)!==(e?.run.identity.binding?.id??null)&&await n.settle?.(h.requestId);return{run:e.run,controller:n}},async syncIdentity(){let p=r;l(await y(()=>t.adapter.syncIdentity()).catch(g),p),await n?.get();for(let S of n?.pendingCommands??[])a.has(S.requestId)&&a.get(S.requestId)!==(e?.run.identity.binding?.id??null)&&await n?.settle?.(S.requestId);return e.run},async detach(){r++,n?.reset(),n=void 0,e=null,a.clear(),d.clear(),await y(()=>t.adapter.detach())},forProcess(p){if(!e?.run.identity.binding)throw new s("UNAUTHENTICATED","Sign in before a commercial operation",401);return{runId:e.run.id,bindingId:e.run.identity.binding.id,receiptId:p}},subscribe(p){return o.add(p),()=>{o.delete(p)}},destroy(){r++,n?.reset(),n=void 0,e=null,a.clear(),d.clear(),o.clear()}}}export{xt as a,Ne as b,Mt as c,Kt as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as A}from"./chunk-W32FI2A2.js";import{b as D,e as L}from"./chunk-SLUA7ABW.js";import{d as T}from"./chunk-LVG5ED52.js";import{b as O}from"./chunk-O4KXODTJ.js";import{a as R}from"./chunk-DSPLGTQI.js";var m=new WeakMap;function B(e){let o=e.view,n=o?.paywall?.resolution;if(!o||!["running","waiting"].includes(o.status)||o.stopped||!n||"document"in n||!e.resolvePaywall||e.identitySignal?.aborted)return;let a=JSON.stringify(n);if(m.get(e)?.key===a)return;let i=JSON.parse(a),c=e.identitySignal,u=Promise.resolve().then(async()=>{c?.throwIfAborted();let v=await e.resolvePaywall(i);return c?.throwIfAborted(),v}),f={key:a,content:u};return m.set(e,f),u.catch(()=>{}),()=>{m.get(e)===f&&m.delete(e)}}function Q(e,o){let n=m.get(e);return m.delete(e),n?.key===JSON.stringify(o)?n.content:e.resolvePaywall(o)}function re(e){if(!e.client.pageExperiments)throw new Error("The Run controller does not support page experiments");let o=e.client.pageExperiments.bind(e.client),n=!1,a=!1,i=0,c=!1,u=!1,f="",v=()=>{let t=e.client.view;return JSON.stringify([t?.id,t?.source.versionId,t?.visit,t?.revision,t?.status,t?.stopped])},s=new Map,x=new Set,q={},d=new Map,U=D(e.appManifestRelease),C=()=>{for(let t of s.values())t.effect.revert();s.clear()},g=()=>{C();for(let t of d.values())t();d.clear()};function E(t){if(n||x.has(t))return;x.add(t);let h=i;o(e.appManifestRelease,[t]).catch(k=>{x.delete(t),!n&&h===i&&R(e.onError,k)})}async function w(){if(n)return;f=v();let t=e.client.view;if(!t||t.stopped||!["running","waiting"].includes(t.status)){i++,g();return}if(document.visibilityState==="hidden")return;if(c){u=!0;return}c=!0;let h=++i,k=`${t.id}:${t.visit}:${t.revision}`,W=location.href;try{let[P,{applyVisualVariation:j}]=await Promise.all([o(e.appManifestRelease),import("./visual-dom-5LUN4AHO.js")]),p=e.client.view;if(n||h!==i||!p||p.stopped||!["running","waiting"].includes(p.status)||`${p.id}:${p.visit}:${p.revision}`!==k||location.href!==W)return;let $=new Set,I=new Set;for(let r of P.assignments){let l=`${P.payload.environmentId}:${r.experimentKey}`;if(I.add(l),d.has(l)||d.set(l,L(l,q)),!!r.inExperiment)for(let y of P.payload.experiments){if(y.key!==r.experimentKey||!O(location.href,y.urlPatterns??[]))continue;let z=y.meta?.findIndex(F=>F.key===r.variationKey)??-1,S=y.variations[z];if(!S?.renderGuard)continue;let b=r.receiptId+":"+y.changeId,J=JSON.stringify([r.variationKey,S]);$.add(b);let N=s.get(b);if(N?.signature===J){N.effect.applied&&E(r.receiptId);continue}s.get(b)?.effect.revert(),s.delete(b);let K=j(S,{requireUniqueTargets:!0,boundVariations:y.variations,allowJs:!1,onApplied:()=>E(r.receiptId),onError:F=>R(e.onError,F)});s.set(b,{signature:J,effect:K}),K.applied&&E(r.receiptId)}}for(let[r,l]of s)$.has(r)||(l.effect.revert(),s.delete(r));for(let[r,l]of d)I.has(r)||(l(),d.delete(r))}catch(P){h===i&&g(),!n&&h===i&&R(e.onError,P)}finally{c=!1,u&&!n&&(u=!1,w())}}let G=e.client.subscribe(()=>{if(v()===f)return;f=v(),i++;let t=e.client.view;(!t||t.stopped||!["running","waiting"].includes(t.status))&&g(),a&&w()}),H=T(()=>{i++,g(),a&&w()}),V=()=>{i++,C()};document.addEventListener("visibilitychange",V);let M=A({document,run:async()=>{a&&await w()},delay:()=>a&&!n?15e3:void 0});return{async start(){a||n||(a=!0,await M.refresh())},refresh:w,destroy(){n=!0,i++,M.destroy(),document.removeEventListener("visibilitychange",V),G(),H(),g(),U.destroy()}}}export{B as a,Q as b,re as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function l(e){let i=!1,n,r,d=()=>{clearTimeout(n),n=void 0};function t(){if(d(),i)return;let o=e.document.visibilityState==="hidden"?e.hiddenDelay?.():e.delay();o!==void 0&&(n=setTimeout(()=>{u().catch(()=>{})},o))}function u(){if(i)return Promise.resolve();if(r)return r;d();let o=Promise.resolve().then(()=>i?void 0:e.run());r=o;let c=()=>{r===o&&(r=void 0),t()};return o.then(c,c),o}let s=()=>{e.document.visibilityState==="hidden"?t():u().catch(()=>{})};return e.document.addEventListener("visibilitychange",s),{schedule:t,refresh:u,destroy(){i=!0,d(),e.document.removeEventListener("visibilitychange",s)}}}function a(e,i,n){return new Promise(r=>{let d,t=()=>{clearTimeout(d),i.removeEventListener("visibilitychange",s),n.removeEventListener("abort",t),r()},u=()=>{clearTimeout(d),d=setTimeout(t,i.visibilityState==="hidden"?Math.max(e,3e4):e)},s=()=>{i.visibilityState==="visible"?t():u()};i.addEventListener("visibilitychange",s),n.addEventListener("abort",t,{once:!0}),u(),n.aborted&&t()})}export{l as a,a as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p as n,s as t}from"./chunk-HYE2YQYM.js";function u(o,e,a){return n(o,e,a,t)}export{u as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as e}from"./chunk-ZYN4CRHS.js";var c=e.enum(["replace","stack_native"]);export{c as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as s,b as o,c as u}from"./chunk-LAGGWYH3.js";import{d as m,g as p}from"./chunk-DHT3AWJQ.js";import{b as e}from"./chunk-ZYN4CRHS.js";var f=["USD","EUR","CNY","GBP","JPY","CAD","AUD","NZD","CHF","HKD","SGD","KRW","INR","BRL","MXN","TWD","THB","IDR","MYR","PHP","VND","ZAR","AED","SAR","SEK","NOK","DKK","PLN","CZK","HUF","ILS","TRY","RON"],i=e.enum(f);function x(t){let r=i.parse(t.toUpperCase());return["JPY","KRW","VND"].includes(r)?0:2}function I(t,r,n="en",y={}){let a=i.parse(r.toUpperCase());return new Intl.NumberFormat(n,{style:"currency",currency:a,...y}).format(t/10**x(a))}var d=e.enum(["stripe","apple","google","merchant"]),_=e.enum(["membership","credit_pack","lifetime"]),v=e.enum(["active","grace","suspended","inactive","revoked"]),z=e.strictObject({currency:e.string().regex(/^[A-Z]{3}$/),micros:e.string().regex(/^(0|[1-9][0-9]{0,29})$/)});var l=e.object({provider:d,currency:i}).strict();var c=e.strictObject({internal_feature_id:e.uuid(),quantity:m.refine(t=>/[1-9]/.test(t)),properties:p,entityId:e.uuid().optional()}),B=e.strictObject({requirement:c,commerce:l.optional(),paywallId:e.uuid().optional()}),g=e.enum(["not_entitled","insufficient_balance","capacity_exceeded","limit_exceeded","awaiting_topup","authorization_required","payment_blocked","cash_budget_exceeded","unavailable","authentication_required"]),S=e.strictObject({productId:e.string().min(1),productVersionId:e.string().min(1),name:e.string().min(1).max(120),action:e.enum(["purchase","upgrade","addon","topup"]),membershipId:e.string().min(1).nullable(),currency:i,amountMinor:e.string().regex(/^(0|[1-9]\d{0,8})$/),interval:e.enum(["free","week","month","year","one_time"]),intervalCount:e.number().int().min(1).max(156)}),h=e.strictObject({subject:o,authority:e.enum(["longplay","merchant"]),observedAt:e.iso.datetime({offset:!0}),sourceRevision:e.string().min(1).max(128),requirementDigest:s});function b(t,r){return u({subject:o.parse(t),requirement:c.parse(r)})}var C=e.strictObject({internal_feature_id:e.string().min(1),name:e.string().min(1).max(120),kind:e.enum(["access","metered","credit"]),quantity:m,allowed:e.boolean(),observation:h.optional(),reason:g.nullable(),preview:e.strictObject({scenario:e.enum(["feature_flag","usage_limit"]),candidates:e.array(S).max(20)}).nullable()}).superRefine((t,r)=>{(t.allowed!==(t.reason===null)||t.allowed&&t.preview!==null||new Set(t.preview?.candidates.map(n=>n.productVersionId)).size!==(t.preview?.candidates.length??0)||t.preview?.candidates.some(n=>n.action==="upgrade"!=(n.membershipId!==null)))&&r.addIssue({code:"custom",message:"Invalid access recommendation"})}),T=e.strictObject({paywallId:e.uuid(),requirement:c}),U=e.strictObject({subject:o,requirement:c}),$=C.safeExtend({observation:h.extend({authority:e.literal("merchant")})});function F(t,r){let n=c.parse(t);return r.internal_feature_id===n.internal_feature_id&&r.quantity===n.quantity&&(!r.observation||r.observation.requirementDigest===b(r.observation.subject,n))}export{i as a,x as b,I as c,_ as d,l as e,c as f,B as g,S as h,b as i,C as j,U as k,$ as l,F as m};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as p,i as d}from"./chunk-
|
|
1
|
+
import{h as p,i as d}from"./chunk-GLYFT5WW.js";import{B as m,v as a,y as u}from"./chunk-QHJWVLJC.js";import{b as e}from"./chunk-ZYN4CRHS.js";var s=e.enum(["page","popup","banner"]),y=3e5,f=e.strictObject({type:e.enum(["string","number","boolean","strings","json"]),nullable:e.boolean()}),h=e.strictObject({inputs:e.record(a,f.extend({required:e.boolean()})).refine(t=>Object.keys(t).length<=40,"Too many content inputs"),outputs:e.record(a,f).refine(t=>Object.keys(t).length<=40,"Too many content outputs")}),g=e.strictObject({kind:s,schemaVersion:e.literal(1),name:e.string().trim().min(1).max(80),screen:u,contract:h}),c=g.superRefine((t,r)=>{let n=(o,b)=>r.addIssue({code:"custom",message:o,path:b});t.screen.surface!==t.kind&&n("Content surface must match its domain",["screen","surface"]),t.screen.name!==t.name&&n("Content has one editable name",["screen","name"]),t.kind==="banner"&&t.screen.presentation.type!=="inline"&&n("Banner requires an inline container",["screen","presentation"]),t.kind!=="banner"&&t.screen.presentation.type==="inline"&&n("Inline presentation belongs to Banner",["screen","presentation"]),t.screen.actions.some(o=>o.type!=="event"&&o.type!=="navigate")&&n("Content actions must emit host intents or navigate locally",["screen","actions"]);let i=new Set(t.screen.actions.filter(o=>o.type==="event").map(o=>o.id));(Object.keys(t.contract.outputs).some(o=>!i.has(o))||[...i].some(o=>!Object.hasOwn(t.contract.outputs,o)))&&n("Every event needs exactly one output declaration",["contract","outputs"]),d(t)>y&&n("Content document exceeds its byte budget",[])});function S(t,r){if(t===null)return r.nullable;switch(r.type){case"json":return!0;case"string":return typeof t=="string";case"number":return typeof t=="number"&&Number.isFinite(t);case"boolean":return typeof t=="boolean";case"strings":return Array.isArray(t)&&t.every(n=>typeof n=="string")}}var x=c.superRefine((t,r)=>{for(let n of p(t.screen))Object.keys(t.contract.inputs).some(i=>n===i||n.startsWith(i+"."))||r.addIssue({code:"custom",path:["contract","inputs"],message:"Declare every reusable input read"});for(let n of t.screen.actions){if(n.type!=="event")continue;let i=t.contract.outputs[n.id],o=Object.hasOwn(n.properties,"value")?n.properties.value:n.properties;i&&!S(o,i)&&r.addIssue({code:"custom",path:["contract","outputs",n.id],message:"Action value differs from its declared type"})}m(t.screen).some(n=>!n.complete)&&r.addIssue({code:"custom",path:["screen","strings"],message:"Content needs complete localized copy"})}),l=e.strictObject({id:e.uuid(),kind:s,projectId:e.uuid(),environmentId:e.uuid(),name:e.string(),revision:e.number().int().nonnegative(),status:e.enum(["draft","published","archived"]),publishedVersionId:e.uuid().nullable(),createdAt:e.iso.datetime({offset:!0}),updatedAt:e.iso.datetime({offset:!0})}),D=l.extend({draft:c}),I=e.strictObject({rows:e.array(l).max(200),nextCursor:e.uuid().nullable()}),v=e.strictObject({id:e.uuid(),kind:s,resourceId:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),version:e.number().int().positive(),sourceRevision:e.number().int().nonnegative(),document:x,createdAt:e.iso.datetime({offset:!0})}),z=v.omit({document:!0}),V=e.discriminatedUnion("action",[e.strictObject({action:e.literal("create"),kind:s,id:e.uuid(),document:c}),e.strictObject({action:e.literal("save"),kind:s,id:e.uuid(),revision:e.number().int().nonnegative(),document:c}),e.strictObject({action:e.enum(["publish","archive"]),kind:s,id:e.uuid(),revision:e.number().int().nonnegative()})]).superRefine((t,r)=>{"document"in t&&t.document.kind!==t.kind&&r.addIssue({code:"custom",path:["document","kind"],message:"Content cannot change domain"})});export{s as a,v as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as k}from"./chunk-QHJWVLJC.js";import{a as M}from"./chunk-DSPLGTQI.js";var z={sm:420,md:640,lg:900},A=767;function le(e,r,o=()=>!0,c="Close"){let n=e.ownerDocument.defaultView,i=e.ownerDocument.createElement("button");i.type="button",i.setAttribute("aria-label",c),i.style.cssText="position:absolute;inset:0 48px auto;z-index:2;height:24px;border:0;padding:0;background:transparent;touch-action:none;cursor:grab";let d=e.ownerDocument.createElement("span");d.style.cssText="display:block;width:36px;height:4px;border-radius:4px;margin:8px auto 12px;background:currentColor;opacity:.22;pointer-events:none",i.append(d),e.prepend(i);let p,s=0,a=!1,f=()=>{i.hidden=e.dataset.presentation!=="sheet",i.setAttribute("aria-disabled",String(!o()))},v=t=>{f(),!(i.hidden||!o()||t.button!==0)&&(p={y:t.clientY,time:Date.now(),id:t.pointerId},s=0,a=!1,i.setPointerCapture?.(t.pointerId))},y=t=>{!p||t.pointerId!==p.id||(s=Math.max(0,t.clientY-p.y),e.style.transform=`translateY(${s}px)`)},g=t=>{if(!p||t.pointerId!==p.id)return;let u=Math.max(1,Date.now()-p.time),x=t.type!=="pointercancel"&&o()&&(s>120||s>40&&s/u>.5);a=s>6,p=void 0,i.releasePointerCapture?.(t.pointerId),e.style.transform="",x?r():s&&typeof e.animate=="function"&&!n?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&e.animate([{transform:`translateY(${s}px)`},{transform:"none"}],{duration:200,easing:"cubic-bezier(.2,.8,.2,1)"}),s=0},m=()=>{if(a){a=!1;return}!p&&s===0&&o()&&r()};i.addEventListener("pointerdown",v),i.addEventListener("pointermove",y),i.addEventListener("pointerup",g),i.addEventListener("pointercancel",g),i.addEventListener("click",m);let l=typeof MutationObserver=="function"?new MutationObserver(f):void 0;return l?.observe(e,{attributes:!0,attributeFilter:["data-presentation"]}),n?.addEventListener("resize",f),f(),()=>{l?.disconnect(),n?.removeEventListener("resize",f),i.remove(),e.style.transform=""}}function O(e,r,o=!1){return(e.type==="modal"||e.type==="sheet")&&e.mobile&&o&&r<=A?e.mobile:e.type}function W(e,r,o){let c=e.ownerDocument.defaultView,n=r.presentation,i;if((n.type==="modal"||n.type==="sheet")&&n.backdrop){let t=`lp-backdrop-${crypto.randomUUID()}`,u={none:"transparent",scrim:"#f2f2f2cc",dim:"#0006","strong-dim":"#000000bf",blur:"#0006"};e.dataset.indianaBackdrop=t,i=e.ownerDocument.createElement("style"),i.textContent=`dialog[data-indiana-backdrop="${t}"]::backdrop{background:${u[n.backdrop]};backdrop-filter:${n.backdrop==="blur"?"blur(16px)":"none"}}`,e.append(i)}let d=r.pages?.[0]?.root.style?.shape,p=d?.type==="pill"?"9999px":d?.type==="rect"?typeof d.radius=="number"?`${d.radius}px`:[d.radius.topLeft,d.radius.topRight,d.radius.bottomRight,d.radius.bottomLeft].map(t=>`${t}px`).join(" "):void 0,s=(n.type==="modal"||n.type==="sheet")&&(n.desktopWidth!==void 0||n.mobile!==void 0||n.type==="modal"&&n.position!==void 0),a=n.type,f,v,y=!1,g=t=>{y||!Number.isFinite(t)||t<0||(v=t,a!=="fullscreen"&&a!=="inline"&&(e.style.height=`min(${Math.max(t,40)}px, calc(100dvh - ${a==="sheet"?0:32}px))`))},m=()=>{if(!y&&(a=f??O(n,c?.innerWidth??1024,c?.matchMedia?.("(pointer: coarse)").matches===!0),e.dataset.presentation=a,!(!s||n.type!=="modal"&&n.type!=="sheet"))){if(e.style.boxSizing="border-box",e.style.padding="0",e.style.border="0",e.style.overflow="hidden",e.style.outline="none",e.tabIndex=-1,e.style.background=r.theme.background,e.style.color=r.theme.text,a==="fullscreen")e.style.width="100vw",e.style.height="100dvh",e.style.maxWidth="100vw",e.style.maxHeight="100dvh",e.style.margin="0",e.style.borderRadius="0";else{let t=n.mobile==="sheet"&&a==="sheet",u=n.desktopWidth,x=c?.innerWidth??1024;e.style.width=t?`${x}px`:u?`${Math.min(u.max,Math.max(x*u.viewport/100,u.min))}px`:`${k[n.size]}px`,e.style.maxWidth=`${Math.max(0,x-(a==="sheet"?0:32))}px`,e.style.maxHeight=a==="sheet"?"100dvh":"calc(100dvh - 32px)",e.style.margin=a==="sheet"?"auto auto 0":n.type==="modal"&&n.position==="top"?"16px auto auto":n.type==="modal"&&n.position==="bottom"?"auto auto 16px":"auto",e.style.borderRadius=p??(a==="sheet"?"16px 16px 0 0":"24px"),e.style.height="",v!==void 0&&g(v)}o?.(a)}},l=s?[c?.matchMedia?.(`(max-width: ${A}px)`),c?.matchMedia?.("(pointer: coarse)")].filter(t=>t!==void 0):[];if(s){c?.addEventListener("resize",m);for(let t of l)t.addEventListener?t.addEventListener("change",m):t.addListener?.(m)}return m(),{responsive:s,get type(){return a},latch(){y||f!==void 0||(m(),f=a)},setContentHeight:g,destroy(){if(!y){y=!0,i?.remove(),delete e.dataset.indianaBackdrop,c?.removeEventListener("resize",m);for(let t of l)t.removeEventListener?t.removeEventListener("change",m):t.removeListener?.(m)}}}}function ue(e,r,o){let{presentation:c}=r,n="size"in c?`${z[c.size]}px`:"100vw";return e.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${n}`,W(e,r,o)}function me(e,r,o=!1){let c=e.ownerDocument.defaultView;if(typeof e.animate!="function"||c?.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;let n=o?{duration:300,easing:"cubic-bezier(0.23, 1, 0.32, 1)"}:{duration:240,easing:"cubic-bezier(0.2, 0.8, 0.2, 1)"};e.animate(r==="sheet"?[{transform:"translateY(100%)"},{transform:"none"}]:r==="modal"?[{opacity:0,transform:o?"translateY(12px) scale(0.96)":"translateY(8px) scale(0.98)"},{opacity:1,transform:"none"}]:[{opacity:0},{opacity:1}],n);try{e.animate([{opacity:0},{opacity:1}],{...n,pseudoElement:"::backdrop"})}catch{}}function $(e,r){e.style.cssText=["position:absolute","z-index:1","top:calc(4px + env(safe-area-inset-top, 0px))","inset-inline-end:calc(4px + env(safe-area-inset-right, 0px))","width:44px","height:44px","padding:0","border:0","border-radius:50%","font:400 20px/1 system-ui,sans-serif","cursor:pointer","touch-action:manipulation"].join(";"),e.style.background=`radial-gradient(circle, ${r.background} 0 15px, color-mix(in srgb, ${r.text} 22%, ${r.background}) 15px 16px, transparent 16.5px)`,e.style.color=r.text}var C=new WeakMap;function he(e,r){return C.set(e,r),()=>C.delete(e)}function xe(e){let r=e.defaultView?.HTMLElement,o=e.activeElement;for(let n=0;n<16&&o?.shadowRoot?.activeElement;n++)o=o.shadowRoot.activeElement;let c=o?C.get(o)?.():void 0;return()=>{!o?.isConnected||!r||!(o instanceof r)||(o.focus({preventScroll:!0}),c?.())}}var ge=15e3;function we(e,r,o,c,n){let i=e.ownerDocument,d=new AbortController,p=!1,s=!1,a,f;function v(){f?.(),f=void 0,a?.tagName==="DIALOG"&&a.close?.(),a?.remove(),a=void 0}function y(l,t){s||(s=!0,v(),(l==="dismissed"||l==="error")&&d.abort(t??new DOMException("Presentation cancelled","AbortError")),!(!p&&l!=="ready")&&M(r.onPresentationState,l==="error"?{surface:o,state:l,error:t}:{surface:o,state:l}))}let g=c,m=()=>{s||g()};return{setDismissHandler(l){g=l},get active(){return p&&!s},get cancelled(){return d.signal.aborted},start(l,t,u){if(!(p||s)){if(p=!0,r.loading!=="host"){let x=(t??i.documentElement.lang)||"en",b=l&&u?.presentation?.type!=="inline",S=u!==void 0,h=i.createElement(b?"dialog":"div");a=h,h.dataset.longplayLoading=o;let E=x.startsWith("zh"),I=S?E?"\u6B63\u5728\u52A0\u8F7D\u5957\u9910":"Loading plans":E?"\u6B63\u5728\u52A0\u8F7D":"Loading",R=u?.screen.theme??{background:"Canvas",text:"CanvasText"};h.setAttribute("aria-label",I);let P=i.createElement("div");P.setAttribute("role","status");let L=i.createElement("div");L.setAttribute("aria-hidden","true");let H=()=>{P.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)"};S?P.style.cssText="padding:24px 60px 24px 24px;font:500 16px/1.5 system-ui,sans-serif":H(),P.textContent=I;let w=i.createElement("button");w.type="button",w.textContent="\xD7",w.setAttribute("aria-label",E?"\u53D6\u6D88\u52A0\u8F7D":"Cancel loading"),$(w,R),w.addEventListener("click",m),h.addEventListener("cancel",D=>{D.preventDefault(),m()}),h.append(P,L,w),e.append(h);let T=()=>{if(!s&&b){let D=h;D.showModal?D.showModal():D.open=!0,w.focus({preventScroll:!0})}};u&&n?(f=n(h,L,u,x,()=>{s||(L.style.visibility="",H())}),T()):S?(h.style.cssText=b?"padding:0;border:0;border-radius:24px;background:Canvas;color:CanvasText;width:min(420px,calc(100vw - 32px))":"position:relative;background:Canvas;color:CanvasText;width:100%",T()):(_(h,L,b,o),T())}M(r.onPresentationState,{surface:o,state:"loading",dismiss:m})}},present(l){if(s)return;let t=!!a;v(),l(t),y("ready")},dismiss:m,finish:y,async wait(l,t){let u=d.signal,x,b,S=new Promise((h,E)=>{b=()=>E(u.reason),u.aborted?b():u.addEventListener("abort",b,{once:!0}),t!==void 0&&(x=setTimeout(()=>E(new Error("Presentation data timed out")),t))});try{let h=await Promise.race([S,l]);return u.throwIfAborted(),h}finally{u.removeEventListener("abort",b),clearTimeout(x)}}}}function _(e,r,o,c){e.style.cssText="position:relative;box-sizing:border-box;background:Canvas;color:CanvasText;padding:24px 48px 24px 24px;"+(o?"position:fixed;width:min(480px,calc(100% - 32px));border:0;border-radius:16px;max-height:calc(100dvh - 32px)":"width:100%"),r.style.cssText="display:grid;gap:12px";let n=c==="banner"?[["72%",12],["44%",10]]:[["46%",20],["84%",12],["65%",12],["100%",64]];for(let[i,d]of n){let p=e.ownerDocument.createElement("div");p.style.cssText=`width:${i};height:${d}px;background:currentColor;opacity:.11;border-radius:6px`,r.append(p)}}function F(e){let r={display:"block",position:"fixed",top:"0",left:"0",opacity:"0",pointerEvents:"none",zIndex:"-1"},o=Object.keys(r).map(i=>{let d=i,p=e.style[d];return e.style[d]=r[d],[d,p]}),c=e.inert??!1,n=e.getAttribute("aria-hidden");return e.inert=!0,e.setAttribute("aria-hidden","true"),()=>{for(let[i,d]of o)e.style[i]=d;e.inert=c,n===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n)}}function Se(e,r){let o=e.style.width;e.style.width=`${r.getBoundingClientRect().width||r.ownerDocument.defaultView?.innerWidth||800}px`;let c=F(e);return()=>{c(),e.style.width=o}}export{le as a,O as b,W as c,ue as d,me as e,$ as f,he as g,xe as h,ge as i,we as j,F as k,Se as l};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as e}from"./chunk-
|
|
1
|
+
import{b as e}from"./chunk-ZYN4CRHS.js";var s=/^gg_ct_[A-Za-z0-9_-]{32,128}$/,o=e.object({customerId:e.uuid(),sessionId:e.uuid(),accessToken:e.string().regex(/^gg_ct_[A-Za-z0-9_-]{43}$/),refreshToken:e.string().regex(/^gg_rt_[A-Za-z0-9_-]{43}$/),expiresAt:e.iso.datetime(),refreshExpiresAt:e.iso.datetime()});export{s as a,o as b};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { S as StackNode } from './screen-
|
|
2
|
+
import { S as StackNode } from './screen-qUBRsUi9.js';
|
|
3
3
|
|
|
4
4
|
declare const configurationScopeSchema: z.ZodObject<{
|
|
5
5
|
projectId: z.ZodString;
|
|
@@ -421,6 +421,11 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
421
421
|
event: "screen_enter" | "button_click";
|
|
422
422
|
cooldownSeconds: number;
|
|
423
423
|
behavior: "observe";
|
|
424
|
+
delivery?: {
|
|
425
|
+
delaySeconds?: number | undefined;
|
|
426
|
+
maxPerDay?: number | undefined;
|
|
427
|
+
maxPerSession?: number | undefined;
|
|
428
|
+
} | undefined;
|
|
424
429
|
}[] | undefined;
|
|
425
430
|
position?: {
|
|
426
431
|
x: number;
|
|
@@ -439,6 +444,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
439
444
|
} | undefined;
|
|
440
445
|
mobile?: "sheet" | "fullscreen" | undefined;
|
|
441
446
|
backdrop?: "none" | "scrim" | "dim" | "strong-dim" | "blur" | undefined;
|
|
447
|
+
position?: "center" | "top" | "bottom" | undefined;
|
|
442
448
|
} | {
|
|
443
449
|
type: "sheet";
|
|
444
450
|
size: "sm" | "md" | "lg";
|
|
@@ -762,6 +768,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
762
768
|
} | undefined;
|
|
763
769
|
mobile?: "sheet" | "fullscreen" | undefined;
|
|
764
770
|
backdrop?: "none" | "scrim" | "dim" | "strong-dim" | "blur" | undefined;
|
|
771
|
+
position?: "center" | "top" | "bottom" | undefined;
|
|
765
772
|
} | {
|
|
766
773
|
type: "sheet";
|
|
767
774
|
size: "sm" | "md" | "lg";
|
|
@@ -1228,6 +1235,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
1228
1235
|
} | undefined;
|
|
1229
1236
|
mobile?: "sheet" | "fullscreen" | undefined;
|
|
1230
1237
|
backdrop?: "none" | "scrim" | "dim" | "strong-dim" | "blur" | undefined;
|
|
1238
|
+
position?: "center" | "top" | "bottom" | undefined;
|
|
1231
1239
|
} | {
|
|
1232
1240
|
type: "sheet";
|
|
1233
1241
|
size: "sm" | "md" | "lg";
|
|
@@ -1258,6 +1266,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
1258
1266
|
} | undefined;
|
|
1259
1267
|
mobile?: "sheet" | "fullscreen" | undefined;
|
|
1260
1268
|
backdrop?: "none" | "scrim" | "dim" | "strong-dim" | "blur" | undefined;
|
|
1269
|
+
position?: "center" | "top" | "bottom" | undefined;
|
|
1261
1270
|
} | {
|
|
1262
1271
|
type: "sheet";
|
|
1263
1272
|
size: "sm" | "md" | "lg";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as ie}from"./chunk-C4GBV32U.js";import{a as Z,c as ee,e as te,f as ne,h as N,j as re,k as oe,l as se}from"./chunk-YQX27SBG.js";import{b as X}from"./chunk-XQTCEQXI.js";import{r as V}from"./chunk-JOIPLLHK.js";import"./chunk-GLYFT5WW.js";import"./chunk-WRLVPHPE.js";import"./chunk-35VG2IYD.js";import"./chunk-HVVJGLYZ.js";import"./chunk-ZYF6TRJ3.js";import{$ as K,C as G,H as R,_ as Y,r as $}from"./chunk-QHJWVLJC.js";import"./chunk-XE7GU6FZ.js";import"./chunk-LAGGWYH3.js";import"./chunk-DHT3AWJQ.js";import{a as p}from"./chunk-TIQS5DUF.js";import"./chunk-7ZEXY4GC.js";import"./chunk-RHF4NFCZ.js";import{b as u}from"./chunk-ZYN4CRHS.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as h}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";var z=new WeakMap;function ce(s){let t={string:u.string(),number:u.number().finite(),boolean:u.boolean(),strings:u.array(u.string()),json:R}[s.type];return s.nullable?t.nullable():t}function ae(s,t){let f=u.record(u.string(),R).parse(s);if(Object.keys(f).length>40)throw new p("INVALID_REQUEST","Too many content inputs");for(let[m,r]of Object.entries(f))Y.parse({[m]:r});if(Object.keys(f).some(m=>!Object.hasOwn(t.inputs,m)))throw new p("INVALID_REQUEST","Undeclared content input");for(let[m,r]of Object.entries(t.inputs))if(Object.hasOwn(f,m))ce(r).parse(f[m]);else if(r.required)throw new p("INVALID_REQUEST",`Missing content input ${m}`);return f}async function Ae(s,t){return le(s,t,!1)}async function Se(s,t){return le(s,t,!0)}async function le(s,t,f){t.signal?.throwIfAborted();let m=X.parse(t.content),r=m.document;if(t.closeControl==="content"&&!r.screen.actions.some(e=>e.type==="event"&&e.close))throw new p("INVALID_REQUEST","An authored Close control requires a declared Close action");if(z.has(s))throw new p("CONFLICT","Content is already mounted in this container");let y=ae(t.inputs??{},r.contract),T=new Set(u.array(u.string()).max(40).parse(t.mutableInputs??[]));if(T.size!==(t.mutableInputs?.length??0)||[...T].some(e=>!Object.hasOwn(r.contract.inputs,e)))throw new p("INVALID_REQUEST","Mutable content inputs must name unique declared inputs");for(let e of Object.keys(r.contract.outputs))if(typeof t.actions[e]!="function")throw new p("INVALID_REQUEST",`Missing host handler for ${e}`);let M=K.parse(t.bindings??[]),d=s.ownerDocument,ue=s.clientHeight||d.defaultView?.innerHeight||800,P,w,a,_,x=r.kind==="popup",n=x?d.createElement("dialog"):null,c=d.createElement("div");if(c.dataset.indianaContent=r.kind,c.setAttribute("aria-label",r.name),c.style.cssText="width:100%;min-width:0",n){n.setAttribute("aria-label",r.name);let e=r.screen.presentation;n.style.cssText="box-sizing:border-box;padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto",e.type==="modal"||e.type==="sheet"?(n.style.width=`${$[e.size]}px`,e.type==="sheet"&&(n.style.margin="auto auto 0")):n.style.width="100vw",a=ee(n,r.screen,()=>{w?.resizeViewport(d.defaultView?.innerHeight||800,d.defaultView?.innerWidth||1024)}),n.append(c),s.append(n)}else s.append(c);let i=!1,A=!1,E=!1,S=!1,de=n?oe(n):se(c,s),D=re(s,t,r.kind,()=>{k()&&(b(),h(t.onDismiss))}),q,H,L=new Promise((e,o)=>{q=e,H=o});L.catch(()=>{});let g=null,I=structuredClone(r.screen),W=G(I,[t.locale,...d.defaultView?.navigator.languages??[]]),j=t.capabilities;I.actions=I.actions.map(e=>e.type==="event"?{...e,close:!1}:e);function b(){i||(i=!0,t.signal?.removeEventListener("abort",b),D.finish("dismissed"),H(new Error("Content preparation cancelled")),a?.destroy(),_?.(),w?.destroy(),n?.close(),n?.remove(),c.remove(),z.delete(s),n&&P?.())}let v=()=>{!E||!k()||(b(),h(t.onDismiss))};function k(){try{return t.canDismiss?.()!==!1}catch(e){return h(t.onError,e),!1}}if(n&&t.closeControl!=="content"){let e=d.createElement("button");e.type="button",e.textContent="\xD7",e.setAttribute("aria-label",t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),ne(e,r.screen.theme),e.addEventListener("click",v),n.prepend(e)}n&&a?.responsive&&(_=Z(n,v,k,t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),n.addEventListener("click",e=>{if(e.target!==n)return;let o=n.getBoundingClientRect();(e.clientX<o.left||e.clientX>o.right||e.clientY<o.top||e.clientY>o.bottom)&&v()})),n?.addEventListener("cancel",e=>{e.preventDefault(),v()}),n?.addEventListener("keydown",e=>{e.key==="Escape"&&(e.preventDefault(),v())});async function F(){if(i||!E||A||!g)return;let e=g;A=!0,c.setAttribute("aria-busy","true");try{await t.actions[e.actionId](structuredClone(e)),g=null}catch(o){i||h(t.onError,o)}finally{A=!1,i||c.removeAttribute("aria-busy")}}function J(){if(i)throw new p("CONFLICT","Content host has been destroyed");E||!S||(P??=N(d),D.present(e=>{de(),n&&(a?.latch(),n.showModal(),a?.responsive&&n.focus({preventScroll:!0}),!e&&t.loading!=="host"&&te(n,a?.type??r.screen.presentation.type,a?.responsive)),E=!0}))}function U(e){D.finish("error",e),H(e instanceof Error?e:new Error(String(e))),b()}let Q={destroy:b,show:J,get pendingAction(){return g?structuredClone(g):null},retryAction:F,updateInputs(e){if(i)throw new p("CONFLICT","Content host has been destroyed");let o=u.record(u.string(),R).parse(e),C=ae({...y,...o},r.contract);for(let l of Object.keys(o))if(!T.has(l)&&(!Object.hasOwn(y,l)||V(y[l])!==V(C[l])))throw new p("PRECONDITION_FAILED","This content input is frozen; prepare a new presentation");V(y)!==V(C)&&(w?.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:C}}),y=C)},updateCapabilities(e){if(i)return;let o=structuredClone(e);w?.updateCapabilities(o),j=o}};z.set(s,Q),t.signal?.addEventListener("abort",b,{once:!0});try{if(t.signal?.throwIfAborted(),f||(P=N(d),D.start(x,t.locale??r.screen.strings.defaultLocale),i&&await L),w=ie(c,{mode:"live",rendererUrl:t.rendererUrl,title:r.name,viewportHeight:r.kind==="page"?ue:a?.responsive?d.defaultView?.innerHeight||800:void 0,...a?.responsive?{viewportWidth:d.defaultView?.innerWidth||1024,hostPresentation:()=>a.type}:{},onResize:e=>{i||a?.responsive&&(c.style.height=`${e}px`,c.style.overflow="clip",a.setContentHeight(e))},onRendered:e=>{if(!i&&(e&&n?.setAttribute("aria-label",e),!S))try{S=!0,f||J(),q()}catch(o){U(o),h(t.onError,o)}},onError:e=>{if(i)return;let o=new Error(e);S||U(o),h(t.onError,o)},onEscape:x?v:void 0,onAction:(e,o,C)=>{if(i||!E||A||g)return;let l=r.screen.actions.find(O=>O.id===e),B=r.contract.outputs[e];if(!(l?.type!=="event"||!B)&&!(l.close&&!k()))try{let O=ce(B).parse(Object.hasOwn(l.properties,"value")?l.properties.value:l.properties);g=structuredClone({requestId:crypto.randomUUID(),contentVersionId:m.id,actionId:e,event:l.event,value:O,selection:o??{},answers:C??{},requestedClose:l.close}),F()}catch(O){h(t.onError,O)}}}),w.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:y}}),await Promise.race([w.ready,L]),f&&await L,i)throw new Error("Content preparation cancelled");return Q}catch(e){throw U(e),e}}export{Ae as mountContent,Se as prepareContent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as B}from"./chunk-OL2AI6DA.js";import{a as z}from"./chunk-I6D25FWU.js";import{b as S}from"./chunk-DB4EO3JG.js";import{b as V}from"./chunk-BL7E4RZ2.js";import"./chunk-VWMFR22O.js";import"./chunk-W32FI2A2.js";import{i as W,j}from"./chunk-YQX27SBG.js";import"./chunk-M3GGR53D.js";import"./chunk-UVUFJO2V.js";import"./chunk-HYE2YQYM.js";import"./chunk-MHWPEMX7.js";import"./chunk-5XKFUFXK.js";import"./chunk-2KKLY323.js";import"./chunk-R3YVDRTB.js";import"./chunk-U4WUX3WB.js";import"./chunk-JOIPLLHK.js";import"./chunk-GLYFT5WW.js";import"./chunk-WRLVPHPE.js";import"./chunk-3NCMYTNG.js";import"./chunk-35VG2IYD.js";import"./chunk-CGXNU5BC.js";import"./chunk-HVVJGLYZ.js";import"./chunk-ZYF6TRJ3.js";import"./chunk-QHJWVLJC.js";import"./chunk-XE7GU6FZ.js";import"./chunk-LAGGWYH3.js";import"./chunk-DHT3AWJQ.js";import{a as v}from"./chunk-TIQS5DUF.js";import"./chunk-7ZEXY4GC.js";import"./chunk-SLUA7ABW.js";import"./chunk-LVG5ED52.js";import"./chunk-3VUPVXAV.js";import"./chunk-RHF4NFCZ.js";import"./chunk-ZYN4CRHS.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as u}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";var m=new WeakMap,I=new WeakMap,H=new WeakSet;function re(C,e){let s=e.prepared,N=()=>{s&&!H.has(s)&&S(s)?.release()},R=m.get(e.client);if(R)return N(),R;let c=e.allowNewPurchase===!1||!e.start?void 0:{...e.start,requestId:e.start.requestId??crypto.randomUUID()};c&&s?.state==="ready"&&s.matches(c)&&s.open();let i=c&&s&&(s.state==="preparing"||["shown","closed"].includes(s.state)&&s.matches(c))?s:void 0;i?H.add(i):N();let d=i&&S(i);d?.claim();let b=Promise.resolve().then(async()=>{let r=!1,w,E,U=!1,T=()=>{},L=()=>{},y,M=!1,O=!1,f,_=!1,n=e.signal?AbortSignal.any([e.signal,e.client.identitySignal]):e.client.identitySignal,P=()=>{m.get(e.client)===b&&m.delete(e.client),n.removeEventListener("abort",A),T(),L(),i&&H.delete(i),d?.release()};function x(){if(f)return f;let l=new Promise(h=>f=h);return I.set(e.client,l),l.then(()=>{I.get(e.client)===l&&I.delete(e.client)}),m.get(e.client)===b&&m.delete(e.client),f}let a=j(C,e,"funnel",()=>F(),z);function A(){F()}function F(l=!1){if(!r){if(r=!0,a.finish("dismissed"),w){w.destroy();return}if(l&&y){let h=x();_=!0,y.then(async g=>{g.mode==="run"&&g.status!=="blocked"&&e.client.controller&&e.client.attempt?.requestId===c?.requestId&&await e.client.close()}).catch(()=>{}).finally(()=>{h(),u(e.onDismiss,null)}),P();return}P(),u(e.onDismiss,null)}}n.addEventListener("abort",A,{once:!0}),d&&(L=d.onClose(()=>{M?r||x():F(!0)}));try{let k=function(){!r&&!n.aborted&&!U&&E&&e.client.recovery.status==="complete"&&(U=!0,u(e.onComplete,structuredClone(E)))},D=function(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");return e.onCheckoutUrl?e.onCheckoutUrl(t):C.ownerDocument.defaultView?.location.assign(t)};var J=k,K=D;n.throwIfAborted();let l=e.client.controller?.view?.paywall?.resolution,h=l&&"document"in l?l.document:e.loadingDocument;a.start(!0,c?.locale??e.client.attempt?.locale??h?.screen.strings.defaultLocale,h??null),i?.state==="shown"?(O=!0,a.present(()=>{})):i?.state==="preparing"&&i.ready.then(t=>{if(t){if(r||!a.active||!i.matches(c)||!d?.revealable)return d?.release();a.present(()=>{i.open()==="shown"?O=!0:d.release()})}});let g=I.get(e.client);if(g&&await a.wait(g),r)return null;n.throwIfAborted(),y=c?e.client.start(c):e.client.refresh();let q=await a.wait(y,W);if(r)return null;n.throwIfAborted();let G=e.client.controller;return q.mode!=="run"||q.status==="blocked"||!G?(a.finish("skipped"),P(),O&&u(e.onDismiss,null),null):(n.removeEventListener("abort",A),M=!0,T=e.client.subscribe(k),w=await B(C,{...e,prepared:i,client:G,signal:n,checkoutNavigation:"after_confirmation",resumeCheckout:t=>e.client.continueCheckout(D,t),terminateCheckout:e.allowNewPurchase===!1?void 0:t=>e.client.terminateCheckout(t),async onCheckoutUrl(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");let o=e.client.recovery;if((!o.actions.includes("continue_checkout")||!o.purchases.some(p=>p.type==="checkout"&&p.checkoutUrl===t))&&(o=await e.client.refresh(),n.throwIfAborted(),r))throw new DOMException("Presentation dismissed","AbortError");if(V(o)!==t)throw new v("PURCHASE_PENDING","Checkout differs from the original recovery proof");return D(t)},async resolveOfferId(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");let o=e.client.attempt;if(!o)throw new v("PURCHASE_PENDING","Read the original Start before selecting an offer");let p=await e.resolveOfferId?.(t,o);if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");if(e.client.attempt?.requestId!==o.requestId)throw new v("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting an offer");return p},onComplete(t){E=t,k()},onError(t){u(e.onError,t),t instanceof v&&t.status===401&&!n.aborted&&e.client.refresh().catch(o=>u(e.onError,o))},onDismiss(t){r=!0,P(),f?.(),u(e.onDismiss,t)}},a),r||n.aborted?(w.destroy(),null):w)}catch(l){if(_||f?.(),r)return null;throw a.finish("error",l),P(),u(e.onError,l),l}});return m.set(e.client,b),b}export{re as showFunnelPurchase};
|