@tinkerlandai/longplay-sdk 0.10.37 → 0.10.38

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 (74) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/check-response-Q7GOBUGJ.js +1 -0
  3. package/dist/chunk-2LND3R7K.js +1 -0
  4. package/dist/{chunk-XJRDO3NI.js → chunk-4E326NPY.js} +1 -1
  5. package/dist/{chunk-DDLSQSWO.js → chunk-5IGASP6C.js} +1 -1
  6. package/dist/{chunk-AB7GEGZ2.js → chunk-64ETX3AY.js} +1 -1
  7. package/dist/{chunk-OX2A3UD2.js → chunk-6QOJRLVM.js} +1 -1
  8. package/dist/{chunk-PW5PIBSO.js → chunk-6WEHTOED.js} +1 -1
  9. package/dist/{chunk-E7CCHUSO.js → chunk-7PXJUHDS.js} +1 -1
  10. package/dist/{chunk-T2KWLYCW.js → chunk-BDC7B4KM.js} +1 -1
  11. package/dist/{chunk-ZYOZSUZS.js → chunk-DK5PHPSO.js} +1 -1
  12. package/dist/{chunk-OQRMAU2B.js → chunk-DSLJUN3P.js} +1 -1
  13. package/dist/{chunk-AOGDCT4T.js → chunk-DTWSDNYI.js} +1 -1
  14. package/dist/{chunk-AHUYZ6IW.js → chunk-EEYDOVVS.js} +1 -1
  15. package/dist/{chunk-KFIL73QY.js → chunk-G7Y7LPOB.js} +1 -1
  16. package/dist/{chunk-W74JLL2O.js → chunk-GEPX4AUR.js} +1 -1
  17. package/dist/{chunk-ZZIBLQCJ.js → chunk-H2I37CQ4.js} +1 -1
  18. package/dist/{chunk-WZMZMJCK.js → chunk-HJVEVJXS.js} +1 -1
  19. package/dist/chunk-I7QTCEYR.js +1 -0
  20. package/dist/{chunk-CY7OKV7E.js → chunk-IHB275C3.js} +1 -1
  21. package/dist/{chunk-VIBJNB5B.js → chunk-IV6LKRYM.js} +1 -1
  22. package/dist/{chunk-TASEZY5T.js → chunk-JBDNNV3P.js} +1 -1
  23. package/dist/{chunk-XGNXZWZL.js → chunk-JXTJT2EW.js} +1 -1
  24. package/dist/{chunk-HEHLFHW7.js → chunk-K3VQKR4G.js} +1 -1
  25. package/dist/{chunk-YV6UFESO.js → chunk-KQF4BVOL.js} +1 -1
  26. package/dist/{chunk-4KLXQKNO.js → chunk-KTBXAATX.js} +1 -1
  27. package/dist/{chunk-2KJLN65C.js → chunk-L54MODP5.js} +1 -1
  28. package/dist/{chunk-UV4H6VCS.js → chunk-NK55HFFF.js} +1 -1
  29. package/dist/{chunk-U7NX5ET2.js → chunk-O5VA3E5D.js} +1 -1
  30. package/dist/{chunk-LC6UCDWE.js → chunk-PLOUC66F.js} +1 -1
  31. package/dist/{chunk-VLSP3LRH.js → chunk-Q7K66FTS.js} +1 -1
  32. package/dist/{chunk-OCWSWXCW.js → chunk-QZRJ3ZXU.js} +1 -1
  33. package/dist/{chunk-2VMEDQHT.js → chunk-RK7XOT3F.js} +1 -1
  34. package/dist/{chunk-Q676H74B.js → chunk-SY7AYEDO.js} +1 -1
  35. package/dist/{chunk-ECKVJGXQ.js → chunk-TLV3NVUU.js} +1 -1
  36. package/dist/{chunk-S43TYW3V.js → chunk-UAJTQ23E.js} +1 -1
  37. package/dist/{chunk-LOLMUXHW.js → chunk-UD7XPHE4.js} +1 -1
  38. package/dist/{chunk-6F4JS3RK.js → chunk-UFTLA3ZI.js} +1 -1
  39. package/dist/{chunk-7XDQKZYA.js → chunk-WP3SZU24.js} +1 -1
  40. package/dist/chunk-WQZOT22S.js +1 -0
  41. package/dist/{chunk-RE4OLOOT.js → chunk-XBCKVHOT.js} +1 -1
  42. package/dist/{chunk-GH6FM44P.js → chunk-Y5RT7PAD.js} +1 -1
  43. package/dist/{chunk-D3OYXTMC.js → chunk-YYXINZ4A.js} +1 -1
  44. package/dist/{content-QNBATPA2.js → content-B4CC4O23.js} +1 -1
  45. package/dist/{funnel-host-purchase-FVYPBPET.js → funnel-host-purchase-AGBJG3RK.js} +1 -1
  46. package/dist/funnel-paywall-prerender-HHAQBIIB.js +1 -0
  47. package/dist/funnel-runtime-host-IJDKXLST.js +1 -0
  48. package/dist/index.js +1 -1
  49. package/dist/merchant-bridge-contracts-KVOFRPKV.js +1 -0
  50. package/dist/native-shell.js +1 -1
  51. package/dist/openrouter.js +1 -1
  52. package/dist/operation-contracts-G4C7ZLEH.js +1 -0
  53. package/dist/page.js +1 -1
  54. package/dist/{paywall-OAVC654P.js → paywall-TVCH6VQT.js} +1 -1
  55. package/dist/paywall-content-QSTCRYU5.js +1 -0
  56. package/dist/paywall-session-UBQYU5XD.js +1 -0
  57. package/dist/popup.js +1 -1
  58. package/dist/react-native.js +1 -1
  59. package/dist/screen-renderer-Q3VSMB2N.js +1 -0
  60. package/dist/server.js +1 -1
  61. package/dist/visual.js +1 -1
  62. package/package.json +1 -1
  63. package/dist/check-response-N22NNTIT.js +0 -1
  64. package/dist/chunk-2HBIBIOF.js +0 -1
  65. package/dist/chunk-HKXFCRVT.js +0 -1
  66. package/dist/chunk-WQ3O5RXN.js +0 -1
  67. package/dist/funnel-paywall-prerender-Z7RA4YDY.js +0 -1
  68. package/dist/funnel-runtime-host-TJPF3FJS.js +0 -1
  69. package/dist/merchant-bridge-contracts-67AYXZFI.js +0 -1
  70. package/dist/operation-contracts-EK4RCUWJ.js +0 -1
  71. package/dist/paywall-content-75XEM7K3.js +0 -1
  72. package/dist/paywall-session-U6SPRJRS.js +0 -1
  73. package/dist/screen-renderer-YIIT742O.js +0 -1
  74. /package/dist/{chunk-CR2XJ2CX.js → chunk-42UXYMRZ.js} +0 -0
