@tinkerlandai/longplay-sdk 0.10.77 → 0.10.79
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 +9 -0
- package/dist/check-response-XGOTG3KL.js +1 -0
- package/dist/{chunk-3ZYWGEBY.js → chunk-2OBXRQMW.js} +1 -1
- package/dist/chunk-2WXUJGGZ.js +1 -0
- package/dist/{chunk-H3LBNH34.js → chunk-3532HSBP.js} +1 -1
- package/dist/{chunk-47SYSZJP.js → chunk-3WCIX4VH.js} +1 -1
- package/dist/{chunk-Q6SK6G7T.js → chunk-5BPZUW6B.js} +1 -1
- package/dist/{chunk-DRCBHEC6.js → chunk-67WFVDTV.js} +1 -1
- package/dist/{chunk-TQKNQGWV.js → chunk-6VVQWTHV.js} +1 -1
- package/dist/{chunk-TZTWXL53.js → chunk-6XRQR43F.js} +1 -1
- package/dist/{chunk-MWTSCBSY.js → chunk-72UVQYXH.js} +1 -1
- package/dist/{chunk-62MMCXIA.js → chunk-7CZEXBQY.js} +1 -1
- package/dist/{chunk-SHJUMRYM.js → chunk-7KW3LCWQ.js} +1 -1
- package/dist/{chunk-45PGU2HW.js → chunk-7ZAM4YRK.js} +1 -1
- package/dist/{chunk-FINCNJBH.js → chunk-A5WUQLAO.js} +1 -1
- package/dist/{chunk-FSHGHFU4.js → chunk-BLXI5I3S.js} +2 -2
- package/dist/{chunk-X6ZYJHX4.js → chunk-BOT6ZDLK.js} +1 -1
- package/dist/{chunk-IEYSWIRA.js → chunk-CHRNCOXJ.js} +1 -1
- package/dist/{chunk-XSEYXS4X.js → chunk-CO6HDNOC.js} +1 -1
- package/dist/{chunk-CWBL2S3A.js → chunk-DUS5V65Z.js} +1 -1
- package/dist/{chunk-464CINQK.js → chunk-EQBJNU6R.js} +1 -1
- package/dist/{chunk-CLV4ROBM.js → chunk-EQUVI5QU.js} +1 -1
- package/dist/{chunk-BB6PDBS4.js → chunk-F4AIEI5N.js} +1 -1
- package/dist/{chunk-YMTCZWZG.js → chunk-FFEJS4K3.js} +1 -1
- package/dist/{chunk-VPT5MFDG.js → chunk-FYMVNLQN.js} +2 -2
- package/dist/{chunk-4G52SO64.js → chunk-FYUMVOCV.js} +1 -1
- package/dist/{chunk-DMMD4TMS.js → chunk-GADT6JMW.js} +1 -1
- package/dist/{chunk-65QMZQE6.js → chunk-GB74QWAG.js} +1 -1
- package/dist/{chunk-6JCM2PSZ.js → chunk-GJPOVI7F.js} +1 -1
- package/dist/{chunk-LYTPUZOW.js → chunk-I5ZXIKOT.js} +1 -1
- package/dist/{chunk-66SRWQES.js → chunk-KCUE2VFJ.js} +1 -1
- package/dist/{chunk-RM6RSLKI.js → chunk-KX67ZM7H.js} +1 -1
- package/dist/{chunk-5SNUVXZ7.js → chunk-LFR2LWYC.js} +1 -1
- package/dist/{chunk-QJLVJLVX.js → chunk-LQV7EC5H.js} +1 -1
- package/dist/{chunk-EQJIC52H.js → chunk-MOIVJERE.js} +1 -1
- package/dist/{chunk-TULPOZKV.js → chunk-NS4YGWQP.js} +1 -1
- package/dist/{chunk-NUIKM2BY.js → chunk-ORR47GDS.js} +1 -1
- package/dist/{chunk-IJRQSIVF.js → chunk-PG5Q3B7Z.js} +1 -1
- package/dist/chunk-PGKKIL6M.js +1 -0
- package/dist/{chunk-KCRL2BDG.js → chunk-PGNIOWKY.js} +1 -1
- package/dist/{chunk-B7CFFTJI.js → chunk-PUDTOCQF.js} +1 -1
- package/dist/{chunk-CJJ4R645.js → chunk-SX7U2ONB.js} +1 -1
- package/dist/chunk-SYFRWKJP.js +1 -0
- package/dist/{chunk-E4B7243C.js → chunk-UGATOG2T.js} +1 -1
- package/dist/{chunk-QLMQI6SX.js → chunk-VXNN3RV3.js} +1 -1
- package/dist/chunk-WU6HDOZM.js +1 -0
- package/dist/{chunk-HT5TYVH7.js → chunk-XH6VXXCX.js} +1 -1
- package/dist/{chunk-SUUBL2WC.js → chunk-Y3W5G4BF.js} +1 -1
- package/dist/{chunk-STASMAS7.js → chunk-Y6KA56V2.js} +1 -1
- package/dist/{chunk-SGI3Q2DQ.js → chunk-YQ2PQWHZ.js} +1 -1
- package/dist/{chunk-OJ4VMUMS.js → chunk-Z5JTYDD5.js} +1 -1
- package/dist/{chunk-ENZRUXTJ.js → chunk-ZHVVJBT6.js} +1 -1
- package/dist/{content-BEW3GFZ3.js → content-6MJOU3SX.js} +1 -1
- package/dist/{funnel-host-purchase-TLN4Z45B.js → funnel-host-purchase-526HVMXY.js} +1 -1
- package/dist/funnel-host-recovery-paywall-GRX7CLGF.js +1 -0
- package/dist/{funnel-paywall-copies-43CVL4UQ.js → funnel-paywall-copies-SKNQNABD.js} +1 -1
- package/dist/funnel-paywall-prerender-GVHYSFWI.js +1 -0
- package/dist/funnel-route-prediction-Q4HMRAVQ.js +1 -0
- package/dist/funnel-route-source-HYWJWEM3.js +1 -0
- package/dist/funnel-runtime-host-4KBMPKBE.js +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +1 -1
- package/dist/merchant-bridge-contracts-OIYML3DE.js +1 -0
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.js +1 -1
- package/dist/operation-contracts-3JEVPMO2.js +1 -0
- package/dist/page.js +1 -1
- package/dist/paywall-22EYVJAK.js +1 -0
- package/dist/paywall-content-XH344BMX.js +1 -0
- package/dist/paywall-session-TJ3X7NZA.js +1 -0
- package/dist/popup.js +1 -1
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-HJOKBOZH.js +1 -0
- package/dist/server.js +1 -1
- package/dist/{visual-dom-5LUN4AHO.js → visual-dom-KUABNJV6.js} +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/check-response-LYK2HZFK.js +0 -1
- package/dist/chunk-2GVAT6HI.js +0 -1
- package/dist/chunk-KO4CSQ6R.js +0 -1
- package/dist/chunk-PBPKZLMG.js +0 -1
- package/dist/chunk-S5KGFAAW.js +0 -1
- package/dist/funnel-host-recovery-paywall-EMYMKT2L.js +0 -1
- package/dist/funnel-paywall-prerender-WG6BWWPM.js +0 -1
- package/dist/funnel-route-prediction-DXMYNMCA.js +0 -1
- package/dist/funnel-route-source-2OGRCZKX.js +0 -1
- package/dist/funnel-runtime-host-CHBYLSSZ.js +0 -1
- package/dist/merchant-bridge-contracts-MEMS65CV.js +0 -1
- package/dist/operation-contracts-L3CZMIL6.js +0 -1
- package/dist/paywall-RCDK73ML.js +0 -1
- package/dist/paywall-content-G3Q7KTR7.js +0 -1
- package/dist/paywall-session-RZHCKRRG.js +0 -1
- package/dist/screen-renderer-IKROGLA7.js +0 -1
- /package/dist/{chunk-FSHGHFU4.js.LEGAL.txt → chunk-BLXI5I3S.js.LEGAL.txt} +0 -0
- /package/dist/{chunk-CILM5XMH.js → chunk-FRK6322O.js} +0 -0
- /package/dist/{chunk-VPT5MFDG.js.LEGAL.txt → chunk-FYMVNLQN.js.LEGAL.txt} +0 -0
- /package/dist/{chunk-OJM6ORHE.js → chunk-KV5MZ4NI.js} +0 -0
- /package/dist/{chunk-7RUOZL6C.js → chunk-W22ESUYY.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as He,i as Ze,y as We}from"./chunk-H3LBNH34.js";import{w as Pe}from"./chunk-DRCBHEC6.js";import{a as K,b as fe,c as ge,d as ye,e as T,f as $e,g as Le,j as be,m as Q}from"./chunk-TQKNQGWV.js";import{a as q}from"./chunk-VILB5M4X.js";import{a as Fe}from"./chunk-66SRWQES.js";import{m as Je,n as J,o as B}from"./chunk-SUUBL2WC.js";import{C as me,f as Ve,g as Ue,h as Be,p as pe,v as L,w as H,x as Z,y as de,z as Te}from"./chunk-4G52SO64.js";import{b as Me,d as S,e as U,f as qe,g as Ge,h as W}from"./chunk-FINCNJBH.js";import{h as V}from"./chunk-5SNUVXZ7.js";import{b as e}from"./chunk-7RUOZL6C.js";var E=e.string().min(1).max(255).regex(/^[a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+){0,9}$/).refine(t=>t.split(".").every(o=>!["__proto__","constructor","prototype"].includes(o)),"Reserved value path"),C=e.discriminatedUnion("source",[e.strictObject({source:e.literal("literal"),value:S}),e.strictObject({source:e.literal("variable"),key:e.string().min(1).max(255),path:E.optional()})]);function Qe(t,o){if(!o)return t;for(let n of E.parse(o).split(".")){if(Array.isArray(t)){if(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=t.length)return;t=t[Number(n)];continue}if(t===null||typeof t!="object"||!Object.hasOwn(t,n))return;t=Reflect.get(t,n)}return t}function _t(t,o){if(t.source==="literal")return structuredClone(t.value);let n=Le(o.declarations,o);if(!Object.hasOwn(n,t.key))throw new Error("Capability input is missing");return structuredClone(S.parse(Qe(n[t.key],t.path)))}function he(t,o){let n=[...o].sort((i,a)=>a.length-i.length).find(i=>t===i||t.startsWith(i+"."));if(!n)return null;let s=t===n?void 0:t.slice(n.length+1);return s&&!E.safeParse(s).success?null:{key:n,path:s}}function xe(t){let o=Object.values(t.strings.locales).flatMap(n=>Object.values(n));return L(t,n=>{n.type==="custom_html"&&o.push(...Object.values(n.html))}),[...new Set(o.flatMap(Be))]}function Xe(t){return xe(t).filter(o=>o.startsWith("variables.")).map(o=>o.slice(10))}function F(t){let o=JSON.stringify(t);if(o===void 0)throw new TypeError("A JSON value is required");let n=new TextEncoder().encode(o).length,s=!1;for(let i=0;i<o.length;i++){let a=o.charAt(i);if(s)a==="\\"?i++:a==='"'&&(s=!1);else if(a==='"')s=!0;else if(a===":"||a===",")n++;else if(a==="-"||a>="0"&&a<="9"){let f=i;for(;i+1<o.length&&/[0-9.eE+-]/.test(o.charAt(i+1));)i++;let m=o.slice(f,i+1);if(!/[eE]/.test(m))continue;let[x="",_]=m.split(/[eE]/),p=x.replace(/^-/,""),v=p.replace(".","").length,N=(p.includes(".")?p.indexOf("."):v)+Number(_),d=N<=0?2-N+v:N>=v?N:v+1;n+=d+(x.startsWith("-")?1:0)-m.length}}return n}var Kt=e.string().regex(/^[a-f0-9]{64}$/),Et=Ve.pick({text:!0,label:!0,alt:!0,html:!0,couponId:!0,countdownAt:!0,missing:!0}),Ye=e.strictObject({couponDigests:e.record(e.uuid(),Kt),variables:e.record(pe,e.record(e.uuid(),e.partialRecord(e.enum(["offer.name","offer.description","offer.headline","offer.eligibility","offer.validity","offer.terms","offer.discount","offer.months","offer.ends_at"]),e.string()))),locales:e.record(pe,Ue.extend({nodes:e.record(e.string(),e.strictObject({base:Et})),plans:e.object({}).strict(),pickers:e.object({}).strict()}).omit({paywall:!0}))});var et=e.enum(["funnel-run/1","funnel-process/1"]),Kn="funnel-process/1";var Se=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),tt=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,128}$/),nt=B.refine(t=>new TextEncoder().encode(JSON.stringify(t)).byteLength<=8192,"Task data exceeds 8 KiB"),ve=e.record(Se,e.enum(["string","number","boolean","strings"])).refine(t=>Object.keys(t).length<=20,"Too many output fields"),Dt=C,rt=e.strictObject({type:e.literal("external_task"),endpointId:e.uuid(),taskKey:Se,inputs:e.record(Se,Dt).refine(t=>Object.keys(t).length<=20),outputs:ve}),it=e.strictObject({maxAttempts:e.number().int().min(1).max(5),retryDelaySeconds:e.number().int().min(1).max(30),backoff:e.enum(["fixed","exponential"]),requestTimeoutSeconds:e.number().int().min(1).max(10),timeoutSeconds:e.number().int().min(1).max(300)}).refine(t=>t.requestTimeoutSeconds<=t.timeoutSeconds,"Request timeout exceeds action deadline");var Pn=e.strictObject({outcome:e.enum(["success","failure"]),data:nt});var Vn=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("signal"),runId:e.uuid(),nodeId:tt,eventName:Q,eventId:e.uuid(),data:nt}),e.strictObject({operation:e.literal("read_results"),runId:e.uuid()})]),Un=e.strictObject({scope:V,runId:e.uuid(),eventId:e.uuid(),accepted:e.boolean()}),At=e.record(tt,be),Bn=e.strictObject({scope:V,runId:e.uuid(),results:At});var Ct=["id","externalUserId","createdAt","ageDays","subscription"],we=e.array(e.string().trim().min(1).max(40).refine(t=>!t.includes(","),"标签不能包含逗号")).max(20).refine(t=>new Set(t).size===t.length,"标签不能重复"),X=e.intersection(U,e.looseObject({tags:we.optional()})).refine(t=>![...Ct,"parameters","answers","results"].some(o=>Object.hasOwn(t,o)),"Reserved customer attribute"),Y=e.string().trim().max(80),ee=e.string().regex(/^\+[1-9]\d{1,14}$/).nullable(),te=e.union([e.email().max(254),e.literal("")]),Nt=e.string().trim().min(1).max(255).refine(t=>!/\p{Cc}/u.test(t),"Fingerprint must not contain control characters"),ot=e.string().trim().min(1).max(255).refine(t=>!t.startsWith("gg_guest_"),"Reserved guest identity namespace"),Gn=e.object({externalUserId:ot.optional(),name:Y.default(""),email:te.default(""),phone:ee.optional(),attributes:X.default({})}).strict().refine(t=>t.externalUserId!==void 0||t.email!=="","请提供业务用户 ID 或邮箱"),ne=e.discriminatedUnion("type",[e.strictObject({type:e.literal("id"),value:e.uuid()}),e.strictObject({type:e.literal("externalUserId"),value:ot})]),re=e.strictObject({name:Y.optional(),email:te.optional(),phone:ee.optional(),attributes:X.optional(),fingerprint:Nt.optional()}),ie=t=>!t.customerData||t.customer?.type==="externalUserId",oe="customerData requires an externalUserId customer",at=e.object({id:e.uuid(),externalUserId:e.string().min(1).max(255).nullable(),name:Y,email:te,phone:ee.optional(),attributes:X,createdAt:e.iso.datetime()}).strict(),$n=e.object({customer:at,changed:e.boolean(),replayed:e.boolean()}).strict(),zt=e.discriminatedUnion("type",[e.object({type:e.literal("id"),value:e.uuid()}).strict(),e.object({type:e.literal("externalUserId"),value:e.string().trim().min(1).max(255)}).strict()]),Ft=e.object({name:Y.optional(),email:te.optional(),phone:ee.optional(),attributes:X.refine(t=>!Object.hasOwn(t,"tags"),"Use incremental tagChanges").optional(),removeAttributes:e.array(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_]{0,127}$/)).max(128).refine(t=>!t.includes("tags")).optional(),tagChanges:e.strictObject({add:we,remove:we}).optional()}).strict().refine(t=>Object.keys(t).length>0,"请提供需要修改的字段"),Pt=e.object({lookup:zt}).strict(),Ln=Pt.extend({requestId:e.uuid(),patch:Ft}).strict(),Hn=e.object({search:e.string().trim().max(200).default(""),tag:e.string().trim().max(40).default(""),planId:e.string().max(200).default(""),versionId:e.string().max(200).default(""),holdingStatus:e.enum(["","active","scheduled","expired","unavailable","none"]).default(""),membershipStatus:e.enum(["","active","trial","past_due","ended"]).default(""),createdFrom:e.union([e.iso.datetime(),e.literal("")]).default(""),createdUntil:e.union([e.iso.datetime(),e.literal("")]).default(""),offset:e.coerce.number().int().min(0).max(1e5).default(0),limit:e.coerce.number().int().min(1).max(100).default(50)}).strict(),Zn=e.object({customers:at.array(),hasMore:e.boolean(),total:e.number().int().nonnegative().nullable(),evaluatedAt:e.iso.datetime()}).strict();var Yn=e.enum(["local","remote"]),Ie=e.strictObject({port:e.string().regex(/^[a-zA-Z0-9_.:-]{1,128}$/),value:S.optional(),sticky:e.array(e.strictObject({expected:W.nullable(),next:W})).max(100),exposures:e.array(S).max(100),features:e.array(S).max(100)}),st=e.strictObject({type:e.literal("evaluate"),receiptId:e.uuid(),environmentId:e.uuid(),policyRevision:e.number().int().nonnegative(),attributes:U,sticky:e.record(e.string(),W)}),ct=st.extend({runId:e.uuid(),versionId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative()}),Vt=st.omit({type:!0,receiptId:!0}).extend({type:e.literal("evaluate_segment")}),ut=e.strictObject({nodeId:e.string().min(1).max(64),result:Ie}),lt=Vt.extend({runId:e.uuid(),versionId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),parameters:B,answers:J,variables:e.record(e.string(),S)});var Oe=e.discriminatedUnion("type",[e.strictObject({type:e.literal("literal"),value:S}),e.strictObject({type:e.literal("variable"),key:K,path:E.optional()}),e.strictObject({type:e.literal("feature"),featureKey:e.string().min(1).max(128)})]),Ut=e.strictObject({requestId:e.uuid(),decisionId:e.uuid(),customerId:e.uuid(),externalUserId:e.string().min(1).max(255).nullable(),versionId:e.uuid(),receiptId:e.uuid(),value:S}),Bt={funnelId:e.uuid(),requestId:e.uuid(),customer:ne,customerData:re.optional(),attributes:U.refine(t=>!["parameters","answers","results","variables"].some(o=>Object.hasOwn(t,o)),"parameters, answers, results and variables are reserved flow namespaces")},cr=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("decide"),...Bt}).refine(ie,oe),e.strictObject({operation:e.literal("read_decision"),decisionId:e.uuid()}),e.strictObject({operation:e.literal("evaluate_decision"),decisionId:e.uuid(),requestId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),receiptId:e.uuid(),policyRevision:e.number().int().nonnegative(),generation:e.string().min(1).max(256),result:Ie}),e.strictObject({operation:e.literal("feature_config"),funnelId:e.uuid()}),e.strictObject({operation:e.literal("commit_decision_segment"),decisionId:e.uuid(),requestId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),policyRevision:e.number().int().nonnegative(),generation:e.string().min(1).max(256),steps:e.array(ut).max(32),boundary:e.strictObject({nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative()}).optional()}),e.strictObject({operation:e.literal("segment_configuration"),funnelId:e.uuid(),versionId:e.uuid()}),e.strictObject({operation:e.literal("configuration"),funnelId:e.uuid(),versionId:e.uuid().optional()}),e.strictObject({operation:e.literal("local_configuration"),funnelId:e.uuid()}),e.strictObject({operation:e.literal("report_used"),decisionId:e.uuid(),eventId:e.uuid(),occurredAt:e.iso.datetime({offset:!0}),reference:e.string().min(1).max(128).optional()})]),ur=e.strictObject({scope:V,decisionId:e.uuid(),requestId:e.uuid(),status:e.enum(["pending","completed","failed"]),decision:Ut.nullable(),evaluation:e.discriminatedUnion("type",[ct,lt]).optional()}).refine(t=>t.status==="completed"==(t.decision!==null)&&(!t.decision||t.decision.decisionId===t.decisionId&&t.decision.requestId===t.requestId),"Completed decisions carry their committed result"),lr=e.strictObject({scope:V,decisionId:e.uuid(),eventId:e.uuid(),source:e.literal("caller_reported")});function Mt(t,o=[]){let n=[];L(t,i=>{i.hidden&&n.push("Hidden components must not be delivered"),o.includes(i.type)&&n.push(`Node type ${i.type} cannot be delivered`)});let s=new Set(de(t).map(i=>i.key));for(let[i,a]of Object.entries(t.strings.locales))for(let f of Object.keys(a))s.has(f)||n.push(`Unused string ${f} must not be delivered (${i})`);return n}function pt(t){return t.hidden?null:t.type!=="stack"?t:{...t,children:t.children.flatMap(o=>pt(o)??[])}}function Tt(t){let o=t.pages.map(i=>{let a=pt(i.root);return a?.type==="stack"?{...i,root:a}:{...i,root:{type:"stack",id:i.root.id,...i.root.name===void 0?{}:{name:i.root.name},direction:"vertical",align:"stretch",justify:"start",children:[]}}}),n=new Set(de({pages:o}).map(i=>i.key)),s=Object.fromEntries(Object.entries(t.strings.locales).map(([i,a])=>[i,Object.fromEntries(Object.entries(a).filter(([f])=>n.has(f)))]));return{...t,pages:o,strings:{...t.strings,locales:s}}}function dt(t,o=[]){let n=H.parse(structuredClone(Tt(t))),s=a=>a.type!=="stack"||a.interaction!==void 0||a.children.some(s);for(let a of n.pages)if(!s(a.root))throw new Error(`Page ${a.id} has no visible content`);let i=Mt(n,o);if(i.length)throw new Error(i.join("; "));return n}var gr=e.strictObject({schemaVersion:e.literal(1),renderKey:e.string().min(1).max(256),routeTemplate:e.string().startsWith("/").max(2048),selectors:e.array(e.string().regex(/^[a-z][a-z0-9-]*\[(?:id|data-testid|data-test|data-qa|data-indiana-id)="(?:[^"\\\x00-\x1f\x7f]|\\["\\])*"\]$/).max(512)),present:e.array(e.number().int().min(0)).min(1),absent:e.array(e.number().int().min(0))}).superRefine((t,o)=>{let n=[...t.present,...t.absent];(new Set(t.selectors).size!==t.selectors.length||new Set(n).size!==n.length||n.length!==t.selectors.length||n.some(s=>s>=t.selectors.length))&&o.addIssue({code:"custom",message:"Incomplete or ambiguous render signature"})}),mt=e.strictObject({renderKey:e.string().min(1).max(256),routeKey:e.string().min(1).max(256),stateKey:e.string().min(1).max(256),documentKey:e.string().min(1).max(256),documentHash:e.string().regex(/^[a-f0-9]{64}$/),compositionKey:e.string().min(1).max(256),entryMode:e.enum(["hard","soft"]),match:e.strictObject({present:e.array(e.number().int().min(0)),absent:e.array(e.number().int().min(0))})});var qt=["enterprise-internal-indiana-test","tinkerland-indiana-prod"],je="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",Gt=e.string().regex(new RegExp(`^${je}/${je}/${je}/manifest\\.json$`)),ft=e.strictObject({kind:e.literal("gcs-resumable"),url:e.url(),bucket:e.enum(qt),objectKey:Gt,byteLength:e.number().int().positive(),expiresAt:e.iso.datetime()}).superRefine((t,o)=>{let n=new URL(t.url),s=n.searchParams,i=["uploadType","upload_id","name","upload_protocol","ifGenerationMatch"];(n.origin!=="https://storage.googleapis.com"||n.username||n.password||n.hash||n.pathname!==`/upload/storage/v1/b/${t.bucket}/o`||[...s.keys()].some(a=>!i.includes(a)||s.getAll(a).length!==1)||s.get("uploadType")!=="resumable"||!/^[A-Za-z0-9_-]{1,4096}$/.test(s.get("upload_id")??"")||s.has("name")&&s.get("name")!==`app-manifests/${t.objectKey}`||s.has("upload_protocol")&&s.get("upload_protocol")!=="resumable"||s.has("ifGenerationMatch")&&s.get("ifGenerationMatch")!=="0")&&o.addIssue({code:"custom",message:"Invalid IAM upload capability"})});var h=e.string().min(1).max(256),j=e.string().regex(/^[a-f0-9]{64}$/),ae=e.strictObject({versionId:e.uuid(),manifestDigest:j,sourceGraphDigest:j,pageKey:h,stateKey:h,documentKey:h,documentHash:j,elementKey:h.optional(),nodeId:h.optional(),contentHash:j.optional(),renderKey:h.optional()}),gt=e.strictObject({pageKey:h,documentKey:h,expectedDocumentHash:j,renderKey:h.optional(),nodeId:h,elementKey:h,expectedContentHash:j,property:e.enum(["text","fontSize","color"]),value:e.union([e.string().max(4e3),e.number().finite()])}),wr=e.strictObject({versionId:e.uuid(),manifestDigest:j,sourceGraphDigest:j,pageKey:h,stateKey:h,documentKey:h,documentHash:j,renderKey:h.optional(),patches:e.array(gt.omit({pageKey:!0,documentKey:!0,expectedDocumentHash:!0,renderKey:!0})).min(1).max(200)}),$t=/^[a-z][a-z0-9-]{0,39}$/,G=e.string().regex($t),Re=e.enum(["web","ios","android"]),yt={requestId:e.uuid(),client:G,platform:Re,label:e.string().trim().min(1).max(100),sha256:j,bytes:e.number().int().min(1),transferBytes:e.number().int().min(1)},Lt=e.strictObject({action:e.literal("upload"),...yt,transferBytes:e.number().int().min(1).max(2e6),base64:e.string().min(4).max(2666668).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/)}),Ir=e.discriminatedUnion("action",[Lt,e.strictObject({action:e.literal("register"),...yt}),e.strictObject({action:e.literal("complete"),versionId:e.uuid()}),e.strictObject({action:e.literal("current"),versionId:e.uuid(),expectedCurrent:e.uuid().nullable()}),e.strictObject({action:e.literal("delivery"),enabled:e.boolean()}),e.strictObject({action:e.literal("changes"),versionId:e.uuid(),experimentId:e.uuid(),variationId:h,changesetId:e.uuid().nullable(),expectedRevision:j.nullable(),editorUrl:e.string().url().max(2048),patches:e.array(gt).max(200)})]),_e=e.strictObject({id:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),clientKey:G,platform:Re,label:e.string(),sha256:j,bytes:e.number().int().positive(),objectKey:e.string(),state:e.enum(["uploading","ready","rejected"]),isCurrent:e.boolean(),revision:e.number().int().nonnegative(),createdAt:e.string(),expiresAt:e.string(),readyAt:e.string().nullable(),summary:e.record(e.string(),e.json()),routeTree:e.json().nullable(),validation:e.record(e.string(),e.json())}),Ht=e.strictObject({key:G,platform:Re,currentId:e.uuid().nullable()}),Or=e.strictObject({rows:e.array(_e).max(100),nextCursor:e.uuid().nullable(),clients:e.array(Ht).max(20)}),ke=e.strictObject({storedBytes:e.number().int().nonnegative(),reservedBytes:e.number().int().nonnegative(),chargedBytes:e.number().int().nonnegative(),versions:e.number().int().nonnegative(),objects:e.number().int().nonnegative(),orphanObjects:e.number().int().nonnegative(),missingReadyObjects:e.number().int().nonnegative(),unknownObjectSizes:e.number().int().nonnegative(),byteLimit:e.number().int().positive(),versionLimit:e.number().int().positive(),remainingBytes:e.number().int().nonnegative()}),jr=e.strictObject({asOf:e.iso.datetime({offset:!0}),reclamation:e.literal("manual-review-required"),buckets:e.strictObject({source:ke,runtime:ke,previews:ke})}),kr=e.strictObject({version:_e,actorId:e.uuid(),claims:e.record(e.string(),e.json())}),Rr=e.strictObject({version:_e,upload:ft.nullable()}),_r=e.object({format:e.literal("indiana-route-state-index"),schemaVersion:e.literal(3),routes:e.array(e.object({routeKey:h,path:e.string(),documentKey:h,documentHash:j,initialStateKey:h,initialRenderKey:h})),renders:e.array(mt)}).loose().superRefine((t,o)=>{(!t.renders||t.routes.some(n=>!t.renders?.some(s=>s.renderKey===n.initialRenderKey&&s.routeKey===n.routeKey&&s.documentKey===n.documentKey&&s.stateKey===n.initialStateKey&&s.documentHash===n.documentHash&&s.entryMode==="hard")))&&o.addIssue({code:"custom",message:"Incomplete render catalog"})}),Kr=e.strictObject({rows:e.array(e.object({id:e.uuid(),name:e.string(),status:e.string(),variations:e.array(e.object({id:h,key:h,name:e.string().optional()}).loose())}).loose()),limited:e.boolean()}),Er=e.strictObject({enabled:e.boolean(),allowedOrigins:e.array(e.string())});var Zt=e.strictObject({delaySeconds:e.number().int().min(0).max(86400).optional(),maxPerDay:e.number().int().min(1).max(100).optional(),maxPerSession:e.number().int().min(1).max(100).optional()}),bt=e.strictObject({id:e.uuid(),name:e.string().trim().min(1).max(80),client:G,source:ae,event:e.enum(["screen_enter","button_click"]),cooldownSeconds:e.number().int().min(0).max(2592e3),behavior:e.literal("observe"),delivery:Zt.optional()}).superRefine((t,o)=>{t.event==="button_click"&&(!t.source.nodeId||!t.source.elementKey)&&o.addIssue({code:"custom",path:["source"],message:"Choose a uniquely bound button"})});var D={flowNodes:500,logicNodes:480,pages:100,components:1500,actions:250,questions:40,documentBytes:1e6,conditionDepth:3,conditionChildren:20,conditionPredicates:100},ht="00000000-0000-0000-0000-000000000000";var xt=e.strictObject({type:e.literal("bundle"),paywall:C.optional(),offering:C.optional(),coupons:C,data:C}),Wt=t=>e.strictObject({type:e.literal(t),id:e.uuid()}),Br=e.strictObject({type:e.literal("bundle"),paywallVersionId:e.uuid().optional(),offeringVersionId:e.uuid().optional(),couponIds:e.array(e.uuid()).max(20).refine(t=>new Set(t).size===t.length),data:S});var Mr=e.strictObject({type:e.literal("bundle"),offering:Wt("offering_version").nullable(),paywall:e.strictObject({versionId:e.uuid(),paywallId:e.uuid(),offeringVersionId:e.uuid()}).nullable(),coupons:e.array(Ze).max(20),data:S});var St=e.union([e.string(),e.number().finite(),e.boolean(),e.null()]),Jt=e.union([St,e.array(St).min(1).max(20)]),Qt=e.record(E,Jt).refine(t=>Object.keys(t).length<=10),vt=e.strictObject({path:E,type:e.enum(["string","number","boolean","strings"]),nullable:e.boolean().optional(),aggregation:e.enum(["count","exists"]).optional(),where:Qt.optional()}).superRefine((t,o)=>{(t.aggregation==="count"&&t.type!=="number"||t.aggregation==="exists"&&t.type!=="boolean"||!t.aggregation&&t.where)&&o.addIssue({code:"custom",message:"Collection summaries require their matching type"})});var Xt=["sendMessage","checkEntitlement","resolveOffering","readHoldings","readLedger","readBillingInvoice","readCreditStatement","previewAttach","attach","readSubscriptionOperation","previewUpdate","update","readSubscriptionUpdate","setupPayment","readPaymentSetup","verifySubscriptions","previewRefund","refund","readRefund","restoreNativePurchase","readBillingControls","prepareBillingAuthorization","confirmBillingAuthorization","setBillingCoupons","revokeBillingAuthorization","listBillingInvoices","confirmBillingAdjustment","manageBillingLimits","readSeats","manageSeat","quoteBalance","mutateBalance","trackUsage","readUsage","setUsage","adjustBalance","readBalanceSource","manageBalanceGrant","listBalanceGrants","manageUsageEntity","readUsageAnalytics","readCreditAnalytics","submitUsageBatch","readUsageBatch","redeemCoupon","listOffers","grantOffer","redeemReward","createReferralCode","claimRewardProduct"],wt=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Yt=C,It=e.discriminatedUnion("type",[rt,e.strictObject({type:e.literal("claim_offer"),coupon:C}),e.strictObject({type:e.literal("event"),event:wt}),e.strictObject({type:e.literal("api"),operation:e.enum(Xt),inputs:e.record(E,Yt).refine(t=>Object.keys(t).length<=40),outputs:e.record(wt,vt).refine(t=>Object.keys(t).length<=20)})]);var y=Q,en=e.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/),k={id:y,name:e.string().trim().min(1).max(80),position:e.strictObject({x:e.number().finite(),y:e.number().finite()}).optional()},tn={success:y,cancel:y,unavailable:y,failure:y},nn=e.url().max(2048).refine(t=>{try{return new URL(t).protocol==="https:"}catch{return!1}},{message:"External pages require HTTPS"}),rn=e.enum(["same_window","new_window"]),on=e.discriminatedUnion("type",[e.strictObject({...k,type:e.literal("entry"),next:y,triggers:e.array(bt).max(20).refine(t=>new Set(t.map(o=>o.id)).size===t.length,"Entry trigger IDs must be unique").optional()}),e.strictObject({...k,type:e.literal("screen"),screenId:y,presentation:Me,outputs:e.record(y,y),offering:e.discriminatedUnion("source",[e.strictObject({source:e.literal("variable"),key:K}),e.strictObject({source:e.literal("fixed"),versionId:e.uuid()})]).optional()}),e.strictObject({...k,type:e.literal("offering"),configuration:e.discriminatedUnion("source",[e.strictObject({source:e.literal("fixed"),versionId:e.uuid()}),e.strictObject({source:e.literal("feature"),featureKey:e.string().min(1).max(128)})]),writes:e.strictObject({value:K}),next:y}),e.strictObject({...k,type:e.literal("coupon"),couponId:e.uuid(),writes:e.strictObject({value:K}),next:y}),e.strictObject({...k,type:e.literal("coupons"),couponIds:e.array(e.uuid()).max(20).refine(t=>new Set(t).size===t.length),writes:e.strictObject({value:K}),next:y}),e.strictObject({...k,type:e.literal("output"),value:e.discriminatedUnion("type",[...Oe.options,xt,e.strictObject({type:e.literal("selection"),screenId:y,offeringKey:K})])}),e.strictObject({...k,type:e.literal("condition"),cases:e.array(e.strictObject({condition:qe,target:y})).min(1).max(50),default:y}),e.strictObject({...k,type:e.literal("feature"),featureKey:e.string().min(1).max(128),writes:e.strictObject({value:K}),next:y}),e.strictObject({...k,type:e.literal("split"),experimentId:e.uuid(),applyPageExperiment:e.literal(!0).optional(),routes:e.record(en,y).refine(t=>Object.keys(t).length>=2&&Object.keys(t).length<=20),notParticipating:y}),e.strictObject({...k,type:e.literal("action"),...tn,execution:it,action:It,writes:ye.optional()}),e.strictObject({...k,type:e.literal("external_page"),appManifest:ae.optional(),url:nn,openIn:rn,opened:y,failed:y}),e.strictObject({...k,type:e.literal("end"),outcome:e.enum(["completed","closed","ineligible","failed"]),output:Oe.optional()}),e.strictObject({...k,type:e.literal("wait"),writes:ye.optional(),wait:e.discriminatedUnion("type",[e.strictObject({type:e.literal("duration"),delaySeconds:e.number().int().min(1).max(2592e3),elapsed:y}),e.strictObject({type:e.literal("event"),eventName:y,outputs:ve,timeoutSeconds:e.number().int().min(1).max(2592e3),received:y,timeout:y})])})]),Ke=e.strictObject({version:e.literal(5),entry:y,nodes:e.array(on).min(1).max(D.flowNodes)}),Ee=Ke.superRefine((t,o)=>{an(t,n=>o.addIssue({code:"custom",message:n.message,path:n.path,params:{reason:n.reason}}))});function se(t){switch(t.type){case"entry":case"feature":case"offering":case"coupon":case"coupons":return[t.next];case"screen":return Object.values(t.outputs);case"condition":return[...t.cases.map(o=>o.target),t.default];case"split":return[...Object.values(t.routes),t.notParticipating];case"action":return[t.success,t.cancel,t.unavailable,t.failure];case"external_page":return[t.opened,t.failed];case"end":case"output":return[];case"wait":return t.wait.type==="duration"?[t.wait.elapsed]:[t.wait.received,t.wait.timeout]}}function an(t,o){let n=[],s=new Map(t.nodes.map(p=>[p.id,p])),i=(p,v,N)=>{n.push(p),o?.({message:p,reason:v,path:N?["nodes",t.nodes.indexOf(N)]:[]})};s.size!==t.nodes.length&&i("Node identifiers must be unique","uniqueNodes"),(s.get(t.entry)?.type!=="entry"||t.nodes.filter(p=>p.type==="entry").length!==1)&&i("A flow has exactly one entry node","entry"),(t.nodes.filter(p=>p.type==="screen").length>D.pages||t.nodes.filter(p=>!["screen","entry","end","output"].includes(p.type)).length>D.logicNodes)&&i("Flow node limit exceeded","budget");let a=new Set;for(let p of t.nodes){for(let v of se(p))v===t.entry&&i("An entry cannot be a transition target","entryTarget",p),s.has(v)||i(`Missing target ${v}`,"missingTarget",p);p.type==="screen"&&(a.has(p.screenId)&&i("Every screen has exactly one node owner","screenOwner",p),a.add(p.screenId))}let f=new Set,m=new Set,x=new Set;function _(p){if(f.has(p)){i("Flow edges must not form a cycle","cycle",s.get(p));return}if(!(m.has(p)||!s.has(p))){f.add(p),x.add(p);for(let v of se(s.get(p)))_(v);f.delete(p),m.add(p)}}_(t.entry);for(let p of t.nodes)x.has(p.id)||i("Every node must be reachable from Entry","unreachable",p);return[...new Set(n)]}var De={maxTransitions:1e4,runTimeoutSeconds:2592e3};function Ot(t,o,n){let s=[...o].sort((m,x)=>x.length-m.length),i=new Set,a=(m,x=!1)=>{let _=s.find(p=>m===p||x&&m.startsWith(p+"."));i.add(_??m)};if(t.type==="condition"){let m=n?.startsWith("case_")?Number(n.slice(5)):t.cases.length-1;for(let x of t.cases.slice(0,m+1))for(let _ of q(x.condition))_.startsWith("variables.")&&a(_.slice(10),!0)}if(t.type==="screen"&&t.offering?.source==="variable"&&a(t.offering.key),t.type==="action"&&(t.action.type==="api"||t.action.type==="external_task"))for(let m of Object.values(t.action.inputs))m.source==="variable"&&a(m.key);t.type==="action"&&t.action.type==="claim_offer"&&t.action.coupon.source==="variable"&&a(t.action.coupon.key);let f=t.type==="output"?t.value:t.type==="end"?t.output:null;if(f?.type==="variable"&&a(f.key),f?.type==="bundle")for(let m of[f.paywall,f.offering,f.coupons,f.data])m?.source==="variable"&&a(m.key);return f?.type==="selection"&&a(f.offeringKey),[...i]}var M=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,127}$/),ce=t=>e.record(e.string(),S).refine(o=>F(o)<=t,"Funnel evidence exceeds its byte budget"),xi=e.enum(["local_segment","evaluation","presentation","timer","event","operation"]),Ce=e.enum(["entry","presentation","decision","configuration","capability","wait","terminal"]),Ne=e.discriminatedUnion("type",[e.strictObject({type:e.literal("flag"),key:e.string().min(1).max(128)}),e.strictObject({type:e.literal("experiment"),id:e.uuid()}),e.strictObject({type:e.literal("saved_group"),id:e.uuid()}),e.strictObject({type:e.literal("config"),key:e.string().min(1).max(128)}),e.strictObject({type:e.literal("constant"),key:e.string().min(1).max(128)}),e.strictObject({type:e.literal("paywall_version"),id:e.uuid()}),e.strictObject({type:e.literal("offering_version"),id:e.uuid()}),e.strictObject({type:e.literal("reward"),id:e.uuid()})]),Si=e.strictObject({schemaVersion:e.literal(1),kind:Ce,selector:Ne.nullable(),context:ce(131072),contract:e.strictObject({version:e.number().int().positive(),evaluator:e.string().min(1).max(128),policyRevision:e.number().int().nonnegative()})}).refine(t=>F(t)<=131072,"Node input exceeds its byte budget"),vi=e.strictObject({schemaVersion:e.literal(1),kind:Ce,outcome:e.enum(["success","cancel","failure","unavailable","elapsed","received","timeout","not_participating"]),data:ce(131072),route:e.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/).nullable(),evidence:ce(131072)}).refine(t=>F(t)<=131072,"Node result exceeds its byte budget"),wi=e.strictObject({schemaVersion:e.literal(1),operations:e.record(M,e.strictObject({attempts:e.number().int().nonnegative(),maxAttempts:e.number().int().min(1).max(5),deadlineAt:e.iso.datetime({offset:!0}),retryAt:e.iso.datetime({offset:!0}).nullable(),error:e.string().regex(/^[a-z_]{1,64}$/).nullable(),reference:e.strictObject({type:M,id:e.uuid()}).nullable()}))}).refine(t=>F(t)<=65536,"Execution state exceeds its byte budget"),P={receiptId:e.uuid()},Ae=e.iso.datetime({offset:!0}),Ii=e.discriminatedUnion("type",[e.strictObject({type:e.literal("node_entered"),details:e.strictObject({kind:Ce})}),e.strictObject({type:e.literal("presentation_shown"),details:e.strictObject({...P,source:e.literal("client"),occurredAt:Ae.optional()})}),e.strictObject({type:e.literal("decision_accepted"),details:e.strictObject(P)}),e.strictObject({type:e.literal("signal_received"),details:e.strictObject({signalId:e.uuid(),nodeId:M,eventName:M,data:ce(8192),source:e.literal("server"),occurredAt:Ae})}),e.strictObject({type:e.literal("signal_consumed"),details:e.strictObject({...P,signalId:e.uuid()})}),e.strictObject({type:e.literal("wait_elapsed"),details:e.strictObject(P)}),e.strictObject({type:e.literal("wait_timeout"),details:e.strictObject(P)}),e.strictObject({type:e.literal("operation_completed"),details:e.strictObject({...P,operation:M,reference:e.strictObject({type:M,id:e.uuid()}).nullable()})}),e.strictObject({type:e.literal("execution_recovered"),details:e.strictObject({generation:e.number().int().positive(),reason:e.enum(["interrupted","expired_lease","delivery_failed"])})}),e.strictObject({type:e.literal("execution_failed"),details:e.strictObject({generation:e.number().int().positive(),code:e.string().regex(/^[a-z_]{1,64}$/)})}),e.strictObject({type:e.literal("run_completed"),details:e.strictObject({outcome:e.enum(["completed","ineligible","failed"])})}),e.strictObject({type:e.literal("run_closed"),details:e.strictObject({source:e.enum(["client","server","expiry"])})}),e.strictObject({type:e.literal("treatment_used"),details:e.strictObject({...P,source:e.enum(["client","server"]),occurredAt:Ae,reference:e.string().min(1).max(128).optional()})})]);var R=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),sn=e.discriminatedUnion("type",[e.strictObject({id:R,type:e.literal("owned"),publicData:Ye.optional(),document:H.refine(t=>["page","popup","onboarding"].includes(t.surface)&&t.pages.length===1&&t.actions.every(o=>o.type==="event"&&!o.close),"A Funnel owns one Page or Popup per screen and emits outputs; Paywall owns its purchase policies")}),e.strictObject({id:R,type:e.literal("paywall"),paywallVersionId:e.uuid()})]),ze={executionContract:et.optional(),kind:e.literal("funnel"),schemaVersion:e.literal(4),screens:e.array(sn).max(D.pages),references:e.record(R,Ne).refine(t=>Object.keys(t).length<=500),inputs:e.array(e.strictObject({variable:R,screenId:R,componentId:R,required:e.boolean()})).max(D.questions),variables:e.record(K,ge).refine(t=>Object.keys(t).length<=D.logicNodes),outputSchema:fe,execution:e.strictObject({runTimeoutSeconds:e.number().int().min(1).max(De.runTimeoutSeconds),maxTransitions:e.number().int().min(1).max(De.maxTransitions)})},$i=e.strictObject({...ze,graph:Ke});function cn(t,o){let n=!1,s=(i,a)=>{let f=i.type==="stack"||i.type==="button"?i.bind?.coupon??a:a;i.type==="text"&&Object.values(t.strings.locales).some(m=>m[i.text]?.includes("{{offer."))&&!(f&&o(f))&&(n=!0),i.type==="stack"&&i.children.forEach(m=>s(m,f))};for(let i of t.pages)s(i.root);return n}function le(t){return Array.isArray(t)?t.some(le):!t||typeof t!="object"?!1:Object.entries(t).some(([o,n])=>o==="productVersionId"?n===ht:le(n))}function un(t){let o=[],n=new Set(Object.values(t.references).flatMap(s=>s.type==="reward"?[s.id]:[]));for(let[s,i]of t.screens.entries()){if(i.type!=="owned")continue;let a;try{a=dt(i.document)}catch(f){o.push({message:f instanceof Error?f.message:"Screen cannot be delivered",reason:"screen",path:["screens",s,"document"]});continue}for(let[f,m]of t.inputs.entries())m.screenId===i.id&&!me(a,m.componentId)&&o.push({message:`Local Funnel input ${m.variable} targets hidden component ${m.componentId} on screen ${m.screenId}`,reason:"inputBinding",path:["inputs",f]})}for(let[s,i]of t.graph.nodes.entries()){let a=["graph","nodes",s],f=i.type==="screen"?t.screens.find(m=>m.id===i.screenId):void 0;f?.type==="owned"&&(f.document.actions.some(m=>typeof m.properties.templateKey=="string"&&m.properties.templateKey.startsWith("popup-coupon-"))&&o.push({message:"Funnel screens claim Coupons through a Claim Coupon step",reason:"coupon",path:a}),cn(f.document,m=>n.has(m))&&o.push({message:"Offer copy shows the Coupon of a Claim Coupon step",reason:"coupon",path:a})),(i.type==="output"&&i.value.type==="literal"&&le(i.value.value)||i.type==="end"&&i.output?.type==="literal"&&le(i.output.value))&&o.push({message:"Checkout outputs require a Product Version",reason:"product",path:a})}return o}function jt(t,o){for(let{message:n,reason:s,path:i}of un(t))o.addIssue({code:"custom",message:n,path:i,params:{reason:s}})}function kt(t,o){let n=(d,r,c=[])=>o.addIssue({code:"custom",message:d,path:c,params:{reason:r}}),s=Object.values(t.references),i=new Map(t.screens.map(d=>[d.id,d])),a=(d,r)=>s.some(c=>c.type===d&&("id"in c?c.id:c.key)===r);i.size!==t.screens.length&&n("Screen identifiers must be unique","uniqueScreens");let f=t.graph.nodes.filter(d=>d.type==="screen");(f.length!==i.size||f.some(d=>!i.has(d.screenId)))&&n("Every screen belongs to exactly one presentation node","screenOwner");let m=new Map,x=Object.keys(t.variables);x.some(d=>x.some(r=>d!==r&&r.startsWith(d+".")))&&n("Variable paths must not overlap","variable");function _(d,r){Object.hasOwn(t.variables,d)||n("Every produced variable needs a declaration","variable",["graph","nodes",t.graph.nodes.indexOf(r)]);let c=m.get(d)??new Set;c.add(r.id),m.set(d,c)}for(let[d,r]of t.graph.nodes.entries()){let c=["graph","nodes",d],w=r.type==="feature"?r.featureKey:r.type==="offering"&&r.configuration.source==="feature"?r.configuration.featureKey:r.type==="output"&&r.value.type==="feature"?r.value.featureKey:r.type==="end"&&r.output?.type==="feature"?r.output.featureKey:null;w&&!a("flag",w)&&n("Flag selectors require an explicit GB resource reference","feature",c);let I=r.type==="feature"||r.type==="offering"||r.type==="coupon"||r.type==="coupons"||r.type==="action"&&r.action.type==="api"?["value"]:r.type==="action"&&r.action.type==="external_task"?Object.keys(r.action.outputs):r.type==="wait"&&r.wait.type==="event"?Object.keys(r.wait.outputs):[],O="writes"in r?r.writes??{}:{};(I.length!==Object.keys(O).length||I.some(u=>!Object.hasOwn(O,u))||new Set(Object.values(O)).size!==Object.values(O).length)&&n("Node writes must map every named output exactly once","variable",c);for(let[u,b]of Object.entries(O)){_(b,r);let g=t.variables[b],l=r.type==="offering"?"offering_version":r.type==="coupon"?"reward":r.type==="action"&&r.action.type==="api"?"json":r.type==="action"&&r.action.type==="external_task"?r.action.outputs[u]:r.type==="wait"&&r.wait.type==="event"?r.wait.outputs[u]:void 0;(g?.source.type!=="node"||l&&g.type!==l)&&n("Node writer source or output type does not match declaration","variable",c)}if(r.type==="coupons"){let u=t.variables[r.writes.value];(u?.type!=="array"||u.items?.type!=="reward"||u.items.nullable||u.nullable)&&n("Coupons output requires a non-null Reward array","variable",c);for(let b of r.couponIds)a("reward",b)||n("Coupons require Reward references","coupon",c)}if(r.type==="split"&&!a("experiment",r.experimentId)&&n("Experiment selectors require a GB resource reference","experiment",c),r.type==="coupon"&&!a("reward",r.couponId)&&n("Coupon selectors require a Reward reference","coupon",c),r.type==="action"&&r.action.type==="claim_offer"&&r.action.coupon.source==="literal"){let u=r.action.coupon.value;(!u||typeof u!="object"||Array.isArray(u)||u.type!=="reward"||typeof u.id!="string"||Object.keys(u).length!==2||!a("reward",u.id))&&n("Coupon claims require a Reward reference","coupon",c)}if(r.type==="offering"&&r.configuration.source==="fixed"&&!a("offering_version",r.configuration.versionId)&&n("Offering selectors require an explicit Version reference","offering",c),r.type==="screen"&&r.offering?.source==="variable"&&t.variables[r.offering.key]?.type!=="offering_version"&&n("Screen Offering variable must be an Offering reference","offering",c),r.type==="action"&&r.action.type==="claim_offer"&&r.action.coupon.source==="variable"&&(t.variables[r.action.coupon.key]?.type!=="reward"||r.action.coupon.path)&&n("Coupon variable must be a complete Reward reference","coupon",c),r.type==="screen"){let u=i.get(r.screenId);if(r.offering?.source==="fixed"&&!a("offering_version",r.offering.versionId)&&n("Screen Offering requires an explicit Version reference","offering",c),u?.type==="paywall"&&r.offering&&n("Paywall owns its fixed Offering Version","offering",c),u?.type==="paywall"&&!a("paywall_version",u.paywallVersionId)&&n("Paywall screens require an explicit Version reference","paywall",c),u?.type==="owned"){let b=u.document.pages[0];if(!b){n("Owned screen requires a page","screen",c);continue}Te(u.document).some(l=>!l.complete)&&n("Owned screens require complete local content","translations",c);let g=new Set(u.document.actions.map(l=>l.id));(g.size!==Object.keys(r.outputs).length||Object.keys(r.outputs).some(l=>!g.has(l)))&&n("Every screen action requires exactly one outcome route","buttonOutputs",c),Z(b.root,l=>{!r.offering&&(l.type==="plan_picker"||(l.type==="stack"||l.type==="button")&&l.bind?.plan||l.type==="customer_data"&&["customer_plans","credit_packs"].includes(l.data.source))&&n("Product presentation requires an Offering Version","offering",c),l.type==="customer_data"&&Object.values(l.data.outputs??{}).some(z=>z!==void 0&&!g.has(z))&&n("Customer components require declared screen outcomes","componentOutput",c)})}}r.type==="end"&&["completed","ineligible"].includes(r.outcome)&&!r.output&&n("Completed and ineligible ends require a declared output","output",c),r.type==="end"&&r.output?.type==="literal"&&!T(t.outputSchema,r.output.value)&&n("Terminal output does not match outputSchema","output",c),r.type==="output"&&r.value.type==="literal"&&!T(t.outputSchema,r.value.value)&&n("Terminal output does not match outputSchema","output",c);let A=r.type==="output"?r.value:r.type==="end"?r.output:void 0;if(A?.type==="variable"&&!A.path){let u=t.variables[A.key];u&&!$e(u,t.outputSchema)&&n("Variable output does not match outputSchema","output",c)}if(r.type==="screen"){let u=i.get(r.screenId);if(u?.type==="owned")for(let b of xe(u.document))(/^(input|params)\./.test(b)||b.startsWith("variables.")&&!he(b.slice(10),x))&&n("Screen values must reference registered variables","variable",c)}if(r.type==="condition")for(let u of r.cases){for(let b of Ge(u.condition))a("saved_group",b)||n("Conditions require explicit Saved Group references","savedGroup",c);for(let b of q(u.condition))b.startsWith("variables.")||n("Funnel conditions read registered variables only","variable",c)}if(r.type==="output"&&r.value.type==="bundle"){t.outputSchema.type!=="json"&&n("Bundle output requires a JSON outputSchema","output",c);for(let[u,b]of[["paywall","paywall_version"],["offering","offering_version"],["coupons","reward"]]){let g=r.value[u];if(g)if(g.source==="literal"){let l=u==="coupons"?g.value:[g.value];(!Array.isArray(l)||l.length>20||l.some(z=>!T({type:b,nullable:!1},z)||!a(b,z.id))||u==="coupons"&&new Set(l.map(z=>z.id)).size!==l.length)&&n("Bundle requires distinct scoped resource references",u==="coupons"?"coupon":u==="paywall"?"paywall":"offering",[...c,"value",u])}else{let l=t.variables[g.key];(g.path||!l||l.nullable||(u==="coupons"?l.type!=="array"||l.items?.type!=="reward"||l.items.nullable:l.type!==b))&&n("Bundle binding type does not match its slot","output",c)}}}}for(let[d,r]of t.graph.nodes.entries()){let c=r.type==="screen"?i.get(r.screenId):void 0,w=[...Ot(r,x),...c?.type==="owned"?Xe(c.document).map(I=>he(I,x)?.key??I):[]];for(let I of new Set(w)){let b=function(g){if(g===r.id)return!0;if(u.has(g))return!1;u.add(g);let l=t.graph.nodes.find(Rt=>Rt.id===g);return l?(A.has(g)?l.type==="action"?[l.cancel,l.unavailable,l.failure]:l.type==="wait"&&l.wait.type==="event"?[l.wait.timeout]:[]:se(l)).some(b):!1};var N=b;if(!Object.hasOwn(t.variables,I)){n("Consumed variable is undeclared","variable",["graph","nodes",d]);continue}let O=t.variables[I];if(r.type==="screen"&&O.source.type==="input"&&t.inputs.some(g=>g.screenId===r.screenId&&g.variable===I)||O.source.type==="parameter"||O.source.type==="attribute")continue;let A=O.source.type==="input"?new Set(t.inputs.filter(g=>g.variable===I&&g.required).flatMap(g=>f.filter(l=>l.screenId===g.screenId).map(l=>l.id))):m.get(I)??new Set,u=new Set;(!A.size||b(t.graph.entry))&&n("Every path must produce the consumed variable","resultReference",["graph","nodes",d])}}(new Set(t.inputs.map(d=>d.variable)).size!==t.inputs.length||new Set(t.inputs.map(d=>`${d.screenId}:${d.componentId}`)).size!==t.inputs.length)&&n("Input keys and component bindings must be unique","inputKeys");for(let[d,r]of t.inputs.entries()){t.variables[r.variable]?.source.type!=="input"&&n("Input binding requires a registered input variable","inputBinding",["inputs",d]);let c=i.get(r.screenId),w=c?.type==="owned"?me(c.document,r.componentId):null;if((w?.type!=="stack"||!w.interaction||!["input","toggle","select","multiselect","tabs"].includes(w.interaction.type))&&n("Input requires an interactive control on its owned screen","inputBinding",["inputs",d]),w?.type==="stack"&&w.interaction){let I=w.interaction.type==="toggle"?"boolean":w.interaction.type==="multiselect"?"strings":"string";t.variables[r.variable]?.type!==I&&n("Input variable type does not match component","inputBinding",["inputs",d]);let O=t.variables[r.variable]?.enum;O&&!w.children.filter(A=>!A.hidden).every(A=>O.includes(A.id))&&n("Input choices must match the variable enum","inputBinding",["inputs",d])}}for(let[d,r]of Object.entries(t.variables))r.enum&&r.type!=="string"&&n("Only string variables support enum","variable",["variables",d]),r.source.type==="input"&&!t.inputs.some(c=>c.variable===d)&&n("Input variable requires a component binding","inputBinding",["variables",d]);let p=0,v=0;for(let d of t.screens)if(d.type==="owned"){for(let r of d.document.pages)Z(r.root,()=>{p++});v+=d.document.actions.length}(p>D.components||v>D.actions||F(t)>D.documentBytes)&&n("Funnel document exceeds its budget","budget")}var ln=e.strictObject({...ze,graph:Ee}).superRefine(kt),pn=e.strictObject({...ze,graph:Ee,displayName:e.string().trim().min(1).max(80)}).superRefine(kt),Li=pn.superRefine(jt),Hi=ln.superRefine(jt),ue=e.string().regex(Fe),$={requestId:e.uuid(),nodeId:R,visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),customerToken:ue.optional()},dn=e.discriminatedUnion("type",[e.strictObject({type:e.literal("screen"),output:R,answers:J,selection:e.record(R,e.union([e.string().max(200),e.boolean(),e.number().int().min(0).max(1e4)])).optional()}),e.strictObject({type:e.literal("paywall_quote"),featureQuantities:e.record(e.uuid(),e.number().int().min(0).max(1e4)).refine(t=>Object.keys(t).length<=100).optional(),actionId:R,productVersionId:e.uuid(),offerId:e.uuid().optional(),nativeOffer:He.optional(),subscriptionChange:We.optional(),predecessor:e.strictObject({operationId:e.uuid().nullable(),generation:e.number().int().positive()}).optional()}),e.strictObject({type:e.literal("paywall_confirm"),operationId:e.uuid(),merchantConfirmation:Pe.optional()}),e.strictObject({type:e.literal("paywall_cancel"),operationId:e.uuid()}),e.strictObject({type:e.literal("client_action"),receiptId:e.uuid(),outcome:e.enum(["success","cancel","failure","opened","failed"])})]),mn=e.object({nodeId:R,visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),components:e.record(R,e.object({resourceKey:e.string().regex(/^[a-z][a-z0-9_]{0,63}$/).optional(),page:e.number().int().min(1).max(1e5),after:Je.nullable(),filter:e.enum(["all","purchase","refund","source","usage","debt","settlement","issued","reserved","redeemed","expired","revoked"])}).strict()).refine(t=>Object.keys(t).length<=150)}).strict(),Zi=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("start"),funnelId:e.uuid(),requestId:e.uuid(),customer:ne.optional(),customerData:re.optional(),locale:e.string().min(1).max(35),parameters:B}).refine(ie,oe),e.strictObject({operation:e.literal("get"),settlementRequestId:e.uuid().optional(),data:mn.optional(),purchase:e.strictObject({receiptId:e.uuid(),operationId:e.uuid()}).optional(),customerToken:ue.optional()}),e.strictObject({operation:e.literal("resume"),requestId:e.uuid(),customerToken:ue.optional()}),e.strictObject({operation:e.literal("submit"),...$,input:dn}),e.strictObject({operation:e.literal("back"),...$}),e.strictObject({operation:e.literal("shown"),...$}),e.strictObject({operation:e.literal("close"),...$}),e.strictObject({operation:e.literal("commit_segment"),...$,policyRevision:e.number().int().nonnegative(),generation:e.string().min(1).max(256)}),e.strictObject({operation:e.literal("review"),receiptId:e.uuid().optional(),customerToken:ue.optional()})]);export{_t as a,Xe as b,F as c,Kt as d,Kn as e,Mt as f,gr as g,wr as h,Zt as i,Vn as j,Un as k,Bn as l,Vt as m,Ct as n,Nt as o,Gn as p,ne as q,re as r,ie as s,oe as t,at as u,$n as v,Pt as w,Ln as x,Hn as y,Zn as z,Oe as A,Bt as B,cr as C,ur as D,lr as E,nn as F,rn as G,Si as H,vi as I,pn as J,Zi as K};
|
|
1
|
+
import{a as He,i as Ze,y as We}from"./chunk-3532HSBP.js";import{w as Pe}from"./chunk-67WFVDTV.js";import{a as K,b as fe,c as ge,d as ye,e as T,f as $e,g as Le,j as be,m as Q}from"./chunk-6VVQWTHV.js";import{a as q}from"./chunk-VILB5M4X.js";import{a as Fe}from"./chunk-KCUE2VFJ.js";import{m as Je,n as J,o as B}from"./chunk-Y3W5G4BF.js";import{C as me,f as Ve,g as Ue,h as Be,p as pe,v as L,w as H,x as Z,y as de,z as Te}from"./chunk-FYUMVOCV.js";import{b as Me,d as S,e as U,f as qe,g as Ge,h as W}from"./chunk-A5WUQLAO.js";import{h as V}from"./chunk-LFR2LWYC.js";import{b as e}from"./chunk-W22ESUYY.js";var E=e.string().min(1).max(255).regex(/^[a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+){0,9}$/).refine(t=>t.split(".").every(o=>!["__proto__","constructor","prototype"].includes(o)),"Reserved value path"),C=e.discriminatedUnion("source",[e.strictObject({source:e.literal("literal"),value:S}),e.strictObject({source:e.literal("variable"),key:e.string().min(1).max(255),path:E.optional()})]);function Qe(t,o){if(!o)return t;for(let n of E.parse(o).split(".")){if(Array.isArray(t)){if(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=t.length)return;t=t[Number(n)];continue}if(t===null||typeof t!="object"||!Object.hasOwn(t,n))return;t=Reflect.get(t,n)}return t}function _t(t,o){if(t.source==="literal")return structuredClone(t.value);let n=Le(o.declarations,o);if(!Object.hasOwn(n,t.key))throw new Error("Capability input is missing");return structuredClone(S.parse(Qe(n[t.key],t.path)))}function he(t,o){let n=[...o].sort((i,a)=>a.length-i.length).find(i=>t===i||t.startsWith(i+"."));if(!n)return null;let s=t===n?void 0:t.slice(n.length+1);return s&&!E.safeParse(s).success?null:{key:n,path:s}}function xe(t){let o=Object.values(t.strings.locales).flatMap(n=>Object.values(n));return L(t,n=>{n.type==="custom_html"&&o.push(...Object.values(n.html))}),[...new Set(o.flatMap(Be))]}function Xe(t){return xe(t).filter(o=>o.startsWith("variables.")).map(o=>o.slice(10))}function F(t){let o=JSON.stringify(t);if(o===void 0)throw new TypeError("A JSON value is required");let n=new TextEncoder().encode(o).length,s=!1;for(let i=0;i<o.length;i++){let a=o.charAt(i);if(s)a==="\\"?i++:a==='"'&&(s=!1);else if(a==='"')s=!0;else if(a===":"||a===",")n++;else if(a==="-"||a>="0"&&a<="9"){let f=i;for(;i+1<o.length&&/[0-9.eE+-]/.test(o.charAt(i+1));)i++;let m=o.slice(f,i+1);if(!/[eE]/.test(m))continue;let[x="",_]=m.split(/[eE]/),p=x.replace(/^-/,""),v=p.replace(".","").length,N=(p.includes(".")?p.indexOf("."):v)+Number(_),d=N<=0?2-N+v:N>=v?N:v+1;n+=d+(x.startsWith("-")?1:0)-m.length}}return n}var Kt=e.string().regex(/^[a-f0-9]{64}$/),Et=Ve.pick({text:!0,label:!0,alt:!0,html:!0,couponId:!0,countdownAt:!0,missing:!0}),Ye=e.strictObject({couponDigests:e.record(e.uuid(),Kt),variables:e.record(pe,e.record(e.uuid(),e.partialRecord(e.enum(["offer.name","offer.description","offer.headline","offer.eligibility","offer.validity","offer.terms","offer.discount","offer.months","offer.ends_at"]),e.string()))),locales:e.record(pe,Ue.extend({nodes:e.record(e.string(),e.strictObject({base:Et})),plans:e.object({}).strict(),pickers:e.object({}).strict()}).omit({paywall:!0}))});var et=e.enum(["funnel-run/1","funnel-process/1"]),Kn="funnel-process/1";var Se=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),tt=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,128}$/),nt=B.refine(t=>new TextEncoder().encode(JSON.stringify(t)).byteLength<=8192,"Task data exceeds 8 KiB"),ve=e.record(Se,e.enum(["string","number","boolean","strings"])).refine(t=>Object.keys(t).length<=20,"Too many output fields"),Dt=C,rt=e.strictObject({type:e.literal("external_task"),endpointId:e.uuid(),taskKey:Se,inputs:e.record(Se,Dt).refine(t=>Object.keys(t).length<=20),outputs:ve}),it=e.strictObject({maxAttempts:e.number().int().min(1).max(5),retryDelaySeconds:e.number().int().min(1).max(30),backoff:e.enum(["fixed","exponential"]),requestTimeoutSeconds:e.number().int().min(1).max(10),timeoutSeconds:e.number().int().min(1).max(300)}).refine(t=>t.requestTimeoutSeconds<=t.timeoutSeconds,"Request timeout exceeds action deadline");var Pn=e.strictObject({outcome:e.enum(["success","failure"]),data:nt});var Vn=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("signal"),runId:e.uuid(),nodeId:tt,eventName:Q,eventId:e.uuid(),data:nt}),e.strictObject({operation:e.literal("read_results"),runId:e.uuid()})]),Un=e.strictObject({scope:V,runId:e.uuid(),eventId:e.uuid(),accepted:e.boolean()}),At=e.record(tt,be),Bn=e.strictObject({scope:V,runId:e.uuid(),results:At});var Ct=["id","externalUserId","createdAt","ageDays","subscription"],we=e.array(e.string().trim().min(1).max(40).refine(t=>!t.includes(","),"标签不能包含逗号")).max(20).refine(t=>new Set(t).size===t.length,"标签不能重复"),X=e.intersection(U,e.looseObject({tags:we.optional()})).refine(t=>![...Ct,"parameters","answers","results"].some(o=>Object.hasOwn(t,o)),"Reserved customer attribute"),Y=e.string().trim().max(80),ee=e.string().regex(/^\+[1-9]\d{1,14}$/).nullable(),te=e.union([e.email().max(254),e.literal("")]),Nt=e.string().trim().min(1).max(255).refine(t=>!/\p{Cc}/u.test(t),"Fingerprint must not contain control characters"),ot=e.string().trim().min(1).max(255).refine(t=>!t.startsWith("gg_guest_"),"Reserved guest identity namespace"),Gn=e.object({externalUserId:ot.optional(),name:Y.default(""),email:te.default(""),phone:ee.optional(),attributes:X.default({})}).strict().refine(t=>t.externalUserId!==void 0||t.email!=="","请提供业务用户 ID 或邮箱"),ne=e.discriminatedUnion("type",[e.strictObject({type:e.literal("id"),value:e.uuid()}),e.strictObject({type:e.literal("externalUserId"),value:ot})]),re=e.strictObject({name:Y.optional(),email:te.optional(),phone:ee.optional(),attributes:X.optional(),fingerprint:Nt.optional()}),ie=t=>!t.customerData||t.customer?.type==="externalUserId",oe="customerData requires an externalUserId customer",at=e.object({id:e.uuid(),externalUserId:e.string().min(1).max(255).nullable(),name:Y,email:te,phone:ee.optional(),attributes:X,createdAt:e.iso.datetime()}).strict(),$n=e.object({customer:at,changed:e.boolean(),replayed:e.boolean()}).strict(),zt=e.discriminatedUnion("type",[e.object({type:e.literal("id"),value:e.uuid()}).strict(),e.object({type:e.literal("externalUserId"),value:e.string().trim().min(1).max(255)}).strict()]),Ft=e.object({name:Y.optional(),email:te.optional(),phone:ee.optional(),attributes:X.refine(t=>!Object.hasOwn(t,"tags"),"Use incremental tagChanges").optional(),removeAttributes:e.array(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_]{0,127}$/)).max(128).refine(t=>!t.includes("tags")).optional(),tagChanges:e.strictObject({add:we,remove:we}).optional()}).strict().refine(t=>Object.keys(t).length>0,"请提供需要修改的字段"),Pt=e.object({lookup:zt}).strict(),Ln=Pt.extend({requestId:e.uuid(),patch:Ft}).strict(),Hn=e.object({search:e.string().trim().max(200).default(""),tag:e.string().trim().max(40).default(""),planId:e.string().max(200).default(""),versionId:e.string().max(200).default(""),holdingStatus:e.enum(["","active","scheduled","expired","unavailable","none"]).default(""),membershipStatus:e.enum(["","active","trial","past_due","ended"]).default(""),createdFrom:e.union([e.iso.datetime(),e.literal("")]).default(""),createdUntil:e.union([e.iso.datetime(),e.literal("")]).default(""),offset:e.coerce.number().int().min(0).max(1e5).default(0),limit:e.coerce.number().int().min(1).max(100).default(50)}).strict(),Zn=e.object({customers:at.array(),hasMore:e.boolean(),total:e.number().int().nonnegative().nullable(),evaluatedAt:e.iso.datetime()}).strict();var Yn=e.enum(["local","remote"]),Ie=e.strictObject({port:e.string().regex(/^[a-zA-Z0-9_.:-]{1,128}$/),value:S.optional(),sticky:e.array(e.strictObject({expected:W.nullable(),next:W})).max(100),exposures:e.array(S).max(100),features:e.array(S).max(100)}),st=e.strictObject({type:e.literal("evaluate"),receiptId:e.uuid(),environmentId:e.uuid(),policyRevision:e.number().int().nonnegative(),attributes:U,sticky:e.record(e.string(),W)}),ct=st.extend({runId:e.uuid(),versionId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative()}),Vt=st.omit({type:!0,receiptId:!0}).extend({type:e.literal("evaluate_segment")}),ut=e.strictObject({nodeId:e.string().min(1).max(64),result:Ie}),lt=Vt.extend({runId:e.uuid(),versionId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),parameters:B,answers:J,variables:e.record(e.string(),S)});var Oe=e.discriminatedUnion("type",[e.strictObject({type:e.literal("literal"),value:S}),e.strictObject({type:e.literal("variable"),key:K,path:E.optional()}),e.strictObject({type:e.literal("feature"),featureKey:e.string().min(1).max(128)})]),Ut=e.strictObject({requestId:e.uuid(),decisionId:e.uuid(),customerId:e.uuid(),externalUserId:e.string().min(1).max(255).nullable(),versionId:e.uuid(),receiptId:e.uuid(),value:S}),Bt={funnelId:e.uuid(),requestId:e.uuid(),customer:ne,customerData:re.optional(),attributes:U.refine(t=>!["parameters","answers","results","variables"].some(o=>Object.hasOwn(t,o)),"parameters, answers, results and variables are reserved flow namespaces")},cr=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("decide"),...Bt}).refine(ie,oe),e.strictObject({operation:e.literal("read_decision"),decisionId:e.uuid()}),e.strictObject({operation:e.literal("evaluate_decision"),decisionId:e.uuid(),requestId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),receiptId:e.uuid(),policyRevision:e.number().int().nonnegative(),generation:e.string().min(1).max(256),result:Ie}),e.strictObject({operation:e.literal("feature_config"),funnelId:e.uuid()}),e.strictObject({operation:e.literal("commit_decision_segment"),decisionId:e.uuid(),requestId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),policyRevision:e.number().int().nonnegative(),generation:e.string().min(1).max(256),steps:e.array(ut).max(32),boundary:e.strictObject({nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative()}).optional()}),e.strictObject({operation:e.literal("segment_configuration"),funnelId:e.uuid(),versionId:e.uuid()}),e.strictObject({operation:e.literal("configuration"),funnelId:e.uuid(),versionId:e.uuid().optional()}),e.strictObject({operation:e.literal("local_configuration"),funnelId:e.uuid()}),e.strictObject({operation:e.literal("report_used"),decisionId:e.uuid(),eventId:e.uuid(),occurredAt:e.iso.datetime({offset:!0}),reference:e.string().min(1).max(128).optional()})]),ur=e.strictObject({scope:V,decisionId:e.uuid(),requestId:e.uuid(),status:e.enum(["pending","completed","failed"]),decision:Ut.nullable(),evaluation:e.discriminatedUnion("type",[ct,lt]).optional()}).refine(t=>t.status==="completed"==(t.decision!==null)&&(!t.decision||t.decision.decisionId===t.decisionId&&t.decision.requestId===t.requestId),"Completed decisions carry their committed result"),lr=e.strictObject({scope:V,decisionId:e.uuid(),eventId:e.uuid(),source:e.literal("caller_reported")});function Mt(t,o=[]){let n=[];L(t,i=>{i.hidden&&n.push("Hidden components must not be delivered"),o.includes(i.type)&&n.push(`Node type ${i.type} cannot be delivered`)});let s=new Set(de(t).map(i=>i.key));for(let[i,a]of Object.entries(t.strings.locales))for(let f of Object.keys(a))s.has(f)||n.push(`Unused string ${f} must not be delivered (${i})`);return n}function pt(t){return t.hidden?null:t.type!=="stack"?t:{...t,children:t.children.flatMap(o=>pt(o)??[])}}function Tt(t){let o=t.pages.map(i=>{let a=pt(i.root);return a?.type==="stack"?{...i,root:a}:{...i,root:{type:"stack",id:i.root.id,...i.root.name===void 0?{}:{name:i.root.name},direction:"vertical",align:"stretch",justify:"start",children:[]}}}),n=new Set(de({pages:o}).map(i=>i.key)),s=Object.fromEntries(Object.entries(t.strings.locales).map(([i,a])=>[i,Object.fromEntries(Object.entries(a).filter(([f])=>n.has(f)))]));return{...t,pages:o,strings:{...t.strings,locales:s}}}function dt(t,o=[]){let n=H.parse(structuredClone(Tt(t))),s=a=>a.type!=="stack"||a.interaction!==void 0||a.children.some(s);for(let a of n.pages)if(!s(a.root))throw new Error(`Page ${a.id} has no visible content`);let i=Mt(n,o);if(i.length)throw new Error(i.join("; "));return n}var gr=e.strictObject({schemaVersion:e.literal(1),renderKey:e.string().min(1).max(256),routeTemplate:e.string().startsWith("/").max(2048),selectors:e.array(e.string().regex(/^[a-z][a-z0-9-]*\[(?:id|data-testid|data-test|data-qa|data-indiana-id)="(?:[^"\\\x00-\x1f\x7f]|\\["\\])*"\]$/).max(512)),present:e.array(e.number().int().min(0)).min(1),absent:e.array(e.number().int().min(0))}).superRefine((t,o)=>{let n=[...t.present,...t.absent];(new Set(t.selectors).size!==t.selectors.length||new Set(n).size!==n.length||n.length!==t.selectors.length||n.some(s=>s>=t.selectors.length))&&o.addIssue({code:"custom",message:"Incomplete or ambiguous render signature"})}),mt=e.strictObject({renderKey:e.string().min(1).max(256),routeKey:e.string().min(1).max(256),stateKey:e.string().min(1).max(256),documentKey:e.string().min(1).max(256),documentHash:e.string().regex(/^[a-f0-9]{64}$/),compositionKey:e.string().min(1).max(256),entryMode:e.enum(["hard","soft"]),match:e.strictObject({present:e.array(e.number().int().min(0)),absent:e.array(e.number().int().min(0))})});var qt=["enterprise-internal-indiana-test","tinkerland-indiana-prod"],je="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",Gt=e.string().regex(new RegExp(`^${je}/${je}/${je}/manifest\\.json$`)),ft=e.strictObject({kind:e.literal("gcs-resumable"),url:e.url(),bucket:e.enum(qt),objectKey:Gt,byteLength:e.number().int().positive(),expiresAt:e.iso.datetime()}).superRefine((t,o)=>{let n=new URL(t.url),s=n.searchParams,i=["uploadType","upload_id","name","upload_protocol","ifGenerationMatch"];(n.origin!=="https://storage.googleapis.com"||n.username||n.password||n.hash||n.pathname!==`/upload/storage/v1/b/${t.bucket}/o`||[...s.keys()].some(a=>!i.includes(a)||s.getAll(a).length!==1)||s.get("uploadType")!=="resumable"||!/^[A-Za-z0-9_-]{1,4096}$/.test(s.get("upload_id")??"")||s.has("name")&&s.get("name")!==`app-manifests/${t.objectKey}`||s.has("upload_protocol")&&s.get("upload_protocol")!=="resumable"||s.has("ifGenerationMatch")&&s.get("ifGenerationMatch")!=="0")&&o.addIssue({code:"custom",message:"Invalid IAM upload capability"})});var h=e.string().min(1).max(256),j=e.string().regex(/^[a-f0-9]{64}$/),ae=e.strictObject({versionId:e.uuid(),manifestDigest:j,sourceGraphDigest:j,pageKey:h,stateKey:h,documentKey:h,documentHash:j,elementKey:h.optional(),nodeId:h.optional(),contentHash:j.optional(),renderKey:h.optional()}),gt=e.strictObject({pageKey:h,documentKey:h,expectedDocumentHash:j,renderKey:h.optional(),nodeId:h,elementKey:h,expectedContentHash:j,property:e.enum(["text","fontSize","color"]),value:e.union([e.string().max(4e3),e.number().finite()])}),wr=e.strictObject({versionId:e.uuid(),manifestDigest:j,sourceGraphDigest:j,pageKey:h,stateKey:h,documentKey:h,documentHash:j,renderKey:h.optional(),patches:e.array(gt.omit({pageKey:!0,documentKey:!0,expectedDocumentHash:!0,renderKey:!0})).min(1).max(200)}),$t=/^[a-z][a-z0-9-]{0,39}$/,G=e.string().regex($t),Re=e.enum(["web","ios","android"]),yt={requestId:e.uuid(),client:G,platform:Re,label:e.string().trim().min(1).max(100),sha256:j,bytes:e.number().int().min(1),transferBytes:e.number().int().min(1)},Lt=e.strictObject({action:e.literal("upload"),...yt,transferBytes:e.number().int().min(1).max(2e6),base64:e.string().min(4).max(2666668).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/)}),Ir=e.discriminatedUnion("action",[Lt,e.strictObject({action:e.literal("register"),...yt}),e.strictObject({action:e.literal("complete"),versionId:e.uuid()}),e.strictObject({action:e.literal("current"),versionId:e.uuid(),expectedCurrent:e.uuid().nullable()}),e.strictObject({action:e.literal("delivery"),enabled:e.boolean()}),e.strictObject({action:e.literal("changes"),versionId:e.uuid(),experimentId:e.uuid(),variationId:h,changesetId:e.uuid().nullable(),expectedRevision:j.nullable(),editorUrl:e.string().url().max(2048),patches:e.array(gt).max(200)})]),_e=e.strictObject({id:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),clientKey:G,platform:Re,label:e.string(),sha256:j,bytes:e.number().int().positive(),objectKey:e.string(),state:e.enum(["uploading","ready","rejected"]),isCurrent:e.boolean(),revision:e.number().int().nonnegative(),createdAt:e.string(),expiresAt:e.string(),readyAt:e.string().nullable(),summary:e.record(e.string(),e.json()),routeTree:e.json().nullable(),validation:e.record(e.string(),e.json())}),Ht=e.strictObject({key:G,platform:Re,currentId:e.uuid().nullable()}),Or=e.strictObject({rows:e.array(_e).max(100),nextCursor:e.uuid().nullable(),clients:e.array(Ht).max(20)}),ke=e.strictObject({storedBytes:e.number().int().nonnegative(),reservedBytes:e.number().int().nonnegative(),chargedBytes:e.number().int().nonnegative(),versions:e.number().int().nonnegative(),objects:e.number().int().nonnegative(),orphanObjects:e.number().int().nonnegative(),missingReadyObjects:e.number().int().nonnegative(),unknownObjectSizes:e.number().int().nonnegative(),byteLimit:e.number().int().positive(),versionLimit:e.number().int().positive(),remainingBytes:e.number().int().nonnegative()}),jr=e.strictObject({asOf:e.iso.datetime({offset:!0}),reclamation:e.literal("manual-review-required"),buckets:e.strictObject({source:ke,runtime:ke,previews:ke})}),kr=e.strictObject({version:_e,actorId:e.uuid(),claims:e.record(e.string(),e.json())}),Rr=e.strictObject({version:_e,upload:ft.nullable()}),_r=e.object({format:e.literal("indiana-route-state-index"),schemaVersion:e.literal(3),routes:e.array(e.object({routeKey:h,path:e.string(),documentKey:h,documentHash:j,initialStateKey:h,initialRenderKey:h})),renders:e.array(mt)}).loose().superRefine((t,o)=>{(!t.renders||t.routes.some(n=>!t.renders?.some(s=>s.renderKey===n.initialRenderKey&&s.routeKey===n.routeKey&&s.documentKey===n.documentKey&&s.stateKey===n.initialStateKey&&s.documentHash===n.documentHash&&s.entryMode==="hard")))&&o.addIssue({code:"custom",message:"Incomplete render catalog"})}),Kr=e.strictObject({rows:e.array(e.object({id:e.uuid(),name:e.string(),status:e.string(),variations:e.array(e.object({id:h,key:h,name:e.string().optional()}).loose())}).loose()),limited:e.boolean()}),Er=e.strictObject({enabled:e.boolean(),allowedOrigins:e.array(e.string())});var Zt=e.strictObject({delaySeconds:e.number().int().min(0).max(86400).optional(),maxPerDay:e.number().int().min(1).max(100).optional(),maxPerSession:e.number().int().min(1).max(100).optional()}),bt=e.strictObject({id:e.uuid(),name:e.string().trim().min(1).max(80),client:G,source:ae,event:e.enum(["screen_enter","button_click"]),cooldownSeconds:e.number().int().min(0).max(2592e3),behavior:e.literal("observe"),delivery:Zt.optional()}).superRefine((t,o)=>{t.event==="button_click"&&(!t.source.nodeId||!t.source.elementKey)&&o.addIssue({code:"custom",path:["source"],message:"Choose a uniquely bound button"})});var D={flowNodes:500,logicNodes:480,pages:100,components:1500,actions:250,questions:40,documentBytes:1e6,conditionDepth:3,conditionChildren:20,conditionPredicates:100},ht="00000000-0000-0000-0000-000000000000";var xt=e.strictObject({type:e.literal("bundle"),paywall:C.optional(),offering:C.optional(),coupons:C,data:C}),Wt=t=>e.strictObject({type:e.literal(t),id:e.uuid()}),Br=e.strictObject({type:e.literal("bundle"),paywallVersionId:e.uuid().optional(),offeringVersionId:e.uuid().optional(),couponIds:e.array(e.uuid()).max(20).refine(t=>new Set(t).size===t.length),data:S});var Mr=e.strictObject({type:e.literal("bundle"),offering:Wt("offering_version").nullable(),paywall:e.strictObject({versionId:e.uuid(),paywallId:e.uuid(),offeringVersionId:e.uuid()}).nullable(),coupons:e.array(Ze).max(20),data:S});var St=e.union([e.string(),e.number().finite(),e.boolean(),e.null()]),Jt=e.union([St,e.array(St).min(1).max(20)]),Qt=e.record(E,Jt).refine(t=>Object.keys(t).length<=10),vt=e.strictObject({path:E,type:e.enum(["string","number","boolean","strings"]),nullable:e.boolean().optional(),aggregation:e.enum(["count","exists"]).optional(),where:Qt.optional()}).superRefine((t,o)=>{(t.aggregation==="count"&&t.type!=="number"||t.aggregation==="exists"&&t.type!=="boolean"||!t.aggregation&&t.where)&&o.addIssue({code:"custom",message:"Collection summaries require their matching type"})});var Xt=["sendMessage","checkEntitlement","resolveOffering","readHoldings","readLedger","readBillingInvoice","readCreditStatement","previewAttach","attach","readSubscriptionOperation","previewUpdate","update","readSubscriptionUpdate","setupPayment","readPaymentSetup","verifySubscriptions","previewRefund","refund","readRefund","restoreNativePurchase","readBillingControls","prepareBillingAuthorization","confirmBillingAuthorization","setBillingCoupons","revokeBillingAuthorization","listBillingInvoices","confirmBillingAdjustment","manageBillingLimits","readSeats","manageSeat","quoteBalance","mutateBalance","trackUsage","readUsage","setUsage","adjustBalance","readBalanceSource","manageBalanceGrant","listBalanceGrants","manageUsageEntity","readUsageAnalytics","readCreditAnalytics","submitUsageBatch","readUsageBatch","redeemCoupon","listOffers","grantOffer","redeemReward","createReferralCode","claimRewardProduct"],wt=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Yt=C,It=e.discriminatedUnion("type",[rt,e.strictObject({type:e.literal("claim_offer"),coupon:C}),e.strictObject({type:e.literal("event"),event:wt}),e.strictObject({type:e.literal("api"),operation:e.enum(Xt),inputs:e.record(E,Yt).refine(t=>Object.keys(t).length<=40),outputs:e.record(wt,vt).refine(t=>Object.keys(t).length<=20)})]);var y=Q,en=e.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/),k={id:y,name:e.string().trim().min(1).max(80),position:e.strictObject({x:e.number().finite(),y:e.number().finite()}).optional()},tn={success:y,cancel:y,unavailable:y,failure:y},nn=e.url().max(2048).refine(t=>{try{return new URL(t).protocol==="https:"}catch{return!1}},{message:"External pages require HTTPS"}),rn=e.enum(["same_window","new_window"]),on=e.discriminatedUnion("type",[e.strictObject({...k,type:e.literal("entry"),next:y,triggers:e.array(bt).max(20).refine(t=>new Set(t.map(o=>o.id)).size===t.length,"Entry trigger IDs must be unique").optional()}),e.strictObject({...k,type:e.literal("screen"),screenId:y,presentation:Me,outputs:e.record(y,y),offering:e.discriminatedUnion("source",[e.strictObject({source:e.literal("variable"),key:K}),e.strictObject({source:e.literal("fixed"),versionId:e.uuid()})]).optional()}),e.strictObject({...k,type:e.literal("offering"),configuration:e.discriminatedUnion("source",[e.strictObject({source:e.literal("fixed"),versionId:e.uuid()}),e.strictObject({source:e.literal("feature"),featureKey:e.string().min(1).max(128)})]),writes:e.strictObject({value:K}),next:y}),e.strictObject({...k,type:e.literal("coupon"),couponId:e.uuid(),writes:e.strictObject({value:K}),next:y}),e.strictObject({...k,type:e.literal("coupons"),couponIds:e.array(e.uuid()).max(20).refine(t=>new Set(t).size===t.length),writes:e.strictObject({value:K}),next:y}),e.strictObject({...k,type:e.literal("output"),value:e.discriminatedUnion("type",[...Oe.options,xt,e.strictObject({type:e.literal("selection"),screenId:y,offeringKey:K})])}),e.strictObject({...k,type:e.literal("condition"),cases:e.array(e.strictObject({condition:qe,target:y})).min(1).max(50),default:y}),e.strictObject({...k,type:e.literal("feature"),featureKey:e.string().min(1).max(128),writes:e.strictObject({value:K}),next:y}),e.strictObject({...k,type:e.literal("split"),experimentId:e.uuid(),applyPageExperiment:e.literal(!0).optional(),routes:e.record(en,y).refine(t=>Object.keys(t).length>=2&&Object.keys(t).length<=20),notParticipating:y}),e.strictObject({...k,type:e.literal("action"),...tn,execution:it,action:It,writes:ye.optional()}),e.strictObject({...k,type:e.literal("external_page"),appManifest:ae.optional(),url:nn,openIn:rn,opened:y,failed:y}),e.strictObject({...k,type:e.literal("end"),outcome:e.enum(["completed","closed","ineligible","failed"]),output:Oe.optional()}),e.strictObject({...k,type:e.literal("wait"),writes:ye.optional(),wait:e.discriminatedUnion("type",[e.strictObject({type:e.literal("duration"),delaySeconds:e.number().int().min(1).max(2592e3),elapsed:y}),e.strictObject({type:e.literal("event"),eventName:y,outputs:ve,timeoutSeconds:e.number().int().min(1).max(2592e3),received:y,timeout:y})])})]),Ke=e.strictObject({version:e.literal(5),entry:y,nodes:e.array(on).min(1).max(D.flowNodes)}),Ee=Ke.superRefine((t,o)=>{an(t,n=>o.addIssue({code:"custom",message:n.message,path:n.path,params:{reason:n.reason}}))});function se(t){switch(t.type){case"entry":case"feature":case"offering":case"coupon":case"coupons":return[t.next];case"screen":return Object.values(t.outputs);case"condition":return[...t.cases.map(o=>o.target),t.default];case"split":return[...Object.values(t.routes),t.notParticipating];case"action":return[t.success,t.cancel,t.unavailable,t.failure];case"external_page":return[t.opened,t.failed];case"end":case"output":return[];case"wait":return t.wait.type==="duration"?[t.wait.elapsed]:[t.wait.received,t.wait.timeout]}}function an(t,o){let n=[],s=new Map(t.nodes.map(p=>[p.id,p])),i=(p,v,N)=>{n.push(p),o?.({message:p,reason:v,path:N?["nodes",t.nodes.indexOf(N)]:[]})};s.size!==t.nodes.length&&i("Node identifiers must be unique","uniqueNodes"),(s.get(t.entry)?.type!=="entry"||t.nodes.filter(p=>p.type==="entry").length!==1)&&i("A flow has exactly one entry node","entry"),(t.nodes.filter(p=>p.type==="screen").length>D.pages||t.nodes.filter(p=>!["screen","entry","end","output"].includes(p.type)).length>D.logicNodes)&&i("Flow node limit exceeded","budget");let a=new Set;for(let p of t.nodes){for(let v of se(p))v===t.entry&&i("An entry cannot be a transition target","entryTarget",p),s.has(v)||i(`Missing target ${v}`,"missingTarget",p);p.type==="screen"&&(a.has(p.screenId)&&i("Every screen has exactly one node owner","screenOwner",p),a.add(p.screenId))}let f=new Set,m=new Set,x=new Set;function _(p){if(f.has(p)){i("Flow edges must not form a cycle","cycle",s.get(p));return}if(!(m.has(p)||!s.has(p))){f.add(p),x.add(p);for(let v of se(s.get(p)))_(v);f.delete(p),m.add(p)}}_(t.entry);for(let p of t.nodes)x.has(p.id)||i("Every node must be reachable from Entry","unreachable",p);return[...new Set(n)]}var De={maxTransitions:1e4,runTimeoutSeconds:2592e3};function Ot(t,o,n){let s=[...o].sort((m,x)=>x.length-m.length),i=new Set,a=(m,x=!1)=>{let _=s.find(p=>m===p||x&&m.startsWith(p+"."));i.add(_??m)};if(t.type==="condition"){let m=n?.startsWith("case_")?Number(n.slice(5)):t.cases.length-1;for(let x of t.cases.slice(0,m+1))for(let _ of q(x.condition))_.startsWith("variables.")&&a(_.slice(10),!0)}if(t.type==="screen"&&t.offering?.source==="variable"&&a(t.offering.key),t.type==="action"&&(t.action.type==="api"||t.action.type==="external_task"))for(let m of Object.values(t.action.inputs))m.source==="variable"&&a(m.key);t.type==="action"&&t.action.type==="claim_offer"&&t.action.coupon.source==="variable"&&a(t.action.coupon.key);let f=t.type==="output"?t.value:t.type==="end"?t.output:null;if(f?.type==="variable"&&a(f.key),f?.type==="bundle")for(let m of[f.paywall,f.offering,f.coupons,f.data])m?.source==="variable"&&a(m.key);return f?.type==="selection"&&a(f.offeringKey),[...i]}var M=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,127}$/),ce=t=>e.record(e.string(),S).refine(o=>F(o)<=t,"Funnel evidence exceeds its byte budget"),xi=e.enum(["local_segment","evaluation","presentation","timer","event","operation"]),Ce=e.enum(["entry","presentation","decision","configuration","capability","wait","terminal"]),Ne=e.discriminatedUnion("type",[e.strictObject({type:e.literal("flag"),key:e.string().min(1).max(128)}),e.strictObject({type:e.literal("experiment"),id:e.uuid()}),e.strictObject({type:e.literal("saved_group"),id:e.uuid()}),e.strictObject({type:e.literal("config"),key:e.string().min(1).max(128)}),e.strictObject({type:e.literal("constant"),key:e.string().min(1).max(128)}),e.strictObject({type:e.literal("paywall_version"),id:e.uuid()}),e.strictObject({type:e.literal("offering_version"),id:e.uuid()}),e.strictObject({type:e.literal("reward"),id:e.uuid()})]),Si=e.strictObject({schemaVersion:e.literal(1),kind:Ce,selector:Ne.nullable(),context:ce(131072),contract:e.strictObject({version:e.number().int().positive(),evaluator:e.string().min(1).max(128),policyRevision:e.number().int().nonnegative()})}).refine(t=>F(t)<=131072,"Node input exceeds its byte budget"),vi=e.strictObject({schemaVersion:e.literal(1),kind:Ce,outcome:e.enum(["success","cancel","failure","unavailable","elapsed","received","timeout","not_participating"]),data:ce(131072),route:e.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/).nullable(),evidence:ce(131072)}).refine(t=>F(t)<=131072,"Node result exceeds its byte budget"),wi=e.strictObject({schemaVersion:e.literal(1),operations:e.record(M,e.strictObject({attempts:e.number().int().nonnegative(),maxAttempts:e.number().int().min(1).max(5),deadlineAt:e.iso.datetime({offset:!0}),retryAt:e.iso.datetime({offset:!0}).nullable(),error:e.string().regex(/^[a-z_]{1,64}$/).nullable(),reference:e.strictObject({type:M,id:e.uuid()}).nullable()}))}).refine(t=>F(t)<=65536,"Execution state exceeds its byte budget"),P={receiptId:e.uuid()},Ae=e.iso.datetime({offset:!0}),Ii=e.discriminatedUnion("type",[e.strictObject({type:e.literal("node_entered"),details:e.strictObject({kind:Ce})}),e.strictObject({type:e.literal("presentation_shown"),details:e.strictObject({...P,source:e.literal("client"),occurredAt:Ae.optional()})}),e.strictObject({type:e.literal("decision_accepted"),details:e.strictObject(P)}),e.strictObject({type:e.literal("signal_received"),details:e.strictObject({signalId:e.uuid(),nodeId:M,eventName:M,data:ce(8192),source:e.literal("server"),occurredAt:Ae})}),e.strictObject({type:e.literal("signal_consumed"),details:e.strictObject({...P,signalId:e.uuid()})}),e.strictObject({type:e.literal("wait_elapsed"),details:e.strictObject(P)}),e.strictObject({type:e.literal("wait_timeout"),details:e.strictObject(P)}),e.strictObject({type:e.literal("operation_completed"),details:e.strictObject({...P,operation:M,reference:e.strictObject({type:M,id:e.uuid()}).nullable()})}),e.strictObject({type:e.literal("execution_recovered"),details:e.strictObject({generation:e.number().int().positive(),reason:e.enum(["interrupted","expired_lease","delivery_failed"])})}),e.strictObject({type:e.literal("execution_failed"),details:e.strictObject({generation:e.number().int().positive(),code:e.string().regex(/^[a-z_]{1,64}$/)})}),e.strictObject({type:e.literal("run_completed"),details:e.strictObject({outcome:e.enum(["completed","ineligible","failed"])})}),e.strictObject({type:e.literal("run_closed"),details:e.strictObject({source:e.enum(["client","server","expiry"])})}),e.strictObject({type:e.literal("treatment_used"),details:e.strictObject({...P,source:e.enum(["client","server"]),occurredAt:Ae,reference:e.string().min(1).max(128).optional()})})]);var R=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),sn=e.discriminatedUnion("type",[e.strictObject({id:R,type:e.literal("owned"),publicData:Ye.optional(),document:H.refine(t=>["page","popup","onboarding"].includes(t.surface)&&t.pages.length===1&&t.actions.every(o=>o.type==="event"&&!o.close),"A Funnel owns one Page or Popup per screen and emits outputs; Paywall owns its purchase policies")}),e.strictObject({id:R,type:e.literal("paywall"),paywallVersionId:e.uuid()})]),ze={executionContract:et.optional(),kind:e.literal("funnel"),schemaVersion:e.literal(4),screens:e.array(sn).max(D.pages),references:e.record(R,Ne).refine(t=>Object.keys(t).length<=500),inputs:e.array(e.strictObject({variable:R,screenId:R,componentId:R,required:e.boolean()})).max(D.questions),variables:e.record(K,ge).refine(t=>Object.keys(t).length<=D.logicNodes),outputSchema:fe,execution:e.strictObject({runTimeoutSeconds:e.number().int().min(1).max(De.runTimeoutSeconds),maxTransitions:e.number().int().min(1).max(De.maxTransitions)})},$i=e.strictObject({...ze,graph:Ke});function cn(t,o){let n=!1,s=(i,a)=>{let f=i.type==="stack"||i.type==="button"?i.bind?.coupon??a:a;i.type==="text"&&Object.values(t.strings.locales).some(m=>m[i.text]?.includes("{{offer."))&&!(f&&o(f))&&(n=!0),i.type==="stack"&&i.children.forEach(m=>s(m,f))};for(let i of t.pages)s(i.root);return n}function le(t){return Array.isArray(t)?t.some(le):!t||typeof t!="object"?!1:Object.entries(t).some(([o,n])=>o==="productVersionId"?n===ht:le(n))}function un(t){let o=[],n=new Set(Object.values(t.references).flatMap(s=>s.type==="reward"?[s.id]:[]));for(let[s,i]of t.screens.entries()){if(i.type!=="owned")continue;let a;try{a=dt(i.document)}catch(f){o.push({message:f instanceof Error?f.message:"Screen cannot be delivered",reason:"screen",path:["screens",s,"document"]});continue}for(let[f,m]of t.inputs.entries())m.screenId===i.id&&!me(a,m.componentId)&&o.push({message:`Local Funnel input ${m.variable} targets hidden component ${m.componentId} on screen ${m.screenId}`,reason:"inputBinding",path:["inputs",f]})}for(let[s,i]of t.graph.nodes.entries()){let a=["graph","nodes",s],f=i.type==="screen"?t.screens.find(m=>m.id===i.screenId):void 0;f?.type==="owned"&&(f.document.actions.some(m=>typeof m.properties.templateKey=="string"&&m.properties.templateKey.startsWith("popup-coupon-"))&&o.push({message:"Funnel screens claim Coupons through a Claim Coupon step",reason:"coupon",path:a}),cn(f.document,m=>n.has(m))&&o.push({message:"Offer copy shows the Coupon of a Claim Coupon step",reason:"coupon",path:a})),(i.type==="output"&&i.value.type==="literal"&&le(i.value.value)||i.type==="end"&&i.output?.type==="literal"&&le(i.output.value))&&o.push({message:"Checkout outputs require a Product Version",reason:"product",path:a})}return o}function jt(t,o){for(let{message:n,reason:s,path:i}of un(t))o.addIssue({code:"custom",message:n,path:i,params:{reason:s}})}function kt(t,o){let n=(d,r,c=[])=>o.addIssue({code:"custom",message:d,path:c,params:{reason:r}}),s=Object.values(t.references),i=new Map(t.screens.map(d=>[d.id,d])),a=(d,r)=>s.some(c=>c.type===d&&("id"in c?c.id:c.key)===r);i.size!==t.screens.length&&n("Screen identifiers must be unique","uniqueScreens");let f=t.graph.nodes.filter(d=>d.type==="screen");(f.length!==i.size||f.some(d=>!i.has(d.screenId)))&&n("Every screen belongs to exactly one presentation node","screenOwner");let m=new Map,x=Object.keys(t.variables);x.some(d=>x.some(r=>d!==r&&r.startsWith(d+".")))&&n("Variable paths must not overlap","variable");function _(d,r){Object.hasOwn(t.variables,d)||n("Every produced variable needs a declaration","variable",["graph","nodes",t.graph.nodes.indexOf(r)]);let c=m.get(d)??new Set;c.add(r.id),m.set(d,c)}for(let[d,r]of t.graph.nodes.entries()){let c=["graph","nodes",d],w=r.type==="feature"?r.featureKey:r.type==="offering"&&r.configuration.source==="feature"?r.configuration.featureKey:r.type==="output"&&r.value.type==="feature"?r.value.featureKey:r.type==="end"&&r.output?.type==="feature"?r.output.featureKey:null;w&&!a("flag",w)&&n("Flag selectors require an explicit GB resource reference","feature",c);let I=r.type==="feature"||r.type==="offering"||r.type==="coupon"||r.type==="coupons"||r.type==="action"&&r.action.type==="api"?["value"]:r.type==="action"&&r.action.type==="external_task"?Object.keys(r.action.outputs):r.type==="wait"&&r.wait.type==="event"?Object.keys(r.wait.outputs):[],O="writes"in r?r.writes??{}:{};(I.length!==Object.keys(O).length||I.some(u=>!Object.hasOwn(O,u))||new Set(Object.values(O)).size!==Object.values(O).length)&&n("Node writes must map every named output exactly once","variable",c);for(let[u,b]of Object.entries(O)){_(b,r);let g=t.variables[b],l=r.type==="offering"?"offering_version":r.type==="coupon"?"reward":r.type==="action"&&r.action.type==="api"?"json":r.type==="action"&&r.action.type==="external_task"?r.action.outputs[u]:r.type==="wait"&&r.wait.type==="event"?r.wait.outputs[u]:void 0;(g?.source.type!=="node"||l&&g.type!==l)&&n("Node writer source or output type does not match declaration","variable",c)}if(r.type==="coupons"){let u=t.variables[r.writes.value];(u?.type!=="array"||u.items?.type!=="reward"||u.items.nullable||u.nullable)&&n("Coupons output requires a non-null Reward array","variable",c);for(let b of r.couponIds)a("reward",b)||n("Coupons require Reward references","coupon",c)}if(r.type==="split"&&!a("experiment",r.experimentId)&&n("Experiment selectors require a GB resource reference","experiment",c),r.type==="coupon"&&!a("reward",r.couponId)&&n("Coupon selectors require a Reward reference","coupon",c),r.type==="action"&&r.action.type==="claim_offer"&&r.action.coupon.source==="literal"){let u=r.action.coupon.value;(!u||typeof u!="object"||Array.isArray(u)||u.type!=="reward"||typeof u.id!="string"||Object.keys(u).length!==2||!a("reward",u.id))&&n("Coupon claims require a Reward reference","coupon",c)}if(r.type==="offering"&&r.configuration.source==="fixed"&&!a("offering_version",r.configuration.versionId)&&n("Offering selectors require an explicit Version reference","offering",c),r.type==="screen"&&r.offering?.source==="variable"&&t.variables[r.offering.key]?.type!=="offering_version"&&n("Screen Offering variable must be an Offering reference","offering",c),r.type==="action"&&r.action.type==="claim_offer"&&r.action.coupon.source==="variable"&&(t.variables[r.action.coupon.key]?.type!=="reward"||r.action.coupon.path)&&n("Coupon variable must be a complete Reward reference","coupon",c),r.type==="screen"){let u=i.get(r.screenId);if(r.offering?.source==="fixed"&&!a("offering_version",r.offering.versionId)&&n("Screen Offering requires an explicit Version reference","offering",c),u?.type==="paywall"&&r.offering&&n("Paywall owns its fixed Offering Version","offering",c),u?.type==="paywall"&&!a("paywall_version",u.paywallVersionId)&&n("Paywall screens require an explicit Version reference","paywall",c),u?.type==="owned"){let b=u.document.pages[0];if(!b){n("Owned screen requires a page","screen",c);continue}Te(u.document).some(l=>!l.complete)&&n("Owned screens require complete local content","translations",c);let g=new Set(u.document.actions.map(l=>l.id));(g.size!==Object.keys(r.outputs).length||Object.keys(r.outputs).some(l=>!g.has(l)))&&n("Every screen action requires exactly one outcome route","buttonOutputs",c),Z(b.root,l=>{!r.offering&&(l.type==="plan_picker"||(l.type==="stack"||l.type==="button")&&l.bind?.plan||l.type==="customer_data"&&["customer_plans","credit_packs"].includes(l.data.source))&&n("Product presentation requires an Offering Version","offering",c),l.type==="customer_data"&&Object.values(l.data.outputs??{}).some(z=>z!==void 0&&!g.has(z))&&n("Customer components require declared screen outcomes","componentOutput",c)})}}r.type==="end"&&["completed","ineligible"].includes(r.outcome)&&!r.output&&n("Completed and ineligible ends require a declared output","output",c),r.type==="end"&&r.output?.type==="literal"&&!T(t.outputSchema,r.output.value)&&n("Terminal output does not match outputSchema","output",c),r.type==="output"&&r.value.type==="literal"&&!T(t.outputSchema,r.value.value)&&n("Terminal output does not match outputSchema","output",c);let A=r.type==="output"?r.value:r.type==="end"?r.output:void 0;if(A?.type==="variable"&&!A.path){let u=t.variables[A.key];u&&!$e(u,t.outputSchema)&&n("Variable output does not match outputSchema","output",c)}if(r.type==="screen"){let u=i.get(r.screenId);if(u?.type==="owned")for(let b of xe(u.document))(/^(input|params)\./.test(b)||b.startsWith("variables.")&&!he(b.slice(10),x))&&n("Screen values must reference registered variables","variable",c)}if(r.type==="condition")for(let u of r.cases){for(let b of Ge(u.condition))a("saved_group",b)||n("Conditions require explicit Saved Group references","savedGroup",c);for(let b of q(u.condition))b.startsWith("variables.")||n("Funnel conditions read registered variables only","variable",c)}if(r.type==="output"&&r.value.type==="bundle"){t.outputSchema.type!=="json"&&n("Bundle output requires a JSON outputSchema","output",c);for(let[u,b]of[["paywall","paywall_version"],["offering","offering_version"],["coupons","reward"]]){let g=r.value[u];if(g)if(g.source==="literal"){let l=u==="coupons"?g.value:[g.value];(!Array.isArray(l)||l.length>20||l.some(z=>!T({type:b,nullable:!1},z)||!a(b,z.id))||u==="coupons"&&new Set(l.map(z=>z.id)).size!==l.length)&&n("Bundle requires distinct scoped resource references",u==="coupons"?"coupon":u==="paywall"?"paywall":"offering",[...c,"value",u])}else{let l=t.variables[g.key];(g.path||!l||l.nullable||(u==="coupons"?l.type!=="array"||l.items?.type!=="reward"||l.items.nullable:l.type!==b))&&n("Bundle binding type does not match its slot","output",c)}}}}for(let[d,r]of t.graph.nodes.entries()){let c=r.type==="screen"?i.get(r.screenId):void 0,w=[...Ot(r,x),...c?.type==="owned"?Xe(c.document).map(I=>he(I,x)?.key??I):[]];for(let I of new Set(w)){let b=function(g){if(g===r.id)return!0;if(u.has(g))return!1;u.add(g);let l=t.graph.nodes.find(Rt=>Rt.id===g);return l?(A.has(g)?l.type==="action"?[l.cancel,l.unavailable,l.failure]:l.type==="wait"&&l.wait.type==="event"?[l.wait.timeout]:[]:se(l)).some(b):!1};var N=b;if(!Object.hasOwn(t.variables,I)){n("Consumed variable is undeclared","variable",["graph","nodes",d]);continue}let O=t.variables[I];if(r.type==="screen"&&O.source.type==="input"&&t.inputs.some(g=>g.screenId===r.screenId&&g.variable===I)||O.source.type==="parameter"||O.source.type==="attribute")continue;let A=O.source.type==="input"?new Set(t.inputs.filter(g=>g.variable===I&&g.required).flatMap(g=>f.filter(l=>l.screenId===g.screenId).map(l=>l.id))):m.get(I)??new Set,u=new Set;(!A.size||b(t.graph.entry))&&n("Every path must produce the consumed variable","resultReference",["graph","nodes",d])}}(new Set(t.inputs.map(d=>d.variable)).size!==t.inputs.length||new Set(t.inputs.map(d=>`${d.screenId}:${d.componentId}`)).size!==t.inputs.length)&&n("Input keys and component bindings must be unique","inputKeys");for(let[d,r]of t.inputs.entries()){t.variables[r.variable]?.source.type!=="input"&&n("Input binding requires a registered input variable","inputBinding",["inputs",d]);let c=i.get(r.screenId),w=c?.type==="owned"?me(c.document,r.componentId):null;if((w?.type!=="stack"||!w.interaction||!["input","toggle","select","multiselect","tabs"].includes(w.interaction.type))&&n("Input requires an interactive control on its owned screen","inputBinding",["inputs",d]),w?.type==="stack"&&w.interaction){let I=w.interaction.type==="toggle"?"boolean":w.interaction.type==="multiselect"?"strings":"string";t.variables[r.variable]?.type!==I&&n("Input variable type does not match component","inputBinding",["inputs",d]);let O=t.variables[r.variable]?.enum;O&&!w.children.filter(A=>!A.hidden).every(A=>O.includes(A.id))&&n("Input choices must match the variable enum","inputBinding",["inputs",d])}}for(let[d,r]of Object.entries(t.variables))r.enum&&r.type!=="string"&&n("Only string variables support enum","variable",["variables",d]),r.source.type==="input"&&!t.inputs.some(c=>c.variable===d)&&n("Input variable requires a component binding","inputBinding",["variables",d]);let p=0,v=0;for(let d of t.screens)if(d.type==="owned"){for(let r of d.document.pages)Z(r.root,()=>{p++});v+=d.document.actions.length}(p>D.components||v>D.actions||F(t)>D.documentBytes)&&n("Funnel document exceeds its budget","budget")}var ln=e.strictObject({...ze,graph:Ee}).superRefine(kt),pn=e.strictObject({...ze,graph:Ee,displayName:e.string().trim().min(1).max(80)}).superRefine(kt),Li=pn.superRefine(jt),Hi=ln.superRefine(jt),ue=e.string().regex(Fe),$={requestId:e.uuid(),nodeId:R,visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),customerToken:ue.optional()},dn=e.discriminatedUnion("type",[e.strictObject({type:e.literal("screen"),output:R,answers:J,selection:e.record(R,e.union([e.string().max(200),e.boolean(),e.number().int().min(0).max(1e4)])).optional()}),e.strictObject({type:e.literal("paywall_quote"),featureQuantities:e.record(e.uuid(),e.number().int().min(0).max(1e4)).refine(t=>Object.keys(t).length<=100).optional(),actionId:R,productVersionId:e.uuid(),offerId:e.uuid().optional(),nativeOffer:He.optional(),subscriptionChange:We.optional(),predecessor:e.strictObject({operationId:e.uuid().nullable(),generation:e.number().int().positive()}).optional()}),e.strictObject({type:e.literal("paywall_confirm"),operationId:e.uuid(),merchantConfirmation:Pe.optional()}),e.strictObject({type:e.literal("paywall_cancel"),operationId:e.uuid()}),e.strictObject({type:e.literal("client_action"),receiptId:e.uuid(),outcome:e.enum(["success","cancel","failure","opened","failed"])})]),mn=e.object({nodeId:R,visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),components:e.record(R,e.object({resourceKey:e.string().regex(/^[a-z][a-z0-9_]{0,63}$/).optional(),page:e.number().int().min(1).max(1e5),after:Je.nullable(),filter:e.enum(["all","purchase","refund","source","usage","debt","settlement","issued","reserved","redeemed","expired","revoked"])}).strict()).refine(t=>Object.keys(t).length<=150)}).strict(),Zi=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("start"),funnelId:e.uuid(),requestId:e.uuid(),customer:ne.optional(),customerData:re.optional(),locale:e.string().min(1).max(35),parameters:B}).refine(ie,oe),e.strictObject({operation:e.literal("get"),settlementRequestId:e.uuid().optional(),data:mn.optional(),purchase:e.strictObject({receiptId:e.uuid(),operationId:e.uuid()}).optional(),customerToken:ue.optional()}),e.strictObject({operation:e.literal("resume"),requestId:e.uuid(),customerToken:ue.optional()}),e.strictObject({operation:e.literal("submit"),...$,input:dn}),e.strictObject({operation:e.literal("back"),...$}),e.strictObject({operation:e.literal("shown"),...$}),e.strictObject({operation:e.literal("close"),...$}),e.strictObject({operation:e.literal("commit_segment"),...$,policyRevision:e.number().int().nonnegative(),generation:e.string().min(1).max(256)}),e.strictObject({operation:e.literal("review"),receiptId:e.uuid().optional(),customerToken:ue.optional()})]);export{_t as a,Xe as b,F as c,Kt as d,Kn as e,Mt as f,gr as g,wr as h,Zt as i,Vn as j,Un as k,Bn as l,Vt as m,Ct as n,Nt as o,Gn as p,ne as q,re as r,ie as s,oe as t,at as u,$n as v,Pt as w,Ln as x,Hn as y,Zn as z,Oe as A,Bt as B,cr as C,ur as D,lr as E,nn as F,rn as G,Si as H,vi as I,pn as J,Zi as K};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as e}from"./chunk-
|
|
1
|
+
import{b as e}from"./chunk-W22ESUYY.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 +1 @@
|
|
|
1
|
-
import{h as c}from"./chunk-
|
|
1
|
+
import{h as c}from"./chunk-6VVQWTHV.js";import{b as p}from"./chunk-W22ESUYY.js";import{d as x,e as y,f as g}from"./chunk-FYMVNLQN.js";import{a as m,b as d}from"./chunk-FRK6322O.js";var u=class extends Error{constructor(t){super(t),this.name="FunnelCalculationError"}};function F(e,t,f){let i={},l,s,n,o="next",a;switch(e.type){case"entry":a=e.next;break;case"condition":{let r=e.cases.findIndex(b=>x(t.attributes??{},b.condition,t.savedGroups??{}));o=r<0?"default":`case:${r}`,a=r<0?e.default:e.cases[r].target;break}case"feature":if(!Object.hasOwn(t.features??{},e.featureKey))throw new u("Required GB Feature is unavailable");l=g(e.featureKey,t),n=l.value,Object.assign(i,c(e,{value:n})),a=e.next;break;case"split":{let r=f[e.experimentId];if(!r)throw new u("Required GB Experiment is unavailable");if(s=y(r,t),n=s.value,o=s.inExperiment&&!s.passthrough&&typeof n=="string"?n:"notParticipating",a=o==="notParticipating"?e.notParticipating:e.routes[o],!a)throw new u("Experiment Variation has no published route");break}case"offering":{let r=e.configuration.source==="fixed"?e.configuration.versionId:g(e.configuration.featureKey,t).value;n={type:"offering_version",id:p.uuid().parse(r)},Object.assign(i,c(e,{value:n})),a=e.next;break}case"coupon":case"coupons":n=e.type==="coupons"?e.couponIds.map(r=>({type:"reward",id:r})):{type:"reward",id:e.couponId},Object.assign(i,c(e,{value:n})),a=e.next;break}return{port:o,target:a,projections:i,...n===void 0?{}:{value:n},...l?{feature:l}:{},...s?{experiment:s}:{}}}function E(e,t,f){p.uuid().parse(e),p.number().int().nonnegative().parse(t);let i=m(d(new TextEncoder().encode(JSON.stringify([e,t,f])))).slice(0,32);return`${i.slice(0,8)}-${i.slice(8,12)}-5${i.slice(13,16)}-a${i.slice(17,20)}-${i.slice(20)}`}export{F as a,E as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as r}from"./chunk-
|
|
1
|
+
import{b as r}from"./chunk-W22ESUYY.js";var R=r.enum(["INVALID_PROTOCOL_VERSION","UNSUPPORTED_PROTOCOL_VERSION","PROTOCOL_RETIRED","UNAUTHENTICATED","FORBIDDEN","SCOPE_MISMATCH","INVALID_REQUEST","NOT_FOUND","CONFLICT","PAYLOAD_TOO_LARGE","RATE_LIMITED","SERVICE_UNAVAILABLE","NOT_CONFIGURED","CAPABILITY_UNAVAILABLE","INTERNAL_ERROR"]),H=r.enum([...R.options,"INVALID_SERVER_RESPONSE","RESPONSE_TOO_LARGE","AMBIGUOUS_AUTHENTICATION","BROWSER_REQUIRED","INVALID_REDIRECT_URI","AUTHORIZATION_UNAVAILABLE","UNREGISTERED_CLIENT","MANAGEMENT_OPERATION_FAILED","SENSITIVE_OUTPUT_REQUIRED"]),j=r.enum([...R.options,"stale_revision"]),v=r.enum(["fix_request","authenticate","check_permissions","check_scope","resolve_conflict","reload_state","retry_same_request","configure_integration","check_availability","upgrade_sdk","recover_operation","contact_support"]),x=r.enum(["CAPABILITY_NOT_ENABLED","INTEGRATION_MISSING","PROVIDER_CREDENTIAL_REJECTED","PRICE_BINDING_REQUIRED","IDEMPOTENCY_CONFLICT","RESULT_UNKNOWN","STATE_CHANGED","IDENTITY_CONTEXT_CHANGED","CUSTOMER_BINDING_CONFLICT","RUN_CONTRACT_MISMATCH","OPERATION_IN_PROGRESS","FUNNEL_VERSION_RETIRED","FUNNEL_PAUSED"]),L={INVALID_PROTOCOL_VERSION:{status:400,recovery:"fix_request"},UNSUPPORTED_PROTOCOL_VERSION:{status:400,recovery:"upgrade_sdk"},PROTOCOL_RETIRED:{status:410,recovery:"upgrade_sdk"},UNAUTHENTICATED:{status:401,recovery:"authenticate"},FORBIDDEN:{status:403,recovery:"check_permissions"},SCOPE_MISMATCH:{status:403,recovery:"check_scope"},INVALID_REQUEST:{status:400,recovery:"fix_request"},NOT_FOUND:{status:404,recovery:"fix_request"},CONFLICT:{status:409,recovery:"resolve_conflict"},PAYLOAD_TOO_LARGE:{status:413,recovery:"fix_request"},RATE_LIMITED:{status:429,recovery:"retry_same_request"},SERVICE_UNAVAILABLE:{status:503,recovery:"retry_same_request"},NOT_CONFIGURED:{status:501,recovery:"configure_integration"},CAPABILITY_UNAVAILABLE:{status:501,recovery:"check_availability"},INTERNAL_ERROR:{status:500,recovery:"recover_operation"}};var S={TIMEOUT:"recover_operation",NETWORK_ERROR:"recover_operation",HTTP_ERROR:"recover_operation",INVALID_RESPONSE:"recover_operation",NOT_IDENTIFIED:"authenticate",CUSTOMER_SESSION_REQUIRED:"authenticate",INVALID_TOKEN:"authenticate",INVALID_URL:"fix_request",INVALID_TIMEOUT:"fix_request",SERVER_ONLY:"fix_request",PROTOCOL_MISMATCH:"upgrade_sdk",IDENTITY_CHANGED:"reload_state",INVALID_STATE:"reload_state",EVENT_QUEUE_FULL:"retry_same_request",COMMAND_PENDING:"recover_operation",PURCHASE_PENDING:"recover_operation",DECISION_PENDING:"recover_operation",DECISION_ACCEPTANCE_UNKNOWN:"recover_operation",RUN_RECONCILIATION_REQUIRED:"recover_operation",DECISION_FAILED:"contact_support",COMMAND_STORAGE_CONFLICT:"resolve_conflict",COMMAND_STORAGE_INVALID:"fix_request",PURCHASE_STORAGE_CONFLICT:"resolve_conflict",PURCHASE_STORAGE_INVALID:"recover_operation",EXECUTION_POLICY_REFUSED:"fix_request",CONFIGURATION_UNAVAILABLE:"check_availability",CONFIGURATION_EXPIRED:"reload_state",CONFIGURATION_CHANGED:"reload_state",CONFIGURATION_DISPOSED:"reload_state",UNSUPPORTED_SCHEMA:"upgrade_sdk",FUNNEL_STOPPED:"check_availability",PAYWALL_UNAVAILABLE:"check_availability",ROUTE_UNAVAILABLE:"check_availability",EVALUATION_MODE:"reload_state",SERVER_REQUIRED:"fix_request",STICKY_SAVE_FAILED:"retry_same_request",TRANSITION_LIMIT:"resolve_conflict",PRECONDITION_FAILED:"reload_state",PRODUCT_UNAVAILABLE:"fix_request",COUPON_UNAVAILABLE:"reload_state",PURCHASE_HANDLER_REQUIRED:"fix_request",EVENT_HANDLER_REQUIRED:"fix_request",CLOSED:"fix_request",BRIDGE_UNAVAILABLE:"check_availability",INVALID_CONFIGURATION:"fix_request",NATIVE_OPERATION_FAILED:"contact_support",AI_PRICE_UNAVAILABLE:"fix_request",AI_USAGE_UNAVAILABLE:"recover_operation",AI_PROVIDER_ERROR:"check_availability",AI_BALANCE_REJECTED:"resolve_conflict"};function g(e,o){if(e==="CONFLICT"&&o===425)return{retryable:!0,recovery:"retry_same_request"};if(e==="CONFLICT"&&o===412)return{retryable:!1,recovery:"reload_state"};if(e==="INVALID_SERVER_RESPONSE")return{retryable:!1,recovery:"recover_operation"};if(e==="AMBIGUOUS_AUTHENTICATION"||e==="SENSITIVE_OUTPUT_REQUIRED")return{retryable:!1,recovery:"fix_request"};if(Object.hasOwn(S,e)){let n=S[e];return{retryable:n==="retry_same_request",recovery:n}}let t=R.safeParse(e);return t.success?{retryable:e==="RATE_LIMITED"||e==="SERVICE_UNAVAILABLE",recovery:L[t.data].recovery}:{retryable:!1,recovery:"contact_support"}}function Q(e,o){let t=R.safeParse(e);if(t.success)return e==="CONFLICT"?[409,412,425].includes(o):e==="SERVICE_UNAVAILABLE"?[408,502,503,504].includes(o):e==="INVALID_REQUEST"?[400,405,415,422].includes(o):e==="NOT_CONFIGURED"?[501,503].includes(o):L[t.data].status===o;let n={INVALID_SERVER_RESPONSE:[502],RESPONSE_TOO_LARGE:[502],AMBIGUOUS_AUTHENTICATION:[400],SENSITIVE_OUTPUT_REQUIRED:[400],BROWSER_REQUIRED:[403],INVALID_REDIRECT_URI:[403],AUTHORIZATION_UNAVAILABLE:[400],UNREGISTERED_CLIENT:[403],MANAGEMENT_OPERATION_FAILED:[400,422,500]};return Object.hasOwn(n,e)&&(n[e]?.includes(o)??!1)}function P(e,o=Date.now()){if(e===null)return;let t=e.trim();if(/^\d+$/.test(t)){let s=Number(t);return Number.isSafeInteger(s)?s:void 0}if(!/^[A-Za-z]{3}, \d{2} [A-Za-z]{3} \d{4} \d{2}:\d{2}:\d{2} GMT$/.test(t))return;let n=Date.parse(t);return Number.isFinite(n)?Math.max(0,Math.ceil((n-o)/1e3)):void 0}var y=r.object({retryable:r.boolean(),recovery:v,reason:x.optional(),retryAfterSeconds:r.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional()}),b=r.object({requestId:r.uuid().optional(),error:r.object({code:r.string().regex(/^[A-Z][A-Z0-9_]{0,95}$/),message:r.string(),...y.partial().shape})}),z=r.object({error:b.shape.error.extend({requestId:r.uuid().optional()})}),Y=r.object({error:r.string(),code:r.string().regex(/^[A-Za-z][A-Za-z0-9_]{0,95}$/),requestId:r.uuid(),...y.shape});function $(e,o,t={}){let n=g(e,o),s=t.reason==="RESULT_UNKNOWN"?"recover_operation":t.recovery??n.recovery,A=n.retryable&&t.retryable!==!1&&s!=="recover_operation",i=A?P(t.retryAfter??null):void 0;return{...n,retryable:A,recovery:s,...i===void 0?{}:{retryAfterSeconds:i},...t.reason?{reason:t.reason}:{}}}var V=r.enum(["sandbox","live"]),W=r.object({projectId:r.string().min(1),environment:V}).strict();var J=r.string().regex(/^(0|[1-9]\d{0,12})(\.\d{1,12})?$/),u=r.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e),M=r.string().regex(/^-?(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>{let o=e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e;return o==="-0"?"0":o}),p=u.refine(e=>/[1-9]/.test(e),"数量必须大于 0"),D=r.string().min(1).max(64),B=r.string().min(1).regex(/^[a-zA-Z0-9_-]+$/),C=r.string().min(1).max(64).refine(e=>!e.includes("::"),"Dimension IDs cannot contain ::"),ee=r.record(D,r.union([r.string().max(120),r.number().finite(),r.boolean()])).refine(e=>Object.keys(e).length<=16,"最多 16 个计价属性").transform(e=>Object.fromEntries(Object.entries(e).map(([o,t])=>[o,String(t)]))),U=r.record(D,r.union([r.string().max(120),r.number().finite(),r.boolean()]).transform(String)).refine(e=>Object.keys(e).length<=8,"匹配条件最多 8 个属性"),I=e=>{let o=e.startsWith("-");o&&(e=e.slice(1));let[t,n=""]=e.split(".");if(t===void 0||t==="")throw new Error("Invalid decimal value");let s=BigInt(t)*BigInt("1000000")+BigInt(n.padEnd(6,"0"));return o?-s:s},h=r.array(r.object({upTo:p.nullable(),cost:u}).strict()).min(1).max(12).refine(e=>e.at(-1)?.upTo===null&&e.slice(0,-1).every((o,t)=>{let n=e[t-1]?.upTo;return o.upTo!==null&&(t===0||n!=null&&I(o.upTo)>I(n))}),"阶梯上限必须递增,最后一档为无限"),G=r.object({key:C,match:U,priority:r.number().int().default(0),cost:u.optional(),tiers:h.optional()}).strict().refine(e=>e.cost!==void 0||e.tiers!==void 0,"维度需要指定单价或阶梯"),F=r.object({key:C,match:U,factor:p.optional(),add:M.optional()}).strict().refine(e=>e.factor!==void 0||e.add!==void 0,"A multiplier needs a factor or an add").transform(e=>({...e,factor:e.factor??"1",add:e.add??"0"})),k=r.object({units:p.default("1"),cost:u,tiers:h.optional(),dimensions:r.array(G).max(12).optional(),multipliers:r.array(F).max(4).optional()}).strict().superRefine((e,o)=>{let t=e.dimensions??[],n=e.multipliers??[];(new Set(t.map(i=>i.key)).size!==t.length||new Set(n.map(i=>i.key)).size!==n.length)&&o.addIssue({code:"custom",message:"维度和倍率的 ID 不能重复"});for(let[i,a]of t.entries())for(let c of t.slice(i+1))Object.keys(a.match).length===Object.keys(c.match).length&&a.priority===c.priority&&!Object.keys(a.match).some(E=>c.match[E]!==void 0&&c.match[E]!==a.match[E])&&o.addIssue({code:"custom",message:"维度可能同时匹配,请调整优先级"});let s=[e.cost,...(e.tiers??[]).map(i=>i.cost),...t.flatMap(i=>[...i.cost===void 0?[]:[i.cost],...(i.tiers??[]).map(a=>a.cost)])],A=I(e.units);for(let i of s)for(let a=0;a<1<<n.length;a++){let c=n.filter((N,_)=>a&1<<_);if(c.some((N,_)=>c.slice(_+1).some(d=>Object.keys(N.match).some(l=>d.match[l]!==void 0&&d.match[l]!==N.match[l]))))continue;let E=I(i),O=BigInt("1"),f=BigInt("0");for(let[N,_]of n.entries())a&1<<N&&(E*=I(_.factor??"1"),O*=BigInt("1000000"),f+=I(_.add??"0"));let T=(E+f*O)*BigInt("1000000"),m=O*A;(T<BigInt("0")||T%m!==BigInt("0")||T/m>BigInt("999999999999999999"))&&o.addIssue({code:"custom",message:"每个业务单位的最终单价必须非负、在范围内且能精确表示为最多 6 位小数"})}}),re=k.safeExtend({featureKey:B});export{R as a,v as b,x as c,Q as d,b as e,$ as f,V as g,W as h,J as i,u as j,M as k,B as l,ee as m};
|