@tinkerlandai/longplay-sdk 0.10.84 → 0.10.85

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.
Files changed (89) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +3 -0
  3. package/dist/check-response-SOTWWQ3J.js +1 -0
  4. package/dist/{chunk-P6O6ULXW.js → chunk-2FDRWKO4.js} +1 -1
  5. package/dist/{chunk-MCQGIPH7.js → chunk-3IDEYQBG.js} +1 -1
  6. package/dist/{chunk-HFLMTQ5S.js → chunk-4HCUQJOA.js} +1 -1
  7. package/dist/{chunk-BKN33GVY.js → chunk-4SDB3T2F.js} +1 -1
  8. package/dist/{chunk-HVWHUYSF.js → chunk-52G77TMV.js} +2 -2
  9. package/dist/{chunk-TQIZN3GB.js → chunk-533YCYLO.js} +1 -1
  10. package/dist/{chunk-U3TW2YVO.js → chunk-5O6YRAHQ.js} +1 -1
  11. package/dist/{chunk-SY3GVNMT.js → chunk-7C4OOGQX.js} +1 -1
  12. package/dist/{chunk-YJHL2DPP.js → chunk-7ROXL6N2.js} +1 -1
  13. package/dist/{chunk-SBZFPW6N.js → chunk-7SQPGOJV.js} +1 -1
  14. package/dist/{chunk-BNVQIMXY.js → chunk-AECGOS7O.js} +1 -1
  15. package/dist/{chunk-UDVFPFL6.js → chunk-AJHLDSPG.js} +1 -1
  16. package/dist/{chunk-TGY77F4A.js → chunk-BQUSJPMG.js} +1 -1
  17. package/dist/{chunk-Q2ZKKRIB.js → chunk-BZ7HAITJ.js} +1 -1
  18. package/dist/{chunk-BJSY53HD.js → chunk-CQYEM7U6.js} +1 -1
  19. package/dist/{chunk-B3FNR6MN.js → chunk-DJTZR2NR.js} +1 -1
  20. package/dist/{chunk-S7UDY3NL.js → chunk-DT2OMMAT.js} +1 -1
  21. package/dist/{chunk-HVDAQX2D.js → chunk-E6ND7YQW.js} +1 -1
  22. package/dist/{chunk-CTDXIKX3.js → chunk-EXHNZVTM.js} +1 -1
  23. package/dist/{chunk-4CWYR6NX.js → chunk-F53UXSUI.js} +1 -1
  24. package/dist/{chunk-3QRVHAWK.js → chunk-F54HTDAC.js} +1 -1
  25. package/dist/{chunk-25LM2JXB.js → chunk-FBHEBXK4.js} +1 -1
  26. package/dist/{chunk-W5MSVU2K.js → chunk-FGAIHKFS.js} +1 -1
  27. package/dist/{chunk-TG7FSNRF.js → chunk-HMT4SHIK.js} +1 -1
  28. package/dist/{chunk-FRWORXER.js → chunk-HSNAFHCP.js} +1 -1
  29. package/dist/{chunk-45RTRADT.js → chunk-JJEOS374.js} +1 -1
  30. package/dist/{chunk-NBIHNC2C.js → chunk-JTCS63ER.js} +1 -1
  31. package/dist/{chunk-3AUMX2ZW.js → chunk-JUI7TMIM.js} +1 -1
  32. package/dist/{chunk-UO3DDQEW.js → chunk-KICIH4PE.js} +1 -1
  33. package/dist/chunk-LIWSSQAG.js +1 -0
  34. package/dist/{chunk-ZBVIIFB4.js → chunk-MDNT2TC3.js} +1 -1
  35. package/dist/{chunk-DGGXLPHI.js → chunk-MEBCS2JG.js} +1 -1
  36. package/dist/{chunk-EPKQGOCT.js → chunk-MGVWCLVQ.js} +1 -1
  37. package/dist/{chunk-VUGDBVIZ.js → chunk-MMAMK7OQ.js} +1 -1
  38. package/dist/{chunk-VJXGTINT.js → chunk-MUU6LV3R.js} +1 -1
  39. package/dist/{chunk-YBDTPMGD.js → chunk-OKHCU6ET.js} +1 -1
  40. package/dist/chunk-OT6DGH5B.js +1 -0
  41. package/dist/{chunk-OT3ED6TT.js → chunk-RGXNLSFL.js} +1 -1
  42. package/dist/{chunk-RWGMLH42.js → chunk-TORHBU45.js} +1 -1
  43. package/dist/{chunk-Q3K63EFB.js → chunk-U2JO7MX2.js} +1 -1
  44. package/dist/{chunk-AH36XJ2P.js → chunk-WFRZHLIV.js} +1 -1
  45. package/dist/{chunk-KHJZA73V.js → chunk-WJDHBJGU.js} +1 -1
  46. package/dist/{chunk-X6WXJJED.js → chunk-XMZ2FNYA.js} +1 -1
  47. package/dist/{chunk-Z42LII54.js → chunk-Y7Z6F6Y3.js} +1 -1
  48. package/dist/{chunk-YMNCFP4X.js → chunk-YEUQXQWK.js} +1 -1
  49. package/dist/{chunk-K6Q64QHZ.js → chunk-YQ2TU6TG.js} +1 -1
  50. package/dist/{chunk-R6NVHYXW.js → chunk-ZAD5WJWS.js} +1 -1
  51. package/dist/{chunk-HJLZY2VK.js → chunk-ZMDKCBLI.js} +1 -1
  52. package/dist/{content-YCHZNM7Y.js → content-KXWLR6IG.js} +1 -1
  53. package/dist/{funnel-host-purchase-O2XMLQLO.js → funnel-host-purchase-IT23CWX7.js} +1 -1
  54. package/dist/funnel-host-recovery-paywall-QGH574CM.js +1 -0
  55. package/dist/{funnel-paywall-copies-GHMZFYUK.js → funnel-paywall-copies-LZZILAWG.js} +1 -1
  56. package/dist/funnel-paywall-prerender-BKPL2SLY.js +1 -0
  57. package/dist/funnel-route-prediction-7B5FGESC.js +1 -0
  58. package/dist/funnel-route-source-F5OML4HC.js +1 -0
  59. package/dist/funnel-runtime-host-7UOEQRZV.js +1 -0
  60. package/dist/index.js +1 -1
  61. package/dist/merchant-bridge-contracts-47PO4USZ.js +1 -0
  62. package/dist/openrouter.js +1 -1
  63. package/dist/operation-contracts-EDUVKUPX.js +1 -0
  64. package/dist/page.js +1 -1
  65. package/dist/paywall-GUW4NI2B.js +1 -0
  66. package/dist/paywall-content-HMUHTWWL.js +1 -0
  67. package/dist/paywall-session-NJHRHCKM.js +1 -0
  68. package/dist/popup.js +1 -1
  69. package/dist/react-native.js +1 -1
  70. package/dist/screen-renderer-XJDNUC7B.js +1 -0
  71. package/dist/server.js +1 -1
  72. package/dist/visual.js +1 -1
  73. package/package.json +1 -1
  74. package/dist/check-response-AB52X53M.js +0 -1
  75. package/dist/chunk-57NEGKC5.js +0 -1
  76. package/dist/chunk-J6F2XFDL.js +0 -1
  77. package/dist/funnel-host-recovery-paywall-3OLSW5TK.js +0 -1
  78. package/dist/funnel-paywall-prerender-ZUE3E5CD.js +0 -1
  79. package/dist/funnel-route-prediction-EFAGTU7F.js +0 -1
  80. package/dist/funnel-route-source-D66HFVVK.js +0 -1
  81. package/dist/funnel-runtime-host-CHUEAXTG.js +0 -1
  82. package/dist/merchant-bridge-contracts-RF4XQQTE.js +0 -1
  83. package/dist/operation-contracts-IAMHNJCL.js +0 -1
  84. package/dist/paywall-SMS52HSX.js +0 -1
  85. package/dist/paywall-content-ZJWLT3BD.js +0 -1
  86. package/dist/paywall-session-YNYTE7BE.js +0 -1
  87. package/dist/screen-renderer-MVJ5BKQS.js +0 -1
  88. /package/dist/{chunk-HVWHUYSF.js.LEGAL.txt → chunk-52G77TMV.js.LEGAL.txt} +0 -0
  89. /package/dist/{chunk-VITB5MIL.js → chunk-ZL247MPX.js} +0 -0