@@ -1 +1 @@
1
- import{M as S,a as v,b as A,c as C,f as h,g as f,k as w,l as j,m as R,n as M,o as P,q as b,r as y}from"./chunk-S43TYW3V.js";import{j as O,o as q,p as B}from"./chunk-YV6UFESO.js";import{a as D,b as g,c as k,d as N}from"./chunk-WZMZMJCK.js";import{a as s,d as U}from"./chunk-T2KWLYCW.js";import{b as t}from"./chunk-CR2XJ2CX.js";var me=t.registry(),{BillingInterval:F}=(()=>{var e;return(function(i){i.OneOff="one_off",i.Week="week",i.Month="month",i.Quarter="quarter",i.SemiAnnual="semi_annual",i.Year="year"})(e||(e={})),{BillingInterval:e}})(),{DisplaySchema:de}=(e=>({DisplaySchema:e.object({primary_text:e.string().meta({description:"Main display text (e.g. '$10' or '100 messages')."}),secondary_text:e.string().optional().meta({description:"Secondary display text (e.g. 'per month' or 'then $0.5 per 100')."})})}))(t),{withSpecDefault:pe}=(e=>({withSpecDefault:({schema:r,defaultValue:n,description:a})=>(e.add(r,{description:a,default:n}),r)}))(me),{COMMON:L}={COMMON:["usd","eur","gbp","cad","aud","jpy","chf","cny","inr"]},{STRIPE_PRESENTMENT_CURRENCIES:le}={STRIPE_PRESENTMENT_CURRENCIES:["usd","aed","afn","all","amd","ang","aoa","ars","aud","awg","azn","bam","bbd","bdt","bif","bmd","bnd","bob","brl","bsd","bwp","byn","bzd","cad","cdf","chf","clp","cny","cop","crc","cve","czk","djf","dkk","dop","dzd","egp","etb","eur","fjd","fkp","gbp","gel","gip","gmd","gnf","gtq","gyd","hkd","hnl","htg","huf","idr","ils","inr","isk","jmd","jpy","kes","kgs","khr","kmf","krw","kyd","kzt","lak","lbp","lkr","lrd","lsl","mad","mdl","mga","mkd","mmk","mnt","mop","mur","mvr","mwk","mxn","myr","mzn","nad","ngn","nio","nok","npr","nzd","pab","pen","pgk","php","pkr","pln","pyg","qar","ron","rsd","rub","rwf","sar","sbd","scr","sek","sgd","shp","sle","sos","srd","std","szl","thb","tjs","top","try","ttd","twd","tzs","uah","ugx","uyu","uzs","vnd","vuv","wst","xaf","xcd","xcg","xof","xpf","yer","zar","zmw"]},{COMMON_SET:he}=(e=>({COMMON_SET:new Set(e)}))(L),{hasNoDuplicateCurrencies:Q}={hasNoDuplicateCurrencies:i=>{let r=new Set;for(let{currency:n}of i){let a=n.toLowerCase();if(r.has(a))return!1;r.add(a)}return!0}},{DUPLICATE_CURRENCY_MESSAGE:V}={DUPLICATE_CURRENCY_MESSAGE:"Each currency may appear at most once in additional_currencies."},{ApiStripePriceProcessorSchema:fe}=(e=>({ApiStripePriceProcessorSchema:e.object({price_id:e.string().meta({description:"Stripe price ID. For prepaid with included > 0 this is the V2 price."})})}))(t),{Infinite:be}={Infinite:"inf"},{TierBehavior:ye}=(()=>{var e;return(function(i){i.Graduated="graduated",i.VolumeBased="volume"})(e||(e={})),{TierBehavior:e}})(),{BillingMethod:G}=(()=>{var e;return(function(i){i.Prepaid="prepaid",i.UsageBased="usage_based"})(e||(e={})),{BillingMethod:e}})(),{AllocatedBilling:ge}=(()=>{var e;return(function(i){i.Arrear="arrear",i.ProratedLegacy="prorated_legacy"})(e||(e={})),{AllocatedBilling:e}})(),{CREDIT_DIMENSION_NAME_MAX_LENGTH:Se}={CREDIT_DIMENSION_NAME_MAX_LENGTH:64},{USAGE_ATTRIBUTION_DIMENSION_SEPARATOR:_e}={USAGE_ATTRIBUTION_DIMENSION_SEPARATOR:"::"},{CreditMatchSchema:Ie}=(e=>({CreditMatchSchema:e.record(e.string(),e.union([e.string(),e.number(),e.boolean()]).transform(String).pipe(e.string()))}))(t),{ApiCreditTierSchema:$}=(e=>({ApiCreditTierSchema:e.object({to:e.union([e.number().positive(),e.enum(["inf"])]).meta({description:"Inclusive upper usage boundary for this graduated tier. The final tier must be 'inf'."}),credit_cost:e.number().min(0).meta({description:"Credits consumed per billing-unit group within this tier."})})}))(t),{VIOLATION_MESSAGES:xe}={VIOLATION_MESSAGES:{non_final_infinity:"Only the final tier may use an 'inf' boundary.",not_increasing:"Tier boundaries must be strictly increasing.",final_not_infinity:"The final tier must use an 'inf' boundary."}},{MarkupEntrySchema:K}=(e=>({MarkupEntrySchema:e.object({markup:e.number().min(-100)})}))(t),{ModelMarkupsSchema:ve}=((e,i)=>({ModelMarkupsSchema:e.record(e.string().regex(/.+\/.+/,'Model keys are "<provider>/<model>", e.g. "openai/gpt-4o" or "custom/my-model".'),i.extend({markup:e.number().min(-100).optional(),input_cost:e.number().min(0).optional(),output_cost:e.number().min(0).optional()})).nullish()}))(t,K),{InvoiceUsageEntrySchema:Ae}=(e=>({InvoiceUsageEntrySchema:e.object({feature_id:e.string().meta({description:"The metered feature whose units are being converted."}),quantity:e.number().nonnegative().meta({description:"Billable units of the metered feature. Converted to the credit-system feature through its rate card."}),properties:e.record(e.string(),e.unknown()).optional().meta({description:"Event properties used to pick the rate card dimension and multipliers."})}).strict()}))(t),{AttachDiscountSchema:Z}=(e=>({AttachDiscountSchema:e.object({reward_id:e.string().optional().meta({description:"The ID of the reward to apply as a discount."}),promotion_code:e.string().optional().meta({description:"The promotion code to apply as a discount."})}).refine(r=>r.reward_id||r.promotion_code,{message:"Either reward_id or promotion_code must be provided."}).meta({title:"AttachDiscount",description:"A discount to apply. Can be either a reward ID or a promotion code."})}))(t),{CustomLineItemSchema:Ce}=(e=>({CustomLineItemSchema:e.object({amount:e.number().meta({description:"Amount in dollars for this line item (e.g. 10.50). Can be negative for credits."}),description:e.string().meta({description:"Description for the line item."})})}))(t),{UnixMsTimestampSchema:Me}=(e=>({UnixMsTimestampSchema:e.number().int().safe().nonnegative()}))(t),{CreateInvoicePreviewLineSchema:Pe}=(e=>({CreateInvoicePreviewLineSchema:e.object({plan_id:e.string().nullable(),feature_id:e.string().nullable(),description:e.string(),amount:e.number(),amount_after_discounts:e.number(),quantity:e.number().nullable(),prorated:e.boolean(),period_start:e.number().nullable(),period_end:e.number().nullable()})}))(t),{ReissueInvoiceParamsSchema:ht}=(e=>({ReissueInvoiceParamsSchema:e.object({invoice_id:e.string().meta({description:"The Autumn invoice ID to void and replace.",example:"inv_2b3c4d5e6f7g8h"}),invoice_template_id:e.string().optional().meta({description:"ID of an invoice template (configured in billing settings) whose footer and memo are applied to the replacement invoice."}),net_terms_days:e.number().int().positive().optional().meta({description:"Number of days the customer has to pay the replacement invoice. Defaults to the original invoice's due date; required when that date has already passed."}),update_customer_email:e.email().optional().meta({description:"Updates the customer's billing email before the replacement is issued, so Stripe sends the new invoice to this address."})})}))(t),{InvoiceModeParamsSchema:p}=(e=>({InvoiceModeParamsSchema:e.object({enabled:e.boolean().meta({description:"When true, creates an invoice and sends it to the customer instead of charging their card immediately. Uses Stripe's send_invoice collection method."}),enable_plan_immediately:e.boolean().default(!1).meta({description:"If true, enables the plan immediately even though the invoice is not paid yet."}),finalize:e.boolean().default(!0).meta({description:"If true, finalizes the invoice so it can be sent to the customer. If false, keeps it as a draft for manual review."}),invoice_template_id:e.string().optional().meta({description:"ID of an invoice template (configured in billing settings) whose footer (e.g. bank details) is applied to the invoice."}),net_terms_days:e.number().int().positive().optional().meta({description:"Number of days the customer has to pay the invoice before it is due (Stripe days_until_due)."})}).meta({title:"InvoiceMode",description:"Invoice mode configuration. Creates an invoice instead of charging the card immediately."})}))(t),{InvoiceTemplateSchema:ft}=(e=>({InvoiceTemplateSchema:e.object({id:e.string().meta({description:"Unique identifier for the invoice template."}),name:e.string().meta({description:"User-defined name to distinguish this template when sending an invoice."}),footer:e.string().optional().meta({description:"Footer text rendered on the invoice, typically bank details so customers can pay directly."}),memo:e.string().optional().meta({description:"Memo shown near the top of the invoice (Stripe invoice description), e.g. a contact line for payment questions."}),net_terms_days:e.number().int().positive().optional().meta({description:"Default number of days the customer has to pay before the invoice is due. Overridable when sending."}),created_at:e.number().optional().meta({description:"Timestamp (ms) when the template was created."})})}))(t),{BasePriceSchema:Oe}=((e,i,r)=>({BasePriceSchema:e.object({amount:e.number().meta({description:"Base price amount for the plan, in major currency units (e.g. dollars)."}),interval:e.enum(i).meta({description:"Billing interval (e.g. 'month', 'year')."}),interval_count:e.number().optional().meta({description:"Number of intervals per billing cycle. Defaults to 1."}),display:r.optional().meta({description:"Display text for showing this price in pricing pages."})})}))(t,F,de),{CURRENCY_CODES:Ee}=((e,i,r)=>({CURRENCY_CODES:[...e,...i.filter(a=>!r.has(a)).sort()]}))(L,le,he),{ApiPriceProcessorsSchema:W}=((e,i)=>({ApiPriceProcessorsSchema:e.object({stripe:i.nullish()}).meta({"x-atmn-mapping":!0})}))(t,fe),{AllocatedBillingFieldSchema:Te}=((e,i)=>({AllocatedBillingFieldSchema:e.enum(i).optional().meta({internal:!0,description:"How an allocated usage_based price bills mid-cycle quantity changes. 'arrear' (default) bills at period end. 'prorated_legacy' is only returned for prices still on the legacy immediate-proration behavior; omit it to migrate the price to 'arrear'."})}))(t,ge),{CreditDimensionNameSchema:we}=((e,i,r)=>({CreditDimensionNameSchema:e.string().min(1).max(i).refine(a=>!a.includes(r),{message:`Dimension names cannot contain "${r}"`})}))(t,Se,_e),{ApiCreditMatchSchema:Y}=(e=>({ApiCreditMatchSchema:e.meta({description:"Event properties this entry applies to. Every key must equal the tracked property, compared as strings."})}))(Ie),{findCreditTierViolations:je}=(e=>({findCreditTierViolations:r=>{let n=[],a=(c,m)=>n.push({index:c,reason:m,message:e[m]}),u=0;for(let[c,m]of r.entries()){let l=c===r.length-1;if(m==="inf"){l||a(c,"non_final_infinity");continue}(!Number.isFinite(m)||m<=u)&&a(c,"not_increasing"),u=m,l&&a(c,"final_not_infinity")}return n}}))(xe),{ApiCreditMultiplierSchema:Re}=((e,i)=>({ApiCreditMultiplierSchema:e.object({match:i,factor:e.number().positive().optional().meta({description:"Multiplies the matched rate. All matching multipliers stack."}),add:e.number().optional().meta({description:"Added to the rate after every factor is applied, in credits per billing-unit group."})}).strict().refine(n=>n.factor!==void 0||n.add!==void 0,{message:"A multiplier needs a factor or an add."})}))(t,Y),{ProviderMarkupsSchema:De}=((e,i)=>({ProviderMarkupsSchema:e.record(e.string(),i).nullish()}))(t,K),{InvoiceFeatureQuantitySchema:H}=((e,i,r)=>({InvoiceFeatureQuantitySchema:e.object({feature_id:e.string().meta({description:"The feature to bill."}),billing_behavior:e.enum(i).meta({description:"Which of the feature's prices to use: 'prepaid' or 'usage_based'."}),quantity:e.number().nonnegative().optional().meta({description:"Billable feature units in total, exclusive of any included usage. Not per seat or per entity. For a credit-system feature this is the number of credits."}),usage:e.array(r).optional().meta({description:"For credit-system features: billable units of the source features, converted through the credit rate card. Mutually exclusive with quantity."}),prorate:e.boolean().optional().meta({description:"Whether to prorate this line against period_start / period_end. Defaults to true for prepaid and false for usage-based."})}).strict().refine(a=>a.quantity!==void 0!=(a.usage!==void 0),{message:"Provide exactly one of quantity or usage."})}))(t,G,Ae),{CreateInvoicePreviewSchema:bt}=((e,i)=>({CreateInvoicePreviewSchema:e.object({currency:e.string(),lines:e.array(i),subtotal:e.number(),discount_total:e.number(),tax:e.object({total:e.number(),amount_inclusive:e.number(),amount_exclusive:e.number(),status:e.enum(["complete","incomplete"])}).nullable(),total:e.number(),due_date:e.number().nullable()})}))(t,Pe),{SUPPORTED_SET:ke}=(e=>({SUPPORTED_SET:new Set(e)}))(Ee),{ApiCreditDimensionBaseSchema:Ne}=((e,i)=>({ApiCreditDimensionBaseSchema:e.object({match:i,priority:e.number().int().optional().meta({description:"Breaks ties between dimensions that match the same number of keys. Higher wins."})})}))(t,Y),{refineGraduatedTiers:X}=(e=>({refineGraduatedTiers:(r,n)=>{let a=e(r.tiers.map(u=>u.to));for(let{index:u,message:c}of a)n.addIssue({code:"custom",message:c,path:["tiers",u,"to"]})}}))(je),{ApiFeatureMarkupsOverrideSchema:Ue}=((e,i,r)=>({ApiFeatureMarkupsOverrideSchema:e.strictObject({default_markup:e.number().min(-100).optional().meta({description:"Default percentage markup for customers on this plan. Use -100 to make usage free."}),provider_markups:i.meta({description:"Per-provider markup percentages for customers on this plan."}),model_markups:r.meta({description:"Per-model markup overrides for customers on this plan."})})}))(t,De,ve),{isValidCurrencyCode:qe}=(e=>({isValidCurrencyCode:r=>!!r&&e.has(r.toLowerCase())}))(ke),{ApiCreditDimensionSchema:Be}=((e,i,r,n)=>({ApiCreditDimensionSchema:e.union([i.extend({tier_behavior:e.literal("graduated"),tiers:e.array(r).min(1)}).strict().superRefine(n),i.extend({credit_cost:e.number().min(0).meta({description:"Credits consumed per billing-unit group when this dimension matches."})}).strict()])}))(t,Ne,$,X),{CurrencyCodeSchema:J}=((e,i)=>({CurrencyCodeSchema:e.string().refine(i,"must be a Stripe-supported currency code").meta({description:"Three-letter Stripe-supported currency code (e.g. 'eur', 'gbp')."})}))(t,qe),{AdditionalCurrencyTierSchema:Fe}=((e,i)=>({AdditionalCurrencyTierSchema:e.object({currency:i,amount:e.number().optional().meta({description:"Per-unit amount for this tier in this currency."}),flat_amount:e.number().optional().meta({description:"Flat amount for this tier in this currency, if the tier uses one."})}).refine(n=>n.amount!==void 0||n.flat_amount!==void 0,{message:"Either amount or flat_amount, or both must be defined",path:["amount","flat_amount"]})}))(t,J),{ApiCreditSchemaItemBaseSchema:z}=((e,i,r,n)=>({ApiCreditSchemaItemBaseSchema:e.object({metered_feature_id:e.string().nonempty().meta({description:"ID of the metered feature that draws from this credit system."}),billing_units:e.number().positive().optional().meta({description:"Number of metered-feature units priced together. Defaults to one when omitted."}),dimensions:e.record(i,r).optional().meta({description:"Named rates chosen by event properties. The most specific match sets the rate; with no match the item's own rate applies."}),multipliers:e.record(i,n).optional().meta({description:"Named adjustments chosen by event properties. Every match applies: factors multiply, then adds are summed."})})}))(t,we,Be,Re),{ApiFlatCreditSchemaItemSchema:Le}=((e,i)=>({ApiFlatCreditSchemaItemSchema:e.extend({credit_cost:i.number().min(0).meta({description:"Credits consumed per billing-unit group."})}).strict()}))(z,t),{AdditionalCurrencyPriceSchema:Qe}=((e,i)=>({AdditionalCurrencyPriceSchema:e.object({currency:i,amount:e.number().meta({description:"Price amount in this currency. Set explicitly per currency, not converted from the base amount."})})}))(t,J),{AdditionalCurrencyTierArraySchema:Ve}=((e,i,r,n)=>({AdditionalCurrencyTierArraySchema:e.array(i).refine(r,{message:n})}))(t,Fe,Q,V),{ApiGraduatedCreditSchemaItemSchema:Ge}=((e,i,r,n)=>({ApiGraduatedCreditSchemaItemSchema:e.extend({tier_behavior:i.literal("graduated"),tiers:i.array(r).min(1)}).strict().superRefine(n)}))(z,t,$,X),{AdditionalCurrencyPriceArraySchema:ee}=((e,i,r,n)=>({AdditionalCurrencyPriceArraySchema:e.array(i).refine(r,{message:n})}))(t,Qe,Q,V),{ApiUsageTierWithCurrenciesSchema:$e}=((e,i,r)=>({ApiUsageTierWithCurrenciesSchema:e.object({to:e.number().or(e.literal(i)),amount:e.number().optional(),flat_amount:e.number().optional(),additional_currencies:r.optional().meta({description:"Per-currency amounts for this tier. Tier boundaries ('to') are shared across all currencies."})}).refine(a=>a.amount!==void 0||a.flat_amount!==void 0,{message:"Either amount or flat_amount, or both must be defined",path:["amount","flat_amount"]}).transform(a=>({...a,amount:a.amount??0})).pipe(e.object({to:e.number().or(e.literal(i)),amount:e.number(),flat_amount:e.number().optional(),additional_currencies:r.optional()}))}))(t,be,Ve),{ApiCreditSchemaItemSchema:Ke}=((e,i,r)=>({ApiCreditSchemaItemSchema:e.union([i,r])}))(t,Ge,Le),{BasePriceParamsSchema:Ze}=((e,i,r,n)=>({BasePriceParamsSchema:e.omit({display:!0}).extend({interval_count:i({schema:r.number().optional(),defaultValue:1,description:"Number of intervals per billing cycle. Defaults to 1."}),additional_currencies:n.optional().meta({description:"Base price amounts in additional currencies. The base 'amount' is in the org's default currency."}),base_currency:r.string().optional().meta({internal:!0}),entitlement_id:r.string().optional().meta({internal:!0}),price_id:r.string().optional().meta({internal:!0}),stripe_price_id:r.string().optional().meta({description:"Stripe price id this base price is billed under. Set by sync flows to capture the actual Stripe price when it differs from the catalog default.",internal:!0})}).meta({title:"BasePrice",description:"Base price configuration for a plan."})}))(Oe,pe,t,ee),{PlanItemPriceParamsSchema:We}=((e,i,r,n,a,u,c)=>({PlanItemPriceParamsSchema:e.object({stripe_price_id:e.string().nullish().transform(l=>l??void 0).meta({description:"Stripe price id this feature price is billed under. Set by sync flows to preserve an existing Stripe price.",internal:!0}).optional(),amount:e.number().optional().meta({description:"Price per billing_units after included usage. Either 'amount' or 'tiers' is required."}),additional_currencies:i.optional().meta({description:"Amounts in additional currencies for this flat price. The base 'amount' is in the org's default currency. Only valid with 'amount', not 'tiers'."}),tiers:e.array(r).optional().meta({description:"Tiered pricing. Either 'amount' or 'tiers' is required."}),tier_behavior:e.enum(n).optional(),interval:e.enum(a).meta({description:"Billing interval. For consumable features, should match reset.interval."}),interval_count:e.number().default(1).optional().meta({description:"Number of intervals per billing cycle. Defaults to 1."}),billing_units:e.number().default(1).optional().meta({description:"Units per price increment. Usage is rounded UP when billed (e.g. billing_units=100 means 101 rounds to 200)."}),billing_method:e.enum(u).meta({description:"'prepaid' for upfront payment (seats), 'usage_based' for pay-as-you-go."}),allocated_billing:c,max_purchase:e.number().nullish().meta({description:"Max units purchasable beyond included. E.g. included=100, max_purchase=300 allows 400 total. Null for no limit."})})}))(t,ee,$e,ye,F,G,Te),{ApiFeatureOverrideSchema:Ye}=((e,i,r)=>({ApiFeatureOverrideSchema:e.strictObject({credit_schema:e.array(i).optional().meta({description:"For credit system features: replaces the feature's credit_schema entirely for customers on this plan."}),markups:r.optional().meta({description:"For AI credit system features: replaces the feature's markup chain entirely for customers on this plan. An unset level means no markup at that level rather than inheriting the feature's."})})}))(t,Ke,Ue),{InvoiceBasePriceParamsSchema:te}=((e,i)=>({InvoiceBasePriceParamsSchema:e.pick({amount:!0,interval:!0,interval_count:!0}).extend({processors:i.optional().meta({description:"Bill this line under an existing Stripe price instead of an inline one."})}).strict()}))(Ze,W),{InvoiceItemPriceParamsSchema:He}=((e,i)=>({InvoiceItemPriceParamsSchema:e.pick({amount:!0,tiers:!0,tier_behavior:!0,interval:!0,interval_count:!0,billing_units:!0,billing_method:!0}).extend({processors:i.optional().meta({description:"Bill this line under an existing Stripe price instead of an inline one."})}).strict()}))(We,W),{InvoiceLicenseQuantitySchema:Xe}=((e,i,r)=>({InvoiceLicenseQuantitySchema:e.object({license_plan_id:e.string().meta({description:"The license plan linked to the parent plan."}),quantity:e.number().int().nonnegative().meta({description:"Billable seats, exclusive of any included seats."}),customize:e.object({price:i.nullable().optional()}).strict().optional().meta({description:"Override the license's per-seat price on this invoice."}),feature_quantities:e.array(r).optional().meta({description:"Feature charges priced through the license plan."}),prorate:e.boolean().optional().meta({description:"Whether to prorate seat charges against period_start / period_end. Defaults to true."})}).strict()}))(t,te,H),{InvoiceCustomizeItemSchema:Je}=((e,i,r)=>({InvoiceCustomizeItemSchema:e.object({feature_id:e.string().meta({description:"The feature whose pricing is overridden on this invoice."}),price:i.optional().meta({description:"Pricing to use for this feature on this invoice."}),feature_override:r.pick({credit_schema:!0}).strict().optional().meta({description:"For credit-system features: a credit rate card to use when converting `usage` on this invoice."})}).strict()}))(t,He,Ye),{InvoiceCustomizeSchema:ze}=((e,i,r)=>({InvoiceCustomizeSchema:e.object({price:i.nullable().optional().meta({description:"Override the plan's base price for this invoice. Pass null or an amount of 0 to omit the base price line."}),items:e.array(r).optional().meta({description:"Override feature pricing for this invoice. Only pricing fields are accepted; grants, resets and rollovers are not part of an invoice."})}).strict().meta({title:"InvoiceCustomize",description:"Pricing overrides applied to this invoice only. The catalog and the customer's plan are not changed."})}))(t,te,Je),{InvoicePlanParamsSchema:et}=((e,i,r,n,a)=>({InvoicePlanParamsSchema:e.object({plan_id:e.string().meta({description:"The catalog plan (or variant) whose pricing to use."}),version:e.number().optional().meta({description:"Plan version. Defaults to the active version."}),customize:i.optional(),feature_quantities:e.array(r).optional(),license_quantities:e.array(n).optional(),discounts:e.array(a).optional().meta({description:"Discounts applied only to this plan's lines."}),prorate:e.boolean().optional().meta({description:"Whether to prorate the base price against period_start / period_end. Defaults to true."})}).strict()}))(t,ze,H,Xe,Z),{CreateInvoiceParamsSchema:yt}=((e,i,r,n,a)=>({CreateInvoiceParamsSchema:e.object({customer_id:e.string().meta({description:"The customer to invoice."}),plans:e.array(i).optional(),custom_line_items:e.array(r).optional().meta({description:"Charges that are not tied to any plan or feature."}),discounts:e.array(n).optional().meta({description:"Discounts applied to the whole invoice."}),invoice_template_id:e.string().optional().meta({description:"ID of an invoice template whose footer, memo and default payment terms are applied."}),net_terms_days:e.number().int().positive().optional().meta({description:"Days until the invoice is due. Defaults to the template's terms, then the org default."}),tax_rate_id:e.string().optional().meta({description:"Stripe tax rate ID (txr_...) applied to every line."}),period_start:a.optional().meta({description:"Start of the period being invoiced, in milliseconds. Prorated lines are charged for period_start \u2192 period_end against one price interval starting at period_start."}),period_end:a.optional().meta({description:"End of the period being invoiced, in milliseconds."}),preview:e.boolean().optional().meta({description:"If true, returns the calculated lines and totals without creating an invoice."})}).strict().refine(c=>c.period_start===void 0==(c.period_end===void 0),{message:"period_start and period_end must be provided together."}).refine(c=>c.period_start===void 0||c.period_end===void 0||c.period_end>c.period_start,{message:"period_end must be after period_start."})}))(t,et,Ce,Z,Me);var E=t.object({type:t.literal("native_purchase"),receiptId:t.uuid(),orderId:t.uuid(),productVersionId:t.uuid(),provider:t.enum(["apple","google"]),productId:t.string().min(1).max(255),productKind:U,replacement:t.strictObject({sourceOrderId:t.uuid(),sourceProductId:t.string().min(1).max(255),policy:t.enum(["apple_store","google_full_price"]),sourceAccountTokens:t.array(t.uuid()).max(50)}).nullable(),appAccountToken:t.uuid().optional(),obfuscatedAccountId:t.string().min(1).max(64).optional(),obfuscatedProfileId:t.uuid().optional(),basePlanId:t.string().min(1).max(255).optional(),offerId:t.string().min(1).max(255).optional(),offerKind:t.enum(["none","introductory","promotional"]),currency:s,catalogAmountMinor:t.number().int().nonnegative().max(1e8),discountMinor:t.number().int().nonnegative().max(1e8),trialDays:t.number().int().min(1).max(730).nullable(),seatBundle:t.array(t.strictObject({key:t.string().regex(/^[a-z][a-z0-9_]{0,63}$/),quantity:t.number().int().min(1).max(1e4)})).max(20),applePromotionalOffer:t.strictObject({offerId:t.string().min(1).max(255),keyId:t.string().min(1).max(255),nonce:t.uuid(),signature:t.string().min(1).max(1024),timestamp:t.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)}).nullable()}).strict().superRefine((e,i)=>{let r=e.provider==="apple";(e.replacement!==null&&(e.productKind!=="membership"||e.offerKind!=="none"||e.trialDays!==null||e.replacement.policy!==(r?"apple_store":"google_full_price"))||e.productKind!=="membership"&&(e.trialDays!==null||e.offerKind!=="none"||e.basePlanId!==void 0)||!r&&e.productKind==="membership"&&e.basePlanId===void 0||e.discountMinor>e.catalogAmountMinor||new Set(e.seatBundle.map(a=>a.key)).size!==e.seatBundle.length||e.trialDays!==null&&(e.discountMinor!==0||e.offerKind==="none")||e.offerKind==="none"&&e.discountMinor!==0||(r?!e.appAccountToken||e.obfuscatedAccountId!==void 0||e.obfuscatedProfileId!==void 0||e.basePlanId!==void 0||e.offerKind==="promotional"!=(e.applePromotionalOffer!==null)||e.offerKind==="promotional"!=(e.offerId!==void 0)||e.applePromotionalOffer!==null&&e.applePromotionalOffer.offerId!==e.offerId:e.appAccountToken!==void 0||!e.obfuscatedAccountId||!e.obfuscatedProfileId||e.applePromotionalOffer!==null||e.offerKind==="none"!=(e.offerId===void 0)))&&i.addIssue({code:"custom",message:"Native purchase terms must match the accepted store selection"})});var ie=t.strictObject({itemKey:t.string().regex(/^paid:feature:[a-f0-9]{8}-[a-f0-9]{4}-[1-8][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/),internal_feature_id:t.uuid(),includedAmount:t.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/),quantity:t.number().int().min(0).max(1e4),terms:k,pricing:D.optional(),unitAmountMinor:t.number().int().min(0).max(1e8),productId:t.string().min(1).max(255).nullable(),priceId:t.string().min(1).max(255).nullable()}).superRefine((e,i)=>{(e.quantity<e.terms.minimumQuantity||e.quantity>e.terms.maximumQuantity||e.productId===null!=(e.priceId===null)||e.quantity>0&&(e.pricing||e.unitAmountMinor>0)&&e.priceId===null)&&i.addIssue({code:"custom",message:"Purchased quantities need their published bounds and immutable price binding"});try{N(e.includedAmount,e.terms.units,e.quantity),g({quantity:e.quantity,unitAmountMinor:e.unitAmountMinor,...e.pricing===void 0?{}:{pricing:e.pricing}})}catch{i.addIssue({code:"custom",message:"Purchased allowance exceeds the ledger quantity limit"})}});var _=t.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/,"ID \u4F7F\u7528\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u4E0B\u5212\u7EBF\uFF0C\u5E76\u4EE5\u5B57\u6BCD\u5F00\u5934"),Et=t.object({amountCents:t.number().int().min(0).max(1e8),currency:s,interval:t.enum(["free","month","year"]),currencyOptions:t.partialRecord(s,t.number().int().min(1).max(1e8)).optional()}).refine(e=>e.interval==="free"?e.amountCents===0:e.amountCents>0,"\u514D\u8D39\u5957\u9910\u91D1\u989D\u5FC5\u987B\u4E3A 0\uFF0C\u4ED8\u8D39\u91D1\u989D\u5FC5\u987B\u5927\u4E8E 0").refine(e=>!e.currencyOptions||!Object.hasOwn(e.currencyOptions,e.currency)&&(e.interval!=="free"||Object.keys(e.currencyOptions).length===0),"\u9644\u52A0\u5E01\u79CD\u4E0D\u80FD\u91CD\u590D\u9ED8\u8BA4\u5E01\u79CD\uFF1B\u514D\u8D39\u5957\u9910\u4E0D\u8BBE\u7F6E\u9644\u52A0\u4EF7\u683C");var $t=t.strictObject({requestId:t.uuid(),predecessorOperationId:t.uuid().optional(),invoiceMode:p.optional(),entityId:t.uuid().optional(),billingSubscriptionId:t.uuid().optional(),newBillingSubscription:t.literal(!0).optional(),offerId:t.uuid().optional(),nativeOffer:O.optional(),plans:t.array(t.strictObject({productVersionId:t.uuid(),seatQuantities:t.record(_,t.number().int().min(0).max(1e4)).optional(),featureQuantities:t.record(t.uuid(),t.number().int().min(0).max(1e4)).refine(e=>Object.keys(e).length<=100,"At most 100 feature quantities").optional()})).min(1).max(20).refine(e=>new Set(e.map(i=>i.productVersionId)).size===e.length,"Plan versions must be unique"),provider:t.enum(["stripe","apple","google","merchant"]),currency:s}).refine(e=>!e.offerId||!e.billingSubscriptionId&&(["stripe","merchant"].includes(e.provider)||e.nativeOffer!==void 0),"Held offers apply to new purchases; existing subscriptions use billing coupons").refine(e=>!e.nativeOffer||["apple","google"].includes(e.provider)&&e.plans.length===1,"A store selection applies to exactly one native SKU").refine(e=>!e.newBillingSubscription||["stripe","merchant"].includes(e.provider)&&!e.billingSubscriptionId,"A new billing subscription has no existing subscription target").refine(e=>!e.invoiceMode?.enabled||e.provider==="stripe"&&!e.entityId,"Invoice mode requires a Stripe subscription without an Entity target"),Kt=t.strictObject({operationId:t.uuid()}),o=t.number().int().min(0).max(1e8),tt=t.strictObject({lineId:t.uuid(),productVersionId:t.uuid(),productName:t.string().min(1).max(80),interval:t.enum(["free","week","month","year","one_time"]),intervalCount:t.number().int().min(1).max(156).optional(),baseAmountMinor:o,seats:t.array(t.strictObject({key:_,quantity:t.number().int().min(0).max(1e4),includedQuantity:t.number().int().min(0).max(1e4),maximumQuantity:t.number().int().min(0).max(1e4),unitAmountMinor:o})).max(20),prepaid:t.array(ie).max(100).optional(),catalogAmountMinor:o,trial:w.nullable()}).refine(e=>new Set(e.seats.map(i=>i.key)).size===e.seats.length&&e.seats.every(i=>i.quantity>=i.includedQuantity&&i.quantity<=i.maximumQuantity)&&e.baseAmountMinor+e.seats.reduce((i,r)=>i+r.unitAmountMinor*(r.quantity-r.includedQuantity),0)+(e.prepaid??[]).reduce((i,r)=>i+g({quantity:r.quantity,unitAmountMinor:r.unitAmountMinor,...r.pricing===void 0?{}:{pricing:r.pricing}}),0)===e.catalogAmountMinor,"Quote must retain its published base price and component quantities"),ae=t.string().regex(/^[A-Za-z0-9_-]{1,200}$/),it=t.strictObject({id:ae,name:t.string().min(1).max(40),percent_off:t.number().gt(0).max(100).optional(),amount_off:t.number().int().positive().optional(),currency:t.string().regex(/^[a-z]{3}$/).optional(),duration:t.enum(["once","repeating","forever"]),duration_in_months:t.number().int().min(1).max(36).optional()}).refine(e=>e.percent_off===void 0!=(e.amount_off===void 0)&&e.amount_off===void 0==(e.currency===void 0)&&e.duration==="repeating"==(e.duration_in_months!==void 0),"A Stripe coupon has one percentage or amount and months only when repeating"),rt=t.strictObject({subscriptionId:t.string().regex(/^sub_[A-Za-z0-9]+$/),customerId:t.string().regex(/^cus_[A-Za-z0-9]+$/),sourceItems:t.array(t.strictObject({id:t.string(),price_id:t.string(),quantity:t.number().int().nonnegative(),discounts:t.array(t.strictObject({id:t.string(),coupon:t.string(),start:t.number(),end:t.number().nullable()})).optional()})).min(1).max(100),prorationDate:t.number().int().nonnegative(),amountMinor:t.number().int().positive(),periodStartMs:t.number(),periodEndMs:t.number()}),oe=t.strictObject({invoiceMode:p.optional(),append:rt.optional(),provider:t.literal("stripe"),executor:t.enum(["indiana","merchant"]),accountId:t.string().regex(/^acct_[A-Za-z0-9]+$/),mode:t.enum(["payment","subscription"]),lineItems:t.array(t.strictObject({price:t.string().regex(/^price_[A-Za-z0-9]+$/).nullable(),quantity:t.number().int().min(1).max(1e4),priceId:t.uuid(),productName:t.string().min(1).max(80),amountMinor:t.number().int().min(0).max(1e8),currency:t.string().regex(/^[a-z]{3}$/),interval:t.enum(["week","month","year","one_off"]),intervalCount:t.number().int().min(1).max(52),slot:t.enum(["stripe_price_id","stripe_empty_price_id"]),tiers:t.strictObject({mode:t.enum(["graduated","volume"]),tiers:t.array(t.strictObject({upTo:t.number().int().min(1).max(1e6).nullable(),unitAmountMinor:t.number().int().min(0).max(1e8),flatAmountMinor:t.number().int().min(0).max(1e8).optional()})).min(2).max(12)}).nullable()})).min(1).max(100),discounts:t.array(t.strictObject({coupon:ae,terms:it})).max(1),trialPeriodDays:t.number().int().min(1).max(730).nullable(),metadata:t.strictObject({grooveCheckoutId:t.uuid(),grooveCustomerId:t.uuid()}),expiresAt:t.iso.datetime({offset:!0})}),nt=t.strictObject({operationId:t.uuid(),merchantTerms:b.optional(),entityId:t.uuid().nullable(),billingSubscriptionId:t.uuid().nullable(),discount:t.strictObject({offerId:t.uuid(),couponId:t.uuid(),discount:q,duration:B,amountMinor:o,allocations:t.array(t.strictObject({productVersionId:t.uuid(),amountMinor:o})).min(1).max(20),expiresAt:t.iso.datetime({offset:!0})}).nullable(),charge:t.strictObject({effectiveAt:t.iso.datetime({offset:!0}),periodEndsAt:t.iso.datetime({offset:!0}),debitMinor:o,discountMinor:o,taxMinor:o,totalMinor:o}).nullable(),expiresAt:t.iso.datetime({offset:!0}),provider:t.enum(["stripe","apple","google","merchant"]),nativeOffer:O.optional(),currency:s,lines:t.array(tt).min(1).max(20),catalogAmountMinor:o,nativeDiscountMinor:o.optional(),automaticTax:t.boolean(),execution:t.union([oe,v]).nullable()}).refine(e=>!e.merchantTerms||e.provider==="merchant"&&y(e.merchantTerms,e.operationId,"purchase",e.currency)).refine(e=>e.provider==="merchant"?e.execution?.provider==="merchant"&&e.execution.operationId===e.operationId&&e.execution.catalogAmountMinor===e.catalogAmountMinor&&e.execution.currency===e.currency&&Date.parse(e.execution.expiresAt)<=Date.parse(e.expiresAt)&&e.execution.trialPeriodDays===(e.lines[0]?.trial?.days??null)&&e.execution.discount?.grantId===e.discount?.offerId:e.provider==="stripe"?e.execution?.provider!=="merchant"&&(e.lines[0]?.trial?.cardRequired===!1&&!e.execution?.invoiceMode?.enabled?e.execution===null&&e.discount===null:e.execution!==null&&e.execution.metadata.grooveCheckoutId===e.operationId&&Date.parse(e.execution.expiresAt)<=Date.parse(e.expiresAt)&&e.execution.mode===(e.lines.some(i=>!["one_time","free"].includes(i.interval))?"subscription":"payment")&&e.execution.trialPeriodDays===(e.lines[0]?.trial?.days??null)&&(e.execution.executor==="indiana"||e.execution.lineItems.every(i=>i.price!==null))&&e.execution.discounts.every(i=>i.coupon===i.terms.id)&&e.execution.discounts.length===(e.discount?1:0)&&e.execution.discounts.every(i=>e.discount!==null&&(i.coupon===e.discount.couponId||e.discount.discount.type==="amount"&&i.coupon===`${e.discount.couponId}_credit_${e.discount.offerId}_${i.terms.amount_off}`&&i.terms.amount_off===e.discount.discount.amountOffCents&&i.terms.currency?.toUpperCase()===e.currency&&i.terms.duration==="once"))):e.execution===null,"Stripe execution must carry the quote identity, expiry, mode, trial and held coupon").refine(e=>(!e.discount||!e.billingSubscriptionId&&(["stripe","merchant"].includes(e.provider)||e.discount.duration.type==="once")&&e.discount.amountMinor<=e.catalogAmountMinor&&e.discount.allocations.length===e.lines.length&&e.discount.allocations.every((i,r)=>{let n=e.lines[r];return n!==void 0&&i.productVersionId===n.productVersionId&&i.amountMinor<=n.catalogAmountMinor})&&e.discount.allocations.reduce((i,r)=>i+r.amountMinor,0)===e.discount.amountMinor)&&(["stripe","merchant"].includes(e.provider)?e.nativeOffer===void 0:e.nativeOffer!==void 0&&e.lines.length===1&&e.nativeOffer.discountMinor<=e.catalogAmountMinor&&e.nativeOffer.trialDays===(e.lines[0]?.trial?.days??null)&&(!e.discount||e.nativeOffer.discountMinor===e.discount.amountMinor))&&(!e.charge||e.billingSubscriptionId!==null&&e.charge.totalMinor===e.charge.debitMinor-e.charge.discountMinor+e.charge.taxMinor&&e.charge.discountMinor<=e.charge.debitMinor&&Date.parse(e.charge.periodEndsAt)>Date.parse(e.charge.effectiveAt))&&new Set(e.lines.map(i=>i.lineId)).size===e.lines.length&&e.lines.reduce((i,r)=>i+r.catalogAmountMinor,0)===e.catalogAmountMinor,"Quote lines must conserve the catalog amount"),Zt=t.strictObject({operationId:t.uuid(),orderId:t.uuid(),append:t.boolean().optional(),invoiceMode:t.boolean().optional(),status:t.enum(["pending","complete","cancelled","failed"]),executor:t.enum(["indiana","merchant"]),checkoutUrl:t.url().refine(e=>new URL(e).protocol==="https:").nullable(),execution:t.union([oe,v]).nullable(),currency:s,catalogAmountMinor:o,taxMinor:o,totalMinor:t.number().int().min(0).max(2e8).nullable(),quoteFinalized:t.boolean(),nativePurchase:E.nullable(),confirmedAt:t.iso.datetime({offset:!0}).nullable().optional(),quote:nt.optional(),merchantExecution:f.nullable().optional(),problem:h.nullable().optional(),authority:S.optional()}).refine(e=>(e.checkoutUrl===null||e.executor==="indiana"||e.merchantExecution?.type==="purchase")&&(e.execution===null||e.executor==="merchant"),"Only Indiana-executed purchases carry a Checkout URL and only record-only purchases carry execution instructions"),x=t.strictObject({enabled:t.literal(!0),featureIds:t.array(t.uuid()).min(1).max(100).refine(e=>new Set(e).size===e.length,"Feature IDs must be unique").optional()}),Wt=t.strictObject({requestId:t.uuid(),offerId:t.uuid().optional(),invoiceMode:p.optional(),membershipId:t.uuid(),carryOverBalances:x.optional(),carryOverUsages:x.optional(),membershipIds:t.array(t.uuid()).min(1).max(20).optional(),prorationBehavior:t.enum(["prorate_immediately","none","bill_difference"]).optional(),timing:t.enum(["immediate","renewal","store"]),change:t.discriminatedUnion("type",[t.strictObject({type:t.literal("plan"),productVersionId:t.uuid()}),t.strictObject({type:t.literal("seats"),licenseKey:_,quantity:t.number().int().min(0).max(1e4)}),t.strictObject({type:t.literal("quantity"),internal_feature_id:t.uuid(),quantity:t.number().int().min(0).max(1e4)}),t.strictObject({type:t.literal("cancel")}),t.strictObject({type:t.literal("uncancel")}),t.strictObject({type:t.literal("billing_cycle"),billingCycleAnchor:t.union([t.literal("now"),t.number().int().positive().max(0xe677d21fdbff)])})])}).refine(e=>!e.offerId||e.change.type==="plan"&&e.timing!=="store","A selected plan-change offer requires a merchant target Product").refine(e=>e.timing!=="store"||e.change.type==="plan","Store timing applies to a native plan replacement").refine(e=>e.change.type!=="billing_cycle"||e.timing===(e.change.billingCycleAnchor==="now"?"immediate":"renewal"),"Use immediate for now and renewal for a future millisecond anchor").refine(e=>!e.membershipIds||["cancel","uncancel"].includes(e.change.type)&&e.membershipIds.includes(e.membershipId)&&new Set(e.membershipIds).size===e.membershipIds.length,"Grouped actions require unique cancel/uncancel targets including the primary membership").refine(e=>!e.carryOverBalances&&!e.carryOverUsages||e.change.type==="plan"&&e.timing==="immediate","Carry applies only to immediate upgrades").refine(e=>!e.prorationBehavior||e.change.type==="quantity","prorationBehavior applies to prepaid quantity changes"),I=t.string().regex(/^price_[A-Za-z0-9]+$/),re=t.strictObject({grooveUpdateId:t.uuid(),grooveCustomerId:t.uuid()}),ne=t.strictObject({price:I.nullable(),priceId:t.uuid().optional(),quantity:t.number().int().min(0).max(1e4)}),ce=t.strictObject({provider:t.literal("stripe"),invoiceMode:p.optional(),executor:t.enum(["indiana","merchant"]),accountId:t.string().regex(/^acct_[A-Za-z0-9]+$/),subscriptionId:t.string().regex(/^sub_[A-Za-z0-9]+$/),action:t.enum(["update","cancel","schedule","release"]),update:t.strictObject({items:t.array(ne).max(20),remove:t.array(I).max(20),restoreItems:t.array(t.strictObject({price:I,quantity:t.number().int().min(0).max(1e4)})).min(1).max(20).optional(),prorationBehavior:t.enum(["always_invoice","create_prorations","none"]).optional(),prorationDate:t.number().int().positive().optional(),paymentBehavior:t.literal("error_if_incomplete").optional(),cancelAtPeriodEnd:t.boolean().optional(),clearCancelAt:t.literal(!0).optional(),billingCycleAnchorNow:t.literal(!0).optional(),metadata:re}).nullable(),cancel:t.strictObject({prorate:t.literal(!1),invoiceNow:t.literal(!1)}).nullable(),schedule:t.strictObject({currentItems:t.array(t.strictObject({price:I,quantity:t.number().int().min(0).max(1e4)})).max(20),nextItems:t.array(ne).min(1).max(20),switchAt:t.number().int().positive(),interval:t.enum(["week","month","year"]),intervalCount:t.number().int().min(1).max(52),resetBillingCycleAnchor:t.literal(!0).optional(),metadata:re}).nullable(),release:t.strictObject({schedule:t.string().regex(/^sub_sched_[A-Za-z0-9]+$/)}).nullable(),expiresAt:t.iso.datetime({offset:!0})}).refine(e=>["update","cancel","schedule","release"].every(i=>e[i]!==null==(e.action===i))&&(e.executor==="indiana"||[...e.update?.items??[],...e.schedule?.nextItems??[]].every(i=>i.price!==null)),"Stripe update execution carries exactly its action, with bound Prices for the merchant"),se=t.strictObject({merchantTerms:b.optional(),carryOverBalances:x.optional(),carryOverUsages:x.optional(),operationId:t.uuid(),membershipId:t.uuid(),productVersionId:t.uuid(),timing:t.enum(["immediate","renewal"]),effectiveAt:t.iso.datetime({offset:!0}),expiresAt:t.iso.datetime({offset:!0}),currency:s,creditMinor:o,debitMinor:o,discountMinor:o,taxMinor:o,totalMinor:o,retainedProductVersionIds:t.array(t.uuid()).max(19),execution:t.union([ce,A])}).refine(e=>!e.merchantTerms||e.execution.provider==="merchant"&&y(e.merchantTerms,e.operationId,"subscription_change",e.currency)),at=t.strictObject({operationId:t.uuid(),invoiceMode:t.boolean().optional(),membershipId:t.uuid(),productVersionId:t.uuid(),status:t.enum(["prepared","quoted","confirmed","pending","scheduled","effective","cancelled","failed"]),timing:t.enum(["immediate","renewal"]),effectiveAt:t.iso.datetime({offset:!0}),checkoutUrl:t.url().refine(e=>new URL(e).protocol==="https:").nullable(),executor:t.enum(["indiana","merchant"]),execution:t.union([ce,A]).nullable(),confirmedAt:t.iso.datetime({offset:!0}).nullable().optional(),merchantExecution:f.nullable().optional(),problem:h.nullable().optional(),quote:se.optional(),authority:S.optional()}).refine(e=>e.execution===null||e.executor==="merchant","Only record-only changes carry execution instructions"),ot=t.strictObject({operationId:t.uuid(),membershipId:t.uuid(),productVersionId:t.uuid(),timing:t.literal("store"),effectiveAt:t.null(),expiresAt:t.iso.datetime({offset:!0}),currency:s,creditMinor:t.null(),debitMinor:t.null(),discountMinor:t.null(),taxMinor:t.null(),totalMinor:t.null(),retainedProductVersionIds:t.array(t.uuid()).max(19),store:t.strictObject({provider:t.enum(["apple","google"]),productId:t.string().min(1).max(255),catalogAmountMinor:o,policy:t.enum(["apple_store","google_full_price"])})}),ct=t.strictObject({operationId:t.uuid(),membershipId:t.uuid(),productVersionId:t.uuid(),status:t.enum(["prepared","pending","effective","cancelled","failed"]),timing:t.literal("store"),effectiveAt:t.iso.datetime({offset:!0}).nullable(),checkoutUrl:t.null(),nativePurchase:E.nullable()}),Yt=t.union([se,ot]),Ht=t.union([at,ct]),T=j,d=R,Xt=t.strictObject({requestId:t.uuid(),invoiceId:t.uuid(),...P.shape}).refine(M,"A partial refund states amountMinor; a full refund refunds the remaining amount"),ue=t.strictObject({provider:t.literal("stripe"),executor:t.enum(["indiana","merchant"]),accountId:t.string().regex(/^acct_[A-Za-z0-9]+$/),invoice:t.string().regex(/^in_[A-Za-z0-9]+$/),amountMinor:T,currency:t.string().regex(/^[a-z]{3}$/),metadata:t.strictObject({indianaRefundId:t.uuid()}),idempotencyKey:t.string().regex(/^indiana-refund-[0-9a-f-]{36}$/),cancelSubscriptions:t.array(t.string().regex(/^sub_[A-Za-z0-9]+$/)).max(20)}),st=t.strictObject({operationId:t.uuid(),merchantTerms:b.optional(),invoiceId:t.uuid(),providerInvoiceId:t.string().min(1).max(200),currency:s,paidMinor:d,refundedMinor:d,pendingMinor:d,amountMinor:T,mode:t.enum(["full","partial"]),entitlementAction:t.enum(["retain","revoke"]),revokes:t.strictObject({customerProductIds:t.array(t.uuid()).max(100),subscriptionIds:t.array(t.string().min(1).max(200)).max(20)}),execution:t.union([ue,C]),expiresAt:t.iso.datetime({offset:!0})}).refine(e=>!e.merchantTerms||e.execution.provider==="merchant"&&y(e.merchantTerms,e.operationId,"refund",e.currency)).refine(e=>e.amountMinor<=e.paidMinor-e.refundedMinor-e.pendingMinor&&e.execution.amountMinor===e.amountMinor&&(e.execution.provider==="merchant"?e.execution.merchantInvoiceId===e.providerInvoiceId&&e.execution.operationId===e.operationId&&e.execution.currency===e.currency:e.execution.invoice===e.providerInvoiceId&&e.execution.metadata.indianaRefundId===e.operationId&&e.execution.currency===e.currency.toLowerCase())&&(e.entitlementAction==="revoke"||e.revokes.customerProductIds.length===0&&e.revokes.subscriptionIds.length===0),"Refund quote must stay within the refundable amount and match its execution"),ut=t.strictObject({operationId:t.uuid(),invoiceId:t.uuid(),providerInvoiceId:t.string().min(1).max(200),status:t.enum(["quoted","pending","succeeded","failed","expired"]),executor:t.enum(["indiana","merchant"]),currency:s,amountMinor:T,mode:t.enum(["full","partial"]),entitlementAction:t.enum(["retain","revoke"]),refundId:t.string().min(1).max(200).nullable(),quote:st.optional(),execution:t.union([ue,C]).nullable(),confirmedAt:t.iso.datetime({offset:!0}).nullable().optional(),merchantExecution:f.nullable().optional(),problem:h.nullable().optional(),authority:S.optional(),failureReason:t.string().min(1).max(200).nullable(),createdAt:t.iso.datetime({offset:!0}),completedAt:t.iso.datetime({offset:!0}).nullable()}).refine(e=>(e.execution===null||e.executor==="merchant"&&e.status==="quoted")&&(e.status!=="succeeded"||e.refundId!==null),"Only quoted record-only refunds carry instructions; a succeeded refund names its Stripe refund"),Jt=t.strictObject({invoiceId:t.uuid(),currency:s,paidMinor:d,refundedMinor:d,pendingMinor:d,refundableMinor:d,executor:t.enum(["indiana","merchant"]).nullable(),canRefund:t.boolean(),operations:t.array(ut).max(50)}).refine(e=>e.operations.every(i=>i.invoiceId===e.invoiceId),"Refund operations belong to the invoice"),zt=t.strictObject({requestId:t.uuid(),...P.shape}).refine(M,"A partial refund states amountMinor; a full refund refunds the remaining amount");export{ht as a,bt as b,yt as c,$t as d,Kt as e,nt as f,Zt as g,Wt as h,se as i,Yt as j,Ht as k,Xt as l,st as m,ut as n};
1
+ import{M as S,a as v,b as A,c as C,f as h,g as f,k as w,l as j,m as R,n as M,o as P,q as b,r as y}from"./chunk-UAJTQ23E.js";import{j as O,o as q,p as B}from"./chunk-KQF4BVOL.js";import{a as D,b as g,c as k,d as N}from"./chunk-HJVEVJXS.js";import{a as s,d as U}from"./chunk-BDC7B4KM.js";import{b as t}from"./chunk-42UXYMRZ.js";var me=t.registry(),{BillingInterval:F}=(()=>{var e;return(function(i){i.OneOff="one_off",i.Week="week",i.Month="month",i.Quarter="quarter",i.SemiAnnual="semi_annual",i.Year="year"})(e||(e={})),{BillingInterval:e}})(),{DisplaySchema:de}=(e=>({DisplaySchema:e.object({primary_text:e.string().meta({description:"Main display text (e.g. '$10' or '100 messages')."}),secondary_text:e.string().optional().meta({description:"Secondary display text (e.g. 'per month' or 'then $0.5 per 100')."})})}))(t),{withSpecDefault:pe}=(e=>({withSpecDefault:({schema:r,defaultValue:n,description:a})=>(e.add(r,{description:a,default:n}),r)}))(me),{COMMON:L}={COMMON:["usd","eur","gbp","cad","aud","jpy","chf","cny","inr"]},{STRIPE_PRESENTMENT_CURRENCIES:le}={STRIPE_PRESENTMENT_CURRENCIES:["usd","aed","afn","all","amd","ang","aoa","ars","aud","awg","azn","bam","bbd","bdt","bif","bmd","bnd","bob","brl","bsd","bwp","byn","bzd","cad","cdf","chf","clp","cny","cop","crc","cve","czk","djf","dkk","dop","dzd","egp","etb","eur","fjd","fkp","gbp","gel","gip","gmd","gnf","gtq","gyd","hkd","hnl","htg","huf","idr","ils","inr","isk","jmd","jpy","kes","kgs","khr","kmf","krw","kyd","kzt","lak","lbp","lkr","lrd","lsl","mad","mdl","mga","mkd","mmk","mnt","mop","mur","mvr","mwk","mxn","myr","mzn","nad","ngn","nio","nok","npr","nzd","pab","pen","pgk","php","pkr","pln","pyg","qar","ron","rsd","rub","rwf","sar","sbd","scr","sek","sgd","shp","sle","sos","srd","std","szl","thb","tjs","top","try","ttd","twd","tzs","uah","ugx","uyu","uzs","vnd","vuv","wst","xaf","xcd","xcg","xof","xpf","yer","zar","zmw"]},{COMMON_SET:he}=(e=>({COMMON_SET:new Set(e)}))(L),{hasNoDuplicateCurrencies:Q}={hasNoDuplicateCurrencies:i=>{let r=new Set;for(let{currency:n}of i){let a=n.toLowerCase();if(r.has(a))return!1;r.add(a)}return!0}},{DUPLICATE_CURRENCY_MESSAGE:V}={DUPLICATE_CURRENCY_MESSAGE:"Each currency may appear at most once in additional_currencies."},{ApiStripePriceProcessorSchema:fe}=(e=>({ApiStripePriceProcessorSchema:e.object({price_id:e.string().meta({description:"Stripe price ID. For prepaid with included > 0 this is the V2 price."})})}))(t),{Infinite:be}={Infinite:"inf"},{TierBehavior:ye}=(()=>{var e;return(function(i){i.Graduated="graduated",i.VolumeBased="volume"})(e||(e={})),{TierBehavior:e}})(),{BillingMethod:G}=(()=>{var e;return(function(i){i.Prepaid="prepaid",i.UsageBased="usage_based"})(e||(e={})),{BillingMethod:e}})(),{AllocatedBilling:ge}=(()=>{var e;return(function(i){i.Arrear="arrear",i.ProratedLegacy="prorated_legacy"})(e||(e={})),{AllocatedBilling:e}})(),{CREDIT_DIMENSION_NAME_MAX_LENGTH:Se}={CREDIT_DIMENSION_NAME_MAX_LENGTH:64},{USAGE_ATTRIBUTION_DIMENSION_SEPARATOR:_e}={USAGE_ATTRIBUTION_DIMENSION_SEPARATOR:"::"},{CreditMatchSchema:Ie}=(e=>({CreditMatchSchema:e.record(e.string(),e.union([e.string(),e.number(),e.boolean()]).transform(String).pipe(e.string()))}))(t),{ApiCreditTierSchema:$}=(e=>({ApiCreditTierSchema:e.object({to:e.union([e.number().positive(),e.enum(["inf"])]).meta({description:"Inclusive upper usage boundary for this graduated tier. The final tier must be 'inf'."}),credit_cost:e.number().min(0).meta({description:"Credits consumed per billing-unit group within this tier."})})}))(t),{VIOLATION_MESSAGES:xe}={VIOLATION_MESSAGES:{non_final_infinity:"Only the final tier may use an 'inf' boundary.",not_increasing:"Tier boundaries must be strictly increasing.",final_not_infinity:"The final tier must use an 'inf' boundary."}},{MarkupEntrySchema:K}=(e=>({MarkupEntrySchema:e.object({markup:e.number().min(-100)})}))(t),{ModelMarkupsSchema:ve}=((e,i)=>({ModelMarkupsSchema:e.record(e.string().regex(/.+\/.+/,'Model keys are "<provider>/<model>", e.g. "openai/gpt-4o" or "custom/my-model".'),i.extend({markup:e.number().min(-100).optional(),input_cost:e.number().min(0).optional(),output_cost:e.number().min(0).optional()})).nullish()}))(t,K),{InvoiceUsageEntrySchema:Ae}=(e=>({InvoiceUsageEntrySchema:e.object({feature_id:e.string().meta({description:"The metered feature whose units are being converted."}),quantity:e.number().nonnegative().meta({description:"Billable units of the metered feature. Converted to the credit-system feature through its rate card."}),properties:e.record(e.string(),e.unknown()).optional().meta({description:"Event properties used to pick the rate card dimension and multipliers."})}).strict()}))(t),{AttachDiscountSchema:Z}=(e=>({AttachDiscountSchema:e.object({reward_id:e.string().optional().meta({description:"The ID of the reward to apply as a discount."}),promotion_code:e.string().optional().meta({description:"The promotion code to apply as a discount."})}).refine(r=>r.reward_id||r.promotion_code,{message:"Either reward_id or promotion_code must be provided."}).meta({title:"AttachDiscount",description:"A discount to apply. Can be either a reward ID or a promotion code."})}))(t),{CustomLineItemSchema:Ce}=(e=>({CustomLineItemSchema:e.object({amount:e.number().meta({description:"Amount in dollars for this line item (e.g. 10.50). Can be negative for credits."}),description:e.string().meta({description:"Description for the line item."})})}))(t),{UnixMsTimestampSchema:Me}=(e=>({UnixMsTimestampSchema:e.number().int().safe().nonnegative()}))(t),{CreateInvoicePreviewLineSchema:Pe}=(e=>({CreateInvoicePreviewLineSchema:e.object({plan_id:e.string().nullable(),feature_id:e.string().nullable(),description:e.string(),amount:e.number(),amount_after_discounts:e.number(),quantity:e.number().nullable(),prorated:e.boolean(),period_start:e.number().nullable(),period_end:e.number().nullable()})}))(t),{ReissueInvoiceParamsSchema:ht}=(e=>({ReissueInvoiceParamsSchema:e.object({invoice_id:e.string().meta({description:"The Autumn invoice ID to void and replace.",example:"inv_2b3c4d5e6f7g8h"}),invoice_template_id:e.string().optional().meta({description:"ID of an invoice template (configured in billing settings) whose footer and memo are applied to the replacement invoice."}),net_terms_days:e.number().int().positive().optional().meta({description:"Number of days the customer has to pay the replacement invoice. Defaults to the original invoice's due date; required when that date has already passed."}),update_customer_email:e.email().optional().meta({description:"Updates the customer's billing email before the replacement is issued, so Stripe sends the new invoice to this address."})})}))(t),{InvoiceModeParamsSchema:p}=(e=>({InvoiceModeParamsSchema:e.object({enabled:e.boolean().meta({description:"When true, creates an invoice and sends it to the customer instead of charging their card immediately. Uses Stripe's send_invoice collection method."}),enable_plan_immediately:e.boolean().default(!1).meta({description:"If true, enables the plan immediately even though the invoice is not paid yet."}),finalize:e.boolean().default(!0).meta({description:"If true, finalizes the invoice so it can be sent to the customer. If false, keeps it as a draft for manual review."}),invoice_template_id:e.string().optional().meta({description:"ID of an invoice template (configured in billing settings) whose footer (e.g. bank details) is applied to the invoice."}),net_terms_days:e.number().int().positive().optional().meta({description:"Number of days the customer has to pay the invoice before it is due (Stripe days_until_due)."})}).meta({title:"InvoiceMode",description:"Invoice mode configuration. Creates an invoice instead of charging the card immediately."})}))(t),{InvoiceTemplateSchema:ft}=(e=>({InvoiceTemplateSchema:e.object({id:e.string().meta({description:"Unique identifier for the invoice template."}),name:e.string().meta({description:"User-defined name to distinguish this template when sending an invoice."}),footer:e.string().optional().meta({description:"Footer text rendered on the invoice, typically bank details so customers can pay directly."}),memo:e.string().optional().meta({description:"Memo shown near the top of the invoice (Stripe invoice description), e.g. a contact line for payment questions."}),net_terms_days:e.number().int().positive().optional().meta({description:"Default number of days the customer has to pay before the invoice is due. Overridable when sending."}),created_at:e.number().optional().meta({description:"Timestamp (ms) when the template was created."})})}))(t),{BasePriceSchema:Oe}=((e,i,r)=>({BasePriceSchema:e.object({amount:e.number().meta({description:"Base price amount for the plan, in major currency units (e.g. dollars)."}),interval:e.enum(i).meta({description:"Billing interval (e.g. 'month', 'year')."}),interval_count:e.number().optional().meta({description:"Number of intervals per billing cycle. Defaults to 1."}),display:r.optional().meta({description:"Display text for showing this price in pricing pages."})})}))(t,F,de),{CURRENCY_CODES:Ee}=((e,i,r)=>({CURRENCY_CODES:[...e,...i.filter(a=>!r.has(a)).sort()]}))(L,le,he),{ApiPriceProcessorsSchema:W}=((e,i)=>({ApiPriceProcessorsSchema:e.object({stripe:i.nullish()}).meta({"x-atmn-mapping":!0})}))(t,fe),{AllocatedBillingFieldSchema:Te}=((e,i)=>({AllocatedBillingFieldSchema:e.enum(i).optional().meta({internal:!0,description:"How an allocated usage_based price bills mid-cycle quantity changes. 'arrear' (default) bills at period end. 'prorated_legacy' is only returned for prices still on the legacy immediate-proration behavior; omit it to migrate the price to 'arrear'."})}))(t,ge),{CreditDimensionNameSchema:we}=((e,i,r)=>({CreditDimensionNameSchema:e.string().min(1).max(i).refine(a=>!a.includes(r),{message:`Dimension names cannot contain "${r}"`})}))(t,Se,_e),{ApiCreditMatchSchema:Y}=(e=>({ApiCreditMatchSchema:e.meta({description:"Event properties this entry applies to. Every key must equal the tracked property, compared as strings."})}))(Ie),{findCreditTierViolations:je}=(e=>({findCreditTierViolations:r=>{let n=[],a=(c,m)=>n.push({index:c,reason:m,message:e[m]}),u=0;for(let[c,m]of r.entries()){let l=c===r.length-1;if(m==="inf"){l||a(c,"non_final_infinity");continue}(!Number.isFinite(m)||m<=u)&&a(c,"not_increasing"),u=m,l&&a(c,"final_not_infinity")}return n}}))(xe),{ApiCreditMultiplierSchema:Re}=((e,i)=>({ApiCreditMultiplierSchema:e.object({match:i,factor:e.number().positive().optional().meta({description:"Multiplies the matched rate. All matching multipliers stack."}),add:e.number().optional().meta({description:"Added to the rate after every factor is applied, in credits per billing-unit group."})}).strict().refine(n=>n.factor!==void 0||n.add!==void 0,{message:"A multiplier needs a factor or an add."})}))(t,Y),{ProviderMarkupsSchema:De}=((e,i)=>({ProviderMarkupsSchema:e.record(e.string(),i).nullish()}))(t,K),{InvoiceFeatureQuantitySchema:H}=((e,i,r)=>({InvoiceFeatureQuantitySchema:e.object({feature_id:e.string().meta({description:"The feature to bill."}),billing_behavior:e.enum(i).meta({description:"Which of the feature's prices to use: 'prepaid' or 'usage_based'."}),quantity:e.number().nonnegative().optional().meta({description:"Billable feature units in total, exclusive of any included usage. Not per seat or per entity. For a credit-system feature this is the number of credits."}),usage:e.array(r).optional().meta({description:"For credit-system features: billable units of the source features, converted through the credit rate card. Mutually exclusive with quantity."}),prorate:e.boolean().optional().meta({description:"Whether to prorate this line against period_start / period_end. Defaults to true for prepaid and false for usage-based."})}).strict().refine(a=>a.quantity!==void 0!=(a.usage!==void 0),{message:"Provide exactly one of quantity or usage."})}))(t,G,Ae),{CreateInvoicePreviewSchema:bt}=((e,i)=>({CreateInvoicePreviewSchema:e.object({currency:e.string(),lines:e.array(i),subtotal:e.number(),discount_total:e.number(),tax:e.object({total:e.number(),amount_inclusive:e.number(),amount_exclusive:e.number(),status:e.enum(["complete","incomplete"])}).nullable(),total:e.number(),due_date:e.number().nullable()})}))(t,Pe),{SUPPORTED_SET:ke}=(e=>({SUPPORTED_SET:new Set(e)}))(Ee),{ApiCreditDimensionBaseSchema:Ne}=((e,i)=>({ApiCreditDimensionBaseSchema:e.object({match:i,priority:e.number().int().optional().meta({description:"Breaks ties between dimensions that match the same number of keys. Higher wins."})})}))(t,Y),{refineGraduatedTiers:X}=(e=>({refineGraduatedTiers:(r,n)=>{let a=e(r.tiers.map(u=>u.to));for(let{index:u,message:c}of a)n.addIssue({code:"custom",message:c,path:["tiers",u,"to"]})}}))(je),{ApiFeatureMarkupsOverrideSchema:Ue}=((e,i,r)=>({ApiFeatureMarkupsOverrideSchema:e.strictObject({default_markup:e.number().min(-100).optional().meta({description:"Default percentage markup for customers on this plan. Use -100 to make usage free."}),provider_markups:i.meta({description:"Per-provider markup percentages for customers on this plan."}),model_markups:r.meta({description:"Per-model markup overrides for customers on this plan."})})}))(t,De,ve),{isValidCurrencyCode:qe}=(e=>({isValidCurrencyCode:r=>!!r&&e.has(r.toLowerCase())}))(ke),{ApiCreditDimensionSchema:Be}=((e,i,r,n)=>({ApiCreditDimensionSchema:e.union([i.extend({tier_behavior:e.literal("graduated"),tiers:e.array(r).min(1)}).strict().superRefine(n),i.extend({credit_cost:e.number().min(0).meta({description:"Credits consumed per billing-unit group when this dimension matches."})}).strict()])}))(t,Ne,$,X),{CurrencyCodeSchema:J}=((e,i)=>({CurrencyCodeSchema:e.string().refine(i,"must be a Stripe-supported currency code").meta({description:"Three-letter Stripe-supported currency code (e.g. 'eur', 'gbp')."})}))(t,qe),{AdditionalCurrencyTierSchema:Fe}=((e,i)=>({AdditionalCurrencyTierSchema:e.object({currency:i,amount:e.number().optional().meta({description:"Per-unit amount for this tier in this currency."}),flat_amount:e.number().optional().meta({description:"Flat amount for this tier in this currency, if the tier uses one."})}).refine(n=>n.amount!==void 0||n.flat_amount!==void 0,{message:"Either amount or flat_amount, or both must be defined",path:["amount","flat_amount"]})}))(t,J),{ApiCreditSchemaItemBaseSchema:z}=((e,i,r,n)=>({ApiCreditSchemaItemBaseSchema:e.object({metered_feature_id:e.string().nonempty().meta({description:"ID of the metered feature that draws from this credit system."}),billing_units:e.number().positive().optional().meta({description:"Number of metered-feature units priced together. Defaults to one when omitted."}),dimensions:e.record(i,r).optional().meta({description:"Named rates chosen by event properties. The most specific match sets the rate; with no match the item's own rate applies."}),multipliers:e.record(i,n).optional().meta({description:"Named adjustments chosen by event properties. Every match applies: factors multiply, then adds are summed."})})}))(t,we,Be,Re),{ApiFlatCreditSchemaItemSchema:Le}=((e,i)=>({ApiFlatCreditSchemaItemSchema:e.extend({credit_cost:i.number().min(0).meta({description:"Credits consumed per billing-unit group."})}).strict()}))(z,t),{AdditionalCurrencyPriceSchema:Qe}=((e,i)=>({AdditionalCurrencyPriceSchema:e.object({currency:i,amount:e.number().meta({description:"Price amount in this currency. Set explicitly per currency, not converted from the base amount."})})}))(t,J),{AdditionalCurrencyTierArraySchema:Ve}=((e,i,r,n)=>({AdditionalCurrencyTierArraySchema:e.array(i).refine(r,{message:n})}))(t,Fe,Q,V),{ApiGraduatedCreditSchemaItemSchema:Ge}=((e,i,r,n)=>({ApiGraduatedCreditSchemaItemSchema:e.extend({tier_behavior:i.literal("graduated"),tiers:i.array(r).min(1)}).strict().superRefine(n)}))(z,t,$,X),{AdditionalCurrencyPriceArraySchema:ee}=((e,i,r,n)=>({AdditionalCurrencyPriceArraySchema:e.array(i).refine(r,{message:n})}))(t,Qe,Q,V),{ApiUsageTierWithCurrenciesSchema:$e}=((e,i,r)=>({ApiUsageTierWithCurrenciesSchema:e.object({to:e.number().or(e.literal(i)),amount:e.number().optional(),flat_amount:e.number().optional(),additional_currencies:r.optional().meta({description:"Per-currency amounts for this tier. Tier boundaries ('to') are shared across all currencies."})}).refine(a=>a.amount!==void 0||a.flat_amount!==void 0,{message:"Either amount or flat_amount, or both must be defined",path:["amount","flat_amount"]}).transform(a=>({...a,amount:a.amount??0})).pipe(e.object({to:e.number().or(e.literal(i)),amount:e.number(),flat_amount:e.number().optional(),additional_currencies:r.optional()}))}))(t,be,Ve),{ApiCreditSchemaItemSchema:Ke}=((e,i,r)=>({ApiCreditSchemaItemSchema:e.union([i,r])}))(t,Ge,Le),{BasePriceParamsSchema:Ze}=((e,i,r,n)=>({BasePriceParamsSchema:e.omit({display:!0}).extend({interval_count:i({schema:r.number().optional(),defaultValue:1,description:"Number of intervals per billing cycle. Defaults to 1."}),additional_currencies:n.optional().meta({description:"Base price amounts in additional currencies. The base 'amount' is in the org's default currency."}),base_currency:r.string().optional().meta({internal:!0}),entitlement_id:r.string().optional().meta({internal:!0}),price_id:r.string().optional().meta({internal:!0}),stripe_price_id:r.string().optional().meta({description:"Stripe price id this base price is billed under. Set by sync flows to capture the actual Stripe price when it differs from the catalog default.",internal:!0})}).meta({title:"BasePrice",description:"Base price configuration for a plan."})}))(Oe,pe,t,ee),{PlanItemPriceParamsSchema:We}=((e,i,r,n,a,u,c)=>({PlanItemPriceParamsSchema:e.object({stripe_price_id:e.string().nullish().transform(l=>l??void 0).meta({description:"Stripe price id this feature price is billed under. Set by sync flows to preserve an existing Stripe price.",internal:!0}).optional(),amount:e.number().optional().meta({description:"Price per billing_units after included usage. Either 'amount' or 'tiers' is required."}),additional_currencies:i.optional().meta({description:"Amounts in additional currencies for this flat price. The base 'amount' is in the org's default currency. Only valid with 'amount', not 'tiers'."}),tiers:e.array(r).optional().meta({description:"Tiered pricing. Either 'amount' or 'tiers' is required."}),tier_behavior:e.enum(n).optional(),interval:e.enum(a).meta({description:"Billing interval. For consumable features, should match reset.interval."}),interval_count:e.number().default(1).optional().meta({description:"Number of intervals per billing cycle. Defaults to 1."}),billing_units:e.number().default(1).optional().meta({description:"Units per price increment. Usage is rounded UP when billed (e.g. billing_units=100 means 101 rounds to 200)."}),billing_method:e.enum(u).meta({description:"'prepaid' for upfront payment (seats), 'usage_based' for pay-as-you-go."}),allocated_billing:c,max_purchase:e.number().nullish().meta({description:"Max units purchasable beyond included. E.g. included=100, max_purchase=300 allows 400 total. Null for no limit."})})}))(t,ee,$e,ye,F,G,Te),{ApiFeatureOverrideSchema:Ye}=((e,i,r)=>({ApiFeatureOverrideSchema:e.strictObject({credit_schema:e.array(i).optional().meta({description:"For credit system features: replaces the feature's credit_schema entirely for customers on this plan."}),markups:r.optional().meta({description:"For AI credit system features: replaces the feature's markup chain entirely for customers on this plan. An unset level means no markup at that level rather than inheriting the feature's."})})}))(t,Ke,Ue),{InvoiceBasePriceParamsSchema:te}=((e,i)=>({InvoiceBasePriceParamsSchema:e.pick({amount:!0,interval:!0,interval_count:!0}).extend({processors:i.optional().meta({description:"Bill this line under an existing Stripe price instead of an inline one."})}).strict()}))(Ze,W),{InvoiceItemPriceParamsSchema:He}=((e,i)=>({InvoiceItemPriceParamsSchema:e.pick({amount:!0,tiers:!0,tier_behavior:!0,interval:!0,interval_count:!0,billing_units:!0,billing_method:!0}).extend({processors:i.optional().meta({description:"Bill this line under an existing Stripe price instead of an inline one."})}).strict()}))(We,W),{InvoiceLicenseQuantitySchema:Xe}=((e,i,r)=>({InvoiceLicenseQuantitySchema:e.object({license_plan_id:e.string().meta({description:"The license plan linked to the parent plan."}),quantity:e.number().int().nonnegative().meta({description:"Billable seats, exclusive of any included seats."}),customize:e.object({price:i.nullable().optional()}).strict().optional().meta({description:"Override the license's per-seat price on this invoice."}),feature_quantities:e.array(r).optional().meta({description:"Feature charges priced through the license plan."}),prorate:e.boolean().optional().meta({description:"Whether to prorate seat charges against period_start / period_end. Defaults to true."})}).strict()}))(t,te,H),{InvoiceCustomizeItemSchema:Je}=((e,i,r)=>({InvoiceCustomizeItemSchema:e.object({feature_id:e.string().meta({description:"The feature whose pricing is overridden on this invoice."}),price:i.optional().meta({description:"Pricing to use for this feature on this invoice."}),feature_override:r.pick({credit_schema:!0}).strict().optional().meta({description:"For credit-system features: a credit rate card to use when converting `usage` on this invoice."})}).strict()}))(t,He,Ye),{InvoiceCustomizeSchema:ze}=((e,i,r)=>({InvoiceCustomizeSchema:e.object({price:i.nullable().optional().meta({description:"Override the plan's base price for this invoice. Pass null or an amount of 0 to omit the base price line."}),items:e.array(r).optional().meta({description:"Override feature pricing for this invoice. Only pricing fields are accepted; grants, resets and rollovers are not part of an invoice."})}).strict().meta({title:"InvoiceCustomize",description:"Pricing overrides applied to this invoice only. The catalog and the customer's plan are not changed."})}))(t,te,Je),{InvoicePlanParamsSchema:et}=((e,i,r,n,a)=>({InvoicePlanParamsSchema:e.object({plan_id:e.string().meta({description:"The catalog plan (or variant) whose pricing to use."}),version:e.number().optional().meta({description:"Plan version. Defaults to the active version."}),customize:i.optional(),feature_quantities:e.array(r).optional(),license_quantities:e.array(n).optional(),discounts:e.array(a).optional().meta({description:"Discounts applied only to this plan's lines."}),prorate:e.boolean().optional().meta({description:"Whether to prorate the base price against period_start / period_end. Defaults to true."})}).strict()}))(t,ze,H,Xe,Z),{CreateInvoiceParamsSchema:yt}=((e,i,r,n,a)=>({CreateInvoiceParamsSchema:e.object({customer_id:e.string().meta({description:"The customer to invoice."}),plans:e.array(i).optional(),custom_line_items:e.array(r).optional().meta({description:"Charges that are not tied to any plan or feature."}),discounts:e.array(n).optional().meta({description:"Discounts applied to the whole invoice."}),invoice_template_id:e.string().optional().meta({description:"ID of an invoice template whose footer, memo and default payment terms are applied."}),net_terms_days:e.number().int().positive().optional().meta({description:"Days until the invoice is due. Defaults to the template's terms, then the org default."}),tax_rate_id:e.string().optional().meta({description:"Stripe tax rate ID (txr_...) applied to every line."}),period_start:a.optional().meta({description:"Start of the period being invoiced, in milliseconds. Prorated lines are charged for period_start \u2192 period_end against one price interval starting at period_start."}),period_end:a.optional().meta({description:"End of the period being invoiced, in milliseconds."}),preview:e.boolean().optional().meta({description:"If true, returns the calculated lines and totals without creating an invoice."})}).strict().refine(c=>c.period_start===void 0==(c.period_end===void 0),{message:"period_start and period_end must be provided together."}).refine(c=>c.period_start===void 0||c.period_end===void 0||c.period_end>c.period_start,{message:"period_end must be after period_start."})}))(t,et,Ce,Z,Me);var E=t.object({type:t.literal("native_purchase"),receiptId:t.uuid(),orderId:t.uuid(),productVersionId:t.uuid(),provider:t.enum(["apple","google"]),productId:t.string().min(1).max(255),productKind:U,replacement:t.strictObject({sourceOrderId:t.uuid(),sourceProductId:t.string().min(1).max(255),policy:t.enum(["apple_store","google_full_price"]),sourceAccountTokens:t.array(t.uuid()).max(50)}).nullable(),appAccountToken:t.uuid().optional(),obfuscatedAccountId:t.string().min(1).max(64).optional(),obfuscatedProfileId:t.uuid().optional(),basePlanId:t.string().min(1).max(255).optional(),offerId:t.string().min(1).max(255).optional(),offerKind:t.enum(["none","introductory","promotional"]),currency:s,catalogAmountMinor:t.number().int().nonnegative().max(1e8),discountMinor:t.number().int().nonnegative().max(1e8),trialDays:t.number().int().min(1).max(730).nullable(),seatBundle:t.array(t.strictObject({key:t.string().regex(/^[a-z][a-z0-9_]{0,63}$/),quantity:t.number().int().min(1).max(1e4)})).max(20),applePromotionalOffer:t.strictObject({offerId:t.string().min(1).max(255),keyId:t.string().min(1).max(255),nonce:t.uuid(),signature:t.string().min(1).max(1024),timestamp:t.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)}).nullable()}).strict().superRefine((e,i)=>{let r=e.provider==="apple";(e.replacement!==null&&(e.productKind!=="membership"||e.offerKind!=="none"||e.trialDays!==null||e.replacement.policy!==(r?"apple_store":"google_full_price"))||e.productKind!=="membership"&&(e.trialDays!==null||e.offerKind!=="none"||e.basePlanId!==void 0)||!r&&e.productKind==="membership"&&e.basePlanId===void 0||e.discountMinor>e.catalogAmountMinor||new Set(e.seatBundle.map(a=>a.key)).size!==e.seatBundle.length||e.trialDays!==null&&(e.discountMinor!==0||e.offerKind==="none")||e.offerKind==="none"&&e.discountMinor!==0||(r?!e.appAccountToken||e.obfuscatedAccountId!==void 0||e.obfuscatedProfileId!==void 0||e.basePlanId!==void 0||e.offerKind==="promotional"!=(e.applePromotionalOffer!==null)||e.offerKind==="promotional"!=(e.offerId!==void 0)||e.applePromotionalOffer!==null&&e.applePromotionalOffer.offerId!==e.offerId:e.appAccountToken!==void 0||!e.obfuscatedAccountId||!e.obfuscatedProfileId||e.applePromotionalOffer!==null||e.offerKind==="none"!=(e.offerId===void 0)))&&i.addIssue({code:"custom",message:"Native purchase terms must match the accepted store selection"})});var ie=t.strictObject({itemKey:t.string().regex(/^paid:feature:[a-f0-9]{8}-[a-f0-9]{4}-[1-8][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/),internal_feature_id:t.uuid(),includedAmount:t.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/),quantity:t.number().int().min(0).max(1e4),terms:k,pricing:D.optional(),unitAmountMinor:t.number().int().min(0).max(1e8),productId:t.string().min(1).max(255).nullable(),priceId:t.string().min(1).max(255).nullable()}).superRefine((e,i)=>{(e.quantity<e.terms.minimumQuantity||e.quantity>e.terms.maximumQuantity||e.productId===null!=(e.priceId===null)||e.quantity>0&&(e.pricing||e.unitAmountMinor>0)&&e.priceId===null)&&i.addIssue({code:"custom",message:"Purchased quantities need their published bounds and immutable price binding"});try{N(e.includedAmount,e.terms.units,e.quantity),g({quantity:e.quantity,unitAmountMinor:e.unitAmountMinor,...e.pricing===void 0?{}:{pricing:e.pricing}})}catch{i.addIssue({code:"custom",message:"Purchased allowance exceeds the ledger quantity limit"})}});var _=t.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/,"ID \u4F7F\u7528\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u4E0B\u5212\u7EBF\uFF0C\u5E76\u4EE5\u5B57\u6BCD\u5F00\u5934"),Et=t.object({amountCents:t.number().int().min(0).max(1e8),currency:s,interval:t.enum(["free","month","year"]),currencyOptions:t.partialRecord(s,t.number().int().min(1).max(1e8)).optional()}).refine(e=>e.interval==="free"?e.amountCents===0:e.amountCents>0,"\u514D\u8D39\u5957\u9910\u91D1\u989D\u5FC5\u987B\u4E3A 0\uFF0C\u4ED8\u8D39\u91D1\u989D\u5FC5\u987B\u5927\u4E8E 0").refine(e=>!e.currencyOptions||!Object.hasOwn(e.currencyOptions,e.currency)&&(e.interval!=="free"||Object.keys(e.currencyOptions).length===0),"\u9644\u52A0\u5E01\u79CD\u4E0D\u80FD\u91CD\u590D\u9ED8\u8BA4\u5E01\u79CD\uFF1B\u514D\u8D39\u5957\u9910\u4E0D\u8BBE\u7F6E\u9644\u52A0\u4EF7\u683C");var $t=t.strictObject({requestId:t.uuid(),predecessorOperationId:t.uuid().optional(),invoiceMode:p.optional(),entityId:t.uuid().optional(),billingSubscriptionId:t.uuid().optional(),newBillingSubscription:t.literal(!0).optional(),offerId:t.uuid().optional(),nativeOffer:O.optional(),plans:t.array(t.strictObject({productVersionId:t.uuid(),seatQuantities:t.record(_,t.number().int().min(0).max(1e4)).optional(),featureQuantities:t.record(t.uuid(),t.number().int().min(0).max(1e4)).refine(e=>Object.keys(e).length<=100,"At most 100 feature quantities").optional()})).min(1).max(20).refine(e=>new Set(e.map(i=>i.productVersionId)).size===e.length,"Plan versions must be unique"),provider:t.enum(["stripe","apple","google","merchant"]),currency:s}).refine(e=>!e.offerId||!e.billingSubscriptionId&&(["stripe","merchant"].includes(e.provider)||e.nativeOffer!==void 0),"Held offers apply to new purchases; existing subscriptions use billing coupons").refine(e=>!e.nativeOffer||["apple","google"].includes(e.provider)&&e.plans.length===1,"A store selection applies to exactly one native SKU").refine(e=>!e.newBillingSubscription||["stripe","merchant"].includes(e.provider)&&!e.billingSubscriptionId,"A new billing subscription has no existing subscription target").refine(e=>!e.invoiceMode?.enabled||e.provider==="stripe"&&!e.entityId,"Invoice mode requires a Stripe subscription without an Entity target"),Kt=t.strictObject({operationId:t.uuid()}),o=t.number().int().min(0).max(1e8),tt=t.strictObject({lineId:t.uuid(),productVersionId:t.uuid(),productName:t.string().min(1).max(80),interval:t.enum(["free","week","month","year","one_time"]),intervalCount:t.number().int().min(1).max(156).optional(),baseAmountMinor:o,seats:t.array(t.strictObject({key:_,quantity:t.number().int().min(0).max(1e4),includedQuantity:t.number().int().min(0).max(1e4),maximumQuantity:t.number().int().min(0).max(1e4),unitAmountMinor:o})).max(20),prepaid:t.array(ie).max(100).optional(),catalogAmountMinor:o,trial:w.nullable()}).refine(e=>new Set(e.seats.map(i=>i.key)).size===e.seats.length&&e.seats.every(i=>i.quantity>=i.includedQuantity&&i.quantity<=i.maximumQuantity)&&e.baseAmountMinor+e.seats.reduce((i,r)=>i+r.unitAmountMinor*(r.quantity-r.includedQuantity),0)+(e.prepaid??[]).reduce((i,r)=>i+g({quantity:r.quantity,unitAmountMinor:r.unitAmountMinor,...r.pricing===void 0?{}:{pricing:r.pricing}}),0)===e.catalogAmountMinor,"Quote must retain its published base price and component quantities"),ae=t.string().regex(/^[A-Za-z0-9_-]{1,200}$/),it=t.strictObject({id:ae,name:t.string().min(1).max(40),percent_off:t.number().gt(0).max(100).optional(),amount_off:t.number().int().positive().optional(),currency:t.string().regex(/^[a-z]{3}$/).optional(),duration:t.enum(["once","repeating","forever"]),duration_in_months:t.number().int().min(1).max(36).optional()}).refine(e=>e.percent_off===void 0!=(e.amount_off===void 0)&&e.amount_off===void 0==(e.currency===void 0)&&e.duration==="repeating"==(e.duration_in_months!==void 0),"A Stripe coupon has one percentage or amount and months only when repeating"),rt=t.strictObject({subscriptionId:t.string().regex(/^sub_[A-Za-z0-9]+$/),customerId:t.string().regex(/^cus_[A-Za-z0-9]+$/),sourceItems:t.array(t.strictObject({id:t.string(),price_id:t.string(),quantity:t.number().int().nonnegative(),discounts:t.array(t.strictObject({id:t.string(),coupon:t.string(),start:t.number(),end:t.number().nullable()})).optional()})).min(1).max(100),prorationDate:t.number().int().nonnegative(),amountMinor:t.number().int().positive(),periodStartMs:t.number(),periodEndMs:t.number()}),oe=t.strictObject({invoiceMode:p.optional(),append:rt.optional(),provider:t.literal("stripe"),executor:t.enum(["indiana","merchant"]),accountId:t.string().regex(/^acct_[A-Za-z0-9]+$/),mode:t.enum(["payment","subscription"]),lineItems:t.array(t.strictObject({price:t.string().regex(/^price_[A-Za-z0-9]+$/).nullable(),quantity:t.number().int().min(1).max(1e4),priceId:t.uuid(),productName:t.string().min(1).max(80),amountMinor:t.number().int().min(0).max(1e8),currency:t.string().regex(/^[a-z]{3}$/),interval:t.enum(["week","month","year","one_off"]),intervalCount:t.number().int().min(1).max(52),slot:t.enum(["stripe_price_id","stripe_empty_price_id"]),tiers:t.strictObject({mode:t.enum(["graduated","volume"]),tiers:t.array(t.strictObject({upTo:t.number().int().min(1).max(1e6).nullable(),unitAmountMinor:t.number().int().min(0).max(1e8),flatAmountMinor:t.number().int().min(0).max(1e8).optional()})).min(2).max(12)}).nullable()})).min(1).max(100),discounts:t.array(t.strictObject({coupon:ae,terms:it})).max(1),trialPeriodDays:t.number().int().min(1).max(730).nullable(),metadata:t.strictObject({grooveCheckoutId:t.uuid(),grooveCustomerId:t.uuid()}),expiresAt:t.iso.datetime({offset:!0})}),nt=t.strictObject({operationId:t.uuid(),merchantTerms:b.optional(),entityId:t.uuid().nullable(),billingSubscriptionId:t.uuid().nullable(),discount:t.strictObject({offerId:t.uuid(),couponId:t.uuid(),discount:q,duration:B,amountMinor:o,allocations:t.array(t.strictObject({productVersionId:t.uuid(),amountMinor:o})).min(1).max(20),expiresAt:t.iso.datetime({offset:!0})}).nullable(),charge:t.strictObject({effectiveAt:t.iso.datetime({offset:!0}),periodEndsAt:t.iso.datetime({offset:!0}),debitMinor:o,discountMinor:o,taxMinor:o,totalMinor:o}).nullable(),expiresAt:t.iso.datetime({offset:!0}),provider:t.enum(["stripe","apple","google","merchant"]),nativeOffer:O.optional(),currency:s,lines:t.array(tt).min(1).max(20),catalogAmountMinor:o,nativeDiscountMinor:o.optional(),automaticTax:t.boolean(),execution:t.union([oe,v]).nullable()}).refine(e=>!e.merchantTerms||e.provider==="merchant"&&y(e.merchantTerms,e.operationId,"purchase",e.currency)).refine(e=>e.provider==="merchant"?e.execution?.provider==="merchant"&&e.execution.operationId===e.operationId&&e.execution.catalogAmountMinor===e.catalogAmountMinor&&e.execution.currency===e.currency&&Date.parse(e.execution.expiresAt)<=Date.parse(e.expiresAt)&&e.execution.trialPeriodDays===(e.lines[0]?.trial?.days??null)&&e.execution.discount?.grantId===e.discount?.offerId:e.provider==="stripe"?e.execution?.provider!=="merchant"&&(e.lines[0]?.trial?.cardRequired===!1&&!e.execution?.invoiceMode?.enabled?e.execution===null&&e.discount===null:e.execution!==null&&e.execution.metadata.grooveCheckoutId===e.operationId&&Date.parse(e.execution.expiresAt)<=Date.parse(e.expiresAt)&&e.execution.mode===(e.lines.some(i=>!["one_time","free"].includes(i.interval))?"subscription":"payment")&&e.execution.trialPeriodDays===(e.lines[0]?.trial?.days??null)&&(e.execution.executor==="indiana"||e.execution.lineItems.every(i=>i.price!==null))&&e.execution.discounts.every(i=>i.coupon===i.terms.id)&&e.execution.discounts.length===(e.discount?1:0)&&e.execution.discounts.every(i=>e.discount!==null&&(i.coupon===e.discount.couponId||e.discount.discount.type==="amount"&&i.coupon===`${e.discount.couponId}_credit_${e.discount.offerId}_${i.terms.amount_off}`&&i.terms.amount_off===e.discount.discount.amountOffCents&&i.terms.currency?.toUpperCase()===e.currency&&i.terms.duration==="once"))):e.execution===null,"Stripe execution must carry the quote identity, expiry, mode, trial and held coupon").refine(e=>(!e.discount||!e.billingSubscriptionId&&(["stripe","merchant"].includes(e.provider)||e.discount.duration.type==="once")&&e.discount.amountMinor<=e.catalogAmountMinor&&e.discount.allocations.length===e.lines.length&&e.discount.allocations.every((i,r)=>{let n=e.lines[r];return n!==void 0&&i.productVersionId===n.productVersionId&&i.amountMinor<=n.catalogAmountMinor})&&e.discount.allocations.reduce((i,r)=>i+r.amountMinor,0)===e.discount.amountMinor)&&(["stripe","merchant"].includes(e.provider)?e.nativeOffer===void 0:e.nativeOffer!==void 0&&e.lines.length===1&&e.nativeOffer.discountMinor<=e.catalogAmountMinor&&e.nativeOffer.trialDays===(e.lines[0]?.trial?.days??null)&&(!e.discount||e.nativeOffer.discountMinor===e.discount.amountMinor))&&(!e.charge||e.billingSubscriptionId!==null&&e.charge.totalMinor===e.charge.debitMinor-e.charge.discountMinor+e.charge.taxMinor&&e.charge.discountMinor<=e.charge.debitMinor&&Date.parse(e.charge.periodEndsAt)>Date.parse(e.charge.effectiveAt))&&new Set(e.lines.map(i=>i.lineId)).size===e.lines.length&&e.lines.reduce((i,r)=>i+r.catalogAmountMinor,0)===e.catalogAmountMinor,"Quote lines must conserve the catalog amount"),Zt=t.strictObject({operationId:t.uuid(),orderId:t.uuid(),append:t.boolean().optional(),invoiceMode:t.boolean().optional(),status:t.enum(["pending","complete","cancelled","failed"]),executor:t.enum(["indiana","merchant"]),checkoutUrl:t.url().refine(e=>new URL(e).protocol==="https:").nullable(),execution:t.union([oe,v]).nullable(),currency:s,catalogAmountMinor:o,taxMinor:o,totalMinor:t.number().int().min(0).max(2e8).nullable(),quoteFinalized:t.boolean(),nativePurchase:E.nullable(),confirmedAt:t.iso.datetime({offset:!0}).nullable().optional(),quote:nt.optional(),merchantExecution:f.nullable().optional(),problem:h.nullable().optional(),authority:S.optional()}).refine(e=>(e.checkoutUrl===null||e.executor==="indiana"||e.merchantExecution?.type==="purchase")&&(e.execution===null||e.executor==="merchant"),"Only Indiana-executed purchases carry a Checkout URL and only record-only purchases carry execution instructions"),x=t.strictObject({enabled:t.literal(!0),featureIds:t.array(t.uuid()).min(1).max(100).refine(e=>new Set(e).size===e.length,"Feature IDs must be unique").optional()}),Wt=t.strictObject({requestId:t.uuid(),offerId:t.uuid().optional(),invoiceMode:p.optional(),membershipId:t.uuid(),carryOverBalances:x.optional(),carryOverUsages:x.optional(),membershipIds:t.array(t.uuid()).min(1).max(20).optional(),prorationBehavior:t.enum(["prorate_immediately","none","bill_difference"]).optional(),timing:t.enum(["immediate","renewal","store"]),change:t.discriminatedUnion("type",[t.strictObject({type:t.literal("plan"),productVersionId:t.uuid()}),t.strictObject({type:t.literal("seats"),licenseKey:_,quantity:t.number().int().min(0).max(1e4)}),t.strictObject({type:t.literal("quantity"),internal_feature_id:t.uuid(),quantity:t.number().int().min(0).max(1e4)}),t.strictObject({type:t.literal("cancel")}),t.strictObject({type:t.literal("uncancel")}),t.strictObject({type:t.literal("billing_cycle"),billingCycleAnchor:t.union([t.literal("now"),t.number().int().positive().max(0xe677d21fdbff)])})])}).refine(e=>!e.offerId||e.change.type==="plan"&&e.timing!=="store","A selected plan-change offer requires a merchant target Product").refine(e=>e.timing!=="store"||e.change.type==="plan","Store timing applies to a native plan replacement").refine(e=>e.change.type!=="billing_cycle"||e.timing===(e.change.billingCycleAnchor==="now"?"immediate":"renewal"),"Use immediate for now and renewal for a future millisecond anchor").refine(e=>!e.membershipIds||["cancel","uncancel"].includes(e.change.type)&&e.membershipIds.includes(e.membershipId)&&new Set(e.membershipIds).size===e.membershipIds.length,"Grouped actions require unique cancel/uncancel targets including the primary membership").refine(e=>!e.carryOverBalances&&!e.carryOverUsages||e.change.type==="plan"&&e.timing==="immediate","Carry applies only to immediate upgrades").refine(e=>!e.prorationBehavior||e.change.type==="quantity","prorationBehavior applies to prepaid quantity changes"),I=t.string().regex(/^price_[A-Za-z0-9]+$/),re=t.strictObject({grooveUpdateId:t.uuid(),grooveCustomerId:t.uuid()}),ne=t.strictObject({price:I.nullable(),priceId:t.uuid().optional(),quantity:t.number().int().min(0).max(1e4)}),ce=t.strictObject({provider:t.literal("stripe"),invoiceMode:p.optional(),executor:t.enum(["indiana","merchant"]),accountId:t.string().regex(/^acct_[A-Za-z0-9]+$/),subscriptionId:t.string().regex(/^sub_[A-Za-z0-9]+$/),action:t.enum(["update","cancel","schedule","release"]),update:t.strictObject({items:t.array(ne).max(20),remove:t.array(I).max(20),restoreItems:t.array(t.strictObject({price:I,quantity:t.number().int().min(0).max(1e4)})).min(1).max(20).optional(),prorationBehavior:t.enum(["always_invoice","create_prorations","none"]).optional(),prorationDate:t.number().int().positive().optional(),paymentBehavior:t.literal("error_if_incomplete").optional(),cancelAtPeriodEnd:t.boolean().optional(),clearCancelAt:t.literal(!0).optional(),billingCycleAnchorNow:t.literal(!0).optional(),metadata:re}).nullable(),cancel:t.strictObject({prorate:t.literal(!1),invoiceNow:t.literal(!1)}).nullable(),schedule:t.strictObject({currentItems:t.array(t.strictObject({price:I,quantity:t.number().int().min(0).max(1e4)})).max(20),nextItems:t.array(ne).min(1).max(20),switchAt:t.number().int().positive(),interval:t.enum(["week","month","year"]),intervalCount:t.number().int().min(1).max(52),resetBillingCycleAnchor:t.literal(!0).optional(),metadata:re}).nullable(),release:t.strictObject({schedule:t.string().regex(/^sub_sched_[A-Za-z0-9]+$/)}).nullable(),expiresAt:t.iso.datetime({offset:!0})}).refine(e=>["update","cancel","schedule","release"].every(i=>e[i]!==null==(e.action===i))&&(e.executor==="indiana"||[...e.update?.items??[],...e.schedule?.nextItems??[]].every(i=>i.price!==null)),"Stripe update execution carries exactly its action, with bound Prices for the merchant"),se=t.strictObject({merchantTerms:b.optional(),carryOverBalances:x.optional(),carryOverUsages:x.optional(),operationId:t.uuid(),membershipId:t.uuid(),productVersionId:t.uuid(),timing:t.enum(["immediate","renewal"]),effectiveAt:t.iso.datetime({offset:!0}),expiresAt:t.iso.datetime({offset:!0}),currency:s,creditMinor:o,debitMinor:o,discountMinor:o,taxMinor:o,totalMinor:o,retainedProductVersionIds:t.array(t.uuid()).max(19),execution:t.union([ce,A])}).refine(e=>!e.merchantTerms||e.execution.provider==="merchant"&&y(e.merchantTerms,e.operationId,"subscription_change",e.currency)),at=t.strictObject({operationId:t.uuid(),invoiceMode:t.boolean().optional(),membershipId:t.uuid(),productVersionId:t.uuid(),status:t.enum(["prepared","quoted","confirmed","pending","scheduled","effective","cancelled","failed"]),timing:t.enum(["immediate","renewal"]),effectiveAt:t.iso.datetime({offset:!0}),checkoutUrl:t.url().refine(e=>new URL(e).protocol==="https:").nullable(),executor:t.enum(["indiana","merchant"]),execution:t.union([ce,A]).nullable(),confirmedAt:t.iso.datetime({offset:!0}).nullable().optional(),merchantExecution:f.nullable().optional(),problem:h.nullable().optional(),quote:se.optional(),authority:S.optional()}).refine(e=>e.execution===null||e.executor==="merchant","Only record-only changes carry execution instructions"),ot=t.strictObject({operationId:t.uuid(),membershipId:t.uuid(),productVersionId:t.uuid(),timing:t.literal("store"),effectiveAt:t.null(),expiresAt:t.iso.datetime({offset:!0}),currency:s,creditMinor:t.null(),debitMinor:t.null(),discountMinor:t.null(),taxMinor:t.null(),totalMinor:t.null(),retainedProductVersionIds:t.array(t.uuid()).max(19),store:t.strictObject({provider:t.enum(["apple","google"]),productId:t.string().min(1).max(255),catalogAmountMinor:o,policy:t.enum(["apple_store","google_full_price"])})}),ct=t.strictObject({operationId:t.uuid(),membershipId:t.uuid(),productVersionId:t.uuid(),status:t.enum(["prepared","pending","effective","cancelled","failed"]),timing:t.literal("store"),effectiveAt:t.iso.datetime({offset:!0}).nullable(),checkoutUrl:t.null(),nativePurchase:E.nullable()}),Yt=t.union([se,ot]),Ht=t.union([at,ct]),T=j,d=R,Xt=t.strictObject({requestId:t.uuid(),invoiceId:t.uuid(),...P.shape}).refine(M,"A partial refund states amountMinor; a full refund refunds the remaining amount"),ue=t.strictObject({provider:t.literal("stripe"),executor:t.enum(["indiana","merchant"]),accountId:t.string().regex(/^acct_[A-Za-z0-9]+$/),invoice:t.string().regex(/^in_[A-Za-z0-9]+$/),amountMinor:T,currency:t.string().regex(/^[a-z]{3}$/),metadata:t.strictObject({indianaRefundId:t.uuid()}),idempotencyKey:t.string().regex(/^indiana-refund-[0-9a-f-]{36}$/),cancelSubscriptions:t.array(t.string().regex(/^sub_[A-Za-z0-9]+$/)).max(20)}),st=t.strictObject({operationId:t.uuid(),merchantTerms:b.optional(),invoiceId:t.uuid(),providerInvoiceId:t.string().min(1).max(200),currency:s,paidMinor:d,refundedMinor:d,pendingMinor:d,amountMinor:T,mode:t.enum(["full","partial"]),entitlementAction:t.enum(["retain","revoke"]),revokes:t.strictObject({customerProductIds:t.array(t.uuid()).max(100),subscriptionIds:t.array(t.string().min(1).max(200)).max(20)}),execution:t.union([ue,C]),expiresAt:t.iso.datetime({offset:!0})}).refine(e=>!e.merchantTerms||e.execution.provider==="merchant"&&y(e.merchantTerms,e.operationId,"refund",e.currency)).refine(e=>e.amountMinor<=e.paidMinor-e.refundedMinor-e.pendingMinor&&e.execution.amountMinor===e.amountMinor&&(e.execution.provider==="merchant"?e.execution.merchantInvoiceId===e.providerInvoiceId&&e.execution.operationId===e.operationId&&e.execution.currency===e.currency:e.execution.invoice===e.providerInvoiceId&&e.execution.metadata.indianaRefundId===e.operationId&&e.execution.currency===e.currency.toLowerCase())&&(e.entitlementAction==="revoke"||e.revokes.customerProductIds.length===0&&e.revokes.subscriptionIds.length===0),"Refund quote must stay within the refundable amount and match its execution"),ut=t.strictObject({operationId:t.uuid(),invoiceId:t.uuid(),providerInvoiceId:t.string().min(1).max(200),status:t.enum(["quoted","pending","succeeded","failed","expired"]),executor:t.enum(["indiana","merchant"]),currency:s,amountMinor:T,mode:t.enum(["full","partial"]),entitlementAction:t.enum(["retain","revoke"]),refundId:t.string().min(1).max(200).nullable(),quote:st.optional(),execution:t.union([ue,C]).nullable(),confirmedAt:t.iso.datetime({offset:!0}).nullable().optional(),merchantExecution:f.nullable().optional(),problem:h.nullable().optional(),authority:S.optional(),failureReason:t.string().min(1).max(200).nullable(),createdAt:t.iso.datetime({offset:!0}),completedAt:t.iso.datetime({offset:!0}).nullable()}).refine(e=>(e.execution===null||e.executor==="merchant"&&e.status==="quoted")&&(e.status!=="succeeded"||e.refundId!==null),"Only quoted record-only refunds carry instructions; a succeeded refund names its Stripe refund"),Jt=t.strictObject({invoiceId:t.uuid(),currency:s,paidMinor:d,refundedMinor:d,pendingMinor:d,refundableMinor:d,executor:t.enum(["indiana","merchant"]).nullable(),canRefund:t.boolean(),operations:t.array(ut).max(50)}).refine(e=>e.operations.every(i=>i.invoiceId===e.invoiceId),"Refund operations belong to the invoice"),zt=t.strictObject({requestId:t.uuid(),...P.shape}).refine(M,"A partial refund states amountMinor; a full refund refunds the remaining amount");export{ht as a,bt as b,yt as c,$t as d,Kt as e,nt as f,Zt as g,Wt as h,se as i,Yt as j,Ht as k,Xt as l,st as m,ut as n};
@@ -1 +1 @@
1
- import{a as A}from"./chunk-W32FI2A2.js";import{b as D,e as L}from"./chunk-SLUA7ABW.js";import{d as T}from"./chunk-OCWSWXCW.js";import{b as O}from"./chunk-O4KXODTJ.js";import{a as R}from"./chunk-DSPLGTQI.js";var m=new WeakMap;function B(e){let o=e.view,n=o?.paywall?.resolution;if(!o||!["running","waiting"].includes(o.status)||o.stopped||!n||"document"in n||!e.resolvePaywall||e.identitySignal?.aborted)return;let a=JSON.stringify(n);if(m.get(e)?.key===a)return;let i=JSON.parse(a),c=e.identitySignal,u=Promise.resolve().then(async()=>{c?.throwIfAborted();let v=await e.resolvePaywall(i);return c?.throwIfAborted(),v}),f={key:a,content:u};return m.set(e,f),u.catch(()=>{}),()=>{m.get(e)===f&&m.delete(e)}}function Q(e,o){let n=m.get(e);return m.delete(e),n?.key===JSON.stringify(o)?n.content:e.resolvePaywall(o)}function re(e){if(!e.client.pageExperiments)throw new Error("The Run controller does not support page experiments");let o=e.client.pageExperiments.bind(e.client),n=!1,a=!1,i=0,c=!1,u=!1,f="",v=()=>{let t=e.client.view;return JSON.stringify([t?.id,t?.source.versionId,t?.visit,t?.revision,t?.status,t?.stopped])},s=new Map,x=new Set,q={},d=new Map,U=D(e.appManifestRelease),C=()=>{for(let t of s.values())t.effect.revert();s.clear()},g=()=>{C();for(let t of d.values())t();d.clear()};function E(t){if(n||x.has(t))return;x.add(t);let h=i;o(e.appManifestRelease,[t]).catch(k=>{x.delete(t),!n&&h===i&&R(e.onError,k)})}async function w(){if(n)return;f=v();let t=e.client.view;if(!t||t.stopped||!["running","waiting"].includes(t.status)){i++,g();return}if(document.visibilityState==="hidden")return;if(c){u=!0;return}c=!0;let h=++i,k=`${t.id}:${t.visit}:${t.revision}`,W=location.href;try{let[P,{applyVisualVariation:j}]=await Promise.all([o(e.appManifestRelease),import("./visual-dom-5LUN4AHO.js")]),p=e.client.view;if(n||h!==i||!p||p.stopped||!["running","waiting"].includes(p.status)||`${p.id}:${p.visit}:${p.revision}`!==k||location.href!==W)return;let $=new Set,I=new Set;for(let r of P.assignments){let l=`${P.payload.environmentId}:${r.experimentKey}`;if(I.add(l),d.has(l)||d.set(l,L(l,q)),!!r.inExperiment)for(let y of P.payload.experiments){if(y.key!==r.experimentKey||!O(location.href,y.urlPatterns??[]))continue;let z=y.meta?.findIndex(F=>F.key===r.variationKey)??-1,S=y.variations[z];if(!S?.renderGuard)continue;let b=r.receiptId+":"+y.changeId,J=JSON.stringify([r.variationKey,S]);$.add(b);let N=s.get(b);if(N?.signature===J){N.effect.applied&&E(r.receiptId);continue}s.get(b)?.effect.revert(),s.delete(b);let K=j(S,{requireUniqueTargets:!0,boundVariations:y.variations,allowJs:!1,onApplied:()=>E(r.receiptId),onError:F=>R(e.onError,F)});s.set(b,{signature:J,effect:K}),K.applied&&E(r.receiptId)}}for(let[r,l]of s)$.has(r)||(l.effect.revert(),s.delete(r));for(let[r,l]of d)I.has(r)||(l(),d.delete(r))}catch(P){h===i&&g(),!n&&h===i&&R(e.onError,P)}finally{c=!1,u&&!n&&(u=!1,w())}}let G=e.client.subscribe(()=>{if(v()===f)return;f=v(),i++;let t=e.client.view;(!t||t.stopped||!["running","waiting"].includes(t.status))&&g(),a&&w()}),H=T(()=>{i++,g(),a&&w()}),V=()=>{i++,C()};document.addEventListener("visibilitychange",V);let M=A({document,run:async()=>{a&&await w()},delay:()=>a&&!n?15e3:void 0});return{async start(){a||n||(a=!0,await M.refresh())},refresh:w,destroy(){n=!0,i++,M.destroy(),document.removeEventListener("visibilitychange",V),G(),H(),g(),U.destroy()}}}export{B as a,Q as b,re as c};
1
+ import{a as A}from"./chunk-W32FI2A2.js";import{b as D,e as L}from"./chunk-SLUA7ABW.js";import{d as T}from"./chunk-QZRJ3ZXU.js";import{b as O}from"./chunk-O4KXODTJ.js";import{a as R}from"./chunk-DSPLGTQI.js";var m=new WeakMap;function B(e){let o=e.view,n=o?.paywall?.resolution;if(!o||!["running","waiting"].includes(o.status)||o.stopped||!n||"document"in n||!e.resolvePaywall||e.identitySignal?.aborted)return;let a=JSON.stringify(n);if(m.get(e)?.key===a)return;let i=JSON.parse(a),c=e.identitySignal,u=Promise.resolve().then(async()=>{c?.throwIfAborted();let v=await e.resolvePaywall(i);return c?.throwIfAborted(),v}),f={key:a,content:u};return m.set(e,f),u.catch(()=>{}),()=>{m.get(e)===f&&m.delete(e)}}function Q(e,o){let n=m.get(e);return m.delete(e),n?.key===JSON.stringify(o)?n.content:e.resolvePaywall(o)}function re(e){if(!e.client.pageExperiments)throw new Error("The Run controller does not support page experiments");let o=e.client.pageExperiments.bind(e.client),n=!1,a=!1,i=0,c=!1,u=!1,f="",v=()=>{let t=e.client.view;return JSON.stringify([t?.id,t?.source.versionId,t?.visit,t?.revision,t?.status,t?.stopped])},s=new Map,x=new Set,q={},d=new Map,U=D(e.appManifestRelease),C=()=>{for(let t of s.values())t.effect.revert();s.clear()},g=()=>{C();for(let t of d.values())t();d.clear()};function E(t){if(n||x.has(t))return;x.add(t);let h=i;o(e.appManifestRelease,[t]).catch(k=>{x.delete(t),!n&&h===i&&R(e.onError,k)})}async function w(){if(n)return;f=v();let t=e.client.view;if(!t||t.stopped||!["running","waiting"].includes(t.status)){i++,g();return}if(document.visibilityState==="hidden")return;if(c){u=!0;return}c=!0;let h=++i,k=`${t.id}:${t.visit}:${t.revision}`,W=location.href;try{let[P,{applyVisualVariation:j}]=await Promise.all([o(e.appManifestRelease),import("./visual-dom-5LUN4AHO.js")]),p=e.client.view;if(n||h!==i||!p||p.stopped||!["running","waiting"].includes(p.status)||`${p.id}:${p.visit}:${p.revision}`!==k||location.href!==W)return;let $=new Set,I=new Set;for(let r of P.assignments){let l=`${P.payload.environmentId}:${r.experimentKey}`;if(I.add(l),d.has(l)||d.set(l,L(l,q)),!!r.inExperiment)for(let y of P.payload.experiments){if(y.key!==r.experimentKey||!O(location.href,y.urlPatterns??[]))continue;let z=y.meta?.findIndex(F=>F.key===r.variationKey)??-1,S=y.variations[z];if(!S?.renderGuard)continue;let b=r.receiptId+":"+y.changeId,J=JSON.stringify([r.variationKey,S]);$.add(b);let N=s.get(b);if(N?.signature===J){N.effect.applied&&E(r.receiptId);continue}s.get(b)?.effect.revert(),s.delete(b);let K=j(S,{requireUniqueTargets:!0,boundVariations:y.variations,allowJs:!1,onApplied:()=>E(r.receiptId),onError:F=>R(e.onError,F)});s.set(b,{signature:J,effect:K}),K.applied&&E(r.receiptId)}}for(let[r,l]of s)$.has(r)||(l.effect.revert(),s.delete(r));for(let[r,l]of d)I.has(r)||(l(),d.delete(r))}catch(P){h===i&&g(),!n&&h===i&&R(e.onError,P)}finally{c=!1,u&&!n&&(u=!1,w())}}let G=e.client.subscribe(()=>{if(v()===f)return;f=v(),i++;let t=e.client.view;(!t||t.stopped||!["running","waiting"].includes(t.status))&&g(),a&&w()}),H=T(()=>{i++,g(),a&&w()}),V=()=>{i++,C()};document.addEventListener("visibilitychange",V);let M=A({document,run:async()=>{a&&await w()},delay:()=>a&&!n?15e3:void 0});return{async start(){a||n||(a=!0,await M.refresh())},refresh:w,destroy(){n=!0,i++,M.destroy(),document.removeEventListener("visibilitychange",V),G(),H(),g(),U.destroy()}}}export{B as a,Q as b,re as c};
@@ -1 +1 @@
1
- import{h as p,i as d}from"./chunk-YV6UFESO.js";import{C as m,w as a,z as u}from"./chunk-WZMZMJCK.js";import{b as e}from"./chunk-CR2XJ2CX.js";var s=e.enum(["page","popup","banner"]),y=3e5,f=e.strictObject({type:e.enum(["string","number","boolean","strings","json"]),nullable:e.boolean()}),h=e.strictObject({inputs:e.record(a,f.extend({required:e.boolean()})).refine(t=>Object.keys(t).length<=40,"Too many content inputs"),outputs:e.record(a,f).refine(t=>Object.keys(t).length<=40,"Too many content outputs")}),g=e.strictObject({kind:s,schemaVersion:e.literal(1),name:e.string().trim().min(1).max(80),screen:u,contract:h}),c=g.superRefine((t,r)=>{let n=(o,b)=>r.addIssue({code:"custom",message:o,path:b});t.screen.surface!==t.kind&&n("Content surface must match its domain",["screen","surface"]),t.screen.name!==t.name&&n("Content has one editable name",["screen","name"]),t.kind==="banner"&&t.screen.presentation.type!=="inline"&&n("Banner requires an inline container",["screen","presentation"]),t.kind!=="banner"&&t.screen.presentation.type==="inline"&&n("Inline presentation belongs to Banner",["screen","presentation"]),t.screen.actions.some(o=>o.type!=="event"&&o.type!=="navigate")&&n("Content actions must emit host intents or navigate locally",["screen","actions"]);let i=new Set(t.screen.actions.filter(o=>o.type==="event").map(o=>o.id));(Object.keys(t.contract.outputs).some(o=>!i.has(o))||[...i].some(o=>!Object.hasOwn(t.contract.outputs,o)))&&n("Every event needs exactly one output declaration",["contract","outputs"]),d(t)>y&&n("Content document exceeds its byte budget",[])});function S(t,r){if(t===null)return r.nullable;switch(r.type){case"json":return!0;case"string":return typeof t=="string";case"number":return typeof t=="number"&&Number.isFinite(t);case"boolean":return typeof t=="boolean";case"strings":return Array.isArray(t)&&t.every(n=>typeof n=="string")}}var x=c.superRefine((t,r)=>{for(let n of p(t.screen))Object.keys(t.contract.inputs).some(i=>n===i||n.startsWith(i+"."))||r.addIssue({code:"custom",path:["contract","inputs"],message:"Declare every reusable input read"});for(let n of t.screen.actions){if(n.type!=="event")continue;let i=t.contract.outputs[n.id],o=Object.hasOwn(n.properties,"value")?n.properties.value:n.properties;i&&!S(o,i)&&r.addIssue({code:"custom",path:["contract","outputs",n.id],message:"Action value differs from its declared type"})}m(t.screen).some(n=>!n.complete)&&r.addIssue({code:"custom",path:["screen","strings"],message:"Content needs complete localized copy"})}),l=e.strictObject({id:e.uuid(),kind:s,projectId:e.uuid(),environmentId:e.uuid(),name:e.string(),revision:e.number().int().nonnegative(),status:e.enum(["draft","published","archived"]),publishedVersionId:e.uuid().nullable(),createdAt:e.iso.datetime({offset:!0}),updatedAt:e.iso.datetime({offset:!0})}),D=l.extend({draft:c}),I=e.strictObject({rows:e.array(l).max(200),nextCursor:e.uuid().nullable()}),v=e.strictObject({id:e.uuid(),kind:s,resourceId:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),version:e.number().int().positive(),sourceRevision:e.number().int().nonnegative(),document:x,createdAt:e.iso.datetime({offset:!0})}),z=v.omit({document:!0}),V=e.discriminatedUnion("action",[e.strictObject({action:e.literal("create"),kind:s,id:e.uuid(),document:c}),e.strictObject({action:e.literal("save"),kind:s,id:e.uuid(),revision:e.number().int().nonnegative(),document:c}),e.strictObject({action:e.enum(["publish","archive"]),kind:s,id:e.uuid(),revision:e.number().int().nonnegative()})]).superRefine((t,r)=>{"document"in t&&t.document.kind!==t.kind&&r.addIssue({code:"custom",path:["document","kind"],message:"Content cannot change domain"})});export{s as a,v as b};
1
+ import{h as p,i as d}from"./chunk-KQF4BVOL.js";import{C as m,w as a,z as u}from"./chunk-HJVEVJXS.js";import{b as e}from"./chunk-42UXYMRZ.js";var s=e.enum(["page","popup","banner"]),y=3e5,f=e.strictObject({type:e.enum(["string","number","boolean","strings","json"]),nullable:e.boolean()}),h=e.strictObject({inputs:e.record(a,f.extend({required:e.boolean()})).refine(t=>Object.keys(t).length<=40,"Too many content inputs"),outputs:e.record(a,f).refine(t=>Object.keys(t).length<=40,"Too many content outputs")}),g=e.strictObject({kind:s,schemaVersion:e.literal(1),name:e.string().trim().min(1).max(80),screen:u,contract:h}),c=g.superRefine((t,r)=>{let n=(o,b)=>r.addIssue({code:"custom",message:o,path:b});t.screen.surface!==t.kind&&n("Content surface must match its domain",["screen","surface"]),t.screen.name!==t.name&&n("Content has one editable name",["screen","name"]),t.kind==="banner"&&t.screen.presentation.type!=="inline"&&n("Banner requires an inline container",["screen","presentation"]),t.kind!=="banner"&&t.screen.presentation.type==="inline"&&n("Inline presentation belongs to Banner",["screen","presentation"]),t.screen.actions.some(o=>o.type!=="event"&&o.type!=="navigate")&&n("Content actions must emit host intents or navigate locally",["screen","actions"]);let i=new Set(t.screen.actions.filter(o=>o.type==="event").map(o=>o.id));(Object.keys(t.contract.outputs).some(o=>!i.has(o))||[...i].some(o=>!Object.hasOwn(t.contract.outputs,o)))&&n("Every event needs exactly one output declaration",["contract","outputs"]),d(t)>y&&n("Content document exceeds its byte budget",[])});function S(t,r){if(t===null)return r.nullable;switch(r.type){case"json":return!0;case"string":return typeof t=="string";case"number":return typeof t=="number"&&Number.isFinite(t);case"boolean":return typeof t=="boolean";case"strings":return Array.isArray(t)&&t.every(n=>typeof n=="string")}}var x=c.superRefine((t,r)=>{for(let n of p(t.screen))Object.keys(t.contract.inputs).some(i=>n===i||n.startsWith(i+"."))||r.addIssue({code:"custom",path:["contract","inputs"],message:"Declare every reusable input read"});for(let n of t.screen.actions){if(n.type!=="event")continue;let i=t.contract.outputs[n.id],o=Object.hasOwn(n.properties,"value")?n.properties.value:n.properties;i&&!S(o,i)&&r.addIssue({code:"custom",path:["contract","outputs",n.id],message:"Action value differs from its declared type"})}m(t.screen).some(n=>!n.complete)&&r.addIssue({code:"custom",path:["screen","strings"],message:"Content needs complete localized copy"})}),l=e.strictObject({id:e.uuid(),kind:s,projectId:e.uuid(),environmentId:e.uuid(),name:e.string(),revision:e.number().int().nonnegative(),status:e.enum(["draft","published","archived"]),publishedVersionId:e.uuid().nullable(),createdAt:e.iso.datetime({offset:!0}),updatedAt:e.iso.datetime({offset:!0})}),D=l.extend({draft:c}),I=e.strictObject({rows:e.array(l).max(200),nextCursor:e.uuid().nullable()}),v=e.strictObject({id:e.uuid(),kind:s,resourceId:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),version:e.number().int().positive(),sourceRevision:e.number().int().nonnegative(),document:x,createdAt:e.iso.datetime({offset:!0})}),z=v.omit({document:!0}),V=e.discriminatedUnion("action",[e.strictObject({action:e.literal("create"),kind:s,id:e.uuid(),document:c}),e.strictObject({action:e.literal("save"),kind:s,id:e.uuid(),revision:e.number().int().nonnegative(),document:c}),e.strictObject({action:e.enum(["publish","archive"]),kind:s,id:e.uuid(),revision:e.number().int().nonnegative()})]).superRefine((t,r)=>{"document"in t&&t.document.kind!==t.kind&&r.addIssue({code:"custom",path:["document","kind"],message:"Content cannot change domain"})});export{s as a,v as b};
@@ -1 +1 @@
1
- import{f as o}from"./chunk-VLSP3LRH.js";var n=class extends Error{constructor(t,s,y,i,r){super(s);this.code=t;this.status=y;this.requestId=i;this.name="IndianaError",this.reason=r?.reason;let e=o(t,y??0,{...r,retryAfter:r?.retryAfterSeconds===void 0?void 0:String(r.retryAfterSeconds)});this.retryable=e.retryable,this.recovery=e.recovery,this.retryAfterSeconds=e.retryAfterSeconds}code;status;requestId;commandRequestId;retryable;recovery;retryAfterSeconds;reason};export{n as a};
1
+ import{f as o}from"./chunk-Q7K66FTS.js";var n=class extends Error{constructor(t,s,y,i,r){super(s);this.code=t;this.status=y;this.requestId=i;this.name="IndianaError",this.reason=r?.reason;let e=o(t,y??0,{...r,retryAfter:r?.retryAfterSeconds===void 0?void 0:String(r.retryAfterSeconds)});this.retryable=e.retryable,this.recovery=e.recovery,this.retryAfterSeconds=e.retryAfterSeconds}code;status;requestId;commandRequestId;retryable;recovery;retryAfterSeconds;reason};export{n as a};