@@ -1 +1 @@
1
- import{J as se,d as O,f as ie}from"./chunk-DGGXLPHI.js";import{a as F}from"./chunk-R6NVHYXW.js";import{b as te,f as ne,g as re,h as oe}from"./chunk-3QRVHAWK.js";import{e as ee,k as ae}from"./chunk-NBIHNC2C.js";import{s as ce}from"./chunk-YBDTPMGD.js";import{C as Y,e as J,j as Z,l as W,p as R,s as X,t as H,v as w,w as P,x as Q,z as k}from"./chunk-W5MSVU2K.js";import{a as T,f as K}from"./chunk-VUGDBVIZ.js";import{a as I,b as S,d as h,e as D,f as C,g as A}from"./chunk-B3FNR6MN.js";import{h as j}from"./chunk-BJSY53HD.js";import{b as e}from"./chunk-VITB5MIL.js";import{a as L,b as U}from"./chunk-CILM5XMH.js";var V=e.strictObject({eventsEnabled:e.boolean(),experimentViewsEnabled:e.boolean(),featureUsageEnabled:e.boolean()}),Ze=Object.freeze({eventsEnabled:!0,experimentViewsEnabled:!0,featureUsageEnabled:!0});function We(t,r){return r==="experiment_exposure"?t.experimentViewsEnabled:r==="feature_usage"?t.featureUsageEnabled:t.eventsEnabled}var z=e.tuple([e.number().min(0).max(1),e.number().min(0).max(1)]).refine(([t,r])=>t<=r),Se=e.strictObject({attribute:e.string().optional(),seed:e.string(),hashVersion:e.literal(2),ranges:e.array(z).max(100)}),we=e.strictObject({id:e.string().min(1).max(255),condition:C,gate:e.boolean().optional()}),Oe=e.strictObject({key:e.string().optional(),name:e.string().optional(),passthrough:e.boolean().optional()}),ue={condition:C.optional(),parentConditions:e.array(we).max(100).optional(),weights:e.array(e.number().min(0).max(1)).max(20).optional(),coverage:e.number().min(0).max(1).optional(),hashAttribute:e.string().optional(),fallbackAttribute:e.string().optional(),hashVersion:e.literal(2).optional(),disableStickyBucketing:e.boolean().optional(),bucketVersion:e.number().int().nonnegative().optional(),minBucketVersion:e.number().int().nonnegative().optional(),filters:e.array(Se).max(100).optional(),ranges:e.array(z).max(20).optional(),meta:e.array(Oe).max(20).optional(),seed:e.string().optional(),name:e.string().optional(),phase:e.string().optional()},pe=e.strictObject({...ue,key:e.string().min(1).max(255),variations:e.tuple([h,h]).rest(h).refine(t=>t.length<=20),urlPatterns:e.array(e.strictObject({include:e.boolean(),type:e.enum(["regex","simple"]),pattern:e.string()})).max(100).optional(),force:e.number().int().nonnegative().optional(),active:e.boolean().optional(),persistQueryString:e.boolean().optional()}),G=e.strictObject({value:h,variationId:e.number().int(),key:e.string(),name:e.string().optional(),bucket:e.number().optional(),passthrough:e.boolean().optional(),inExperiment:e.boolean(),hashUsed:e.boolean().optional(),hashAttribute:e.string(),hashValue:e.string(),featureId:e.string().nullable(),stickyBucketUsed:e.boolean().optional()}),je=e.strictObject({...ue,id:e.string().max(255).optional(),force:h.optional(),variations:e.array(h).min(2).max(20).optional(),key:e.string().optional(),range:z.optional(),tracks:e.array(e.strictObject({experiment:pe,result:G})).max(100).optional()}),Ie=e.strictObject({defaultValue:h.optional(),rules:e.array(je).max(500).optional()}),Pe=e.record(e.string(),e.union([e.strictObject({type:e.literal("hashed"),attributeKey:e.string(),values:e.array(e.string().regex(/^[a-f0-9]{64}$/))}),e.strictObject({type:e.literal("list"),attributeKey:e.string(),values:e.array(e.union([e.string(),e.number()]))}),e.strictObject({type:e.literal("condition"),condition:C})])),v=e.strictObject({scope:j,generation:e.string().regex(/^[a-f0-9]{64}$/),evaluatedAt:e.iso.datetime({offset:!0}),expiresAt:e.iso.datetime({offset:!0}).nullable(),features:e.record(e.string(),Ie),savedGroups:Pe,experiments:e.record(e.uuid(),pe)});var ke=v.extend({analyticsConfig:V,remoteFeatures:e.array(e.string().min(1).max(255)).max(500)}),it=ke.omit({evaluatedAt:!0,expiresAt:!0}).superRefine((t,r)=>{for(let a of t.remoteFeatures)Object.hasOwn(t.features,a)&&r.addIssue({code:"custom",path:["features",a],message:"Remote Feature definitions cannot be public"});for(let[a,o]of Object.entries(t.savedGroups))o.type==="list"&&r.addIssue({code:"custom",path:["savedGroups",a],message:"Raw Saved Group lists cannot be public"})}),at=e.strictObject({attributes:D,features:e.array(e.string().min(1).max(255)).max(500).optional(),customerId:e.uuid().optional()}),me=e.strictObject({value:h,source:e.enum(["unknownFeature","defaultValue","force","override","experiment","prerequisite","cyclicPrerequisite"]),on:e.boolean(),off:e.boolean(),ruleId:e.string(),experimentResult:G.optional()}),st=e.strictObject({generation:v.shape.generation,evaluatedAt:v.shape.evaluatedAt,expiresAt:v.shape.expiresAt,features:e.record(e.string(),me),merchandiseContext:e.strictObject({merchandiseId:e.uuid(),merchandise:D}).optional()}),de={eventUuid:e.uuid(),timestamp:e.iso.datetime({offset:!0}),merchandise:te.optional(),deviceId:e.string().min(1).max(255).optional(),sessionId:e.string().min(1).max(255).optional()},le={...de,generation:v.shape.generation},Ce=e.discriminatedUnion("kind",[e.strictObject({...de,kind:e.literal("custom"),name:e.string().min(1).max(255),properties:e.record(e.string(),h).default({})}),e.strictObject({...le,kind:e.literal("experiment_exposure"),experimentId:e.string().min(1).max(255),variationId:e.string().min(1).max(255)}),e.strictObject({...le,kind:e.literal("feature_usage"),feature:e.string().min(1).max(255),value:h,source:me.shape.source,ruleId:e.string().max(255),variationId:e.string().min(1).max(255).optional()})]),ct=e.strictObject({customerId:e.uuid().optional(),events:e.array(Ce).min(1).max(100)}),Ae=e.strictObject({eventUuid:e.uuid(),reason:e.enum(["invalid_event","invalid_merchandise","not_delivered","reserved_name"])}),ut=e.strictObject({inserted:e.number().int().nonnegative(),duplicates:e.number().int().nonnegative(),rejected:e.number().int().nonnegative(),skipped:e.number().int().nonnegative(),rejections:e.array(Ae).max(100),analyticsConfig:V});function fe(t,r){let a=new Set,o=new Set,c=new Set,p=[],g=new Map,f=new Map,d=new Map;function m(s){for(let n of A(s))i(n)}function i(s){if(c.has(s)||!Object.hasOwn(r.savedGroups,s))return;let n=r.savedGroups[s];n&&(c.add(s),d.set(s,n),p.push(()=>{!Array.isArray(n)&&n.type==="condition"&&m(n.condition)}))}function u(s){for(let n of["hashAttribute","fallbackAttribute"])if(s[n]!==void 0&&ae(s[n]))throw new Error(`Funnel GB ${n} uses a reserved flow namespace`);m(s.condition);for(let n of s.parentConditions??[])l(n.id),m(n.condition)}function l(s,n=!1){let b=Object.hasOwn(r.features,s)?r.features[s]:void 0;if(!b){if(n)throw new Error("Required GB Feature is unavailable");return}a.has(s)||(a.add(s),g.set(s,b),p.push(()=>{for(let x of b.rules??[]){u(x);for(let ve of x.tracks??[])u(ve.experiment)}}))}function y(s){let n=Object.hasOwn(r.experiments,s)?r.experiments[s]:void 0;if(!n)throw new Error("Required GB Experiment is unavailable");o.has(s)||(o.add(s),f.set(s,n),p.push(()=>u(n)))}for(let s of t.graph.nodes){s.type==="feature"&&l(s.featureKey,!0),s.type==="split"&&y(s.experimentId),s.type==="condition"&&s.cases.forEach(b=>m(b.condition)),s.type==="offering"&&s.configuration.source==="feature"&&l(s.configuration.featureKey,!0);let n=s.type==="output"?s.value:s.type==="end"?s.output:null;n?.type==="feature"&&l(n.featureKey,!0)}for(let s of p)s();return{...r,features:Object.fromEntries(g),experiments:Object.fromEntries(f),savedGroups:Object.fromEntries(d)}}var ge=e.object({defaultLocale:R,locales:e.record(R,e.object({name:e.string().max(80),description:e.string().max(500)}).strict())}).strict().superRefine((t,r)=>{let a=Object.keys(t.locales);(!a.length||a.length>20||!t.locales[t.defaultLocale])&&r.addIssue({code:"custom",message:"Invalid content languages"}),new TextEncoder().encode(JSON.stringify(t)).length>5e4&&r.addIssue({code:"custom",message:"Content exceeds 50 KB"})});var M=e.discriminatedUnion("type",[e.strictObject({type:e.literal("event"),event:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/)}),e.strictObject({type:e.literal("open_url"),url:e.url().refine(t=>new URL(t).protocol==="https:")})]),Fe=P,Ee=e.discriminatedUnion("type",[e.object({type:e.literal("checkout"),product:I}).strict(),e.object({type:e.literal("close")}).strict(),e.object({type:e.literal("action"),action:M}).strict()]),E=e.object({schemaVersion:e.literal(3),kind:e.literal("paywall"),name:e.string().trim().min(1).max(80),presentation:S,requirement:K.optional(),products:F,offeringVersionId:e.uuid().nullable(),offeringId:e.uuid(),screen:Fe,buttons:e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Ee)}).strict(),Pt=E.superRefine((t,r)=>{(t.screen.surface!=="paywall"||t.screen.actions.some(o=>!["event","navigate"].includes(o.type)||o.close))&&r.addIssue({code:"custom",message:"Paywall screen is incomplete"});for(let o of Re(t))r.addIssue({code:"custom",message:o});for(let o of _e(t))r.addIssue({code:"custom",message:o});for(let o of t.screen.actions){let c=o.properties.closeControl;c!==void 0&&(c!=="content"||t.buttons[o.id]?.type!=="close")&&r.addIssue({code:"custom",path:["screen","actions",o.id],message:'Only a close button can carry closeControl, and its value is "content"'})}for(let o of t.screen.actions){let c=o.properties.couponBinding;c!==void 0&&(typeof c!="string"||!X.safeParse(c).success||t.buttons[o.id]?.type!=="checkout"||Y(t.screen,c)?.type!=="text")&&r.addIssue({code:"custom",path:["screen","actions",o.id],message:"Choose a Coupon text binding for this checkout action"})}k(t.screen).some(o=>!o.complete)&&r.addIssue({code:"custom",message:"Paywall needs complete local content"}),(Object.keys(t.buttons).length!==t.screen.actions.filter(o=>o.type!=="navigate").length||t.screen.actions.some(o=>o.type!=="navigate"&&!Object.hasOwn(t.buttons,o.id)))&&r.addIssue({code:"custom",message:"Paywall buttons require matching node policies"}),Object.values(t.buttons).some(o=>o.type==="checkout")||r.addIssue({code:"custom",message:"A paywall requires a purchase or membership change button"})});function _e(t){let r=t.products.items.map(p=>p.productVersionId),a=Z(t.screen),o=new Set,c=[];(!r.length||!t.products.defaultProductVersionId||!r.includes(t.products.defaultProductVersionId))&&c.push("products"),t.offeringVersionId||c.push("offering"),t.products.grouping&&(!W(t.products.grouping,r)||t.products.grouping.tiers.some(p=>!t.products.grouping.assignments.some(g=>g.tierId===p.id)))&&c.push("grouping");for(let p of Object.values(t.buttons))if(p.type==="checkout"){let g=p.product;if(g.type==="fixed")o.add(g.productVersionId);else{g.allowedProductVersionIds.forEach(m=>o.add(m));let f=!1,d=a[g.pickerId];d&&(f=!0,(g.allowedProductVersionIds.some(m=>!d.ids.includes(m))||d.ids.some(m=>!g.allowedProductVersionIds.includes(m)))&&c.push("picker")),w(t.screen,m=>{if(m.id!==g.pickerId||m.type!=="plan_picker")return;f=!0,(JSON.stringify(m.planIds)!==JSON.stringify(r)||JSON.stringify(g.allowedProductVersionIds)!==JSON.stringify(r)||m.defaultPlan!==t.products.defaultProductVersionId)&&c.push("picker");let i=m.grouping?{tiers:m.grouping.tiers,assignments:m.grouping.assignments}:void 0;JSON.stringify(i)!==JSON.stringify(t.products.grouping)&&c.push("grouping")}),f||c.push("picker")}}return(!o.size||[...o].some(p=>!r.includes(p)))&&c.push("purchase"),w(t.screen,p=>{p.type==="stack"&&p.productSlot&&!p.bind?.plan&&c.push(`productBinding:${p.id}`),(p.type==="stack"||p.type==="button")&&p.bind?.plan&&!r.includes(p.bind.plan)&&c.push("binding"),p.type==="plan_picker"&&(!p.planIds?.length||p.planIds.some(g=>!r.includes(g)))&&c.push("binding")}),[...new Set(c)]}function Re(t){let r=[],a=t.screen.pages.at(-1),o=new Map;for(let f of t.screen.pages)o.set(f.id,[]),Q(f.root,d=>{let m=d.type==="button"?d.action:d.type==="stack"?d.purchaseAction:void 0;if(m){let i=t.screen.actions.find(l=>l.id===m);i?.type==="navigate"&&o.get(f.id).push(i.pageId);let u=t.buttons[m];f.id!==a.id&&u&&u.type!=="close"&&r.push(`purchaseScreen:${d.id}`)}f.id!==a.id&&(d.type==="plan_picker"||d.type==="stack"&&d.productSlot)&&r.push(`packageScreen:${d.id}`)});let c=new Set;function p(f){if(!c.has(f)){c.add(f);for(let d of o.get(f)??[])p(d)}}let g=t.screen.initialPageId??t.screen.pages[0]?.id;g?p(g):r.push("initialPage");for(let f of t.screen.pages)c.has(f.id)||r.push(`unreachableScreen:${f.id}`);return[...new Set(r)]}var ye=e.object({id:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),revision:e.number().int().nonnegative(),state:e.enum(["active","archived"]),publishedVersionId:e.uuid().nullable(),updatedAt:e.iso.datetime({offset:!0}),draft:E}).strict(),kt=e.object({rows:e.array(ye).max(200),nextCursor:e.uuid().nullable()}).strict(),Ct=ye.omit({draft:!0}).extend({name:e.string(),productCount:e.number().int().nonnegative()}).strict(),At=e.discriminatedUnion("action",[e.object({action:e.literal("save"),id:e.uuid().nullable(),revision:e.number().int().nonnegative(),document:E}).strict(),e.object({action:e.enum(["publish","archive"]),id:e.uuid(),revision:e.number().int().nonnegative()}).strict()]),Ft=e.object({paywalls:e.array(e.object({id:e.uuid(),paywallId:e.uuid(),version:e.number().int().positive(),name:e.string().min(1).max(80),presentation:S,buttons:E.shape.buttons}).strict()).max(500),limited:e.boolean()}).strict();var De=["customer_data","coupon_code"],be=e.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/),Ve=e.string().min(1).max(255).regex(/^[a-z0-9][a-z0-9-]*$/),_=(t,r)=>new Set(t.map(r)).size===t.length,ze=e.strictObject({currency:T,amountMinor:e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)}),Ge=e.strictObject({featureId:e.uuid(),name:e.string().trim().min(1).max(120),allowance:e.string().max(40).nullable(),access:e.boolean()}),Me=e.strictObject({stripe:e.strictObject({prices:e.array(ze).min(1).max(50)}).optional(),apple:e.strictObject({productIds:e.array(be).min(1).max(10)}).optional(),google:e.strictObject({products:e.array(e.strictObject({productId:be,basePlanId:Ve.nullable()})).min(1).max(10)}).optional()}).superRefine((t,r)=>{(t.stripe&&!_(t.stripe.prices,a=>a.currency)||t.apple&&!_(t.apple.productIds,a=>a)||t.google&&!_(t.google.products,a=>`${a.productId}:${a.basePlanId}`))&&r.addIssue({code:"custom",message:"Duplicate channel entry"})}),qe=e.strictObject({name:e.string().trim().min(1).max(80),interval:e.enum(["free","week","month","year","one_time"]),intervalCount:e.number().int().min(1).max(100),trial:e.strictObject({days:e.number().int().min(1).max(730),cardRequired:e.boolean()}).nullable(),benefits:e.array(Ge).max(50).refine(t=>_(t,r=>r.featureId),"Duplicate benefit"),channels:Me,prepaid:e.array(J).max(100).optional()}),Be=e.strictObject({digest:O,content:e.strictObject({discount:ne,duration:re,appliesTo:oe,displayCopy:ge.nullable(),firstPurchaseOnly:e.boolean(),qualificationRequired:e.boolean(),startsAt:e.iso.datetime().nullable(),endsAt:e.iso.datetime().nullable(),grantWindowHours:e.number().int().positive(),perCustomerLimit:e.number().int().positive()})}),Ne=e.discriminatedUnion("type",[e.strictObject({type:e.literal("checkout"),product:I}),e.strictObject({type:e.literal("close")}),e.strictObject({type:e.literal("action"),action:M})]),Lt=e.strictObject({kind:e.literal("paywall"),formatVersion:e.literal(1),name:e.string().trim().min(1).max(80),offeringVersionId:e.uuid(),presentation:S,screen:P,products:F,catalog:e.record(e.uuid(),qe),buttons:e.record(H,Ne),coupons:e.record(e.uuid(),Be)}).superRefine((t,r)=>{let a=n=>r.addIssue({code:"custom",message:n}),{screen:o}=t;ce(o,t.catalog).forEach(a),o.surface!=="paywall"&&a("Screen must be a Paywall"),ie(o,De).forEach(a),k(o).some(n=>!n.complete)&&a("Every published locale must be complete");let c=new Set,p=new Set,g=new Set;w(o,n=>{let b="bind"in n?n.bind:void 0;b?.promotionCode&&a("Promotion codes must not be published"),b?.plan&&c.add(b.plan),b?.coupon&&p.add(b.coupon),n.type==="plan_picker"&&(n.planIds?.forEach(x=>c.add(x)),n.defaultPlan&&c.add(n.defaultPlan)),n.type==="text"&&n.feature&&g.add(n.feature.id)});let f=t.products.items.map(n=>n.productVersionId),d=Object.keys(t.catalog);(f.length!==d.length||f.some(n=>!Object.hasOwn(t.catalog,n)))&&a("Catalog must contain exactly the displayed Products");let m=new Set(f);t.products.defaultProductVersionId!==null&&!m.has(t.products.defaultProductVersionId)&&a("Default Product must be displayed");for(let n of c)m.has(n)||a("Screen references a Product that is not displayed");for(let n of Object.values(t.catalog))!n.channels.stripe&&!n.channels.apple&&!n.channels.google&&a("A displayed Product needs at least one sales channel");let i=new Set(Object.values(t.catalog).flatMap(n=>n.benefits.map(b=>b.featureId)));for(let n of g)i.has(n)||a("Feature text must read a displayed benefit");let u=o.actions.filter(n=>n.type!=="navigate");o.actions.some(n=>n.type!=="event"&&n.type!=="navigate")&&a("Paywall actions are events or navigation"),(Object.keys(t.buttons).length!==u.length||u.some(n=>!Object.hasOwn(t.buttons,n.id)))&&a("Buttons must match the screen's actions");let y=!1;for(let n of Object.values(t.buttons)){if(n.type!=="checkout")continue;y=!0,(n.product.type==="fixed"?[n.product.productVersionId]:n.product.allowedProductVersionIds).some(x=>!m.has(x))&&a("Checkout may only sell displayed Products")}y||a("A Paywall needs a checkout button");let s=Object.keys(t.coupons);(s.length!==p.size||s.some(n=>!p.has(n)))&&a("Coupons must be exactly the bound Coupons")}),he=e.strictObject({state:e.enum(["published","archived"]),controlRevision:e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),currentVersionId:e.uuid(),versions:e.record(e.uuid(),e.strictObject({version:e.number().int().positive(),artifact:e.string().min(1),sourceDigest:e.string().regex(/^[a-f0-9]{64}$/)}))}).refine(t=>Object.keys(t.versions).length>0,"Reviewed Paywall Versions are required");var $e={manifestCdnSeconds:15,maxControlAgeMs:6e4,initializationMs:5e3,maxArtifactBytes:1048576,maxManifestBytes:524288,maxCacheBytes:32*1048576,retentionMs:7*864e5},q=e.string().regex(/^[a-f0-9]{64}$/),B=e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),Le=j.extend({environmentId:e.uuid()}),xe=e.strictObject({features:e.array(e.string()).max(500),experiments:e.record(e.uuid(),e.array(e.string()).max(20)),savedGroups:e.array(e.string()).max(1e3)}),Ue=e.strictObject({kind:e.enum(["funnel","paywall","gb_features","gb_page_experiments"]),formatVersion:e.number().int().positive(),url:e.string().min(1).max(2048),sha256:q,byteLength:e.number().int().positive().max($e.maxArtifactBytes),generation:q.optional()}),Te=e.strictObject({state:e.enum(["active","paused","archived"]),controlRevision:B,evaluationMode:e.enum(["local","remote"]),evaluationRevision:B,currentVersionId:e.uuid(),versions:e.record(e.uuid(),e.strictObject({artifact:e.string(),dependencies:xe,definitionDigest:O.optional(),couponDigests:e.record(e.uuid(),O).optional()}))}),en=e.strictObject({kind:e.literal("sdk_configuration"),schemaVersion:e.literal(1),scope:Le,revision:B,generation:q,policy:e.strictObject({refreshIntervalSeconds:e.number().positive().max(15),maxControlAgeSeconds:e.number().positive().max(60)}),gb:e.strictObject({features:e.string().nullable(),pageExperiments:e.string().nullable()}),artifacts:e.record(e.string(),Ue),funnels:e.record(e.uuid(),Te),paywalls:e.record(e.uuid(),he).optional()}).superRefine((t,r)=>{let a=(o,c)=>{o!==null&&t.artifacts[o]?.kind!==c&&r.addIssue({code:"custom",message:"Missing or wrong-kind configuration artifact"})};a(t.gb.features,"gb_features"),a(t.gb.pageExperiments,"gb_page_experiments");for(let o of Object.values(t.paywalls??{}))for(let c of Object.values(o.versions))a(c.artifact,"paywall");for(let o of Object.values(t.funnels)){o.evaluationMode==="remote"&&Object.keys(o.versions).length&&r.addIssue({code:"custom",message:"Remote Funnel graphs cannot be public"}),o.evaluationMode==="local"&&!o.versions[o.currentVersionId]&&r.addIssue({code:"custom",message:"Current Funnel Version is not retained"});for(let c of Object.values(o.versions))a(c.artifact,"funnel")}});function N(t){if(Array.isArray(t))return`[${t.map(N).join(",")}]`;if(t!==null&&typeof t=="object")return`{${Object.entries(t).sort(([a],[o])=>a<o?-1:a>o?1:0).map(([a,o])=>`${JSON.stringify(a)}:${N(o)}`).join(",")}}`;let r=JSON.stringify(t);if(r===void 0)throw new Error("Configuration must contain JSON values");return r}function Je(t){return L(U(typeof t=="string"?new TextEncoder().encode(t):t))}function tn(t){return Je(N(t))}var $=class extends Error{constructor(a,o){super(a);this.dependency=o}dependency};function nn(t,r){let a=i=>i.type==="feature"?i.featureKey:i.type==="end"&&i.output?.type==="feature"?i.output.featureKey:i.type==="output"&&i.value.type==="feature"?i.value.featureKey:void 0,o=(i,u)=>t.graph.nodes.find(l=>i==="experiment"?l.type==="split"&&l.experimentId===u:i==="feature"&&a(l)===u)?.name,c=(i,u,l=o(u.type,u.resource))=>new $(i,{...u,...l?{step:l}:{}});for(let i of Object.values(t.references)){let u=i.type==="flag"?!Object.hasOwn(r.features,i.key)||r.remoteFeatures.includes(i.key)?{type:"feature",resource:i.key}:null:i.type==="experiment"?Object.hasOwn(r.experiments,i.id)?null:{type:"experiment",resource:i.id}:i.type==="saved_group"&&!Object.hasOwn(r.savedGroups,i.id)?{type:"saved_group",resource:i.id}:null;if(u)throw c("Funnel dependency is absent from GB public delivery",{reason:"unavailable",...u})}let p=fe(t,{...r,evaluatedAt:new Date(0).toISOString(),expiresAt:null}),g=new Set(r.remoteFeatures);for(let i of t.graph.nodes){let u=a(i);if(!u)continue;let l=p.features[u],y=i.type==="feature"?t.variables[i.writes.value]:t.outputSchema,s={type:"feature",resource:u};if(!l||!y)throw c("Required public Feature declaration is unavailable",{reason:"unavailable",...s},i.name);if([l.defaultValue,...(l.rules??[]).flatMap(b=>[...Object.hasOwn(b,"force")?[b.force]:[],...b.variations??[],...(b.tracks??[]).flatMap(x=>x.experiment.variations)])].some(b=>b===void 0||!ee(y,b)))throw c("GB Feature values violate the Funnel type contract",{reason:"value_type",...s},i.name)}let f=new Set,d=(i,u)=>{for(let l of A(i)){if(f.has(l))continue;let y=r.savedGroups[l];if(!y)throw c("Required public Saved Group is unavailable",{reason:"unavailable",type:"saved_group",resource:l},u);f.add(l),!Array.isArray(y)&&y.type==="condition"&&d(y.condition,u)}},m=(i,u)=>{if(g.has(i)||!r.features[i])throw c("Local Funnel requires public Local prerequisites",{reason:"unavailable",type:"feature",resource:i},u)};for(let i of t.graph.nodes)if(i.type==="condition")for(let u of i.cases)d(u.condition,i.name);for(let[i,u]of Object.entries(p.features)){let l=o("feature",i);for(let y of u.rules??[]){d(y.condition,l);for(let s of[...y.parentConditions??[],...(y.tracks??[]).flatMap(n=>n.experiment.parentConditions??[])])m(s.id,l),d(s.condition,l);for(let s of y.tracks??[])d(s.experiment.condition,l)}}for(let[i,u]of Object.entries(p.experiments)){let l=o("experiment",i);d(u.condition,l);for(let y of u.parentConditions??[])m(y.id,l),d(y.condition,l)}for(let i of t.graph.nodes)if(i.type==="split"){let u=p.experiments[i.experimentId],l={type:"experiment",resource:i.experimentId};if(!u)throw c("Local Funnel requires a public Experiment",{reason:"unavailable",...l},i.name);for(let y of u.variations)if(typeof y!="string"||!Object.hasOwn(i.routes,y))throw c("Experiment variation has no declared Funnel route",{reason:"variation_route",...l},i.name)}return xe.parse({features:Object.keys(p.features).sort(),experiments:Object.fromEntries(Object.entries(p.experiments).map(([i,u])=>[i,u.variations.map(String)])),savedGroups:[...f].sort()})}function rn(t){return se.parse(t)}export{E as a,We as b,pe as c,Pe as d,v as e,ke as f,it as g,at as h,st as i,ct as j,ut as k,fe as l,Lt as m,$e as n,Le as o,Ue as p,en as q,N as r,Je as s,tn as t,nn as u,rn as v};
1
+ import{J as se,d as O,f as ie}from"./chunk-MEBCS2JG.js";import{a as F}from"./chunk-ZAD5WJWS.js";import{b as te,f as ne,g as re,h as oe}from"./chunk-F54HTDAC.js";import{e as ee,k as ae}from"./chunk-JTCS63ER.js";import{s as ce}from"./chunk-OKHCU6ET.js";import{C as Y,e as J,j as Z,l as W,p as R,s as X,t as H,v as w,w as P,x as Q,z as k}from"./chunk-FGAIHKFS.js";import{a as T,f as K}from"./chunk-MMAMK7OQ.js";import{a as I,b as S,d as h,e as D,f as C,g as A}from"./chunk-DJTZR2NR.js";import{h as j}from"./chunk-CQYEM7U6.js";import{b as e}from"./chunk-ZL247MPX.js";import{a as L,b as U}from"./chunk-CILM5XMH.js";var V=e.strictObject({eventsEnabled:e.boolean(),experimentViewsEnabled:e.boolean(),featureUsageEnabled:e.boolean()}),Ze=Object.freeze({eventsEnabled:!0,experimentViewsEnabled:!0,featureUsageEnabled:!0});function We(t,r){return r==="experiment_exposure"?t.experimentViewsEnabled:r==="feature_usage"?t.featureUsageEnabled:t.eventsEnabled}var z=e.tuple([e.number().min(0).max(1),e.number().min(0).max(1)]).refine(([t,r])=>t<=r),Se=e.strictObject({attribute:e.string().optional(),seed:e.string(),hashVersion:e.literal(2),ranges:e.array(z).max(100)}),we=e.strictObject({id:e.string().min(1).max(255),condition:C,gate:e.boolean().optional()}),Oe=e.strictObject({key:e.string().optional(),name:e.string().optional(),passthrough:e.boolean().optional()}),ue={condition:C.optional(),parentConditions:e.array(we).max(100).optional(),weights:e.array(e.number().min(0).max(1)).max(20).optional(),coverage:e.number().min(0).max(1).optional(),hashAttribute:e.string().optional(),fallbackAttribute:e.string().optional(),hashVersion:e.literal(2).optional(),disableStickyBucketing:e.boolean().optional(),bucketVersion:e.number().int().nonnegative().optional(),minBucketVersion:e.number().int().nonnegative().optional(),filters:e.array(Se).max(100).optional(),ranges:e.array(z).max(20).optional(),meta:e.array(Oe).max(20).optional(),seed:e.string().optional(),name:e.string().optional(),phase:e.string().optional()},pe=e.strictObject({...ue,key:e.string().min(1).max(255),variations:e.tuple([h,h]).rest(h).refine(t=>t.length<=20),urlPatterns:e.array(e.strictObject({include:e.boolean(),type:e.enum(["regex","simple"]),pattern:e.string()})).max(100).optional(),force:e.number().int().nonnegative().optional(),active:e.boolean().optional(),persistQueryString:e.boolean().optional()}),G=e.strictObject({value:h,variationId:e.number().int(),key:e.string(),name:e.string().optional(),bucket:e.number().optional(),passthrough:e.boolean().optional(),inExperiment:e.boolean(),hashUsed:e.boolean().optional(),hashAttribute:e.string(),hashValue:e.string(),featureId:e.string().nullable(),stickyBucketUsed:e.boolean().optional()}),je=e.strictObject({...ue,id:e.string().max(255).optional(),force:h.optional(),variations:e.array(h).min(2).max(20).optional(),key:e.string().optional(),range:z.optional(),tracks:e.array(e.strictObject({experiment:pe,result:G})).max(100).optional()}),Ie=e.strictObject({defaultValue:h.optional(),rules:e.array(je).max(500).optional()}),Pe=e.record(e.string(),e.union([e.strictObject({type:e.literal("hashed"),attributeKey:e.string(),values:e.array(e.string().regex(/^[a-f0-9]{64}$/))}),e.strictObject({type:e.literal("list"),attributeKey:e.string(),values:e.array(e.union([e.string(),e.number()]))}),e.strictObject({type:e.literal("condition"),condition:C})])),v=e.strictObject({scope:j,generation:e.string().regex(/^[a-f0-9]{64}$/),evaluatedAt:e.iso.datetime({offset:!0}),expiresAt:e.iso.datetime({offset:!0}).nullable(),features:e.record(e.string(),Ie),savedGroups:Pe,experiments:e.record(e.uuid(),pe)});var ke=v.extend({analyticsConfig:V,remoteFeatures:e.array(e.string().min(1).max(255)).max(500)}),it=ke.omit({evaluatedAt:!0,expiresAt:!0}).superRefine((t,r)=>{for(let a of t.remoteFeatures)Object.hasOwn(t.features,a)&&r.addIssue({code:"custom",path:["features",a],message:"Remote Feature definitions cannot be public"});for(let[a,o]of Object.entries(t.savedGroups))o.type==="list"&&r.addIssue({code:"custom",path:["savedGroups",a],message:"Raw Saved Group lists cannot be public"})}),at=e.strictObject({attributes:D,features:e.array(e.string().min(1).max(255)).max(500).optional(),customerId:e.uuid().optional()}),me=e.strictObject({value:h,source:e.enum(["unknownFeature","defaultValue","force","override","experiment","prerequisite","cyclicPrerequisite"]),on:e.boolean(),off:e.boolean(),ruleId:e.string(),experimentResult:G.optional()}),st=e.strictObject({generation:v.shape.generation,evaluatedAt:v.shape.evaluatedAt,expiresAt:v.shape.expiresAt,features:e.record(e.string(),me),merchandiseContext:e.strictObject({merchandiseId:e.uuid(),merchandise:D}).optional()}),de={eventUuid:e.uuid(),timestamp:e.iso.datetime({offset:!0}),merchandise:te.optional(),deviceId:e.string().min(1).max(255).optional(),sessionId:e.string().min(1).max(255).optional()},le={...de,generation:v.shape.generation},Ce=e.discriminatedUnion("kind",[e.strictObject({...de,kind:e.literal("custom"),name:e.string().min(1).max(255),properties:e.record(e.string(),h).default({})}),e.strictObject({...le,kind:e.literal("experiment_exposure"),experimentId:e.string().min(1).max(255),variationId:e.string().min(1).max(255)}),e.strictObject({...le,kind:e.literal("feature_usage"),feature:e.string().min(1).max(255),value:h,source:me.shape.source,ruleId:e.string().max(255),variationId:e.string().min(1).max(255).optional()})]),ct=e.strictObject({customerId:e.uuid().optional(),events:e.array(Ce).min(1).max(100)}),Ae=e.strictObject({eventUuid:e.uuid(),reason:e.enum(["invalid_event","invalid_merchandise","not_delivered","reserved_name"])}),ut=e.strictObject({inserted:e.number().int().nonnegative(),duplicates:e.number().int().nonnegative(),rejected:e.number().int().nonnegative(),skipped:e.number().int().nonnegative(),rejections:e.array(Ae).max(100),analyticsConfig:V});function fe(t,r){let a=new Set,o=new Set,c=new Set,p=[],g=new Map,f=new Map,d=new Map;function m(s){for(let n of A(s))i(n)}function i(s){if(c.has(s)||!Object.hasOwn(r.savedGroups,s))return;let n=r.savedGroups[s];n&&(c.add(s),d.set(s,n),p.push(()=>{!Array.isArray(n)&&n.type==="condition"&&m(n.condition)}))}function u(s){for(let n of["hashAttribute","fallbackAttribute"])if(s[n]!==void 0&&ae(s[n]))throw new Error(`Funnel GB ${n} uses a reserved flow namespace`);m(s.condition);for(let n of s.parentConditions??[])l(n.id),m(n.condition)}function l(s,n=!1){let b=Object.hasOwn(r.features,s)?r.features[s]:void 0;if(!b){if(n)throw new Error("Required GB Feature is unavailable");return}a.has(s)||(a.add(s),g.set(s,b),p.push(()=>{for(let x of b.rules??[]){u(x);for(let ve of x.tracks??[])u(ve.experiment)}}))}function y(s){let n=Object.hasOwn(r.experiments,s)?r.experiments[s]:void 0;if(!n)throw new Error("Required GB Experiment is unavailable");o.has(s)||(o.add(s),f.set(s,n),p.push(()=>u(n)))}for(let s of t.graph.nodes){s.type==="feature"&&l(s.featureKey,!0),s.type==="split"&&y(s.experimentId),s.type==="condition"&&s.cases.forEach(b=>m(b.condition)),s.type==="offering"&&s.configuration.source==="feature"&&l(s.configuration.featureKey,!0);let n=s.type==="output"?s.value:s.type==="end"?s.output:null;n?.type==="feature"&&l(n.featureKey,!0)}for(let s of p)s();return{...r,features:Object.fromEntries(g),experiments:Object.fromEntries(f),savedGroups:Object.fromEntries(d)}}var ge=e.object({defaultLocale:R,locales:e.record(R,e.object({name:e.string().max(80),description:e.string().max(500)}).strict())}).strict().superRefine((t,r)=>{let a=Object.keys(t.locales);(!a.length||a.length>20||!t.locales[t.defaultLocale])&&r.addIssue({code:"custom",message:"Invalid content languages"}),new TextEncoder().encode(JSON.stringify(t)).length>5e4&&r.addIssue({code:"custom",message:"Content exceeds 50 KB"})});var M=e.discriminatedUnion("type",[e.strictObject({type:e.literal("event"),event:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/)}),e.strictObject({type:e.literal("open_url"),url:e.url().refine(t=>new URL(t).protocol==="https:")})]),Fe=P,Ee=e.discriminatedUnion("type",[e.object({type:e.literal("checkout"),product:I}).strict(),e.object({type:e.literal("close")}).strict(),e.object({type:e.literal("action"),action:M}).strict()]),E=e.object({schemaVersion:e.literal(3),kind:e.literal("paywall"),name:e.string().trim().min(1).max(80),presentation:S,requirement:K.optional(),products:F,offeringVersionId:e.uuid().nullable(),offeringId:e.uuid(),screen:Fe,buttons:e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Ee)}).strict(),Pt=E.superRefine((t,r)=>{(t.screen.surface!=="paywall"||t.screen.actions.some(o=>!["event","navigate"].includes(o.type)||o.close))&&r.addIssue({code:"custom",message:"Paywall screen is incomplete"});for(let o of Re(t))r.addIssue({code:"custom",message:o});for(let o of _e(t))r.addIssue({code:"custom",message:o});for(let o of t.screen.actions){let c=o.properties.closeControl;c!==void 0&&(c!=="content"||t.buttons[o.id]?.type!=="close")&&r.addIssue({code:"custom",path:["screen","actions",o.id],message:'Only a close button can carry closeControl, and its value is "content"'})}for(let o of t.screen.actions){let c=o.properties.couponBinding;c!==void 0&&(typeof c!="string"||!X.safeParse(c).success||t.buttons[o.id]?.type!=="checkout"||Y(t.screen,c)?.type!=="text")&&r.addIssue({code:"custom",path:["screen","actions",o.id],message:"Choose a Coupon text binding for this checkout action"})}k(t.screen).some(o=>!o.complete)&&r.addIssue({code:"custom",message:"Paywall needs complete local content"}),(Object.keys(t.buttons).length!==t.screen.actions.filter(o=>o.type!=="navigate").length||t.screen.actions.some(o=>o.type!=="navigate"&&!Object.hasOwn(t.buttons,o.id)))&&r.addIssue({code:"custom",message:"Paywall buttons require matching node policies"}),Object.values(t.buttons).some(o=>o.type==="checkout")||r.addIssue({code:"custom",message:"A paywall requires a purchase or membership change button"})});function _e(t){let r=t.products.items.map(p=>p.productVersionId),a=Z(t.screen),o=new Set,c=[];(!r.length||!t.products.defaultProductVersionId||!r.includes(t.products.defaultProductVersionId))&&c.push("products"),t.offeringVersionId||c.push("offering"),t.products.grouping&&(!W(t.products.grouping,r)||t.products.grouping.tiers.some(p=>!t.products.grouping.assignments.some(g=>g.tierId===p.id)))&&c.push("grouping");for(let p of Object.values(t.buttons))if(p.type==="checkout"){let g=p.product;if(g.type==="fixed")o.add(g.productVersionId);else{g.allowedProductVersionIds.forEach(m=>o.add(m));let f=!1,d=a[g.pickerId];d&&(f=!0,(g.allowedProductVersionIds.some(m=>!d.ids.includes(m))||d.ids.some(m=>!g.allowedProductVersionIds.includes(m)))&&c.push("picker")),w(t.screen,m=>{if(m.id!==g.pickerId||m.type!=="plan_picker")return;f=!0,(JSON.stringify(m.planIds)!==JSON.stringify(r)||JSON.stringify(g.allowedProductVersionIds)!==JSON.stringify(r)||m.defaultPlan!==t.products.defaultProductVersionId)&&c.push("picker");let i=m.grouping?{tiers:m.grouping.tiers,assignments:m.grouping.assignments}:void 0;JSON.stringify(i)!==JSON.stringify(t.products.grouping)&&c.push("grouping")}),f||c.push("picker")}}return(!o.size||[...o].some(p=>!r.includes(p)))&&c.push("purchase"),w(t.screen,p=>{p.type==="stack"&&p.productSlot&&!p.bind?.plan&&c.push(`productBinding:${p.id}`),(p.type==="stack"||p.type==="button")&&p.bind?.plan&&!r.includes(p.bind.plan)&&c.push("binding"),p.type==="plan_picker"&&(!p.planIds?.length||p.planIds.some(g=>!r.includes(g)))&&c.push("binding")}),[...new Set(c)]}function Re(t){let r=[],a=t.screen.pages.at(-1),o=new Map;for(let f of t.screen.pages)o.set(f.id,[]),Q(f.root,d=>{let m=d.type==="button"?d.action:d.type==="stack"?d.purchaseAction:void 0;if(m){let i=t.screen.actions.find(l=>l.id===m);i?.type==="navigate"&&o.get(f.id).push(i.pageId);let u=t.buttons[m];f.id!==a.id&&u&&u.type!=="close"&&r.push(`purchaseScreen:${d.id}`)}f.id!==a.id&&(d.type==="plan_picker"||d.type==="stack"&&d.productSlot)&&r.push(`packageScreen:${d.id}`)});let c=new Set;function p(f){if(!c.has(f)){c.add(f);for(let d of o.get(f)??[])p(d)}}let g=t.screen.initialPageId??t.screen.pages[0]?.id;g?p(g):r.push("initialPage");for(let f of t.screen.pages)c.has(f.id)||r.push(`unreachableScreen:${f.id}`);return[...new Set(r)]}var ye=e.object({id:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),revision:e.number().int().nonnegative(),state:e.enum(["active","archived"]),publishedVersionId:e.uuid().nullable(),updatedAt:e.iso.datetime({offset:!0}),draft:E}).strict(),kt=e.object({rows:e.array(ye).max(200),nextCursor:e.uuid().nullable()}).strict(),Ct=ye.omit({draft:!0}).extend({name:e.string(),productCount:e.number().int().nonnegative()}).strict(),At=e.discriminatedUnion("action",[e.object({action:e.literal("save"),id:e.uuid().nullable(),revision:e.number().int().nonnegative(),document:E}).strict(),e.object({action:e.enum(["publish","archive"]),id:e.uuid(),revision:e.number().int().nonnegative()}).strict()]),Ft=e.object({paywalls:e.array(e.object({id:e.uuid(),paywallId:e.uuid(),version:e.number().int().positive(),name:e.string().min(1).max(80),presentation:S,buttons:E.shape.buttons}).strict()).max(500),limited:e.boolean()}).strict();var De=["customer_data","coupon_code"],be=e.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/),Ve=e.string().min(1).max(255).regex(/^[a-z0-9][a-z0-9-]*$/),_=(t,r)=>new Set(t.map(r)).size===t.length,ze=e.strictObject({currency:T,amountMinor:e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)}),Ge=e.strictObject({featureId:e.uuid(),name:e.string().trim().min(1).max(120),allowance:e.string().max(40).nullable(),access:e.boolean()}),Me=e.strictObject({stripe:e.strictObject({prices:e.array(ze).min(1).max(50)}).optional(),apple:e.strictObject({productIds:e.array(be).min(1).max(10)}).optional(),google:e.strictObject({products:e.array(e.strictObject({productId:be,basePlanId:Ve.nullable()})).min(1).max(10)}).optional()}).superRefine((t,r)=>{(t.stripe&&!_(t.stripe.prices,a=>a.currency)||t.apple&&!_(t.apple.productIds,a=>a)||t.google&&!_(t.google.products,a=>`${a.productId}:${a.basePlanId}`))&&r.addIssue({code:"custom",message:"Duplicate channel entry"})}),qe=e.strictObject({name:e.string().trim().min(1).max(80),interval:e.enum(["free","week","month","year","one_time"]),intervalCount:e.number().int().min(1).max(100),trial:e.strictObject({days:e.number().int().min(1).max(730),cardRequired:e.boolean()}).nullable(),benefits:e.array(Ge).max(50).refine(t=>_(t,r=>r.featureId),"Duplicate benefit"),channels:Me,prepaid:e.array(J).max(100).optional()}),Be=e.strictObject({digest:O,content:e.strictObject({discount:ne,duration:re,appliesTo:oe,displayCopy:ge.nullable(),firstPurchaseOnly:e.boolean(),qualificationRequired:e.boolean(),startsAt:e.iso.datetime().nullable(),endsAt:e.iso.datetime().nullable(),grantWindowHours:e.number().int().positive(),perCustomerLimit:e.number().int().positive()})}),Ne=e.discriminatedUnion("type",[e.strictObject({type:e.literal("checkout"),product:I}),e.strictObject({type:e.literal("close")}),e.strictObject({type:e.literal("action"),action:M})]),Lt=e.strictObject({kind:e.literal("paywall"),formatVersion:e.literal(1),name:e.string().trim().min(1).max(80),offeringVersionId:e.uuid(),presentation:S,screen:P,products:F,catalog:e.record(e.uuid(),qe),buttons:e.record(H,Ne),coupons:e.record(e.uuid(),Be)}).superRefine((t,r)=>{let a=n=>r.addIssue({code:"custom",message:n}),{screen:o}=t;ce(o,t.catalog).forEach(a),o.surface!=="paywall"&&a("Screen must be a Paywall"),ie(o,De).forEach(a),k(o).some(n=>!n.complete)&&a("Every published locale must be complete");let c=new Set,p=new Set,g=new Set;w(o,n=>{let b="bind"in n?n.bind:void 0;b?.promotionCode&&a("Promotion codes must not be published"),b?.plan&&c.add(b.plan),b?.coupon&&p.add(b.coupon),n.type==="plan_picker"&&(n.planIds?.forEach(x=>c.add(x)),n.defaultPlan&&c.add(n.defaultPlan)),n.type==="text"&&n.feature&&g.add(n.feature.id)});let f=t.products.items.map(n=>n.productVersionId),d=Object.keys(t.catalog);(f.length!==d.length||f.some(n=>!Object.hasOwn(t.catalog,n)))&&a("Catalog must contain exactly the displayed Products");let m=new Set(f);t.products.defaultProductVersionId!==null&&!m.has(t.products.defaultProductVersionId)&&a("Default Product must be displayed");for(let n of c)m.has(n)||a("Screen references a Product that is not displayed");for(let n of Object.values(t.catalog))!n.channels.stripe&&!n.channels.apple&&!n.channels.google&&a("A displayed Product needs at least one sales channel");let i=new Set(Object.values(t.catalog).flatMap(n=>n.benefits.map(b=>b.featureId)));for(let n of g)i.has(n)||a("Feature text must read a displayed benefit");let u=o.actions.filter(n=>n.type!=="navigate");o.actions.some(n=>n.type!=="event"&&n.type!=="navigate")&&a("Paywall actions are events or navigation"),(Object.keys(t.buttons).length!==u.length||u.some(n=>!Object.hasOwn(t.buttons,n.id)))&&a("Buttons must match the screen's actions");let y=!1;for(let n of Object.values(t.buttons)){if(n.type!=="checkout")continue;y=!0,(n.product.type==="fixed"?[n.product.productVersionId]:n.product.allowedProductVersionIds).some(x=>!m.has(x))&&a("Checkout may only sell displayed Products")}y||a("A Paywall needs a checkout button");let s=Object.keys(t.coupons);(s.length!==p.size||s.some(n=>!p.has(n)))&&a("Coupons must be exactly the bound Coupons")}),he=e.strictObject({state:e.enum(["published","archived"]),controlRevision:e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),currentVersionId:e.uuid(),versions:e.record(e.uuid(),e.strictObject({version:e.number().int().positive(),artifact:e.string().min(1),sourceDigest:e.string().regex(/^[a-f0-9]{64}$/)}))}).refine(t=>Object.keys(t.versions).length>0,"Reviewed Paywall Versions are required");var $e={manifestCdnSeconds:15,maxControlAgeMs:6e4,initializationMs:5e3,maxArtifactBytes:1048576,maxManifestBytes:524288,maxCacheBytes:32*1048576,retentionMs:7*864e5},q=e.string().regex(/^[a-f0-9]{64}$/),B=e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),Le=j.extend({environmentId:e.uuid()}),xe=e.strictObject({features:e.array(e.string()).max(500),experiments:e.record(e.uuid(),e.array(e.string()).max(20)),savedGroups:e.array(e.string()).max(1e3)}),Ue=e.strictObject({kind:e.enum(["funnel","paywall","gb_features","gb_page_experiments"]),formatVersion:e.number().int().positive(),url:e.string().min(1).max(2048),sha256:q,byteLength:e.number().int().positive().max($e.maxArtifactBytes),generation:q.optional()}),Te=e.strictObject({state:e.enum(["active","paused","archived"]),controlRevision:B,evaluationMode:e.enum(["local","remote"]),evaluationRevision:B,currentVersionId:e.uuid(),versions:e.record(e.uuid(),e.strictObject({artifact:e.string(),dependencies:xe,definitionDigest:O.optional(),couponDigests:e.record(e.uuid(),O).optional()}))}),en=e.strictObject({kind:e.literal("sdk_configuration"),schemaVersion:e.literal(1),scope:Le,revision:B,generation:q,policy:e.strictObject({refreshIntervalSeconds:e.number().positive().max(15),maxControlAgeSeconds:e.number().positive().max(60)}),gb:e.strictObject({features:e.string().nullable(),pageExperiments:e.string().nullable()}),artifacts:e.record(e.string(),Ue),funnels:e.record(e.uuid(),Te),paywalls:e.record(e.uuid(),he).optional()}).superRefine((t,r)=>{let a=(o,c)=>{o!==null&&t.artifacts[o]?.kind!==c&&r.addIssue({code:"custom",message:"Missing or wrong-kind configuration artifact"})};a(t.gb.features,"gb_features"),a(t.gb.pageExperiments,"gb_page_experiments");for(let o of Object.values(t.paywalls??{}))for(let c of Object.values(o.versions))a(c.artifact,"paywall");for(let o of Object.values(t.funnels)){o.evaluationMode==="remote"&&Object.keys(o.versions).length&&r.addIssue({code:"custom",message:"Remote Funnel graphs cannot be public"}),o.evaluationMode==="local"&&!o.versions[o.currentVersionId]&&r.addIssue({code:"custom",message:"Current Funnel Version is not retained"});for(let c of Object.values(o.versions))a(c.artifact,"funnel")}});function N(t){if(Array.isArray(t))return`[${t.map(N).join(",")}]`;if(t!==null&&typeof t=="object")return`{${Object.entries(t).sort(([a],[o])=>a<o?-1:a>o?1:0).map(([a,o])=>`${JSON.stringify(a)}:${N(o)}`).join(",")}}`;let r=JSON.stringify(t);if(r===void 0)throw new Error("Configuration must contain JSON values");return r}function Je(t){return L(U(typeof t=="string"?new TextEncoder().encode(t):t))}function tn(t){return Je(N(t))}var $=class extends Error{constructor(a,o){super(a);this.dependency=o}dependency};function nn(t,r){let a=i=>i.type==="feature"?i.featureKey:i.type==="end"&&i.output?.type==="feature"?i.output.featureKey:i.type==="output"&&i.value.type==="feature"?i.value.featureKey:void 0,o=(i,u)=>t.graph.nodes.find(l=>i==="experiment"?l.type==="split"&&l.experimentId===u:i==="feature"&&a(l)===u)?.name,c=(i,u,l=o(u.type,u.resource))=>new $(i,{...u,...l?{step:l}:{}});for(let i of Object.values(t.references)){let u=i.type==="flag"?!Object.hasOwn(r.features,i.key)||r.remoteFeatures.includes(i.key)?{type:"feature",resource:i.key}:null:i.type==="experiment"?Object.hasOwn(r.experiments,i.id)?null:{type:"experiment",resource:i.id}:i.type==="saved_group"&&!Object.hasOwn(r.savedGroups,i.id)?{type:"saved_group",resource:i.id}:null;if(u)throw c("Funnel dependency is absent from GB public delivery",{reason:"unavailable",...u})}let p=fe(t,{...r,evaluatedAt:new Date(0).toISOString(),expiresAt:null}),g=new Set(r.remoteFeatures);for(let i of t.graph.nodes){let u=a(i);if(!u)continue;let l=p.features[u],y=i.type==="feature"?t.variables[i.writes.value]:t.outputSchema,s={type:"feature",resource:u};if(!l||!y)throw c("Required public Feature declaration is unavailable",{reason:"unavailable",...s},i.name);if([l.defaultValue,...(l.rules??[]).flatMap(b=>[...Object.hasOwn(b,"force")?[b.force]:[],...b.variations??[],...(b.tracks??[]).flatMap(x=>x.experiment.variations)])].some(b=>b===void 0||!ee(y,b)))throw c("GB Feature values violate the Funnel type contract",{reason:"value_type",...s},i.name)}let f=new Set,d=(i,u)=>{for(let l of A(i)){if(f.has(l))continue;let y=r.savedGroups[l];if(!y)throw c("Required public Saved Group is unavailable",{reason:"unavailable",type:"saved_group",resource:l},u);f.add(l),!Array.isArray(y)&&y.type==="condition"&&d(y.condition,u)}},m=(i,u)=>{if(g.has(i)||!r.features[i])throw c("Local Funnel requires public Local prerequisites",{reason:"unavailable",type:"feature",resource:i},u)};for(let i of t.graph.nodes)if(i.type==="condition")for(let u of i.cases)d(u.condition,i.name);for(let[i,u]of Object.entries(p.features)){let l=o("feature",i);for(let y of u.rules??[]){d(y.condition,l);for(let s of[...y.parentConditions??[],...(y.tracks??[]).flatMap(n=>n.experiment.parentConditions??[])])m(s.id,l),d(s.condition,l);for(let s of y.tracks??[])d(s.experiment.condition,l)}}for(let[i,u]of Object.entries(p.experiments)){let l=o("experiment",i);d(u.condition,l);for(let y of u.parentConditions??[])m(y.id,l),d(y.condition,l)}for(let i of t.graph.nodes)if(i.type==="split"){let u=p.experiments[i.experimentId],l={type:"experiment",resource:i.experimentId};if(!u)throw c("Local Funnel requires a public Experiment",{reason:"unavailable",...l},i.name);for(let y of u.variations)if(typeof y!="string"||!Object.hasOwn(i.routes,y))throw c("Experiment variation has no declared Funnel route",{reason:"variation_route",...l},i.name)}return xe.parse({features:Object.keys(p.features).sort(),experiments:Object.fromEntries(Object.entries(p.experiments).map(([i,u])=>[i,u.variations.map(String)])),savedGroups:[...f].sort()})}function rn(t){return se.parse(t)}export{E as a,We as b,pe as c,Pe as d,v as e,ke as f,it as g,at as h,st as i,ct as j,ut as k,fe as l,Lt as m,$e as n,Le as o,Ue as p,en as q,N as r,Je as s,tn as t,nn as u,rn as v};
@@ -1 +1 @@
1
- import{a as He,i as Ze,y as We}from"./chunk-3QRVHAWK.js";import{w as Pe}from"./chunk-HJLZY2VK.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-NBIHNC2C.js";import{a as q}from"./chunk-VILB5M4X.js";import{a as Fe}from"./chunk-FRWORXER.js";import{m as Je,n as J,o as B}from"./chunk-YBDTPMGD.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-W5MSVU2K.js";import{b as Me,d as v,e as U,f as qe,g as Ge,h as W}from"./chunk-B3FNR6MN.js";import{h as V}from"./chunk-BJSY53HD.js";import{b as e}from"./chunk-VITB5MIL.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:v}),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(v.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(/^-/,""),S=p.replace(".","").length,N=(p.includes(".")?p.indexOf("."):S)+Number(_),d=N<=0?2-N+S:N>=S?N:S+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 ve=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"),Se=e.record(ve,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:ve,inputs:e.record(ve,Dt).refine(t=>Object.keys(t).length<=20),outputs:Se}),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:v.optional(),sticky:e.array(e.strictObject({expected:W.nullable(),next:W})).max(100),exposures:e.array(v).max(100),features:e.array(v).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(),v)});var Oe=e.discriminatedUnion("type",[e.strictObject({type:e.literal("literal"),value:v}),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:v}),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:v});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:v});var vt=e.union([e.string(),e.number().finite(),e.boolean(),e.null()]),Jt=e.union([vt,e.array(vt).min(1).max(20)]),Qt=e.record(E,Jt).refine(t=>Object.keys(t).length<=10),St=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,St).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:Se,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,S,N)=>{n.push(p),o?.({message:p,reason:S,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 S of se(p))S===t.entry&&i("An entry cannot be a transition target","entryTarget",p),s.has(S)||i(`Missing target ${S}`,"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 S of se(s.get(p)))_(S);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(),v).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()})]),vi=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"),Si=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,S=0;for(let d of t.screens)if(d.type==="owned"){for(let r of d.document.pages)Z(r.root,()=>{p++});S+=d.document.actions.length}(p>D.components||S>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"),acceptHostedMonthly:e.strictObject({amountMinor:e.number().int().positive().max(1e8),automaticTax:e.boolean()}).optional(),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,vi as H,Si as I,pn as J,Zi as K};
1
+ import{a as He,i as Ze,y as We}from"./chunk-F54HTDAC.js";import{w as Pe}from"./chunk-ZMDKCBLI.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-JTCS63ER.js";import{a as q}from"./chunk-VILB5M4X.js";import{a as Fe}from"./chunk-HSNAFHCP.js";import{m as Je,n as J,o as B}from"./chunk-OKHCU6ET.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-FGAIHKFS.js";import{b as Me,d as v,e as U,f as qe,g as Ge,h as W}from"./chunk-DJTZR2NR.js";import{h as V}from"./chunk-CQYEM7U6.js";import{b as e}from"./chunk-ZL247MPX.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:v}),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(v.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(/^-/,""),S=p.replace(".","").length,N=(p.includes(".")?p.indexOf("."):S)+Number(_),d=N<=0?2-N+S:N>=S?N:S+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 ve=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"),Se=e.record(ve,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:ve,inputs:e.record(ve,Dt).refine(t=>Object.keys(t).length<=20),outputs:Se}),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:v.optional(),sticky:e.array(e.strictObject({expected:W.nullable(),next:W})).max(100),exposures:e.array(v).max(100),features:e.array(v).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(),v)});var Oe=e.discriminatedUnion("type",[e.strictObject({type:e.literal("literal"),value:v}),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:v}),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:v});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:v});var vt=e.union([e.string(),e.number().finite(),e.boolean(),e.null()]),Jt=e.union([vt,e.array(vt).min(1).max(20)]),Qt=e.record(E,Jt).refine(t=>Object.keys(t).length<=10),St=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,St).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:Se,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,S,N)=>{n.push(p),o?.({message:p,reason:S,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 S of se(p))S===t.entry&&i("An entry cannot be a transition target","entryTarget",p),s.has(S)||i(`Missing target ${S}`,"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 S of se(s.get(p)))_(S);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(),v).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()})]),vi=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"),Si=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,S=0;for(let d of t.screens)if(d.type==="owned"){for(let r of d.document.pages)Z(r.root,()=>{p++});S+=d.document.actions.length}(p>D.components||S>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"),acceptHostedMonthly:e.strictObject({amountMinor:e.number().int().positive().max(1e8),automaticTax:e.boolean()}).optional(),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,vi as H,Si as I,pn as J,Zi as K};
@@ -1 +1 @@
1
- import{h as c}from"./chunk-NBIHNC2C.js";import{b as p}from"./chunk-VITB5MIL.js";import{d as x,e as y,f as g}from"./chunk-VPT5MFDG.js";import{a as m,b as d}from"./chunk-CILM5XMH.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
+ import{h as c}from"./chunk-JTCS63ER.js";import{b as p}from"./chunk-ZL247MPX.js";import{d as x,e as y,f as g}from"./chunk-VPT5MFDG.js";import{a as m,b as d}from"./chunk-CILM5XMH.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{a as s,b as c,c as u}from"./chunk-Q3K63EFB.js";import{j as m,m as p}from"./chunk-BJSY53HD.js";import{b as e}from"./chunk-VITB5MIL.js";var y=["USD","EUR","CNY","GBP","JPY","CAD","AUD","NZD","CHF","HKD","SGD","KRW","INR","BRL","MXN","TWD","THB","IDR","MYR","PHP","VND","ZAR","AED","SAR","SEK","NOK","DKK","PLN","CZK","HUF","ILS","TRY","RON"],i=e.enum(y);function x(t){let n=i.parse(t.toUpperCase());return["JPY","KRW","VND"].includes(n)?0:2}function I(t,n,r="en",f={}){let a=i.parse(n.toUpperCase());return new Intl.NumberFormat(r,{style:"currency",currency:a,...f}).format(t/10**x(a))}var l=e.enum(["stripe","apple","google","merchant"]),w=e.enum(["membership","credit_pack","lifetime"]),v=e.enum(["active","grace","suspended","inactive","revoked"]),z=e.strictObject({currency:e.string().regex(/^[A-Z]{3}$/),micros:e.string().regex(/^(0|[1-9][0-9]{0,29})$/)});var d=e.object({provider:l,currency:i,intent:e.literal("subscription_change").optional()}).strict();var o=e.strictObject({internal_feature_id:e.uuid(),quantity:m.refine(t=>/[1-9]/.test(t)),properties:p,entityId:e.uuid().optional()}),B=e.strictObject({requirement:o,commerce:d.optional(),paywallId:e.uuid().optional()}),g=e.enum(["not_entitled","insufficient_balance","capacity_exceeded","limit_exceeded","awaiting_topup","authorization_required","payment_blocked","cash_budget_exceeded","unavailable","authentication_required"]),b=e.strictObject({productId:e.string().min(1),productVersionId:e.string().min(1),name:e.string().min(1).max(120),action:e.enum(["purchase","upgrade","addon","topup"]),membershipId:e.string().min(1).nullable(),featureQuantities:e.record(e.uuid(),e.number().int().min(0).max(1e4)).refine(t=>Object.keys(t).length<=100).optional(),currency:i,amountMinor:e.string().regex(/^(0|[1-9]\d{0,8})$/),interval:e.enum(["free","week","month","year","one_time"]),intervalCount:e.number().int().min(1).max(156)}),h=e.strictObject({subject:c,authority:e.enum(["longplay","merchant"]),observedAt:e.iso.datetime({offset:!0}),sourceRevision:e.string().min(1).max(128),requirementDigest:s});function S(t,n){return u({subject:c.parse(t),requirement:o.parse(n)})}var C=e.strictObject({internal_feature_id:e.string().min(1),name:e.string().min(1).max(120),kind:e.enum(["access","metered","credit"]),quantity:m,allowed:e.boolean(),observation:h.optional(),reason:g.nullable(),preview:e.strictObject({scenario:e.enum(["feature_flag","usage_limit"]),candidates:e.array(b).max(20)}).nullable()}).superRefine((t,n)=>{(t.allowed!==(t.reason===null)||t.allowed&&t.preview!==null||new Set(t.preview?.candidates.map(r=>r.productVersionId)).size!==(t.preview?.candidates.length??0)||t.preview?.candidates.some(r=>r.action==="upgrade"!=(r.membershipId!==null)))&&n.addIssue({code:"custom",message:"Invalid access recommendation"})}),T=e.strictObject({paywallId:e.uuid(),requirement:o}),U=e.strictObject({subject:c,requirement:o}),$=C.safeExtend({observation:h.extend({authority:e.literal("merchant")})});function F(t,n){let r=o.parse(t);return n.internal_feature_id===r.internal_feature_id&&n.quantity===r.quantity&&(!n.observation||n.observation.requirementDigest===S(n.observation.subject,r))}export{i as a,x as b,I as c,w as d,d as e,o as f,B as g,b as h,S as i,C as j,U as k,$ as l,F as m};
1
+ import{a as s,b as c,c as u}from"./chunk-U2JO7MX2.js";import{j as m,m as p}from"./chunk-CQYEM7U6.js";import{b as e}from"./chunk-ZL247MPX.js";var y=["USD","EUR","CNY","GBP","JPY","CAD","AUD","NZD","CHF","HKD","SGD","KRW","INR","BRL","MXN","TWD","THB","IDR","MYR","PHP","VND","ZAR","AED","SAR","SEK","NOK","DKK","PLN","CZK","HUF","ILS","TRY","RON"],i=e.enum(y);function x(t){let n=i.parse(t.toUpperCase());return["JPY","KRW","VND"].includes(n)?0:2}function I(t,n,r="en",f={}){let a=i.parse(n.toUpperCase());return new Intl.NumberFormat(r,{style:"currency",currency:a,...f}).format(t/10**x(a))}var l=e.enum(["stripe","apple","google","merchant"]),w=e.enum(["membership","credit_pack","lifetime"]),v=e.enum(["active","grace","suspended","inactive","revoked"]),z=e.strictObject({currency:e.string().regex(/^[A-Z]{3}$/),micros:e.string().regex(/^(0|[1-9][0-9]{0,29})$/)});var d=e.object({provider:l,currency:i,intent:e.literal("subscription_change").optional()}).strict();var o=e.strictObject({internal_feature_id:e.uuid(),quantity:m.refine(t=>/[1-9]/.test(t)),properties:p,entityId:e.uuid().optional()}),B=e.strictObject({requirement:o,commerce:d.optional(),paywallId:e.uuid().optional()}),g=e.enum(["not_entitled","insufficient_balance","capacity_exceeded","limit_exceeded","awaiting_topup","authorization_required","payment_blocked","cash_budget_exceeded","unavailable","authentication_required"]),b=e.strictObject({productId:e.string().min(1),productVersionId:e.string().min(1),name:e.string().min(1).max(120),action:e.enum(["purchase","upgrade","addon","topup"]),membershipId:e.string().min(1).nullable(),featureQuantities:e.record(e.uuid(),e.number().int().min(0).max(1e4)).refine(t=>Object.keys(t).length<=100).optional(),currency:i,amountMinor:e.string().regex(/^(0|[1-9]\d{0,8})$/),interval:e.enum(["free","week","month","year","one_time"]),intervalCount:e.number().int().min(1).max(156)}),h=e.strictObject({subject:c,authority:e.enum(["longplay","merchant"]),observedAt:e.iso.datetime({offset:!0}),sourceRevision:e.string().min(1).max(128),requirementDigest:s});function S(t,n){return u({subject:c.parse(t),requirement:o.parse(n)})}var C=e.strictObject({internal_feature_id:e.string().min(1),name:e.string().min(1).max(120),kind:e.enum(["access","metered","credit"]),quantity:m,allowed:e.boolean(),observation:h.optional(),reason:g.nullable(),preview:e.strictObject({scenario:e.enum(["feature_flag","usage_limit"]),candidates:e.array(b).max(20)}).nullable()}).superRefine((t,n)=>{(t.allowed!==(t.reason===null)||t.allowed&&t.preview!==null||new Set(t.preview?.candidates.map(r=>r.productVersionId)).size!==(t.preview?.candidates.length??0)||t.preview?.candidates.some(r=>r.action==="upgrade"!=(r.membershipId!==null)))&&n.addIssue({code:"custom",message:"Invalid access recommendation"})}),T=e.strictObject({paywallId:e.uuid(),requirement:o}),U=e.strictObject({subject:c,requirement:o}),$=C.safeExtend({observation:h.extend({authority:e.literal("merchant")})});function F(t,n){let r=o.parse(t);return n.internal_feature_id===r.internal_feature_id&&n.quantity===r.quantity&&(!n.observation||n.observation.requirementDigest===S(n.observation.subject,r))}export{i as a,x as b,I as c,w as d,d as e,o as f,B as g,b as h,S as i,C as j,U as k,$ as l,F as m};
@@ -1 +1 @@
1
- import{B as p,C as u,D as d,E as f}from"./chunk-3QRVHAWK.js";import{v as y}from"./chunk-W5MSVU2K.js";import{a as s}from"./chunk-BNVQIMXY.js";function Q(e,t,r=new Set){let i={...t};return y(e.document.screen,n=>{if(n.hidden)return!1;if(n.type!=="quantity_picker"||r.has(n.id))return;let a=e.capabilities.quantities?.[n.id],o=a?.available?a.value:i[n.id]??n.defaultQuantity;if(a?.available&&(typeof o!="number"||!Number.isSafeInteger(o)||o<Math.max(n.minimumQuantity,a.minimum)||o>Math.min(n.maximumQuantity,a.maximum)||(o-n.minimumQuantity)%n.step!==0))throw new s("INVALID_RESPONSE","The current subscription quantity is outside this control's bounds");typeof o=="number"&&(i[n.id]=o)}),i}function V(e){let t=Object.create(null);for(let r of e.document.screen.actions){let i=r.properties.couponBinding,n=e.document.buttons[r.id];if(typeof i!="string"||n?.type!=="checkout")continue;let a=Object.hasOwn(e.capabilities.nodes,i)?e.capabilities.nodes[i]:void 0,{product:o}=n,b=o.type==="fixed"?[o.productVersionId]:o.allowedProductVersionIds,I=a?[a.base,...Object.values(a.byPlan??{})]:[],w=Object.fromEntries(I.flatMap(l=>l.planVersionId&&l.couponId&&l.text&&b.includes(l.planVersionId)?[[l.planVersionId,l]]:[]));t[r.id]={products:w,...o.type==="picker"?{picker:o.pickerId}:{}}}return Object.keys(t).length?{...e.capabilities,checkoutCoupons:t}:e.capabilities}function E(e,t){let r=structuredClone(e);for(let[i,n]of Object.entries(r.plans)){let a=t.plans[i];!a||a.versionId!==n.versionId||(a.amountMinor!==void 0&&(n.amountMinor=a.amountMinor),a.interval!==void 0&&(n.interval=a.interval),a.intervalCount!==void 0&&(n.intervalCount=a.intervalCount),a.prepaid!==void 0&&(n.prepaid=structuredClone(a.prepaid)))}return r}var h=class extends s{constructor(r="Plans were updated. Choose again.",i="套餐已更新,请重新选择。"){super("CONFLICT",r);this.zhMessage=i}zhMessage;customerMessage(r){return r?this.zhMessage:this.message}};function N(e,t){let r=i=>"document"in i?i.offering.id:i.content.offeringVersionId;return e.id===t.id&&r(e)===r(t)&&e.content?.artifact.sha256===t.content?.artifact.sha256}function D(e,t,r){if(e.operationId!==t.operationId||t.currency!==void 0&&"currency"in e&&e.currency!==t.currency||t.membershipId!==void 0&&(t.membershipId===null?u(e):!u(e)||e.membershipId!==t.membershipId)||t.featureQuantities!==void 0&&(!u(e)||!c(e.featureQuantities,t.featureQuantities)))throw new s("INVALID_RESPONSE",r)}function c(e,t){return Object.keys(e??{}).length===Object.keys(t??{}).length&&Object.entries(t??{}).every(([r,i])=>e?.[r]===i)}function P(e,t,r){if(p(e)){if(!t.subscriptionChange||e.membershipId!==t.subscriptionChange.membershipId||e.timing!==t.subscriptionChange.timing||e.productVersionId!==t.productVersionId||t.currency!==void 0&&e.currency!==t.currency||!c(e.featureQuantities,t.featureQuantities))throw new s("INVALID_RESPONSE",r);if(e.execution.provider==="merchant"){let n=e.execution.change,a=e.merchantTerms?.request;if(e.execution.membershipId!==e.membershipId||e.execution.timing!==e.timing||n.type!=="plan"||n.productVersionId!==e.productVersionId||!c(n.featureQuantities,e.featureQuantities)||a&&(a.action!=="subscription_change"||a.timing!==e.timing||a.change.type!=="plan"||a.change.productVersionId!==e.productVersionId||!c(a.change.featureQuantities,e.featureQuantities)))throw new s("INVALID_RESPONSE",r)}return}if(t.subscriptionChange)throw new s("INVALID_RESPONSE",r);let i=Object.fromEntries((e.lines[0]?.prepaid??[]).map(n=>[n.internal_feature_id,n.quantity]));if(t.featureQuantities&&(Object.keys(i).length!==Object.keys(t.featureQuantities).length||Object.entries(t.featureQuantities).some(([n,a])=>i[n]!==a)))throw new s("INVALID_RESPONSE","The purchase quote changed its selected quantities");if(e.lines.length!==1||e.lines[0].productVersionId!==t.productVersionId||t.currency!==void 0&&e.currency!==t.currency||t.provider!==void 0&&e.provider!==t.provider&&!(t.provider==="stripe"&&e.provider==="merchant"&&e.execution?.provider==="merchant"))throw new s("INVALID_RESPONSE",r)}function m(e,t){if(e.operationId===t.operationId){if(p(e))P(t,{productVersionId:e.productVersionId,currency:e.currency,subscriptionChange:{membershipId:e.membershipId,timing:e.timing},featureQuantities:e.featureQuantities??{}},"The original membership change selection changed");else if(p(t))throw new s("INVALID_RESPONSE","The commercial operation kind changed")}}function C(e,t,r=!1){if(t&&u(t)&&t.quote&&!c(t.featureQuantities,t.quote.featureQuantities))throw new s("INVALID_RESPONSE","The original membership change quantities changed");if(t&&u(t)&&t.quote&&m(t.quote,t.quote),!e||e.operationId!==t?.operationId)return t;if(e.quote&&t.quote&&m(e.quote,t.quote),u(e)&&u(t)&&!c(e.featureQuantities,t.featureQuantities))throw new s("INVALID_RESPONSE","The original membership change quantities changed");let i=e.merchantExecution,n=t.merchantExecution;if(i&&(!n||Date.parse(n.updatedAt)<Date.parse(i.updatedAt)))return e;if(u(e)!==u(t))throw new s("INVALID_RESPONSE","The commercial operation kind changed");if(d(e)&&!d(t))return e;let a=t.status===e.status&&i?.recordingStatus!=="accepted"&&n?.recordingStatus==="accepted";return!f(e)&&(f(t)||r&&!d(t)&&!a)?e:t}function R(e){return e.screen.actions.some(t=>t.properties.closeControl==="content"&&e.buttons[t.id]?.type==="close")}export{Q as a,V as b,E as c,h as d,N as e,D as f,P as g,m as h,C as i,R as j};
1
+ import{B as p,C as u,D as d,E as f}from"./chunk-F54HTDAC.js";import{v as y}from"./chunk-FGAIHKFS.js";import{a as s}from"./chunk-AECGOS7O.js";function Q(e,t,r=new Set){let i={...t};return y(e.document.screen,n=>{if(n.hidden)return!1;if(n.type!=="quantity_picker"||r.has(n.id))return;let a=e.capabilities.quantities?.[n.id],o=a?.available?a.value:i[n.id]??n.defaultQuantity;if(a?.available&&(typeof o!="number"||!Number.isSafeInteger(o)||o<Math.max(n.minimumQuantity,a.minimum)||o>Math.min(n.maximumQuantity,a.maximum)||(o-n.minimumQuantity)%n.step!==0))throw new s("INVALID_RESPONSE","The current subscription quantity is outside this control's bounds");typeof o=="number"&&(i[n.id]=o)}),i}function V(e){let t=Object.create(null);for(let r of e.document.screen.actions){let i=r.properties.couponBinding,n=e.document.buttons[r.id];if(typeof i!="string"||n?.type!=="checkout")continue;let a=Object.hasOwn(e.capabilities.nodes,i)?e.capabilities.nodes[i]:void 0,{product:o}=n,b=o.type==="fixed"?[o.productVersionId]:o.allowedProductVersionIds,I=a?[a.base,...Object.values(a.byPlan??{})]:[],w=Object.fromEntries(I.flatMap(l=>l.planVersionId&&l.couponId&&l.text&&b.includes(l.planVersionId)?[[l.planVersionId,l]]:[]));t[r.id]={products:w,...o.type==="picker"?{picker:o.pickerId}:{}}}return Object.keys(t).length?{...e.capabilities,checkoutCoupons:t}:e.capabilities}function E(e,t){let r=structuredClone(e);for(let[i,n]of Object.entries(r.plans)){let a=t.plans[i];!a||a.versionId!==n.versionId||(a.amountMinor!==void 0&&(n.amountMinor=a.amountMinor),a.interval!==void 0&&(n.interval=a.interval),a.intervalCount!==void 0&&(n.intervalCount=a.intervalCount),a.prepaid!==void 0&&(n.prepaid=structuredClone(a.prepaid)))}return r}var h=class extends s{constructor(r="Plans were updated. Choose again.",i="套餐已更新,请重新选择。"){super("CONFLICT",r);this.zhMessage=i}zhMessage;customerMessage(r){return r?this.zhMessage:this.message}};function N(e,t){let r=i=>"document"in i?i.offering.id:i.content.offeringVersionId;return e.id===t.id&&r(e)===r(t)&&e.content?.artifact.sha256===t.content?.artifact.sha256}function D(e,t,r){if(e.operationId!==t.operationId||t.currency!==void 0&&"currency"in e&&e.currency!==t.currency||t.membershipId!==void 0&&(t.membershipId===null?u(e):!u(e)||e.membershipId!==t.membershipId)||t.featureQuantities!==void 0&&(!u(e)||!c(e.featureQuantities,t.featureQuantities)))throw new s("INVALID_RESPONSE",r)}function c(e,t){return Object.keys(e??{}).length===Object.keys(t??{}).length&&Object.entries(t??{}).every(([r,i])=>e?.[r]===i)}function P(e,t,r){if(p(e)){if(!t.subscriptionChange||e.membershipId!==t.subscriptionChange.membershipId||e.timing!==t.subscriptionChange.timing||e.productVersionId!==t.productVersionId||t.currency!==void 0&&e.currency!==t.currency||!c(e.featureQuantities,t.featureQuantities))throw new s("INVALID_RESPONSE",r);if(e.execution.provider==="merchant"){let n=e.execution.change,a=e.merchantTerms?.request;if(e.execution.membershipId!==e.membershipId||e.execution.timing!==e.timing||n.type!=="plan"||n.productVersionId!==e.productVersionId||!c(n.featureQuantities,e.featureQuantities)||a&&(a.action!=="subscription_change"||a.timing!==e.timing||a.change.type!=="plan"||a.change.productVersionId!==e.productVersionId||!c(a.change.featureQuantities,e.featureQuantities)))throw new s("INVALID_RESPONSE",r)}return}if(t.subscriptionChange)throw new s("INVALID_RESPONSE",r);let i=Object.fromEntries((e.lines[0]?.prepaid??[]).map(n=>[n.internal_feature_id,n.quantity]));if(t.featureQuantities&&(Object.keys(i).length!==Object.keys(t.featureQuantities).length||Object.entries(t.featureQuantities).some(([n,a])=>i[n]!==a)))throw new s("INVALID_RESPONSE","The purchase quote changed its selected quantities");if(e.lines.length!==1||e.lines[0].productVersionId!==t.productVersionId||t.currency!==void 0&&e.currency!==t.currency||t.provider!==void 0&&e.provider!==t.provider&&!(t.provider==="stripe"&&e.provider==="merchant"&&e.execution?.provider==="merchant"))throw new s("INVALID_RESPONSE",r)}function m(e,t){if(e.operationId===t.operationId){if(p(e))P(t,{productVersionId:e.productVersionId,currency:e.currency,subscriptionChange:{membershipId:e.membershipId,timing:e.timing},featureQuantities:e.featureQuantities??{}},"The original membership change selection changed");else if(p(t))throw new s("INVALID_RESPONSE","The commercial operation kind changed")}}function C(e,t,r=!1){if(t&&u(t)&&t.quote&&!c(t.featureQuantities,t.quote.featureQuantities))throw new s("INVALID_RESPONSE","The original membership change quantities changed");if(t&&u(t)&&t.quote&&m(t.quote,t.quote),!e||e.operationId!==t?.operationId)return t;if(e.quote&&t.quote&&m(e.quote,t.quote),u(e)&&u(t)&&!c(e.featureQuantities,t.featureQuantities))throw new s("INVALID_RESPONSE","The original membership change quantities changed");let i=e.merchantExecution,n=t.merchantExecution;if(i&&(!n||Date.parse(n.updatedAt)<Date.parse(i.updatedAt)))return e;if(u(e)!==u(t))throw new s("INVALID_RESPONSE","The commercial operation kind changed");if(d(e)&&!d(t))return e;let a=t.status===e.status&&i?.recordingStatus!=="accepted"&&n?.recordingStatus==="accepted";return!f(e)&&(f(t)||r&&!d(t)&&!a)?e:t}function R(e){return e.screen.actions.some(t=>t.properties.closeControl==="content"&&e.buttons[t.id]?.type==="close")}export{Q as a,V as b,E as c,h as d,N as e,D as f,P as g,m as h,C as i,R as j};
@@ -1 +1 @@
1
- import{C as K,b as U,d as D,v as _}from"./chunk-W5MSVU2K.js";import{a as z,c as F}from"./chunk-VUGDBVIZ.js";import{d as $}from"./chunk-B3FNR6MN.js";import{i as C,j as m,l as O,m as g}from"./chunk-BJSY53HD.js";import{b as e}from"./chunk-VITB5MIL.js";var I=m.refine(t=>/[1-9]/.test(t),"Quantity must be positive"),j=e.string().min(1).max(120),R=e.enum(["cap","overflow"]),p=(t,n)=>{let[i,u=""]=t.split(".");if(i===void 0||i==="")throw new Error("Invalid decimal value");return BigInt(i)*10n**BigInt(n)+BigInt(u.padEnd(n,"0"))},A=t=>{try{return t()}catch{return!1}},le=e.discriminatedUnion("operation",[e.object({operation:e.literal("quote"),overageBehavior:R.optional(),internal_feature_id:e.uuid(),entityId:e.uuid().optional(),quantity:I,properties:g}).strict(),e.object({operation:e.literal("consume"),overageBehavior:R.optional(),occurredAt:e.iso.datetime({offset:!0}).optional(),internal_feature_id:e.uuid(),entityId:e.uuid().optional(),quantity:m,properties:g,idempotencyKey:j}).strict(),e.object({operation:e.literal("reserve"),occurredAt:e.iso.datetime({offset:!0}).optional(),internal_feature_id:e.uuid(),entityId:e.uuid().optional(),quantity:I,properties:g,idempotencyKey:j,expiresInSeconds:e.number().int().min(1).max(86400)}).strict(),e.object({operation:e.literal("confirm"),operationId:e.uuid(),quantity:I,properties:g.optional(),idempotencyKey:j}).strict(),e.object({operation:e.literal("refund"),operationId:e.uuid(),quantity:I,idempotencyKey:j}).strict(),e.object({operation:e.literal("release"),operationId:e.uuid(),idempotencyKey:j}).strict()]),J=e.object({internal_credit_feature_id:e.uuid().nullable(),internal_metered_feature_id:e.uuid(),dimension:e.string().min(1).max(64),counterKey:e.string().min(1).max(240),cycleStart:e.iso.datetime({offset:!0}),unitCost:m,units:I,amount:C,tier:e.number().int().min(1).max(12).nullable()}).strict(),Q=e.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,12})?$/);function N(t,n){let i=t.reduce((u,a)=>u+p(a.units,12),0n)-p(n,12);return t.some(u=>u.funding==="balance")?i>=-100n&&i<=100n:i===0n}var v=e.discriminatedUnion("funding",[e.strictObject({funding:e.literal("balance"),sourceId:e.uuid(),rolloverId:e.uuid().nullable(),units:Q.refine(t=>/[1-9]/.test(t)),amount:C}),e.strictObject({funding:e.literal("unbilled"),units:Q.refine(t=>/[1-9]/.test(t))}),e.object({funding:e.literal("prepaid"),sourceId:e.uuid(),units:I,amount:C,pricing:e.array(J).min(1).max(12)}).strict().refine(t=>A(()=>t.pricing.reduce((n,i)=>n+p(i.units,6),0n)===p(t.units,6)&&t.pricing.reduce((n,i)=>n+p(i.amount,12),0n)===p(t.amount,12)&&t.pricing.every(n=>p(n.unitCost,6)*p(n.units,6)===p(n.amount,12))),"Frozen pricing must conserve allocated units and amounts"),e.object({funding:e.literal("postpaid"),invoiceLineId:e.uuid().nullable(),units:I,authorizationId:e.uuid()}).strict()]),B=e.enum(["unavailable","insufficient_balance","limit_exceeded","awaiting_topup","authorization_required","payment_blocked","cash_budget_exceeded"]),de=e.object({allowed:e.boolean(),internal_feature_id:e.uuid(),quantity:m,requestedQuantity:m.optional(),overageBehavior:R.optional(),reason:B.nullable(),allocations:e.array(v).max(500)}).strict().refine(t=>A(()=>t.allowed?t.reason===null&&N(t.allocations,t.quantity):t.reason!==null&&t.allocations.length===0),"A quote must conserve its accepted units").refine(t=>A(()=>t.overageBehavior===void 0?t.requestedQuantity===void 0&&/[1-9]/.test(t.quantity):t.requestedQuantity!==void 0&&p(t.requestedQuantity,6)>=p(t.quantity,6)&&(t.overageBehavior==="cap"||t.requestedQuantity===t.quantity)),"Explicit overage behavior must retain the requested quantity"),me=e.object({id:e.uuid(),internal_feature_id:e.uuid(),kind:e.enum(["consume","reserve","confirm","refund","release","expire"]),originalId:e.uuid().nullable(),quantity:m,requestedQuantity:m.optional(),overageBehavior:R.optional(),accepted:e.boolean(),reason:e.enum([...B.options,"expired"]).nullable(),createdAt:e.iso.datetime({offset:!0}),reservationStatus:e.enum(["pending","confirmed","released","expired"]).nullable(),expiresAt:e.iso.datetime({offset:!0}).nullable(),allocations:e.array(v).max(500)}).strict().refine(t=>A(()=>t.accepted?t.reason===null&&N(t.allocations,t.quantity):t.reason!==null&&t.allocations.length===0),"An operation must conserve its requested units").refine(t=>A(()=>t.overageBehavior===void 0?t.requestedQuantity===void 0:t.kind==="consume"&&t.requestedQuantity!==void 0&&p(t.requestedQuantity,6)>=p(t.quantity,6)&&(t.overageBehavior==="cap"||t.requestedQuantity===t.quantity)),"Overage metadata belongs to consumption and preserves requested units").refine(t=>/[1-9]/.test(t.quantity)||t.kind==="consume","Only consumption can record a zero cost event").refine(t=>t.allocations.every(n=>n.funding!=="postpaid"||n.invoiceLineId!==null),"Accepted operations must reference persisted invoice lines").refine(t=>t.originalId!==null===["confirm","refund","release","expire"].includes(t.kind)&&t.expiresAt!==null==(t.reservationStatus!==null)&&(t.kind!=="reserve"||!t.accepted||t.reservationStatus!==null),"Operation provenance and reservation state must be explicit");var X=e.string().max(40).regex(/^(0|[1-9]\d*)(\.\d{1,12})?$/),Y=e.string().max(41).regex(/^-?(0|[1-9]\d*)(\.\d{1,12})?$/),T=e.strictObject({internal_feature_id:e.uuid(),entityId:e.uuid().nullable()}),ye=T.extend({quantity:m,expectedRevision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),idempotencyKey:e.string().min(1).max(120),properties:g.refine(t=>Object.keys(t).length<=13&&!Object.keys(t).some(n=>n.startsWith("usage_")),"Usage accounting reserves three properties")}).strict(),V=T.extend({operationId:e.uuid().nullable(),usage:m,capacity:X.nullable(),remaining:Y.nullable(),withinLimit:e.boolean(),revision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),updatedAt:e.iso.datetime({offset:!0}).nullable()}).strict().superRefine((t,n)=>{let i=u=>{let a=u.startsWith("-"),[s,r=""]=(a?u.slice(1):u).split(".");if(s===void 0||s==="")throw new Error("Invalid decimal value");return(a?-1n:1n)*(BigInt(s)*10n**12n+BigInt(r.padEnd(12,"0")))};(t.capacity===null!=(t.remaining===null)||(t.capacity===null?!t.withinLimit:t.remaining===null||i(t.remaining)!==i(t.capacity)-i(t.usage)||t.withinLimit!==i(t.remaining)>=0n)||t.revision===0!=(t.operationId===null)||t.operationId===null!=(t.updatedAt===null))&&n.addIssue({code:"custom",message:"Absolute usage must conserve capacity and its immutable revision"})});var y=e.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,12})?$/),f=e.iso.datetime({offset:!0}),ee=e.enum(["access","metered","credit"]),q={internal_feature_id:e.uuid(),key:O,name:e.string().min(1).max(120),kind:ee},we=e.object({customerId:e.uuid(),snapshotAt:f,memberships:e.array(e.object({id:e.uuid(),productId:e.string().min(1).max(255),productVersionId:e.uuid(),billingProductVersionId:e.uuid(),version:e.number().int().positive(),key:e.string().min(1).max(64),name:e.string().min(1).max(120),groupId:e.string().max(255).nullable(),membershipType:e.enum(["main","addon"]),status:e.enum(["trial","active","past_due","ended","expired","trialing","paused","pending","scheduled","unknown"]),cancelAtPeriodEnd:e.boolean(),accessEnabled:e.boolean(),renewalChange:e.object({productVersionId:e.uuid(),name:e.string().min(1).max(120),version:e.number().int().positive(),effectiveAt:f,benefitsAppliedAt:f.nullable(),timing:e.enum(["immediate","renewal"]),changeKind:e.enum(["plan","seats","quantity"]),feature:e.strictObject({internal_feature_id:e.uuid(),name:e.string().min(1).max(80),fromQuantity:e.number().int().min(0).max(1e4),toQuantity:e.number().int().min(0).max(1e4)}).optional(),seat:e.object({key:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),fromQuantity:e.number().int().min(0).max(1e4),toQuantity:e.number().int().min(0).max(1e4)}).strict().nullable(),status:e.enum(["prepared","quoted","confirmed","pending","scheduled"])}).strict().refine(t=>t.changeKind==="seats"==(t.seat!==null)&&t.changeKind==="quantity"==(t.feature!==void 0),"Quantity changes require their fixed component identities and quantities").nullable(),period:e.object({phase:e.enum(["paid","trial"]),startsAt:f,endsAt:f.nullable()}).strict().nullable()}).strict()).max(100),membershipsLimited:e.boolean(),balances:e.array(e.object({...q,usageType:e.enum(["consumable","non_consumable"]).nullable(),accessible:e.boolean(),unlimited:e.boolean(),available:y,held:y,debt:y,nextExpiresAt:f.nullable(),usage:V.nullable()}).strict().refine(t=>t.kind==="metered"==(t.usageType!==null)&&(t.accessible||t.available==="0"&&t.held==="0")&&(t.usageType==="non_consumable"?t.usage!==null&&t.usage.internal_feature_id===t.internal_feature_id&&t.unlimited===(t.usage.capacity===null)&&t.available===(t.usage.remaining===null||t.usage.remaining.startsWith("-")?"0":t.usage.remaining)&&t.held==="0"&&t.debt==="0":t.usage===null),"Balances must expose their actual spendable or non-consumable state")).max(500),balancesLimited:e.boolean()}).strict(),Z=e.enum(["source","usage","transaction","invoice","debt","settlement"]),E=e.object({at:f,id:e.uuid(),type:Z}).strict(),ke=e.object({type:Z.nullable(),resourceKey:O.optional(),kind:e.enum(["purchase","refund"]).optional(),topup:e.boolean().optional(),from:e.iso.date().nullable(),to:e.iso.date().nullable(),after:E.nullable(),limit:e.number().int().min(1).max(50)}).strict().refine(t=>!t.from||!t.to||t.from<=t.to,"Date range is reversed"),w={id:e.uuid(),occurredAt:f},te=e.discriminatedUnion("type",[e.strictObject({...w,type:e.literal("invoice"),status:e.string().min(1).max(80),paid:y,refunded:y,currency:z,externalId:e.string().nullable()}),e.object({...w,...q,type:e.literal("source"),reason:e.enum(["membership","trial","topup","manual","rollover","upgrade_carry","seat"]),quantity:y,unlimited:e.boolean(),status:e.enum(["scheduled","active","expired","revoked","unavailable"]),startsAt:f,expiresAt:f.nullable(),orderId:e.uuid().nullable(),parentSourceId:e.uuid().nullable()}).strict(),e.object({...w,type:e.literal("usage"),internal_feature_id:e.uuid(),name:e.string().min(1).max(120),kind:e.enum(["consume","set_usage","reserve","confirm","refund","release","expire"]),originalId:e.uuid().nullable(),quantity:m,accepted:e.boolean(),reason:e.enum([...B.options,"expired"]).nullable(),properties:g,reservationStatus:e.enum(["pending","confirmed","released","expired"]).nullable(),expiresAt:f.nullable(),charges:e.array(e.discriminatedUnion("funding",[e.strictObject({funding:e.literal("balance"),sourceId:e.uuid(),rolloverId:e.uuid().nullable(),units:Q,amount:y}),e.strictObject({funding:e.literal("unbilled"),units:Q}),e.object({...q,funding:e.literal("prepaid"),amount:y}).strict(),e.object({funding:e.literal("postpaid"),invoiceId:e.uuid(),invoiceLineId:e.uuid(),authorizationId:e.uuid(),units:m,currency:z}).strict()])).max(500)}).strict().refine(t=>(t.kind==="set_usage"||t.kind==="consume"&&t.quantity==="0"?t.accepted&&t.reason===null&&t.charges.length===0&&t.reservationStatus===null:t.accepted?t.reason===null&&t.charges.length>0:t.reason!==null&&t.charges.length===0)&&t.originalId!==null===["confirm","refund","release","expire"].includes(t.kind)&&t.expiresAt!==null==(t.reservationStatus!==null),"Usage facts must retain their original outcome and receipt"),e.object({...w,type:e.literal("transaction"),purpose:e.enum(["product","invoice"]),productVersionId:e.uuid().nullable(),productName:e.string().min(1).max(120).nullable(),productVersion:e.number().int().positive().nullable(),invoiceId:e.uuid().nullable(),orderId:e.uuid(),originalId:e.uuid().nullable(),kind:e.enum(["purchase","refund"]),amountMinor:e.number().int().nonnegative().max(2e8).nullable(),currency:z.nullable()}).strict().refine(t=>t.currency===null==(t.amountMinor===null)&&(t.purpose==="product"?t.productVersionId!==null&&t.productName!==null&&t.productVersion!==null&&t.invoiceId===null:t.productVersionId===null&&t.productName===null&&t.productVersion===null&&t.invoiceId!==null)&&t.kind==="refund"==(t.originalId!==null)&&(t.kind!=="refund"||t.amountMinor===null||t.amountMinor>0),"Payment fact provenance is incomplete"),e.object({...w,...q,type:e.literal("debt"),sourceId:e.uuid(),transactionId:e.uuid(),amount:y}).strict(),e.object({...w,...q,type:e.literal("settlement"),sourceId:e.uuid(),debtId:e.uuid(),kind:e.enum(["payment","usage_refund","payment_return"]),amount:y}).strict()]),je=e.object({customerId:e.uuid(),rows:e.array(te).max(50),nextCursor:E.nullable()}).strict().refine(t=>new Set(t.rows.map(n=>n.type+n.id)).size===t.rows.length,"A page cannot repeat a fact").refine(t=>{let n=t.rows.at(-1);return!t.nextCursor||!!(n&&n.id===t.nextCursor.id&&n.type===t.nextCursor.type&&n.occurredAt===t.nextCursor.at)},"Cursor must name the final displayed fact");var Ce=e.discriminatedUnion("kind",[e.object({kind:e.literal("ledger"),cursor:E}).strict(),e.object({kind:e.literal("billing"),cursor:e.uuid()}).strict()]),ne=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),ie=e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),e.union([e.string().max(500),e.boolean(),e.array(e.string().max(500)).max(50)])).refine(t=>Object.keys(t).length<=40,"Too many answers"),re=/^(?:api_?key|authorization|password|(?:customer|run|visitor|access|purchase)_?token|client_?secret|signed_?transaction|raw_?proof)$/i;function L(t,n=0){return n>20?!0:!!t&&typeof t=="object"&&(Array.isArray(t)?t.some(i=>L(i,n+1)):Object.entries(t).some(([i,u])=>["__proto__","constructor","prototype"].includes(i)||re.test(i)||L(u,n+1)))}var ae=/gg_(?:sk|ct|fr|fv|gc)_[A-Za-z0-9_-]{20,}/,ze=e.record(ne,$).refine(t=>Object.keys(t).length<=20,"Too many parameters").refine(t=>!L(t)&&!ae.test(JSON.stringify(t)),"Credentials cannot be screen parameters");var W=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),oe=e.array(e.object({variable:W,componentId:W,required:e.boolean()}).strict()).max(40).refine(t=>new Set(t.map(n=>n.variable)).size===t.length&&new Set(t.map(n=>n.componentId)).size===t.length,"Input bindings must be unique"),Re=e.object({bindings:oe,answers:ie,values:e.record(e.string(),$).optional()}).strict();function H(t,n,i=1){if(t==="free")return"";if(t==="one_time")return n.startsWith("zh")?" · 一次付款":" · one-time";let u=n.split("-")[0]??"en",a={zh:["/月","/年"],en:["/month","/year"],ja:["/月","/年"],ko:["/월","/년"],es:["/mes","/año"],fr:["/mois","/an"],de:["/Monat","/Jahr"],pt:["/mês","/ano"],it:["/mese","/anno"],ar:["/شهر","/سنة"]},s={zh:"周",en:"week",ja:"週",ko:"주",es:"semana",fr:"semaine",de:"Woche",pt:"semana",it:"settimana",ar:"أسبوع"},r=t==="week"?`/${s[u]??s.en}`:(a[u]??a.en)[t==="month"?0:1];return i===1?r:`/${i} ${r.slice(1)}${u==="en"?"s":""}`}function De(t,n){let i=[],u={};_(t,a=>{if(a.hidden)return!1;if(a.type!=="quantity_picker")return;let s=a.bind?.plan?[a.bind.plan]:[];a.bind?.picker&&_(t,r=>{if(r.type==="plan_picker"&&r.id===a.bind?.picker&&s.push(...r.planIds??[]),r.type==="stack"&&r.interaction?.type==="select"&&r.interaction.pickerId===a.bind?.picker)for(let o of r.children)o.type==="stack"&&o.bind?.plan&&s.push(o.bind.plan)}),s.length||i.push(`Quantity control ${a.id} needs a Product binding`);for(let r of new Set(s)){let o=n[r]?.prepaid?.find(c=>c.internalFeatureId===a.internalFeatureId)?.terms,d=u[r]??=new Set;(!o||d.has(a.internalFeatureId)||a.minimumQuantity<o.minimumQuantity||a.maximumQuantity>o.maximumQuantity)&&i.push(`Quantity control ${a.id} must match its Product's prepaid Feature and bounds`),d.add(a.internalFeatureId)}});for(let[a,s]of Object.entries(n))for(let r of s.prepaid??[])u[a]?.has(r.internalFeatureId)||i.push(`Product ${a} needs a quantity control for ${r.internalFeatureId}`);return i}function Ke(t,n,i,u){let a=u.plans[n];if(!a?.available)throw new Error("Selected Product is unavailable");let s={};if(_(t,r=>{if(r.hidden)return!1;if(r.type!=="quantity_picker"||r.hidden||(r.bind?.plan??(r.bind?.picker?i[r.bind.picker]:void 0))!==n)return;if(u.quantities?.[r.id]?.available===!1)throw new Error("This prepaid Feature is unavailable");let d=a.prepaid?.find(l=>l.internalFeatureId===r.internalFeatureId)?.terms,c=i[r.id];if(!d||typeof c!="number"||!Number.isSafeInteger(c)||c<Math.max(d.minimumQuantity,r.minimumQuantity)||c>Math.min(d.maximumQuantity,r.maximumQuantity)||(c-r.minimumQuantity)%r.step!==0||s[r.internalFeatureId]!==void 0)throw new Error("Choose a valid quantity for each prepaid Feature");s[r.internalFeatureId]=c}),(a.prepaid??[]).some(r=>s[r.internalFeatureId]===void 0))throw new Error("Choose a quantity for each prepaid Feature");return s}function ue(t,n,i){let u=t.terms.prices.find(a=>a.currency===n);if(!u||i<t.terms.minimumQuantity||i>t.terms.maximumQuantity)throw new Error("Quantity or currency is unavailable");return{amountMinor:U({quantity:i,unitAmountMinor:u.amountMinor,...u.pricing?{pricing:u.pricing}:{}}),allowance:D(t.includedAmount,t.terms.units,i)}}function Ne(t,n,i,u){let a=!1;if(_(t,o=>{o.type==="quantity_picker"&&(a=!0)}),!a)return n;let s=structuredClone(n);s.quantities={};let r=new Map;_(t,o=>{if(o.hidden)return!1;if(o.type!=="quantity_picker")return;let d=o.bind?.plan??(o.bind?.picker?i[o.bind.picker]??s.pickers[o.bind.picker]?.selected:void 0),c=typeof d=="string"?s.plans[d]:void 0,l=c?.prepaid?.find(G=>G.internalFeatureId===o.internalFeatureId),k=Math.max(o.minimumQuantity,l?.terms.minimumQuantity??0),x=Math.min(o.maximumQuantity,l?.terms.maximumQuantity??0),b=i[o.id]??o.defaultQuantity,h=typeof b=="number"&&Number.isSafeInteger(b)?b:o.defaultQuantity,S=!!l&&!!c?.available&&n.quantities?.[o.id]?.available!==!1&&h>=k&&h<=x&&(h-o.minimumQuantity)%o.step===0,P=s.quantities[o.id]={minimum:k,maximum:Math.max(k,x),step:o.step,value:h,label:"",available:S};if(!S||!l||!c?.currency||c.amountMinor===void 0)return;let M=ue(l,c.currency,h);P.label=`${new Intl.NumberFormat(u).format(Number(M.allowance))} ${l.name}${["week","month","year"].includes(l.reset)?H(l.reset,u,l.resetCount):l.reset==="lifetime"?"":` / ${l.resetCount} ${l.reset}`}`,M.amountMinor!==0&&r.set(String(d),(r.get(String(d))??c.amountMinor)+M.amountMinor)});for(let[o,d]of r){let c=s.plans[o];if(!c?.currency)continue;let l=F(d,c.currency,u);c.price=l;for(let[k,x]of Object.entries(s.nodes)){let b=K(t,k),h=S=>{if(S.price&&(S.price={...S.price,current:l,original:null}),b?.type==="text"){let P=t.strings.locales[u]?.[b.text]??t.strings.locales[t.strings.defaultLocale]?.[b.text];P?.includes("{{plan.price")&&(S.text=P.replace(/\{\{\s*plan.price\s*\}\}/g,l).replace(/\{\{\s*plan.price_per_month\s*\}\}/g,F(Math.round(d/((c.interval==="year"?12:1)*(c.intervalCount??1))),c.currency,u)))}};x.byPlan?.[o]&&h(x.byPlan[o]),(x.base.planVersionId===o||b&&"bind"in b&&b.bind?.plan===o)&&h(x.base)}}return s}export{le as a,J as b,Q as c,de as d,me as e,T as f,ye as g,V as h,y as i,we as j,ke as k,je as l,Ce as m,ie as n,ze as o,oe as p,Re as q,H as r,De as s,Ke as t,Ne as u};
1
+ import{C as K,b as U,d as D,v as _}from"./chunk-FGAIHKFS.js";import{a as z,c as F}from"./chunk-MMAMK7OQ.js";import{d as $}from"./chunk-DJTZR2NR.js";import{i as C,j as m,l as O,m as g}from"./chunk-CQYEM7U6.js";import{b as e}from"./chunk-ZL247MPX.js";var I=m.refine(t=>/[1-9]/.test(t),"Quantity must be positive"),j=e.string().min(1).max(120),R=e.enum(["cap","overflow"]),p=(t,n)=>{let[i,u=""]=t.split(".");if(i===void 0||i==="")throw new Error("Invalid decimal value");return BigInt(i)*10n**BigInt(n)+BigInt(u.padEnd(n,"0"))},A=t=>{try{return t()}catch{return!1}},le=e.discriminatedUnion("operation",[e.object({operation:e.literal("quote"),overageBehavior:R.optional(),internal_feature_id:e.uuid(),entityId:e.uuid().optional(),quantity:I,properties:g}).strict(),e.object({operation:e.literal("consume"),overageBehavior:R.optional(),occurredAt:e.iso.datetime({offset:!0}).optional(),internal_feature_id:e.uuid(),entityId:e.uuid().optional(),quantity:m,properties:g,idempotencyKey:j}).strict(),e.object({operation:e.literal("reserve"),occurredAt:e.iso.datetime({offset:!0}).optional(),internal_feature_id:e.uuid(),entityId:e.uuid().optional(),quantity:I,properties:g,idempotencyKey:j,expiresInSeconds:e.number().int().min(1).max(86400)}).strict(),e.object({operation:e.literal("confirm"),operationId:e.uuid(),quantity:I,properties:g.optional(),idempotencyKey:j}).strict(),e.object({operation:e.literal("refund"),operationId:e.uuid(),quantity:I,idempotencyKey:j}).strict(),e.object({operation:e.literal("release"),operationId:e.uuid(),idempotencyKey:j}).strict()]),J=e.object({internal_credit_feature_id:e.uuid().nullable(),internal_metered_feature_id:e.uuid(),dimension:e.string().min(1).max(64),counterKey:e.string().min(1).max(240),cycleStart:e.iso.datetime({offset:!0}),unitCost:m,units:I,amount:C,tier:e.number().int().min(1).max(12).nullable()}).strict(),Q=e.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,12})?$/);function N(t,n){let i=t.reduce((u,a)=>u+p(a.units,12),0n)-p(n,12);return t.some(u=>u.funding==="balance")?i>=-100n&&i<=100n:i===0n}var v=e.discriminatedUnion("funding",[e.strictObject({funding:e.literal("balance"),sourceId:e.uuid(),rolloverId:e.uuid().nullable(),units:Q.refine(t=>/[1-9]/.test(t)),amount:C}),e.strictObject({funding:e.literal("unbilled"),units:Q.refine(t=>/[1-9]/.test(t))}),e.object({funding:e.literal("prepaid"),sourceId:e.uuid(),units:I,amount:C,pricing:e.array(J).min(1).max(12)}).strict().refine(t=>A(()=>t.pricing.reduce((n,i)=>n+p(i.units,6),0n)===p(t.units,6)&&t.pricing.reduce((n,i)=>n+p(i.amount,12),0n)===p(t.amount,12)&&t.pricing.every(n=>p(n.unitCost,6)*p(n.units,6)===p(n.amount,12))),"Frozen pricing must conserve allocated units and amounts"),e.object({funding:e.literal("postpaid"),invoiceLineId:e.uuid().nullable(),units:I,authorizationId:e.uuid()}).strict()]),B=e.enum(["unavailable","insufficient_balance","limit_exceeded","awaiting_topup","authorization_required","payment_blocked","cash_budget_exceeded"]),de=e.object({allowed:e.boolean(),internal_feature_id:e.uuid(),quantity:m,requestedQuantity:m.optional(),overageBehavior:R.optional(),reason:B.nullable(),allocations:e.array(v).max(500)}).strict().refine(t=>A(()=>t.allowed?t.reason===null&&N(t.allocations,t.quantity):t.reason!==null&&t.allocations.length===0),"A quote must conserve its accepted units").refine(t=>A(()=>t.overageBehavior===void 0?t.requestedQuantity===void 0&&/[1-9]/.test(t.quantity):t.requestedQuantity!==void 0&&p(t.requestedQuantity,6)>=p(t.quantity,6)&&(t.overageBehavior==="cap"||t.requestedQuantity===t.quantity)),"Explicit overage behavior must retain the requested quantity"),me=e.object({id:e.uuid(),internal_feature_id:e.uuid(),kind:e.enum(["consume","reserve","confirm","refund","release","expire"]),originalId:e.uuid().nullable(),quantity:m,requestedQuantity:m.optional(),overageBehavior:R.optional(),accepted:e.boolean(),reason:e.enum([...B.options,"expired"]).nullable(),createdAt:e.iso.datetime({offset:!0}),reservationStatus:e.enum(["pending","confirmed","released","expired"]).nullable(),expiresAt:e.iso.datetime({offset:!0}).nullable(),allocations:e.array(v).max(500)}).strict().refine(t=>A(()=>t.accepted?t.reason===null&&N(t.allocations,t.quantity):t.reason!==null&&t.allocations.length===0),"An operation must conserve its requested units").refine(t=>A(()=>t.overageBehavior===void 0?t.requestedQuantity===void 0:t.kind==="consume"&&t.requestedQuantity!==void 0&&p(t.requestedQuantity,6)>=p(t.quantity,6)&&(t.overageBehavior==="cap"||t.requestedQuantity===t.quantity)),"Overage metadata belongs to consumption and preserves requested units").refine(t=>/[1-9]/.test(t.quantity)||t.kind==="consume","Only consumption can record a zero cost event").refine(t=>t.allocations.every(n=>n.funding!=="postpaid"||n.invoiceLineId!==null),"Accepted operations must reference persisted invoice lines").refine(t=>t.originalId!==null===["confirm","refund","release","expire"].includes(t.kind)&&t.expiresAt!==null==(t.reservationStatus!==null)&&(t.kind!=="reserve"||!t.accepted||t.reservationStatus!==null),"Operation provenance and reservation state must be explicit");var X=e.string().max(40).regex(/^(0|[1-9]\d*)(\.\d{1,12})?$/),Y=e.string().max(41).regex(/^-?(0|[1-9]\d*)(\.\d{1,12})?$/),T=e.strictObject({internal_feature_id:e.uuid(),entityId:e.uuid().nullable()}),ye=T.extend({quantity:m,expectedRevision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),idempotencyKey:e.string().min(1).max(120),properties:g.refine(t=>Object.keys(t).length<=13&&!Object.keys(t).some(n=>n.startsWith("usage_")),"Usage accounting reserves three properties")}).strict(),V=T.extend({operationId:e.uuid().nullable(),usage:m,capacity:X.nullable(),remaining:Y.nullable(),withinLimit:e.boolean(),revision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),updatedAt:e.iso.datetime({offset:!0}).nullable()}).strict().superRefine((t,n)=>{let i=u=>{let a=u.startsWith("-"),[s,r=""]=(a?u.slice(1):u).split(".");if(s===void 0||s==="")throw new Error("Invalid decimal value");return(a?-1n:1n)*(BigInt(s)*10n**12n+BigInt(r.padEnd(12,"0")))};(t.capacity===null!=(t.remaining===null)||(t.capacity===null?!t.withinLimit:t.remaining===null||i(t.remaining)!==i(t.capacity)-i(t.usage)||t.withinLimit!==i(t.remaining)>=0n)||t.revision===0!=(t.operationId===null)||t.operationId===null!=(t.updatedAt===null))&&n.addIssue({code:"custom",message:"Absolute usage must conserve capacity and its immutable revision"})});var y=e.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,12})?$/),f=e.iso.datetime({offset:!0}),ee=e.enum(["access","metered","credit"]),q={internal_feature_id:e.uuid(),key:O,name:e.string().min(1).max(120),kind:ee},we=e.object({customerId:e.uuid(),snapshotAt:f,memberships:e.array(e.object({id:e.uuid(),productId:e.string().min(1).max(255),productVersionId:e.uuid(),billingProductVersionId:e.uuid(),version:e.number().int().positive(),key:e.string().min(1).max(64),name:e.string().min(1).max(120),groupId:e.string().max(255).nullable(),membershipType:e.enum(["main","addon"]),status:e.enum(["trial","active","past_due","ended","expired","trialing","paused","pending","scheduled","unknown"]),cancelAtPeriodEnd:e.boolean(),accessEnabled:e.boolean(),renewalChange:e.object({productVersionId:e.uuid(),name:e.string().min(1).max(120),version:e.number().int().positive(),effectiveAt:f,benefitsAppliedAt:f.nullable(),timing:e.enum(["immediate","renewal"]),changeKind:e.enum(["plan","seats","quantity"]),feature:e.strictObject({internal_feature_id:e.uuid(),name:e.string().min(1).max(80),fromQuantity:e.number().int().min(0).max(1e4),toQuantity:e.number().int().min(0).max(1e4)}).optional(),seat:e.object({key:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),fromQuantity:e.number().int().min(0).max(1e4),toQuantity:e.number().int().min(0).max(1e4)}).strict().nullable(),status:e.enum(["prepared","quoted","confirmed","pending","scheduled"])}).strict().refine(t=>t.changeKind==="seats"==(t.seat!==null)&&t.changeKind==="quantity"==(t.feature!==void 0),"Quantity changes require their fixed component identities and quantities").nullable(),period:e.object({phase:e.enum(["paid","trial"]),startsAt:f,endsAt:f.nullable()}).strict().nullable()}).strict()).max(100),membershipsLimited:e.boolean(),balances:e.array(e.object({...q,usageType:e.enum(["consumable","non_consumable"]).nullable(),accessible:e.boolean(),unlimited:e.boolean(),available:y,held:y,debt:y,nextExpiresAt:f.nullable(),usage:V.nullable()}).strict().refine(t=>t.kind==="metered"==(t.usageType!==null)&&(t.accessible||t.available==="0"&&t.held==="0")&&(t.usageType==="non_consumable"?t.usage!==null&&t.usage.internal_feature_id===t.internal_feature_id&&t.unlimited===(t.usage.capacity===null)&&t.available===(t.usage.remaining===null||t.usage.remaining.startsWith("-")?"0":t.usage.remaining)&&t.held==="0"&&t.debt==="0":t.usage===null),"Balances must expose their actual spendable or non-consumable state")).max(500),balancesLimited:e.boolean()}).strict(),Z=e.enum(["source","usage","transaction","invoice","debt","settlement"]),E=e.object({at:f,id:e.uuid(),type:Z}).strict(),ke=e.object({type:Z.nullable(),resourceKey:O.optional(),kind:e.enum(["purchase","refund"]).optional(),topup:e.boolean().optional(),from:e.iso.date().nullable(),to:e.iso.date().nullable(),after:E.nullable(),limit:e.number().int().min(1).max(50)}).strict().refine(t=>!t.from||!t.to||t.from<=t.to,"Date range is reversed"),w={id:e.uuid(),occurredAt:f},te=e.discriminatedUnion("type",[e.strictObject({...w,type:e.literal("invoice"),status:e.string().min(1).max(80),paid:y,refunded:y,currency:z,externalId:e.string().nullable()}),e.object({...w,...q,type:e.literal("source"),reason:e.enum(["membership","trial","topup","manual","rollover","upgrade_carry","seat"]),quantity:y,unlimited:e.boolean(),status:e.enum(["scheduled","active","expired","revoked","unavailable"]),startsAt:f,expiresAt:f.nullable(),orderId:e.uuid().nullable(),parentSourceId:e.uuid().nullable()}).strict(),e.object({...w,type:e.literal("usage"),internal_feature_id:e.uuid(),name:e.string().min(1).max(120),kind:e.enum(["consume","set_usage","reserve","confirm","refund","release","expire"]),originalId:e.uuid().nullable(),quantity:m,accepted:e.boolean(),reason:e.enum([...B.options,"expired"]).nullable(),properties:g,reservationStatus:e.enum(["pending","confirmed","released","expired"]).nullable(),expiresAt:f.nullable(),charges:e.array(e.discriminatedUnion("funding",[e.strictObject({funding:e.literal("balance"),sourceId:e.uuid(),rolloverId:e.uuid().nullable(),units:Q,amount:y}),e.strictObject({funding:e.literal("unbilled"),units:Q}),e.object({...q,funding:e.literal("prepaid"),amount:y}).strict(),e.object({funding:e.literal("postpaid"),invoiceId:e.uuid(),invoiceLineId:e.uuid(),authorizationId:e.uuid(),units:m,currency:z}).strict()])).max(500)}).strict().refine(t=>(t.kind==="set_usage"||t.kind==="consume"&&t.quantity==="0"?t.accepted&&t.reason===null&&t.charges.length===0&&t.reservationStatus===null:t.accepted?t.reason===null&&t.charges.length>0:t.reason!==null&&t.charges.length===0)&&t.originalId!==null===["confirm","refund","release","expire"].includes(t.kind)&&t.expiresAt!==null==(t.reservationStatus!==null),"Usage facts must retain their original outcome and receipt"),e.object({...w,type:e.literal("transaction"),purpose:e.enum(["product","invoice"]),productVersionId:e.uuid().nullable(),productName:e.string().min(1).max(120).nullable(),productVersion:e.number().int().positive().nullable(),invoiceId:e.uuid().nullable(),orderId:e.uuid(),originalId:e.uuid().nullable(),kind:e.enum(["purchase","refund"]),amountMinor:e.number().int().nonnegative().max(2e8).nullable(),currency:z.nullable()}).strict().refine(t=>t.currency===null==(t.amountMinor===null)&&(t.purpose==="product"?t.productVersionId!==null&&t.productName!==null&&t.productVersion!==null&&t.invoiceId===null:t.productVersionId===null&&t.productName===null&&t.productVersion===null&&t.invoiceId!==null)&&t.kind==="refund"==(t.originalId!==null)&&(t.kind!=="refund"||t.amountMinor===null||t.amountMinor>0),"Payment fact provenance is incomplete"),e.object({...w,...q,type:e.literal("debt"),sourceId:e.uuid(),transactionId:e.uuid(),amount:y}).strict(),e.object({...w,...q,type:e.literal("settlement"),sourceId:e.uuid(),debtId:e.uuid(),kind:e.enum(["payment","usage_refund","payment_return"]),amount:y}).strict()]),je=e.object({customerId:e.uuid(),rows:e.array(te).max(50),nextCursor:E.nullable()}).strict().refine(t=>new Set(t.rows.map(n=>n.type+n.id)).size===t.rows.length,"A page cannot repeat a fact").refine(t=>{let n=t.rows.at(-1);return!t.nextCursor||!!(n&&n.id===t.nextCursor.id&&n.type===t.nextCursor.type&&n.occurredAt===t.nextCursor.at)},"Cursor must name the final displayed fact");var Ce=e.discriminatedUnion("kind",[e.object({kind:e.literal("ledger"),cursor:E}).strict(),e.object({kind:e.literal("billing"),cursor:e.uuid()}).strict()]),ne=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),ie=e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),e.union([e.string().max(500),e.boolean(),e.array(e.string().max(500)).max(50)])).refine(t=>Object.keys(t).length<=40,"Too many answers"),re=/^(?:api_?key|authorization|password|(?:customer|run|visitor|access|purchase)_?token|client_?secret|signed_?transaction|raw_?proof)$/i;function L(t,n=0){return n>20?!0:!!t&&typeof t=="object"&&(Array.isArray(t)?t.some(i=>L(i,n+1)):Object.entries(t).some(([i,u])=>["__proto__","constructor","prototype"].includes(i)||re.test(i)||L(u,n+1)))}var ae=/gg_(?:sk|ct|fr|fv|gc)_[A-Za-z0-9_-]{20,}/,ze=e.record(ne,$).refine(t=>Object.keys(t).length<=20,"Too many parameters").refine(t=>!L(t)&&!ae.test(JSON.stringify(t)),"Credentials cannot be screen parameters");var W=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),oe=e.array(e.object({variable:W,componentId:W,required:e.boolean()}).strict()).max(40).refine(t=>new Set(t.map(n=>n.variable)).size===t.length&&new Set(t.map(n=>n.componentId)).size===t.length,"Input bindings must be unique"),Re=e.object({bindings:oe,answers:ie,values:e.record(e.string(),$).optional()}).strict();function H(t,n,i=1){if(t==="free")return"";if(t==="one_time")return n.startsWith("zh")?" · 一次付款":" · one-time";let u=n.split("-")[0]??"en",a={zh:["/月","/年"],en:["/month","/year"],ja:["/月","/年"],ko:["/월","/년"],es:["/mes","/año"],fr:["/mois","/an"],de:["/Monat","/Jahr"],pt:["/mês","/ano"],it:["/mese","/anno"],ar:["/شهر","/سنة"]},s={zh:"周",en:"week",ja:"週",ko:"주",es:"semana",fr:"semaine",de:"Woche",pt:"semana",it:"settimana",ar:"أسبوع"},r=t==="week"?`/${s[u]??s.en}`:(a[u]??a.en)[t==="month"?0:1];return i===1?r:`/${i} ${r.slice(1)}${u==="en"?"s":""}`}function De(t,n){let i=[],u={};_(t,a=>{if(a.hidden)return!1;if(a.type!=="quantity_picker")return;let s=a.bind?.plan?[a.bind.plan]:[];a.bind?.picker&&_(t,r=>{if(r.type==="plan_picker"&&r.id===a.bind?.picker&&s.push(...r.planIds??[]),r.type==="stack"&&r.interaction?.type==="select"&&r.interaction.pickerId===a.bind?.picker)for(let o of r.children)o.type==="stack"&&o.bind?.plan&&s.push(o.bind.plan)}),s.length||i.push(`Quantity control ${a.id} needs a Product binding`);for(let r of new Set(s)){let o=n[r]?.prepaid?.find(c=>c.internalFeatureId===a.internalFeatureId)?.terms,d=u[r]??=new Set;(!o||d.has(a.internalFeatureId)||a.minimumQuantity<o.minimumQuantity||a.maximumQuantity>o.maximumQuantity)&&i.push(`Quantity control ${a.id} must match its Product's prepaid Feature and bounds`),d.add(a.internalFeatureId)}});for(let[a,s]of Object.entries(n))for(let r of s.prepaid??[])u[a]?.has(r.internalFeatureId)||i.push(`Product ${a} needs a quantity control for ${r.internalFeatureId}`);return i}function Ke(t,n,i,u){let a=u.plans[n];if(!a?.available)throw new Error("Selected Product is unavailable");let s={};if(_(t,r=>{if(r.hidden)return!1;if(r.type!=="quantity_picker"||r.hidden||(r.bind?.plan??(r.bind?.picker?i[r.bind.picker]:void 0))!==n)return;if(u.quantities?.[r.id]?.available===!1)throw new Error("This prepaid Feature is unavailable");let d=a.prepaid?.find(l=>l.internalFeatureId===r.internalFeatureId)?.terms,c=i[r.id];if(!d||typeof c!="number"||!Number.isSafeInteger(c)||c<Math.max(d.minimumQuantity,r.minimumQuantity)||c>Math.min(d.maximumQuantity,r.maximumQuantity)||(c-r.minimumQuantity)%r.step!==0||s[r.internalFeatureId]!==void 0)throw new Error("Choose a valid quantity for each prepaid Feature");s[r.internalFeatureId]=c}),(a.prepaid??[]).some(r=>s[r.internalFeatureId]===void 0))throw new Error("Choose a quantity for each prepaid Feature");return s}function ue(t,n,i){let u=t.terms.prices.find(a=>a.currency===n);if(!u||i<t.terms.minimumQuantity||i>t.terms.maximumQuantity)throw new Error("Quantity or currency is unavailable");return{amountMinor:U({quantity:i,unitAmountMinor:u.amountMinor,...u.pricing?{pricing:u.pricing}:{}}),allowance:D(t.includedAmount,t.terms.units,i)}}function Ne(t,n,i,u){let a=!1;if(_(t,o=>{o.type==="quantity_picker"&&(a=!0)}),!a)return n;let s=structuredClone(n);s.quantities={};let r=new Map;_(t,o=>{if(o.hidden)return!1;if(o.type!=="quantity_picker")return;let d=o.bind?.plan??(o.bind?.picker?i[o.bind.picker]??s.pickers[o.bind.picker]?.selected:void 0),c=typeof d=="string"?s.plans[d]:void 0,l=c?.prepaid?.find(G=>G.internalFeatureId===o.internalFeatureId),k=Math.max(o.minimumQuantity,l?.terms.minimumQuantity??0),x=Math.min(o.maximumQuantity,l?.terms.maximumQuantity??0),b=i[o.id]??o.defaultQuantity,h=typeof b=="number"&&Number.isSafeInteger(b)?b:o.defaultQuantity,S=!!l&&!!c?.available&&n.quantities?.[o.id]?.available!==!1&&h>=k&&h<=x&&(h-o.minimumQuantity)%o.step===0,P=s.quantities[o.id]={minimum:k,maximum:Math.max(k,x),step:o.step,value:h,label:"",available:S};if(!S||!l||!c?.currency||c.amountMinor===void 0)return;let M=ue(l,c.currency,h);P.label=`${new Intl.NumberFormat(u).format(Number(M.allowance))} ${l.name}${["week","month","year"].includes(l.reset)?H(l.reset,u,l.resetCount):l.reset==="lifetime"?"":` / ${l.resetCount} ${l.reset}`}`,M.amountMinor!==0&&r.set(String(d),(r.get(String(d))??c.amountMinor)+M.amountMinor)});for(let[o,d]of r){let c=s.plans[o];if(!c?.currency)continue;let l=F(d,c.currency,u);c.price=l;for(let[k,x]of Object.entries(s.nodes)){let b=K(t,k),h=S=>{if(S.price&&(S.price={...S.price,current:l,original:null}),b?.type==="text"){let P=t.strings.locales[u]?.[b.text]??t.strings.locales[t.strings.defaultLocale]?.[b.text];P?.includes("{{plan.price")&&(S.text=P.replace(/\{\{\s*plan.price\s*\}\}/g,l).replace(/\{\{\s*plan.price_per_month\s*\}\}/g,F(Math.round(d/((c.interval==="year"?12:1)*(c.intervalCount??1))),c.currency,u)))}};x.byPlan?.[o]&&h(x.byPlan[o]),(x.base.planVersionId===o||b&&"bind"in b&&b.bind?.plan===o)&&h(x.base)}}return s}export{le as a,J as b,Q as c,de as d,me as e,T as f,ye as g,V as h,y as i,we as j,ke as k,je as l,Ce as m,ie as n,ze as o,oe as p,Re as q,H as r,De as s,Ke as t,Ne as u};
@@ -0,0 +1 @@
1
+ import{o as n,r as t}from"./chunk-4SDB3T2F.js";function u(o,e,a){return n(o,e,a,t)}export{u as a};
@@ -1 +1 @@
1
- import{b as o}from"./chunk-VITB5MIL.js";var s=["input","output","cache_read","cache_write","reasoning","input_audio","output_audio"],n=o.string().regex(/.+\/.+/),e=o.number().min(-100),t=o.string().regex(/^(0|[1-9]\d{0,5})(\.\d{1,12})?$/),p=o.strictObject({input:t,output:t,cache_read:t.optional(),cache_write:t.optional(),reasoning:t.optional(),input_audio:t.optional(),output_audio:t.optional()}),i=(r,a)=>o.record(r,a).refine(c=>Object.keys(c).length<=100,"At most 100 AI overrides"),d=o.strictObject({defaultMarkup:e,providerMarkups:i(o.string().min(1),e),modelMarkups:i(n,e),customModels:i(n,p.partial())});export{s as a,n as b,e as c,p as d,d as e};
1
+ import{b as o}from"./chunk-ZL247MPX.js";var s=["input","output","cache_read","cache_write","reasoning","input_audio","output_audio"],n=o.string().regex(/.+\/.+/),e=o.number().min(-100),t=o.string().regex(/^(0|[1-9]\d{0,5})(\.\d{1,12})?$/),p=o.strictObject({input:t,output:t,cache_read:t.optional(),cache_write:t.optional(),reasoning:t.optional(),input_audio:t.optional(),output_audio:t.optional()}),i=(r,a)=>o.record(r,a).refine(c=>Object.keys(c).length<=100,"At most 100 AI overrides"),d=o.strictObject({defaultMarkup:e,providerMarkups:i(o.string().min(1),e),modelMarkups:i(n,e),customModels:i(n,p.partial())});export{s as a,n as b,e as c,p as d,d as e};