@tinkerlandai/longplay-sdk 0.10.40 → 0.10.41

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 (120) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +56 -1
  3. package/README.zh-CN.md +5 -1
  4. package/dist/{ai-usage-DXwAGTxT.d.ts → ai-usage-B-qsCn-k.d.ts} +1 -1
  5. package/dist/{api-r6FfVQpg.d.ts → api-DpRb_Pd3.d.ts} +52 -0
  6. package/dist/check-response-SR3PDVGE.js +1 -0
  7. package/dist/chunk-24Z3THUR.js +1 -0
  8. package/dist/{chunk-FCDWCQYC.js → chunk-26UXCYBP.js} +1 -1
  9. package/dist/{chunk-7QDT6DO7.js → chunk-2LERKK7O.js} +1 -1
  10. package/dist/{chunk-RV6UAUK2.js → chunk-2LUVO7GM.js} +1 -1
  11. package/dist/{chunk-C2KT5ZFU.js → chunk-2P2YSNYU.js} +1 -1
  12. package/dist/{chunk-X6ONZGRY.js → chunk-2RUJXZCO.js} +1 -1
  13. package/dist/chunk-2XF34Q6D.js +1 -0
  14. package/dist/chunk-4B4RB36N.js +1 -0
  15. package/dist/chunk-5PNH2FPI.js +1 -0
  16. package/dist/{chunk-EREQZWGI.js → chunk-6EBS6MLW.js} +1 -1
  17. package/dist/chunk-6OVMC5BT.js +1 -0
  18. package/dist/{chunk-ASDJTOGM.js → chunk-6STWY5GX.js} +1 -1
  19. package/dist/chunk-756SIMZF.js +1 -0
  20. package/dist/chunk-7IVLNV5H.js +1 -0
  21. package/dist/chunk-ANXK3B5B.js +1 -0
  22. package/dist/{chunk-P6C3PNMQ.js → chunk-AQQJPP3P.js} +1 -1
  23. package/dist/chunk-BWRRZ2NW.js +1 -0
  24. package/dist/{chunk-O4KXODTJ.js → chunk-CQRSMCCG.js} +1 -1
  25. package/dist/{chunk-YLPQLD2A.js → chunk-DPEMW2FO.js} +1 -1
  26. package/dist/chunk-EECTJHI6.js +1 -0
  27. package/dist/{chunk-CZ4TQCUV.js → chunk-EJSDOSP5.js} +1 -1
  28. package/dist/{chunk-POCDWUD3.js → chunk-EON4IKWR.js} +1 -1
  29. package/dist/chunk-EOPKOAR5.js +1 -0
  30. package/dist/{chunk-QZTTKH2H.js → chunk-FTVNGN6Z.js} +1 -1
  31. package/dist/{chunk-WLGLQJ6M.js → chunk-G6CWZBT5.js} +1 -1
  32. package/dist/chunk-GXADA7OV.js +1 -0
  33. package/dist/{chunk-ORMQJAQE.js → chunk-H26F3IOI.js} +1 -1
  34. package/dist/{chunk-BYP4KVB3.js → chunk-H7AHDGVU.js} +2 -2
  35. package/dist/chunk-HGH2X6QM.js +1 -0
  36. package/dist/chunk-KINNES62.js +1 -0
  37. package/dist/{chunk-LSPHUA7V.js → chunk-MYDMOAKX.js} +1 -1
  38. package/dist/chunk-NFY7DKVJ.js +1 -0
  39. package/dist/{chunk-YY445FBU.js → chunk-O3HLNU6T.js} +1 -1
  40. package/dist/chunk-OAAS5LJY.js +1 -0
  41. package/dist/{chunk-2DPNSTCN.js → chunk-OEONV3JY.js} +1 -1
  42. package/dist/chunk-P6XQC7GG.js +1 -0
  43. package/dist/chunk-PYLX3WF6.js +1 -0
  44. package/dist/{chunk-5DZJCFNQ.js → chunk-QJMM37CB.js} +1 -1
  45. package/dist/{chunk-33ZVZOSC.js → chunk-RQTYIUWP.js} +1 -1
  46. package/dist/chunk-S4P4UUUF.js +1 -0
  47. package/dist/{chunk-57GPGWSK.js → chunk-SYHMHKFQ.js} +1 -1
  48. package/dist/{chunk-67AY54E2.js → chunk-TGPZJ5A7.js} +1 -1
  49. package/dist/chunk-VILB5M4X.js +1 -0
  50. package/dist/chunk-VJHURKRY.js +1 -0
  51. package/dist/{chunk-VC2HPREX.js → chunk-VWRQBQZD.js} +1 -1
  52. package/dist/chunk-W35FZWGG.js +1 -0
  53. package/dist/chunk-W3J2SIPY.js +1 -0
  54. package/dist/chunk-Y2HXKANG.js +1 -0
  55. package/dist/{configuration-sync-BHrAf-ql.d.ts → configuration-sync-7ruSsSrL.d.ts} +150 -1
  56. package/dist/content-XYUJFGY2.js +1 -0
  57. package/dist/funnel-host-purchase-BNS3242X.js +1 -0
  58. package/dist/{funnel-local-client-DR8OpKGU.d.ts → funnel-local-client-BMxDQWE6.d.ts} +51987 -22983
  59. package/dist/{funnel-node-evaluation-COxXtZEQ.d.ts → funnel-node-evaluation-COIh1hKs.d.ts} +3 -0
  60. package/dist/funnel-paywall-prerender-DDQI3GAZ.js +1 -0
  61. package/dist/{funnel-process-client-C87U4r_G.d.ts → funnel-process-client-DNR9nHs8.d.ts} +7338 -3163
  62. package/dist/funnel-route-prediction-BT5ZWU54.js +1 -0
  63. package/dist/funnel-route-source-7ZJMZRID.js +1 -0
  64. package/dist/funnel-runtime-host-3SSDNG24.js +1 -0
  65. package/dist/index.d.ts +273 -22
  66. package/dist/index.js +1 -1
  67. package/dist/merchant-bridge-contracts-YU53UKUN.js +1 -0
  68. package/dist/native-shell.js +1 -1
  69. package/dist/openrouter.d.ts +2 -2
  70. package/dist/openrouter.js +1 -1
  71. package/dist/operation-contracts-GEIGP23I.js +1 -0
  72. package/dist/page.d.ts +1 -1
  73. package/dist/page.js +1 -1
  74. package/dist/paywall-YZAEI7TF.js +1 -0
  75. package/dist/paywall-content-QBSB5NA7.js +1 -0
  76. package/dist/paywall-session-MHBAZLS7.js +1 -0
  77. package/dist/popup.d.ts +2 -2
  78. package/dist/popup.js +1 -1
  79. package/dist/{presentation-loading-B_v5XZtM.d.ts → presentation-loading-B2OeFzRN.d.ts} +1 -0
  80. package/dist/react-native.d.ts +6 -6
  81. package/dist/react-native.js +1 -1
  82. package/dist/screen-renderer-SEJG7A2C.js +1 -0
  83. package/dist/server.d.ts +34204 -17797
  84. package/dist/server.js +1 -1
  85. package/dist/{visual-dom-5LUN4AHO.js → visual-dom-7YYJQ2ZI.js} +1 -1
  86. package/dist/visual.js +1 -1
  87. package/package.json +1 -1
  88. package/dist/check-response-DRQCUWDW.js +0 -1
  89. package/dist/chunk-3NCMYTNG.js +0 -1
  90. package/dist/chunk-4TEZZZYK.js +0 -1
  91. package/dist/chunk-6PG3AS3G.js +0 -1
  92. package/dist/chunk-AZFWG352.js +0 -1
  93. package/dist/chunk-C3GYAKIU.js +0 -1
  94. package/dist/chunk-ESAHTG3Y.js +0 -1
  95. package/dist/chunk-GC6JBIRQ.js +0 -1
  96. package/dist/chunk-IJKAQNK6.js +0 -1
  97. package/dist/chunk-IOJVF52Q.js +0 -1
  98. package/dist/chunk-OOD2VDDP.js +0 -1
  99. package/dist/chunk-P23JOPR5.js +0 -1
  100. package/dist/chunk-PJS7M6X3.js +0 -1
  101. package/dist/chunk-PZOQV6MU.js +0 -1
  102. package/dist/chunk-RFNIGJOL.js +0 -1
  103. package/dist/chunk-RULQQ7WI.js +0 -1
  104. package/dist/chunk-U7GH4VME.js +0 -1
  105. package/dist/chunk-VOKEZHAH.js +0 -1
  106. package/dist/chunk-XDOKFAE6.js +0 -1
  107. package/dist/chunk-Y6HL2IY2.js +0 -1
  108. package/dist/content-QUEVNSXD.js +0 -1
  109. package/dist/funnel-host-purchase-LMVMJNUO.js +0 -1
  110. package/dist/funnel-paywall-prerender-LGUSHEP3.js +0 -1
  111. package/dist/funnel-runtime-host-H5FM67UC.js +0 -1
  112. package/dist/merchant-bridge-contracts-LZSQYE3O.js +0 -1
  113. package/dist/operation-contracts-O7TCDGV4.js +0 -1
  114. package/dist/paywall-UANWOKKC.js +0 -1
  115. package/dist/paywall-content-CHPX2P77.js +0 -1
  116. package/dist/paywall-session-3BNUC5ZE.js +0 -1
  117. package/dist/screen-renderer-FFVZ64MR.js +0 -1
  118. /package/dist/{chunk-RGEBK6UF.js → chunk-2ULWP26K.js} +0 -0
  119. /package/dist/{chunk-OJM6ORHE.js → chunk-4PGYQ2TI.js} +0 -0
  120. /package/dist/{chunk-CILM5XMH.js → chunk-PBBREFS5.js} +0 -0
@@ -1 +0,0 @@
1
- import{a as ge}from"./chunk-U7GH4VME.js";import{a as Le}from"./chunk-FCDWCQYC.js";import{$ as B,A as Z,B as xe,C as et,F as Se,I as v,J as N,K as G,L as W,M as Q,Z as tt,_ as X,f as Ze,g as We,h as Qe,q as Xe,s as be,t as Ye,y as H,z as J}from"./chunk-XDOKFAE6.js";import{a as he,b as He,c as Je}from"./chunk-Y6HL2IY2.js";import{b as U}from"./chunk-OOD2VDDP.js";import{b as e}from"./chunk-RGEBK6UF.js";var nt={"zh-Hans":{merchandise:"\u51CF {discount}\uFF08\u5355\u6B21\u4F7F\u7528\uFF09",once:"\u9996\u671F\u51CF {discount}",repeating:"\u524D {months} \u4E2A\u6708\u6BCF\u6708\u51CF {discount}",forever:"\u6BCF\u671F\u51CF {discount}"},"zh-Hant":{merchandise:"\u6E1B {discount}\uFF08\u55AE\u6B21\u4F7F\u7528\uFF09",once:"\u9996\u671F\u6E1B {discount}",repeating:"\u524D {months} \u500B\u6708\u6BCF\u6708\u6E1B {discount}",forever:"\u6BCF\u671F\u6E1B {discount}"},en:{merchandise:"{discount} off \xB7 one use",once:"{discount} off your first payment",repeating:"{discount} off each month for the first {months} months",repeatingOne:"{discount} off the first month",forever:"{discount} off every payment"},ja:{merchandise:"{discount} \u5272\u5F15\uFF081\u56DE\u306E\u307F\uFF09",once:"\u521D\u56DE\u306E\u304A\u652F\u6255\u3044\u304C {discount} \u5272\u5F15",repeating:"\u6700\u521D\u306E {months} \u304B\u6708\u9593\u3001\u6BCE\u6708 {discount} \u5272\u5F15",forever:"\u6BCE\u56DE\u306E\u304A\u652F\u6255\u3044\u304C {discount} \u5272\u5F15"},ko:{merchandise:"{discount} \uD560\uC778 \xB7 1\uD68C \uC0AC\uC6A9",once:"\uCCAB \uACB0\uC81C {discount} \uD560\uC778",repeating:"\uCCAB {months}\uAC1C\uC6D4 \uB3D9\uC548 \uB9E4\uC6D4 {discount} \uD560\uC778",forever:"\uB9E4 \uACB0\uC81C {discount} \uD560\uC778"},es:{merchandise:"{discount} de descuento \xB7 un uso",once:"{discount} de descuento en el primer pago",repeating:"{discount} de descuento cada mes durante los primeros {months} meses",forever:"{discount} de descuento en cada pago",repeatingOne:"{discount} de descuento durante el primer mes"},fr:{merchandise:"{discount} de r\xE9duction \xB7 une utilisation",once:"{discount} de r\xE9duction sur le premier paiement",repeating:"{discount} de r\xE9duction par mois pendant les {months} premiers mois",forever:"{discount} de r\xE9duction sur chaque paiement",repeatingOne:"{discount} de r\xE9duction pendant le premier mois"},de:{merchandise:"{discount} Rabatt \xB7 einmalig",once:"{discount} Rabatt auf die erste Zahlung",repeating:"{discount} Rabatt pro Monat f\xFCr die ersten {months} Monate",forever:"{discount} Rabatt auf jede Zahlung",repeatingOne:"{discount} Rabatt im ersten Monat"},pt:{merchandise:"{discount} de desconto \xB7 um uso",once:"{discount} de desconto no primeiro pagamento",repeating:"{discount} de desconto por m\xEAs nos primeiros {months} meses",forever:"{discount} de desconto em cada pagamento",repeatingOne:"{discount} de desconto no primeiro m\xEAs"},it:{merchandise:"{discount} di sconto \xB7 un utilizzo",once:"{discount} di sconto sul primo pagamento",repeating:"{discount} di sconto al mese per i primi {months} mesi",forever:"{discount} di sconto su ogni pagamento",repeatingOne:"{discount} di sconto per il primo mese"},ru:{merchandise:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \xB7 \u043E\u0434\u043D\u043E \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0435",once:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043D\u0430 \u043F\u0435\u0440\u0432\u044B\u0439 \u043F\u043B\u0430\u0442\u0451\u0436",repeating:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043A\u0430\u0436\u0434\u044B\u0439 \u043C\u0435\u0441\u044F\u0446 \u0432 \u0442\u0435\u0447\u0435\u043D\u0438\u0435 \u043F\u0435\u0440\u0432\u044B\u0445 {months} \u043C\u0435\u0441.",repeatingOne:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u0432 \u043F\u0435\u0440\u0432\u044B\u0439 \u043C\u0435\u0441\u044F\u0446",forever:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043D\u0430 \u043A\u0430\u0436\u0434\u044B\u0439 \u043F\u043B\u0430\u0442\u0451\u0436"},vi:{merchandise:"Gi\u1EA3m {discount} \xB7 d\xF9ng m\u1ED9t l\u1EA7n",once:"Gi\u1EA3m {discount} cho l\u1EA7n thanh to\xE1n \u0111\u1EA7u ti\xEAn",repeating:"Gi\u1EA3m {discount} m\u1ED7i th\xE1ng trong {months} th\xE1ng \u0111\u1EA7u",forever:"Gi\u1EA3m {discount} cho m\u1ED7i l\u1EA7n thanh to\xE1n"},th:{merchandise:"\u0E25\u0E14 {discount} \xB7 \u0E43\u0E0A\u0E49\u0E44\u0E14\u0E49\u0E04\u0E23\u0E31\u0E49\u0E07\u0E40\u0E14\u0E35\u0E22\u0E27",once:"\u0E25\u0E14 {discount} \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E0A\u0E33\u0E23\u0E30\u0E40\u0E07\u0E34\u0E19\u0E04\u0E23\u0E31\u0E49\u0E07\u0E41\u0E23\u0E01",repeating:"\u0E25\u0E14 {discount} \u0E15\u0E48\u0E2D\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E43\u0E19\u0E0A\u0E48\u0E27\u0E07 {months} \u0E40\u0E14\u0E37\u0E2D\u0E19\u0E41\u0E23\u0E01",forever:"\u0E25\u0E14 {discount} \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E0A\u0E33\u0E23\u0E30\u0E40\u0E07\u0E34\u0E19\u0E17\u0E38\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07"},id:{merchandise:"Diskon {discount} \xB7 sekali pakai",once:"Diskon {discount} untuk pembayaran pertama",repeating:"Diskon {discount} setiap bulan selama {months} bulan pertama",forever:"Diskon {discount} untuk setiap pembayaran"},ar:{merchandise:"\u062E\u0635\u0645 {discount} \xB7 \u0627\u0633\u062A\u062E\u062F\u0627\u0645 \u0648\u0627\u062D\u062F",once:"\u062E\u0635\u0645 {discount} \u0639\u0644\u0649 \u0627\u0644\u062F\u0641\u0639\u0629 \u0627\u0644\u0623\u0648\u0644\u0649",repeating:"\u062E\u0635\u0645 {discount} \u0634\u0647\u0631\u064A\u064B\u0627 \u0644\u0645\u062F\u0629 {period}",forever:"\u062E\u0635\u0645 {discount} \u0639\u0644\u0649 \u0643\u0644 \u062F\u0641\u0639\u0629"}};function ve(t){let r=Ye(t)??"en",n=r.split("-"),s=n[0]==="zh"?n.includes("Hans")?"zh-Hans":n.includes("Hant")||n.some(a=>["TW","HK","MO"].includes(a))?"zh-Hant":"zh-Hans":n[0]??"en",i=nt[s];return i?{locale:r,copy:i}:{locale:"en",copy:nt.en}}function Tt(t,r,n="zh-CN"){let s=He(r);return Je(t,r,ve(n).locale,{currencyDisplay:"narrowSymbol",minimumFractionDigits:t%10**s===0?0:s,maximumFractionDigits:s})}function Ut(t,r="zh-CN"){let n=ve(r).locale;return t.type==="percent"?new Intl.NumberFormat(n,{style:"percent",maximumFractionDigits:2}).format(t.percentOff/100):Tt(t.amountOffCents,t.currency,n)}var rt={zh:"\u524D {months} \u4E2A\u6708\u5185\u5F00\u51FA\u7684\u8D26\u5355\u51CF {discount}","zh-Hant":"\u524D {months} \u500B\u6708\u5167\u958B\u51FA\u7684\u5E33\u55AE\u6E1B {discount}",en:"{discount} off invoices issued within the first {months} months",ja:"\u6700\u521D\u306E {months} \u304B\u6708\u4EE5\u5185\u306E\u8ACB\u6C42\u304C {discount} \u5272\u5F15",ko:"\uCCAB {months}\uAC1C\uC6D4 \uB0B4 \uCCAD\uAD6C\uC11C {discount} \uD560\uC778",es:"{discount} de descuento en facturas emitidas durante los primeros {months} meses",fr:"{discount} de r\xE9duction sur les factures \xE9mises pendant les {months} premiers mois",de:"{discount} Rabatt auf Rechnungen innerhalb der ersten {months} Monate",pt:"{discount} de desconto nas faturas emitidas nos primeiros {months} meses",it:"{discount} di sconto sulle fatture emesse nei primi {months} mesi",ru:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043D\u0430 \u0441\u0447\u0435\u0442\u0430 \u0432 \u0442\u0435\u0447\u0435\u043D\u0438\u0435 \u043F\u0435\u0440\u0432\u044B\u0445 {months} \u043C\u0435\u0441.",vi:"Gi\u1EA3m {discount} cho h\xF3a \u0111\u01A1n trong {months} th\xE1ng \u0111\u1EA7u",th:"\u0E25\u0E14 {discount} \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E43\u0E1A\u0E41\u0E08\u0E49\u0E07\u0E2B\u0E19\u0E35\u0E49\u0E43\u0E19\u0E0A\u0E48\u0E27\u0E07 {months} \u0E40\u0E14\u0E37\u0E2D\u0E19\u0E41\u0E23\u0E01",id:"Diskon {discount} untuk tagihan dalam {months} bulan pertama",ar:"\u062E\u0635\u0645 {discount} \u0639\u0644\u0649 \u0627\u0644\u0641\u0648\u0627\u062A\u064A\u0631 \u0627\u0644\u0635\u0627\u062F\u0631\u0629 \u062E\u0644\u0627\u0644 \u0623\u0648\u0644 {period}"};function Mn(t,r="zh-CN",n="month"){let s=ve(r),i=Ut(t.discount,s.locale);if(t.appliesTo?.type==="merchandise")return s.copy.merchandise.replace("{discount}",i);let a=t.duration.type==="repeating"?new Intl.NumberFormat(s.locale).format(t.duration.months):"",u=s.locale.split("-")[0]??"en",c=u==="zh"&&/(?:Hant|TW|HK|MO)/.test(s.locale)?"zh-Hant":u,f=t.duration.type==="repeating"&&n!=="month"?rt[c]??rt.en:t.duration.type==="repeating"&&t.duration.months===1?s.copy.repeatingOne??s.copy.repeating:s.copy[t.duration.type],g=t.duration.type==="repeating"?new Intl.NumberFormat(s.locale,{style:"unit",unit:"month",unitDisplay:"long"}).format(t.duration.months):"";return f.replace("{discount}",i).replace("{months}",a).replace("{period}",g)}var I=e.string().min(1).max(255).regex(/^[A-Za-z0-9_][A-Za-z0-9_.:-]*$/).refine(t=>t.split(".").every(r=>r.length>0&&!["__proto__","constructor","prototype"].includes(r)),"Reserved or empty variable path"),we=e.strictObject({type:e.enum(["string","number","boolean","strings","json","offering_version","reward","paywall_version"]),nullable:e.boolean(),enum:e.array(e.string().max(255)).min(1).max(100).optional()}),Y=we.extend({type:e.enum([...we.shape.type.options,"array"]),items:we.optional()}).superRefine((t,r)=>{(t.type==="array"!=!!t.items||t.enum&&t.type!=="string"||t.items?.enum&&t.items.type!=="string")&&r.addIssue({code:"custom",message:"Array requires items; only strings support enum"})}),ee=Y.safeExtend({source:e.discriminatedUnion("type",[e.strictObject({type:e.literal("input")}),e.strictObject({type:e.literal("node")}),e.strictObject({type:e.enum(["parameter","attribute"]),key:I})])}),Bn=e.record(I,ee),Ie=e.record(I,I).refine(t=>Object.keys(t).length<=20);function P(t,r){return t?r===null?t.nullable:t.enum&&(typeof r!="string"||!t.enum.includes(r))?!1:t.type==="array"?Array.isArray(r)&&r.length<=100&&!!t.items&&r.every(n=>P(t.items,n)):["offering_version","reward","paywall_version"].includes(t.type)?typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===2&&r.type===t.type&&e.uuid().safeParse(r.id).success:t.type==="json"||(t.type==="strings"?Array.isArray(r)&&r.every(n=>typeof n=="string"):typeof r===t.type):!1}function Oe(t,r){return t.nullable&&!r.nullable?!1:r.type==="json"?!0:t.type!==r.type||r.enum&&(!t.enum||t.enum.some(n=>!r.enum.includes(n)))?!1:t.type!=="array"||!!t.items&&!!r.items&&Oe(t.items,r.items)}function te(t,r){let n={};for(let[s,i]of Object.entries(t)){let a=i.source,u=a.type==="input"?r.answers:a.type==="node"?r.results??{}:a.type==="parameter"?r.parameters:r.attributes,c=a.type==="parameter"||a.type==="attribute"?a.key:s,f=Object.hasOwn(u,c),g=u[c];if(a.type==="attribute"&&c.includes(".")&&(!f||c.startsWith("merchandise."))){g=u,f=!0;for(let l of c.split(".")){if(!g||typeof g!="object"||!Object.hasOwn(g,l)||Array.isArray(g)&&(!/^(0|[1-9]\d*)$/.test(l)||Number(l)>=g.length)){f=!1;break}g=g[l]}}if(!(!f||g===void 0)){if(!P(i,g))throw new Error(`Invalid variable value: ${s}`);n[s]=g}}return n}function $n(t,r){let n={};for(let[s,i]of Object.entries(t.writes??{})){if(!Object.hasOwn(r,s))throw new Error(`Node output is missing: ${s}`);if(Object.hasOwn(n,i))throw new Error("Node outputs cannot overwrite one another");n[i]=r[s]}return n}function Gn(t,r,n){let s=new Set(Object.values(r.writes??{}));for(let[i,a]of Object.entries(n))if(!s.has(i)||t[i]?.source.type!=="node"||!P(t[i],a))throw new Error(`Invalid node variable write: ${i}`);if(s.size!==Object.keys(n).length)throw new Error("Node output is incomplete")}var R=e.string().min(1).max(255).regex(/^[a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+){0,9}$/).refine(t=>t.split(".").every(r=>!["__proto__","constructor","prototype"].includes(r)),"Reserved value path"),E=e.discriminatedUnion("source",[e.strictObject({source:e.literal("literal"),value:v}),e.strictObject({source:e.literal("variable"),key:e.string().min(1).max(255),path:R.optional()})]);function it(t,r){if(!r)return t;for(let n of R.parse(r).split(".")){if(Array.isArray(t)){if(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=t.length)return;t=t[Number(n)];continue}if(t===null||typeof t!="object"||!Object.hasOwn(t,n))return;t=Reflect.get(t,n)}return t}function Bt(t,r){if(t.source==="literal")return structuredClone(t.value);let n=te(r.declarations,r);if(!Object.hasOwn(n,t.key))throw new Error("Capability input is missing");return structuredClone(v.parse(it(n[t.key],t.path)))}function je(t,r){let n=[...r].sort((i,a)=>a.length-i.length).find(i=>t===i||t.startsWith(i+"."));if(!n)return null;let s=t===n?void 0:t.slice(n.length+1);return s&&!R.safeParse(s).success?null:{key:n,path:s}}function ke(t){let r=Object.values(t.strings.locales).flatMap(n=>Object.values(n));return H(t,n=>{n.type==="custom_html"&&r.push(...Object.values(n.html))}),[...new Set(r.flatMap(Qe))]}function ot(t){return ke(t).filter(r=>r.startsWith("variables.")).map(r=>r.slice(10))}function M(t){let r=JSON.stringify(t);if(r===void 0)throw new TypeError("A JSON value is required");let n=new TextEncoder().encode(r).length,s=!1;for(let i=0;i<r.length;i++){let a=r.charAt(i);if(s)a==="\\"?i++:a==='"'&&(s=!1);else if(a==='"')s=!0;else if(a===":"||a===",")n++;else if(a==="-"||a>="0"&&a<="9"){let u=i;for(;i+1<r.length&&/[0-9.eE+-]/.test(r.charAt(i+1));)i++;let c=r.slice(u,i+1);if(!/[eE]/.test(c))continue;let[f="",g]=c.split(/[eE]/),l=f.replace(/^-/,""),w=l.replace(".","").length,K=(l.includes(".")?l.indexOf("."):w)+Number(g),y=K<=0?2-K+w:K>=w?K:w+1;n+=y+(f.startsWith("-")?1:0)-c.length}}return n}function F(t){let r=new Set,n=a=>a!==null&&typeof a=="object"&&!Array.isArray(a);function s(a,u){if(n(a))for(let[c,f]of Object.entries(a))c==="$elemMatch"?i(f,u):c==="$not"?s(f,u):c==="$all"&&Array.isArray(f)&&f.forEach(g=>s(g,u))}function i(a,u=""){if(n(a)){for(let[c,f]of Object.entries(a))if(["$and","$or","$nor"].includes(c)&&Array.isArray(f))f.forEach(g=>i(g,u));else if(c==="$not")i(f,u);else if(c==="$savedGroup"&&n(f))typeof f.attributeKey=="string"&&r.add(f.attributeKey);else if(!c.startsWith("$")){let g=u?`${u}.${c}`:c;r.add(g),s(f,g)}}}return i(t),[...r]}var $t=e.enum(["active","inactive"]),Gt=e.preprocess((t,r)=>{let n=0;function s(i,a){if(!(++n>1e4||a>20)){if(Array.isArray(i))i.forEach(u=>s(u,a+1));else if(i&&typeof i=="object")for(let[u,c]of Object.entries(i))["__proto__","constructor","prototype"].includes(u)&&r.addIssue({code:"custom",message:"Reserved merchandise attribute"}),s(c,a+1)}}return s(t,0),t},N),qt=e.strictObject({id:e.string().trim().min(1).max(255),name:e.string().trim().min(1).max(255),status:$t,metadata:Gt}),sr=qt.extend({internal_id:e.uuid(),project_id:e.uuid(),environment_id:e.uuid(),created_at:e.iso.datetime({offset:!0}),updated_at:e.iso.datetime({offset:!0})}),ar=e.union([e.strictObject({id:e.string().trim().min(1).max(255)}),e.strictObject({internalId:e.uuid()})]),cr=e.enum(["customer","merchandise","context"]),ur=e.enum(["system","stored","request"]),lr=e.enum(["customer","merchandise","mixed"]),st=t=>t==="merchandiseId"||t==="merchandise"||t.startsWith("merchandise.");function Ae(t,r={},n=new Set){if(F(t).some(st))return!0;for(let s of W(t)){if(n.has(s))continue;n.add(s);let i=r[s];if(i?.type==="list"&&st(i.attributeKey)||i?.type==="condition"&&Ae(i.condition,r,n))return!0}return!1}var hr=e.enum(["draft","active","paused","archived"]),at=e.discriminatedUnion("type",[e.object({type:e.literal("percent"),percentOff:e.number().min(1).max(100).multipleOf(.01)}).strict(),e.object({type:e.literal("amount"),amountOffCents:e.number().int().min(1).max(1e8),currency:he}).strict()]),ct=e.discriminatedUnion("type",[e.object({type:e.literal("once")}).strict(),e.object({type:e.literal("repeating"),months:e.number().int().min(1).max(36)}).strict(),e.object({type:e.literal("forever")}).strict()]),ut=[e.object({type:e.literal("all")}).strict(),e.object({type:e.literal("plans"),planIds:e.array(e.uuid()).min(1).max(50).refine(t=>new Set(t).size===t.length,"\u5957\u9910\u4E0D\u80FD\u91CD\u590D")}).strict()],Lt=e.discriminatedUnion("type",[...ut,e.strictObject({type:e.literal("merchandise"),scope:e.discriminatedUnion("type",[e.strictObject({type:e.literal("all")}),e.strictObject({type:e.literal("selected"),merchandiseIds:e.array(e.uuid()).min(1).max(1e3).refine(t=>new Set(t).size===t.length,"Duplicate merchandise")}),e.strictObject({type:e.literal("condition"),condition:G})])})]),Ht=e.discriminatedUnion("type",[...ut,e.strictObject({type:e.literal("merchandise"),scope:e.strictObject({type:e.enum(["all","selected","condition"])})})]),Jt=e.strictObject({firstPurchaseOnly:e.boolean(),condition:G}),br=e.object({name:e.string().trim().min(1).max(80),description:e.string().max(500),discount:at,duration:ct,nativeDiscountPolicy:ge.optional(),appliesTo:Lt,eligibility:Jt,selfClaimEnabled:e.boolean().default(!1),startsAt:e.iso.datetime().nullable(),endsAt:e.iso.datetime().nullable(),totalLimit:e.number().int().min(1).max(1e6).nullable(),perCustomerLimit:e.number().int().min(1).max(10),grantWindowHours:e.number().int().min(1).max(2160)}).strict().refine(t=>!t.startsAt||!t.endsAt||Date.parse(t.endsAt)>Date.parse(t.startsAt),{message:"\u7ED3\u675F\u65F6\u95F4\u5FC5\u987B\u665A\u4E8E\u5F00\u59CB\u65F6\u95F4",path:["endsAt"]}).refine(t=>!Ae(t.eligibility.condition),{message:"Customer eligibility cannot read merchandise; use merchandise applicability",path:["eligibility","condition"]}).refine(t=>t.appliesTo.type!=="merchandise"||t.duration.type==="once",{message:"Merchandise Coupons apply to one purchase",path:["duration"]}).refine(t=>t.appliesTo.type!=="merchandise"||!t.eligibility.firstPurchaseOnly,{message:"Merchant purchase eligibility requires trusted targeting attributes",path:["eligibility","firstPurchaseOnly"]}),xr=e.object({code:e.string().trim().transform(t=>t.toUpperCase()).pipe(e.string().regex(/^[A-Z0-9][A-Z0-9_-]{2,31}$/,"\u4F18\u60E0\u7801\u53EA\u80FD\u7528 3\u201332 \u4F4D\u5B57\u6BCD\u3001\u6570\u5B57\u3001- \u548C _\uFF0C\u4EE5\u5B57\u6BCD\u6216\u6570\u5B57\u5F00\u5934")),maxRedemptions:e.number().int().min(1).max(1e6).nullable(),expiresAt:e.iso.datetime().nullable(),firstPurchaseOnly:e.boolean(),minimumAmountCents:e.number().int().min(1).max(1e8).nullable(),minimumAmountCurrency:he.nullable()}).strict().refine(t=>t.minimumAmountCents===null==(t.minimumAmountCurrency===null),"Minimum amount requires its currency");var lt=e.object({id:e.uuid(),couponId:e.uuid(),status:e.enum(["issued","reserved","redeemed","revoked","expired"]),issuedAt:e.iso.datetime(),expiresAt:e.iso.datetime(),coupon:e.object({name:e.string(),discount:at,duration:ct,nativeDiscountPolicy:ge.optional(),appliesTo:Ht}).strict()}).strict(),Sr=e.enum(["claim_disabled","unavailable","inactive","outside_window","not_targeted","not_first_purchase","limit_reached","sold_out"]);var Zt=e.string().regex(/^[a-f0-9]{64}$/),Wt=Ze.pick({text:!0,label:!0,alt:!0,html:!0,couponId:!0,countdownAt:!0,missing:!0}),pt=e.strictObject({couponDigests:e.record(e.uuid(),Zt),variables:e.record(be,e.record(e.uuid(),e.partialRecord(e.enum(["offer.name","offer.description","offer.headline","offer.eligibility","offer.validity","offer.terms","offer.discount","offer.months","offer.ends_at"]),e.string()))),locales:e.record(be,We.extend({nodes:e.record(e.string(),e.strictObject({base:Wt})),plans:e.object({}).strict(),pickers:e.object({}).strict()}).omit({paywall:!0}))});var dt=e.enum(["funnel-run/1","funnel-process/1"]),Ar="funnel-process/1";var Ce=v,Qt=["parameters","answers","results","variables"];function Xt(t){return Qt.some(r=>t===r||t.startsWith(r+"."))}function Yt(t){let r={};for(let[s,i]of Object.entries(te(t.declarations,t))){let a=s.split(".");if(a.some(f=>["__proto__","constructor","prototype"].includes(f)))throw new Error("Reserved result path");let u=r;for(let f of a.slice(0,-1)){Object.hasOwn(u,f)||(u[f]={});let g=u[f];if(!g||typeof g!="object"||Array.isArray(g))throw new Error("Ambiguous result path");u=g}let c=a.at(-1);if(c===void 0)throw new Error("Empty result path");u[c]=i}return{...Object.fromEntries(Object.entries(t.attributes).filter(([s])=>!Xt(s))),variables:r}}var ne=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/);var _e=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),mt=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,128}$/),ft=B.refine(t=>new TextEncoder().encode(JSON.stringify(t)).byteLength<=8192,"Task data exceeds 8 KiB"),Re=e.record(_e,e.enum(["string","number","boolean","strings"])).refine(t=>Object.keys(t).length<=20,"Too many output fields"),en=E,yt=e.strictObject({type:e.literal("external_task"),endpointId:e.uuid(),taskKey:_e,inputs:e.record(_e,en).refine(t=>Object.keys(t).length<=20),outputs:Re}),gt=e.strictObject({maxAttempts:e.number().int().min(1).max(5),retryDelaySeconds:e.number().int().min(1).max(30),backoff:e.enum(["fixed","exponential"]),requestTimeoutSeconds:e.number().int().min(1).max(10),timeoutSeconds:e.number().int().min(1).max(300)}).refine(t=>t.requestTimeoutSeconds<=t.timeoutSeconds,"Request timeout exceeds action deadline");var Br=e.strictObject({outcome:e.enum(["success","failure"]),data:ft});var $r=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("signal"),runId:e.uuid(),nodeId:mt,eventName:ne,eventId:e.uuid(),data:ft}),e.strictObject({operation:e.literal("read_results"),runId:e.uuid()})]),Gr=e.strictObject({scope:U,runId:e.uuid(),eventId:e.uuid(),accepted:e.boolean()}),tn=e.record(mt,Ce),qr=e.strictObject({scope:U,runId:e.uuid(),results:tn});var nn=["id","externalUserId","createdAt","ageDays","subscription"],De=e.array(e.string().trim().min(1).max(40).refine(t=>!t.includes(","),"\u6807\u7B7E\u4E0D\u80FD\u5305\u542B\u9017\u53F7")).max(20).refine(t=>new Set(t).size===t.length,"\u6807\u7B7E\u4E0D\u80FD\u91CD\u590D"),re=e.intersection(N,e.looseObject({tags:De.optional()})).refine(t=>![...nn,"parameters","answers","results"].some(r=>Object.hasOwn(t,r)),"Reserved customer attribute"),ie=e.string().trim().max(80),oe=e.string().regex(/^\+[1-9]\d{1,14}$/).nullable(),se=e.union([e.email().max(254),e.literal("")]),rn=e.string().trim().min(1).max(255).refine(t=>!/\p{Cc}/u.test(t),"Fingerprint must not contain control characters"),ht=e.string().trim().min(1).max(255).refine(t=>!t.startsWith("gg_guest_"),"Reserved guest identity namespace"),Zr=e.object({externalUserId:ht.optional(),name:ie.default(""),email:se.default(""),phone:oe.optional(),attributes:re.default({})}).strict().refine(t=>t.externalUserId!==void 0||t.email!=="","\u8BF7\u63D0\u4F9B\u4E1A\u52A1\u7528\u6237 ID \u6216\u90AE\u7BB1"),ae=e.discriminatedUnion("type",[e.strictObject({type:e.literal("id"),value:e.uuid()}),e.strictObject({type:e.literal("externalUserId"),value:ht})]),ce=e.strictObject({name:ie.optional(),email:se.optional(),phone:oe.optional(),attributes:re.optional(),fingerprint:rn.optional()}),ue=t=>!t.customerData||t.customer?.type==="externalUserId",le="customerData requires an externalUserId customer",bt=e.object({id:e.uuid(),externalUserId:e.string().min(1).max(255).nullable(),name:ie,email:se,phone:oe.optional(),attributes:re,createdAt:e.iso.datetime()}).strict(),Wr=e.object({customer:bt,changed:e.boolean(),replayed:e.boolean()}).strict(),on=e.discriminatedUnion("type",[e.object({type:e.literal("id"),value:e.uuid()}).strict(),e.object({type:e.literal("externalUserId"),value:e.string().trim().min(1).max(255)}).strict()]),sn=e.object({name:ie.optional(),email:se.optional(),phone:oe.optional(),attributes:re.refine(t=>!Object.hasOwn(t,"tags"),"Use incremental tagChanges").optional(),removeAttributes:e.array(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_]{0,127}$/)).max(128).refine(t=>!t.includes("tags")).optional(),tagChanges:e.strictObject({add:De,remove:De}).optional()}).strict().refine(t=>Object.keys(t).length>0,"\u8BF7\u63D0\u4F9B\u9700\u8981\u4FEE\u6539\u7684\u5B57\u6BB5"),an=e.object({lookup:on}).strict(),Qr=an.extend({requestId:e.uuid(),patch:sn}).strict(),Xr=e.object({search:e.string().trim().max(200).default(""),tag:e.string().trim().max(40).default(""),planId:e.string().max(200).default(""),versionId:e.string().max(200).default(""),holdingStatus:e.enum(["","active","scheduled","expired","unavailable","none"]).default(""),membershipStatus:e.enum(["","active","trial","past_due","ended"]).default(""),createdFrom:e.union([e.iso.datetime(),e.literal("")]).default(""),createdUntil:e.union([e.iso.datetime(),e.literal("")]).default(""),offset:e.coerce.number().int().min(0).max(1e5).default(0),limit:e.coerce.number().int().min(1).max(100).default(50)}).strict(),Yr=e.object({customers:bt.array(),hasMore:e.boolean(),total:e.number().int().nonnegative().nullable(),evaluatedAt:e.iso.datetime()}).strict();var ii=e.enum(["local","remote"]),ze=e.strictObject({port:e.string().regex(/^[a-zA-Z0-9_.:-]{1,128}$/),value:v.optional(),sticky:e.array(e.strictObject({expected:Q.nullable(),next:Q})).max(100),exposures:e.array(v).max(100),features:e.array(v).max(100)}),xt=e.strictObject({type:e.literal("evaluate"),receiptId:e.uuid(),environmentId:e.uuid(),policyRevision:e.number().int().nonnegative(),attributes:N,sticky:e.record(e.string(),Q)}),St=xt.extend({runId:e.uuid(),versionId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative()}),cn=xt.omit({type:!0,receiptId:!0}).extend({type:e.literal("evaluate_segment")}),vt=e.strictObject({nodeId:e.string().min(1).max(64),result:ze}),wt=cn.extend({runId:e.uuid(),versionId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),parameters:B,answers:X,variables:e.record(e.string(),v)});var Ee=e.discriminatedUnion("type",[e.strictObject({type:e.literal("literal"),value:v}),e.strictObject({type:e.literal("variable"),key:I,path:R.optional()}),e.strictObject({type:e.literal("feature"),featureKey:e.string().min(1).max(128)})]),un=e.strictObject({requestId:e.uuid(),decisionId:e.uuid(),customerId:e.uuid(),externalUserId:e.string().min(1).max(255).nullable(),versionId:e.uuid(),receiptId:e.uuid(),value:v}),ln={funnelId:e.uuid(),requestId:e.uuid(),customer:ae,customerData:ce.optional(),attributes:N.refine(t=>!["parameters","answers","results","variables"].some(r=>Object.hasOwn(t,r)),"parameters, answers, results and variables are reserved flow namespaces")},mi=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("decide"),...ln}).refine(ue,le),e.strictObject({operation:e.literal("read_decision"),decisionId:e.uuid()}),e.strictObject({operation:e.literal("evaluate_decision"),decisionId:e.uuid(),requestId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),receiptId:e.uuid(),policyRevision:e.number().int().nonnegative(),generation:e.string().min(1).max(256),result:ze}),e.strictObject({operation:e.literal("feature_config"),funnelId:e.uuid()}),e.strictObject({operation:e.literal("commit_decision_segment"),decisionId:e.uuid(),requestId:e.uuid(),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),policyRevision:e.number().int().nonnegative(),generation:e.string().min(1).max(256),steps:e.array(vt).max(32),boundary:e.strictObject({nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative()}).optional()}),e.strictObject({operation:e.literal("segment_configuration"),funnelId:e.uuid(),versionId:e.uuid()}),e.strictObject({operation:e.literal("configuration"),funnelId:e.uuid(),versionId:e.uuid().optional()}),e.strictObject({operation:e.literal("local_configuration"),funnelId:e.uuid()}),e.strictObject({operation:e.literal("report_used"),decisionId:e.uuid(),eventId:e.uuid(),occurredAt:e.iso.datetime({offset:!0}),reference:e.string().min(1).max(128).optional()})]),fi=e.strictObject({scope:U,decisionId:e.uuid(),requestId:e.uuid(),status:e.enum(["pending","completed","failed"]),decision:un.nullable(),evaluation:e.discriminatedUnion("type",[St,wt]).optional()}).refine(t=>t.status==="completed"==(t.decision!==null)&&(!t.decision||t.decision.decisionId===t.decisionId&&t.decision.requestId===t.requestId),"Completed decisions carry their committed result"),yi=e.strictObject({scope:U,decisionId:e.uuid(),eventId:e.uuid(),source:e.literal("caller_reported")});function pn(t,r=[]){let n=[];H(t,i=>{i.hidden&&n.push("Hidden components must not be delivered"),r.includes(i.type)&&n.push(`Node type ${i.type} cannot be delivered`)});let s=new Set(xe(t).map(i=>i.key));for(let[i,a]of Object.entries(t.strings.locales))for(let u of Object.keys(a))s.has(u)||n.push(`Unused string ${u} must not be delivered (${i})`);return n}function It(t){return t.hidden?null:t.type!=="stack"?t:{...t,children:t.children.flatMap(r=>It(r)??[])}}function dn(t){let r=t.pages.map(i=>{let a=It(i.root);return a?.type==="stack"?{...i,root:a}:{...i,root:{type:"stack",id:i.root.id,...i.root.name===void 0?{}:{name:i.root.name},direction:"vertical",align:"stretch",justify:"start",children:[]}}}),n=new Set(xe({pages:r}).map(i=>i.key)),s=Object.fromEntries(Object.entries(t.strings.locales).map(([i,a])=>[i,Object.fromEntries(Object.entries(a).filter(([u])=>n.has(u)))]));return{...t,pages:r,strings:{...t.strings,locales:s}}}function Ot(t,r=[]){let n=J.parse(structuredClone(dn(t))),s=a=>a.type!=="stack"||a.interaction!==void 0||a.children.some(s);for(let a of n.pages)if(!s(a.root))throw new Error(`Page ${a.id} has no visible content`);let i=pn(n,r);if(i.length)throw new Error(i.join("; "));return n}var Si=e.discriminatedUnion("action",[e.strictObject({action:e.literal("create"),couponId:e.uuid(),productBindingId:e.uuid(),storeOfferId:e.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/).nullable(),storeOfferType:e.enum(["introductory","promotional"])}),e.strictObject({action:e.literal("set_enabled"),id:e.uuid(),revision:e.number().int().nonnegative(),enabled:e.boolean()})]),vi=e.array(e.strictObject({id:e.uuid(),couponId:e.uuid(),productBindingId:e.uuid(),storeOfferId:e.string().min(1).max(255).nullable(),storeOfferType:e.enum(["introductory","promotional"]),enabled:e.boolean(),revision:e.number().int().nonnegative()})).max(500),Ke=e.strictObject({offerKind:e.enum(["none","introductory","promotional"]),offerId:e.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/).nullable(),discountMinor:e.number().int().min(0).max(1e8),trialDays:e.number().int().min(1).max(730).nullable()}).superRefine((t,r)=>{(t.offerKind==="none"&&(t.offerId!==null||t.discountMinor!==0||t.trialDays!==null)||t.trialDays!==null&&t.discountMinor!==0)&&r.addIssue({code:"custom",message:"Select one store purchase option with its exact terms"})}),wi=e.record(e.uuid(),Ke).refine(t=>Object.keys(t).length<=20,"At most 20 native store selections");var ji=e.strictObject({schemaVersion:e.literal(1),renderKey:e.string().min(1).max(256),routeTemplate:e.string().startsWith("/").max(2048),selectors:e.array(e.string().regex(/^[a-z][a-z0-9-]*\[(?:id|data-testid|data-test|data-qa|data-indiana-id)="(?:[^"\\\x00-\x1f\x7f]|\\["\\])*"\]$/).max(512)),present:e.array(e.number().int().min(0)).min(1),absent:e.array(e.number().int().min(0))}).superRefine((t,r)=>{let n=[...t.present,...t.absent];(new Set(t.selectors).size!==t.selectors.length||new Set(n).size!==n.length||n.length!==t.selectors.length||n.some(s=>s>=t.selectors.length))&&r.addIssue({code:"custom",message:"Incomplete or ambiguous render signature"})}),jt=e.strictObject({renderKey:e.string().min(1).max(256),routeKey:e.string().min(1).max(256),stateKey:e.string().min(1).max(256),documentKey:e.string().min(1).max(256),documentHash:e.string().regex(/^[a-f0-9]{64}$/),compositionKey:e.string().min(1).max(256),entryMode:e.enum(["hard","soft"]),match:e.strictObject({present:e.array(e.number().int().min(0)),absent:e.array(e.number().int().min(0))})});var mn=["enterprise-internal-indiana-test","tinkerland-indiana-prod"],Ve="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",fn=e.string().regex(new RegExp(`^${Ve}/${Ve}/${Ve}/manifest\\.json$`)),kt=e.strictObject({kind:e.literal("gcs-resumable"),url:e.url(),bucket:e.enum(mn),objectKey:fn,byteLength:e.number().int().positive(),expiresAt:e.iso.datetime()}).superRefine((t,r)=>{let n=new URL(t.url),s=n.searchParams,i=["uploadType","upload_id","name","upload_protocol","ifGenerationMatch"];(n.origin!=="https://storage.googleapis.com"||n.username||n.password||n.hash||n.pathname!==`/upload/storage/v1/b/${t.bucket}/o`||[...s.keys()].some(a=>!i.includes(a)||s.getAll(a).length!==1)||s.get("uploadType")!=="resumable"||!/^[A-Za-z0-9_-]{1,4096}$/.test(s.get("upload_id")??"")||s.has("name")&&s.get("name")!==`app-manifests/${t.objectKey}`||s.has("upload_protocol")&&s.get("upload_protocol")!=="resumable"||s.has("ifGenerationMatch")&&s.get("ifGenerationMatch")!=="0")&&r.addIssue({code:"custom",message:"Invalid IAM upload capability"})});var S=e.string().min(1).max(256),A=e.string().regex(/^[a-f0-9]{64}$/),pe=e.strictObject({versionId:e.uuid(),manifestDigest:A,sourceGraphDigest:A,pageKey:S,stateKey:S,documentKey:S,documentHash:A,elementKey:S.optional(),nodeId:S.optional(),contentHash:A.optional(),renderKey:S.optional()}),At=e.strictObject({pageKey:S,documentKey:S,expectedDocumentHash:A,renderKey:S.optional(),nodeId:S,elementKey:S,expectedContentHash:A,property:e.enum(["text","fontSize","color"]),value:e.union([e.string().max(4e3),e.number().finite()])}),zi=e.strictObject({versionId:e.uuid(),manifestDigest:A,sourceGraphDigest:A,pageKey:S,stateKey:S,documentKey:S,documentHash:A,renderKey:S.optional(),patches:e.array(At.omit({pageKey:!0,documentKey:!0,expectedDocumentHash:!0,renderKey:!0})).min(1).max(200)}),yn=/^[a-z][a-z0-9-]{0,39}$/,q=e.string().regex(yn),Pe=e.enum(["web","ios","android"]),Ct={requestId:e.uuid(),client:q,platform:Pe,label:e.string().trim().min(1).max(100),sha256:A,bytes:e.number().int().min(1),transferBytes:e.number().int().min(1)},gn=e.strictObject({action:e.literal("upload"),...Ct,transferBytes:e.number().int().min(1).max(2e6),base64:e.string().min(4).max(2666668).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/)}),Ei=e.discriminatedUnion("action",[gn,e.strictObject({action:e.literal("register"),...Ct}),e.strictObject({action:e.literal("complete"),versionId:e.uuid()}),e.strictObject({action:e.literal("current"),versionId:e.uuid(),expectedCurrent:e.uuid().nullable()}),e.strictObject({action:e.literal("delivery"),enabled:e.boolean()}),e.strictObject({action:e.literal("changes"),versionId:e.uuid(),experimentId:e.uuid(),variationId:S,changesetId:e.uuid().nullable(),expectedRevision:A.nullable(),editorUrl:e.string().url().max(2048),patches:e.array(At).max(200)})]),Fe=e.strictObject({id:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),clientKey:q,platform:Pe,label:e.string(),sha256:A,bytes:e.number().int().positive(),objectKey:e.string(),state:e.enum(["uploading","ready","rejected"]),isCurrent:e.boolean(),revision:e.number().int().nonnegative(),createdAt:e.string(),expiresAt:e.string(),readyAt:e.string().nullable(),summary:e.record(e.string(),e.json()),routeTree:e.json().nullable(),validation:e.record(e.string(),e.json())}),hn=e.strictObject({key:q,platform:Pe,currentId:e.uuid().nullable()}),Ki=e.strictObject({rows:e.array(Fe).max(100),nextCursor:e.uuid().nullable(),clients:e.array(hn).max(20)}),Ne=e.strictObject({storedBytes:e.number().int().nonnegative(),reservedBytes:e.number().int().nonnegative(),chargedBytes:e.number().int().nonnegative(),versions:e.number().int().nonnegative(),objects:e.number().int().nonnegative(),orphanObjects:e.number().int().nonnegative(),missingReadyObjects:e.number().int().nonnegative(),unknownObjectSizes:e.number().int().nonnegative(),byteLimit:e.number().int().positive(),versionLimit:e.number().int().positive(),remainingBytes:e.number().int().nonnegative()}),Vi=e.strictObject({asOf:e.iso.datetime({offset:!0}),reclamation:e.literal("manual-review-required"),buckets:e.strictObject({source:Ne,runtime:Ne,previews:Ne})}),Ni=e.strictObject({version:Fe,actorId:e.uuid(),claims:e.record(e.string(),e.json())}),Pi=e.strictObject({version:Fe,upload:kt.nullable()}),Fi=e.object({format:e.literal("indiana-route-state-index"),schemaVersion:e.literal(3),routes:e.array(e.object({routeKey:S,path:e.string(),documentKey:S,documentHash:A,initialStateKey:S,initialRenderKey:S})),renders:e.array(jt)}).loose().superRefine((t,r)=>{(!t.renders||t.routes.some(n=>!t.renders?.some(s=>s.renderKey===n.initialRenderKey&&s.routeKey===n.routeKey&&s.documentKey===n.documentKey&&s.stateKey===n.initialStateKey&&s.documentHash===n.documentHash&&s.entryMode==="hard")))&&r.addIssue({code:"custom",message:"Incomplete render catalog"})}),Mi=e.strictObject({rows:e.array(e.object({id:e.uuid(),name:e.string(),status:e.string(),variations:e.array(e.object({id:S,key:S,name:e.string().optional()}).loose())}).loose()),limited:e.boolean()}),Ti=e.strictObject({enabled:e.boolean(),allowedOrigins:e.array(e.string())});var bn=e.strictObject({delaySeconds:e.number().int().min(0).max(86400).optional(),maxPerDay:e.number().int().min(1).max(100).optional(),maxPerSession:e.number().int().min(1).max(100).optional()}),_t=e.strictObject({id:e.uuid(),name:e.string().trim().min(1).max(80),client:q,source:pe,event:e.enum(["screen_enter","button_click"]),cooldownSeconds:e.number().int().min(0).max(2592e3),behavior:e.literal("observe"),delivery:bn.optional()}).superRefine((t,r)=>{t.event==="button_click"&&(!t.source.nodeId||!t.source.elementKey)&&r.addIssue({code:"custom",path:["source"],message:"Choose a uniquely bound button"})});var D={flowNodes:500,logicNodes:480,pages:100,components:1500,actions:250,questions:40,documentBytes:1e6,conditionDepth:3,conditionChildren:20,conditionPredicates:100},Rt="00000000-0000-0000-0000-000000000000";var Dt=e.strictObject({type:e.literal("bundle"),paywall:E.optional(),offering:E.optional(),coupons:E,data:E}),xn=t=>e.strictObject({type:e.literal(t),id:e.uuid()}),Wi=e.strictObject({type:e.literal("bundle"),paywallVersionId:e.uuid().optional(),offeringVersionId:e.uuid().optional(),couponIds:e.array(e.uuid()).max(20).refine(t=>new Set(t).size===t.length),data:v});var Qi=e.strictObject({type:e.literal("bundle"),offering:xn("offering_version").nullable(),paywall:e.strictObject({versionId:e.uuid(),paywallId:e.uuid(),offeringVersionId:e.uuid()}).nullable(),coupons:e.array(lt).max(20),data:v});var zt=e.union([e.string(),e.number().finite(),e.boolean(),e.null()]),Sn=e.union([zt,e.array(zt).min(1).max(20)]),vn=e.record(R,Sn).refine(t=>Object.keys(t).length<=10),Et=e.strictObject({path:R,type:e.enum(["string","number","boolean","strings"]),nullable:e.boolean().optional(),aggregation:e.enum(["count","exists"]).optional(),where:vn.optional()}).superRefine((t,r)=>{(t.aggregation==="count"&&t.type!=="number"||t.aggregation==="exists"&&t.type!=="boolean"||!t.aggregation&&t.where)&&r.addIssue({code:"custom",message:"Collection summaries require their matching type"})});var wn=["sendMessage","checkEntitlement","resolveOffering","readHoldings","readLedger","readBillingInvoice","readCreditStatement","previewAttach","attach","readSubscriptionOperation","previewUpdate","update","readSubscriptionUpdate","setupPayment","readPaymentSetup","verifySubscriptions","previewRefund","refund","readRefund","restoreNativePurchase","readBillingControls","prepareBillingAuthorization","confirmBillingAuthorization","setBillingCoupons","revokeBillingAuthorization","listBillingInvoices","confirmBillingAdjustment","manageBillingLimits","readSeats","manageSeat","quoteBalance","mutateBalance","trackUsage","readUsage","setUsage","adjustBalance","readBalanceSource","manageBalanceGrant","listBalanceGrants","manageUsageEntity","readUsageAnalytics","readCreditAnalytics","submitUsageBatch","readUsageBatch","redeemCoupon","listOffers","grantOffer","redeemReward","createReferralCode","claimRewardProduct"],Kt=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),In=E,Vt=e.discriminatedUnion("type",[yt,e.strictObject({type:e.literal("claim_offer"),coupon:E}),e.strictObject({type:e.literal("event"),event:Kt}),e.strictObject({type:e.literal("api"),operation:e.enum(wn),inputs:e.record(R,In).refine(t=>Object.keys(t).length<=40),outputs:e.record(Kt,Et).refine(t=>Object.keys(t).length<=20)})]);var b=ne,On=e.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/),C={id:b,name:e.string().trim().min(1).max(80),position:e.strictObject({x:e.number().finite(),y:e.number().finite()}).optional()},jn={success:b,cancel:b,unavailable:b,failure:b},kn=e.url().max(2048).refine(t=>{try{return new URL(t).protocol==="https:"}catch{return!1}},{message:"External pages require HTTPS"}),An=e.enum(["same_window","new_window"]),Cn=e.discriminatedUnion("type",[e.strictObject({...C,type:e.literal("entry"),next:b,triggers:e.array(_t).max(20).refine(t=>new Set(t.map(r=>r.id)).size===t.length,"Entry trigger IDs must be unique").optional()}),e.strictObject({...C,type:e.literal("screen"),screenId:b,presentation:Xe,outputs:e.record(b,b),offering:e.discriminatedUnion("source",[e.strictObject({source:e.literal("variable"),key:I}),e.strictObject({source:e.literal("fixed"),versionId:e.uuid()})]).optional()}),e.strictObject({...C,type:e.literal("offering"),configuration:e.discriminatedUnion("source",[e.strictObject({source:e.literal("fixed"),versionId:e.uuid()}),e.strictObject({source:e.literal("feature"),featureKey:e.string().min(1).max(128)})]),writes:e.strictObject({value:I}),next:b}),e.strictObject({...C,type:e.literal("coupon"),couponId:e.uuid(),writes:e.strictObject({value:I}),next:b}),e.strictObject({...C,type:e.literal("coupons"),couponIds:e.array(e.uuid()).max(20).refine(t=>new Set(t).size===t.length),writes:e.strictObject({value:I}),next:b}),e.strictObject({...C,type:e.literal("output"),value:e.discriminatedUnion("type",[...Ee.options,Dt,e.strictObject({type:e.literal("selection"),screenId:b,offeringKey:I})])}),e.strictObject({...C,type:e.literal("condition"),cases:e.array(e.strictObject({condition:G,target:b})).min(1).max(50),default:b}),e.strictObject({...C,type:e.literal("feature"),featureKey:e.string().min(1).max(128),writes:e.strictObject({value:I}),next:b}),e.strictObject({...C,type:e.literal("split"),experimentId:e.uuid(),applyPageExperiment:e.literal(!0).optional(),routes:e.record(On,b).refine(t=>Object.keys(t).length>=2&&Object.keys(t).length<=20),notParticipating:b}),e.strictObject({...C,type:e.literal("action"),...jn,execution:gt,action:Vt,writes:Ie.optional()}),e.strictObject({...C,type:e.literal("external_page"),appManifest:pe.optional(),url:kn,openIn:An,opened:b,failed:b}),e.strictObject({...C,type:e.literal("end"),outcome:e.enum(["completed","closed","ineligible","failed"]),output:Ee.optional()}),e.strictObject({...C,type:e.literal("wait"),writes:Ie.optional(),wait:e.discriminatedUnion("type",[e.strictObject({type:e.literal("duration"),delaySeconds:e.number().int().min(1).max(2592e3),elapsed:b}),e.strictObject({type:e.literal("event"),eventName:b,outputs:Re,timeoutSeconds:e.number().int().min(1).max(2592e3),received:b,timeout:b})])})]),Me=e.strictObject({version:e.literal(5),entry:b,nodes:e.array(Cn).min(1).max(D.flowNodes)}),Te=Me.superRefine((t,r)=>{_n(t,n=>r.addIssue({code:"custom",message:n.message,path:n.path,params:{reason:n.reason}}))});function de(t){switch(t.type){case"entry":case"feature":case"offering":case"coupon":case"coupons":return[t.next];case"screen":return Object.values(t.outputs);case"condition":return[...t.cases.map(r=>r.target),t.default];case"split":return[...Object.values(t.routes),t.notParticipating];case"action":return[t.success,t.cancel,t.unavailable,t.failure];case"external_page":return[t.opened,t.failed];case"end":case"output":return[];case"wait":return t.wait.type==="duration"?[t.wait.elapsed]:[t.wait.received,t.wait.timeout]}}function _n(t,r){let n=[],s=new Map(t.nodes.map(l=>[l.id,l])),i=(l,w,K)=>{n.push(l),r?.({message:l,reason:w,path:K?["nodes",t.nodes.indexOf(K)]:[]})};s.size!==t.nodes.length&&i("Node identifiers must be unique","uniqueNodes"),(s.get(t.entry)?.type!=="entry"||t.nodes.filter(l=>l.type==="entry").length!==1)&&i("A flow has exactly one entry node","entry"),(t.nodes.filter(l=>l.type==="screen").length>D.pages||t.nodes.filter(l=>!["screen","entry","end","output"].includes(l.type)).length>D.logicNodes)&&i("Flow node limit exceeded","budget");let a=new Set;for(let l of t.nodes){for(let w of de(l))w===t.entry&&i("An entry cannot be a transition target","entryTarget",l),s.has(w)||i(`Missing target ${w}`,"missingTarget",l);l.type==="screen"&&(a.has(l.screenId)&&i("Every screen has exactly one node owner","screenOwner",l),a.add(l.screenId))}let u=new Set,c=new Set,f=new Set;function g(l){if(u.has(l)){i("Flow edges must not form a cycle","cycle",s.get(l));return}if(!(c.has(l)||!s.has(l))){u.add(l),f.add(l);for(let w of de(s.get(l)))g(w);u.delete(l),c.add(l)}}g(t.entry);for(let l of t.nodes)f.has(l.id)||i("Every node must be reachable from Entry","unreachable",l);return[...new Set(n)]}var Ue={maxTransitions:1e4,runTimeoutSeconds:2592e3};function Nt(t,r,n){let s=[...r].sort((c,f)=>f.length-c.length),i=new Set,a=(c,f=!1)=>{let g=s.find(l=>c===l||f&&c.startsWith(l+"."));i.add(g??c)};if(t.type==="condition"){let c=n?.startsWith("case_")?Number(n.slice(5)):t.cases.length-1;for(let f of t.cases.slice(0,c+1))for(let g of F(f.condition))g.startsWith("variables.")&&a(g.slice(10),!0)}if(t.type==="screen"&&t.offering?.source==="variable"&&a(t.offering.key),t.type==="action"&&(t.action.type==="api"||t.action.type==="external_task"))for(let c of Object.values(t.action.inputs))c.source==="variable"&&a(c.key);t.type==="action"&&t.action.type==="claim_offer"&&t.action.coupon.source==="variable"&&a(t.action.coupon.key);let u=t.type==="output"?t.value:t.type==="end"?t.output:null;if(u?.type==="variable"&&a(u.key),u?.type==="bundle")for(let c of[u.paywall,u.offering,u.coupons,u.data])c?.source==="variable"&&a(c.key);return u?.type==="selection"&&a(u.offeringKey),[...i]}var $=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,127}$/),me=t=>e.record(e.string(),v).refine(r=>M(r)<=t,"Funnel evidence exceeds its byte budget"),_o=e.enum(["local_segment","evaluation","presentation","timer","event","operation"]),$e=e.enum(["entry","presentation","decision","configuration","capability","wait","terminal"]),Ge=e.discriminatedUnion("type",[e.strictObject({type:e.literal("flag"),key:e.string().min(1).max(128)}),e.strictObject({type:e.literal("experiment"),id:e.uuid()}),e.strictObject({type:e.literal("saved_group"),id:e.uuid()}),e.strictObject({type:e.literal("config"),key:e.string().min(1).max(128)}),e.strictObject({type:e.literal("constant"),key:e.string().min(1).max(128)}),e.strictObject({type:e.literal("paywall_version"),id:e.uuid()}),e.strictObject({type:e.literal("offering_version"),id:e.uuid()}),e.strictObject({type:e.literal("reward"),id:e.uuid()})]),Ro=e.strictObject({schemaVersion:e.literal(1),kind:$e,selector:Ge.nullable(),context:me(131072),contract:e.strictObject({version:e.number().int().positive(),evaluator:e.string().min(1).max(128),policyRevision:e.number().int().nonnegative()})}).refine(t=>M(t)<=131072,"Node input exceeds its byte budget"),Do=e.strictObject({schemaVersion:e.literal(1),kind:$e,outcome:e.enum(["success","cancel","failure","unavailable","elapsed","received","timeout","not_participating"]),data:me(131072),route:e.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/).nullable(),evidence:me(131072)}).refine(t=>M(t)<=131072,"Node result exceeds its byte budget"),zo=e.strictObject({schemaVersion:e.literal(1),operations:e.record($,e.strictObject({attempts:e.number().int().nonnegative(),maxAttempts:e.number().int().min(1).max(5),deadlineAt:e.iso.datetime({offset:!0}),retryAt:e.iso.datetime({offset:!0}).nullable(),error:e.string().regex(/^[a-z_]{1,64}$/).nullable(),reference:e.strictObject({type:$,id:e.uuid()}).nullable()}))}).refine(t=>M(t)<=65536,"Execution state exceeds its byte budget"),T={receiptId:e.uuid()},Be=e.iso.datetime({offset:!0}),Eo=e.discriminatedUnion("type",[e.strictObject({type:e.literal("node_entered"),details:e.strictObject({kind:$e})}),e.strictObject({type:e.literal("presentation_shown"),details:e.strictObject({...T,source:e.literal("client"),occurredAt:Be.optional()})}),e.strictObject({type:e.literal("decision_accepted"),details:e.strictObject(T)}),e.strictObject({type:e.literal("signal_received"),details:e.strictObject({signalId:e.uuid(),nodeId:$,eventName:$,data:me(8192),source:e.literal("server"),occurredAt:Be})}),e.strictObject({type:e.literal("signal_consumed"),details:e.strictObject({...T,signalId:e.uuid()})}),e.strictObject({type:e.literal("wait_elapsed"),details:e.strictObject(T)}),e.strictObject({type:e.literal("wait_timeout"),details:e.strictObject(T)}),e.strictObject({type:e.literal("operation_completed"),details:e.strictObject({...T,operation:$,reference:e.strictObject({type:$,id:e.uuid()}).nullable()})}),e.strictObject({type:e.literal("execution_recovered"),details:e.strictObject({generation:e.number().int().positive(),reason:e.enum(["interrupted","expired_lease","delivery_failed"])})}),e.strictObject({type:e.literal("execution_failed"),details:e.strictObject({generation:e.number().int().positive(),code:e.string().regex(/^[a-z_]{1,64}$/)})}),e.strictObject({type:e.literal("run_completed"),details:e.strictObject({outcome:e.enum(["completed","ineligible","failed"])})}),e.strictObject({type:e.literal("run_closed"),details:e.strictObject({source:e.enum(["client","server","expiry"])})}),e.strictObject({type:e.literal("treatment_used"),details:e.strictObject({...T,source:e.enum(["client","server"]),occurredAt:Be,reference:e.string().min(1).max(128).optional()})})]);var _=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Rn=e.discriminatedUnion("type",[e.strictObject({id:_,type:e.literal("owned"),publicData:pt.optional(),document:J.refine(t=>["page","popup","onboarding"].includes(t.surface)&&t.pages.length===1&&t.actions.every(r=>r.type==="event"&&!r.close),"A Funnel owns one Page or Popup per screen and emits outputs; Paywall owns its purchase policies")}),e.strictObject({id:_,type:e.literal("paywall"),paywallVersionId:e.uuid()})]),qe={executionContract:dt.optional(),kind:e.literal("funnel"),schemaVersion:e.literal(4),screens:e.array(Rn).max(D.pages),references:e.record(_,Ge).refine(t=>Object.keys(t).length<=500),inputs:e.array(e.strictObject({variable:_,screenId:_,componentId:_,required:e.boolean()})).max(D.questions),variables:e.record(I,ee).refine(t=>Object.keys(t).length<=D.logicNodes),outputSchema:Y,execution:e.strictObject({runTimeoutSeconds:e.number().int().min(1).max(Ue.runTimeoutSeconds),maxTransitions:e.number().int().min(1).max(Ue.maxTransitions)})},Yo=e.strictObject({...qe,graph:Me});function Dn(t,r){let n=!1,s=(i,a)=>{let u=i.type==="stack"||i.type==="button"?i.bind?.coupon??a:a;i.type==="text"&&Object.values(t.strings.locales).some(c=>c[i.text]?.includes("{{offer."))&&!(u&&r(u))&&(n=!0),i.type==="stack"&&i.children.forEach(c=>s(c,u))};for(let i of t.pages)s(i.root);return n}function ye(t){return Array.isArray(t)?t.some(ye):!t||typeof t!="object"?!1:Object.entries(t).some(([r,n])=>r==="productVersionId"?n===Rt:ye(n))}function zn(t){let r=[],n=new Set(Object.values(t.references).flatMap(s=>s.type==="reward"?[s.id]:[]));for(let[s,i]of t.screens.entries()){if(i.type!=="owned")continue;let a;try{a=Ot(i.document)}catch(u){r.push({message:u instanceof Error?u.message:"Screen cannot be delivered",reason:"screen",path:["screens",s,"document"]});continue}for(let[u,c]of t.inputs.entries())c.screenId===i.id&&!Se(a,c.componentId)&&r.push({message:`Local Funnel input ${c.variable} targets hidden component ${c.componentId} on screen ${c.screenId}`,reason:"inputBinding",path:["inputs",u]})}for(let[s,i]of t.graph.nodes.entries()){let a=["graph","nodes",s],u=i.type==="screen"?t.screens.find(c=>c.id===i.screenId):void 0;u?.type==="owned"&&(u.document.actions.some(c=>typeof c.properties.templateKey=="string"&&c.properties.templateKey.startsWith("popup-coupon-"))&&r.push({message:"Funnel screens claim Coupons through a Claim Coupon step",reason:"coupon",path:a}),Dn(u.document,c=>n.has(c))&&r.push({message:"Offer copy shows the Coupon of a Claim Coupon step",reason:"coupon",path:a})),(i.type==="output"&&i.value.type==="literal"&&ye(i.value.value)||i.type==="end"&&i.output?.type==="literal"&&ye(i.output.value))&&r.push({message:"Checkout outputs require a Product Version",reason:"product",path:a})}return r}function Pt(t,r){for(let{message:n,reason:s,path:i}of zn(t))r.addIssue({code:"custom",message:n,path:i,params:{reason:s}})}function Ft(t,r){let n=(y,o,p=[])=>r.addIssue({code:"custom",message:y,path:p,params:{reason:o}}),s=Object.values(t.references),i=new Map(t.screens.map(y=>[y.id,y])),a=(y,o)=>s.some(p=>p.type===y&&("id"in p?p.id:p.key)===o);i.size!==t.screens.length&&n("Screen identifiers must be unique","uniqueScreens");let u=t.graph.nodes.filter(y=>y.type==="screen");(u.length!==i.size||u.some(y=>!i.has(y.screenId)))&&n("Every screen belongs to exactly one presentation node","screenOwner");let c=new Map,f=Object.keys(t.variables);f.some(y=>f.some(o=>y!==o&&o.startsWith(y+".")))&&n("Variable paths must not overlap","variable");function g(y,o){Object.hasOwn(t.variables,y)||n("Every produced variable needs a declaration","variable",["graph","nodes",t.graph.nodes.indexOf(o)]);let p=c.get(y)??new Set;p.add(o.id),c.set(y,p)}for(let[y,o]of t.graph.nodes.entries()){let p=["graph","nodes",y],O=o.type==="feature"?o.featureKey:o.type==="offering"&&o.configuration.source==="feature"?o.configuration.featureKey:o.type==="output"&&o.value.type==="feature"?o.value.featureKey:o.type==="end"&&o.output?.type==="feature"?o.output.featureKey:null;O&&!a("flag",O)&&n("Flag selectors require an explicit GB resource reference","feature",p);let j=o.type==="feature"||o.type==="offering"||o.type==="coupon"||o.type==="coupons"||o.type==="action"&&o.action.type==="api"?["value"]:o.type==="action"&&o.action.type==="external_task"?Object.keys(o.action.outputs):o.type==="wait"&&o.wait.type==="event"?Object.keys(o.wait.outputs):[],k="writes"in o?o.writes??{}:{};(j.length!==Object.keys(k).length||j.some(d=>!Object.hasOwn(k,d))||new Set(Object.values(k)).size!==Object.values(k).length)&&n("Node writes must map every named output exactly once","variable",p);for(let[d,x]of Object.entries(k)){g(x,o);let h=t.variables[x],m=o.type==="offering"?"offering_version":o.type==="coupon"?"reward":o.type==="action"&&o.action.type==="api"?"json":o.type==="action"&&o.action.type==="external_task"?o.action.outputs[d]:o.type==="wait"&&o.wait.type==="event"?o.wait.outputs[d]:void 0;(h?.source.type!=="node"||m&&h.type!==m)&&n("Node writer source or output type does not match declaration","variable",p)}if(o.type==="coupons"){let d=t.variables[o.writes.value];(d?.type!=="array"||d.items?.type!=="reward"||d.items.nullable||d.nullable)&&n("Coupons output requires a non-null Reward array","variable",p);for(let x of o.couponIds)a("reward",x)||n("Coupons require Reward references","coupon",p)}if(o.type==="split"&&!a("experiment",o.experimentId)&&n("Experiment selectors require a GB resource reference","experiment",p),o.type==="coupon"&&!a("reward",o.couponId)&&n("Coupon selectors require a Reward reference","coupon",p),o.type==="action"&&o.action.type==="claim_offer"&&o.action.coupon.source==="literal"){let d=o.action.coupon.value;(!d||typeof d!="object"||Array.isArray(d)||d.type!=="reward"||typeof d.id!="string"||Object.keys(d).length!==2||!a("reward",d.id))&&n("Coupon claims require a Reward reference","coupon",p)}if(o.type==="offering"&&o.configuration.source==="fixed"&&!a("offering_version",o.configuration.versionId)&&n("Offering selectors require an explicit Version reference","offering",p),o.type==="screen"&&o.offering?.source==="variable"&&t.variables[o.offering.key]?.type!=="offering_version"&&n("Screen Offering variable must be an Offering reference","offering",p),o.type==="action"&&o.action.type==="claim_offer"&&o.action.coupon.source==="variable"&&(t.variables[o.action.coupon.key]?.type!=="reward"||o.action.coupon.path)&&n("Coupon variable must be a complete Reward reference","coupon",p),o.type==="screen"){let d=i.get(o.screenId);if(o.offering?.source==="fixed"&&!a("offering_version",o.offering.versionId)&&n("Screen Offering requires an explicit Version reference","offering",p),d?.type==="paywall"&&o.offering&&n("Paywall owns its fixed Offering Version","offering",p),d?.type==="paywall"&&!a("paywall_version",d.paywallVersionId)&&n("Paywall screens require an explicit Version reference","paywall",p),d?.type==="owned"){let x=d.document.pages[0];if(!x){n("Owned screen requires a page","screen",p);continue}et(d.document).some(m=>!m.complete)&&n("Owned screens require complete local content","translations",p);let h=new Set(d.document.actions.map(m=>m.id));(h.size!==Object.keys(o.outputs).length||Object.keys(o.outputs).some(m=>!h.has(m)))&&n("Every screen action requires exactly one outcome route","buttonOutputs",p),Z(x.root,m=>{!o.offering&&(m.type==="plan_picker"||(m.type==="stack"||m.type==="button")&&m.bind?.plan||m.type==="customer_data"&&["customer_plans","credit_packs"].includes(m.data.source))&&n("Product presentation requires an Offering Version","offering",p),m.type==="customer_data"&&Object.values(m.data.outputs??{}).some(V=>V!==void 0&&!h.has(V))&&n("Customer components require declared screen outcomes","componentOutput",p)})}}o.type==="end"&&["completed","ineligible"].includes(o.outcome)&&!o.output&&n("Completed and ineligible ends require a declared output","output",p),o.type==="end"&&o.output?.type==="literal"&&!P(t.outputSchema,o.output.value)&&n("Terminal output does not match outputSchema","output",p),o.type==="output"&&o.value.type==="literal"&&!P(t.outputSchema,o.value.value)&&n("Terminal output does not match outputSchema","output",p);let z=o.type==="output"?o.value:o.type==="end"?o.output:void 0;if(z?.type==="variable"&&!z.path){let d=t.variables[z.key];d&&!Oe(d,t.outputSchema)&&n("Variable output does not match outputSchema","output",p)}if(o.type==="screen"){let d=i.get(o.screenId);if(d?.type==="owned")for(let x of ke(d.document))(/^(input|params)\./.test(x)||x.startsWith("variables.")&&!je(x.slice(10),f))&&n("Screen values must reference registered variables","variable",p)}if(o.type==="condition")for(let d of o.cases){for(let x of W(d.condition))a("saved_group",x)||n("Conditions require explicit Saved Group references","savedGroup",p);for(let x of F(d.condition))x.startsWith("variables.")||n("Funnel conditions read registered variables only","variable",p)}if(o.type==="output"&&o.value.type==="bundle"){t.outputSchema.type!=="json"&&n("Bundle output requires a JSON outputSchema","output",p);for(let[d,x]of[["paywall","paywall_version"],["offering","offering_version"],["coupons","reward"]]){let h=o.value[d];if(h)if(h.source==="literal"){let m=d==="coupons"?h.value:[h.value];(!Array.isArray(m)||m.length>20||m.some(V=>!P({type:x,nullable:!1},V)||!a(x,V.id))||d==="coupons"&&new Set(m.map(V=>V.id)).size!==m.length)&&n("Bundle requires distinct scoped resource references",d==="coupons"?"coupon":d==="paywall"?"paywall":"offering",[...p,"value",d])}else{let m=t.variables[h.key];(h.path||!m||m.nullable||(d==="coupons"?m.type!=="array"||m.items?.type!=="reward"||m.items.nullable:m.type!==x))&&n("Bundle binding type does not match its slot","output",p)}}}}for(let[y,o]of t.graph.nodes.entries()){let p=o.type==="screen"?i.get(o.screenId):void 0,O=[...Nt(o,f),...p?.type==="owned"?ot(p.document).map(j=>je(j,f)?.key??j):[]];for(let j of new Set(O)){let x=function(h){if(h===o.id)return!0;if(d.has(h))return!1;d.add(h);let m=t.graph.nodes.find(Mt=>Mt.id===h);return m?(z.has(h)?m.type==="action"?[m.cancel,m.unavailable,m.failure]:m.type==="wait"&&m.wait.type==="event"?[m.wait.timeout]:[]:de(m)).some(x):!1};var K=x;if(!Object.hasOwn(t.variables,j)){n("Consumed variable is undeclared","variable",["graph","nodes",y]);continue}let k=t.variables[j];if(o.type==="screen"&&k.source.type==="input"&&t.inputs.some(h=>h.screenId===o.screenId&&h.variable===j)||k.source.type==="parameter"||k.source.type==="attribute")continue;let z=k.source.type==="input"?new Set(t.inputs.filter(h=>h.variable===j&&h.required).flatMap(h=>u.filter(m=>m.screenId===h.screenId).map(m=>m.id))):c.get(j)??new Set,d=new Set;(!z.size||x(t.graph.entry))&&n("Every path must produce the consumed variable","resultReference",["graph","nodes",y])}}(new Set(t.inputs.map(y=>y.variable)).size!==t.inputs.length||new Set(t.inputs.map(y=>`${y.screenId}:${y.componentId}`)).size!==t.inputs.length)&&n("Input keys and component bindings must be unique","inputKeys");for(let[y,o]of t.inputs.entries()){t.variables[o.variable]?.source.type!=="input"&&n("Input binding requires a registered input variable","inputBinding",["inputs",y]);let p=i.get(o.screenId),O=p?.type==="owned"?Se(p.document,o.componentId):null;if((O?.type!=="stack"||!O.interaction||!["input","toggle","select","multiselect","tabs"].includes(O.interaction.type))&&n("Input requires an interactive control on its owned screen","inputBinding",["inputs",y]),O?.type==="stack"&&O.interaction){let j=O.interaction.type==="toggle"?"boolean":O.interaction.type==="multiselect"?"strings":"string";t.variables[o.variable]?.type!==j&&n("Input variable type does not match component","inputBinding",["inputs",y]);let k=t.variables[o.variable]?.enum;k&&!O.children.filter(z=>!z.hidden).every(z=>k.includes(z.id))&&n("Input choices must match the variable enum","inputBinding",["inputs",y])}}for(let[y,o]of Object.entries(t.variables))o.enum&&o.type!=="string"&&n("Only string variables support enum","variable",["variables",y]),o.source.type==="input"&&!t.inputs.some(p=>p.variable===y)&&n("Input variable requires a component binding","inputBinding",["variables",y]);let l=0,w=0;for(let y of t.screens)if(y.type==="owned"){for(let o of y.document.pages)Z(o.root,()=>{l++});w+=y.document.actions.length}(l>D.components||w>D.actions||M(t)>D.documentBytes)&&n("Funnel document exceeds its budget","budget")}var En=e.strictObject({...qe,graph:Te}).superRefine(Ft),Kn=e.strictObject({...qe,graph:Te,displayName:e.string().trim().min(1).max(80)}).superRefine(Ft),es=Kn.superRefine(Pt),ts=En.superRefine(Pt),fe=e.string().regex(Le),L={requestId:e.uuid(),nodeId:_,visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),customerToken:fe.optional()},Vn=e.discriminatedUnion("type",[e.strictObject({type:e.literal("screen"),output:_,answers:X,selection:e.record(_,e.union([e.string().max(200),e.boolean(),e.number().int().min(0).max(1e4)])).optional()}),e.strictObject({type:e.literal("paywall_quote"),featureQuantities:e.record(e.uuid(),e.number().int().min(0).max(1e4)).refine(t=>Object.keys(t).length<=100).optional(),actionId:_,productVersionId:e.uuid(),offerId:e.uuid().optional(),nativeOffer:Ke.optional(),predecessor:e.strictObject({operationId:e.uuid().nullable(),generation:e.number().int().positive()}).optional()}),e.strictObject({type:e.literal("paywall_confirm"),operationId:e.uuid()}),e.strictObject({type:e.literal("paywall_cancel"),operationId:e.uuid()}),e.strictObject({type:e.literal("client_action"),receiptId:e.uuid(),outcome:e.enum(["success","cancel","failure","opened","failed"])})]),Nn=e.object({nodeId:_,visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),components:e.record(_,e.object({resourceKey:e.string().regex(/^[a-z][a-z0-9_]{0,63}$/).optional(),page:e.number().int().min(1).max(1e5),after:tt.nullable(),filter:e.enum(["all","purchase","refund","source","usage","debt","settlement","issued","reserved","redeemed","expired","revoked"])}).strict()).refine(t=>Object.keys(t).length<=150)}).strict(),ns=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("start"),funnelId:e.uuid(),requestId:e.uuid(),customer:ae.optional(),customerData:ce.optional(),locale:e.string().min(1).max(35),parameters:B}).refine(ue,le),e.strictObject({operation:e.literal("get"),settlementRequestId:e.uuid().optional(),data:Nn.optional(),purchase:e.strictObject({receiptId:e.uuid(),operationId:e.uuid()}).optional(),customerToken:fe.optional()}),e.strictObject({operation:e.literal("resume"),requestId:e.uuid(),customerToken:fe.optional()}),e.strictObject({operation:e.literal("submit"),...L,input:Vn}),e.strictObject({operation:e.literal("back"),...L}),e.strictObject({operation:e.literal("shown"),...L}),e.strictObject({operation:e.literal("close"),...L}),e.strictObject({operation:e.literal("commit_segment"),...L,policyRevision:e.number().int().nonnegative(),generation:e.string().min(1).max(256)}),e.strictObject({operation:e.literal("review"),receiptId:e.uuid().optional(),customerToken:fe.optional()})]);export{I as a,Y as b,ee as c,P as d,$n as e,Gn as f,Bt as g,ot as h,M as i,Ke as j,ar as k,Tt as l,Ut as m,Mn as n,at as o,ct as p,Ht as q,lt as r,Sr as s,Zt as t,Ar as u,pn as v,ji as w,zi as x,bn as y,Xt as z,Yt as A,$r as B,Gr as C,qr as D,cn as E,nn as F,rn as G,Zr as H,ae as I,ce as J,ue as K,le as L,bt as M,Wr as N,an as O,Qr as P,Xr as Q,Yr as R,Ee as S,ln as T,mi as U,fi as V,yi as W,kn as X,An as Y,Ro as Z,Do as _,Kn as $,ns as aa};
@@ -1 +0,0 @@
1
- import{b as t}from"./chunk-RGEBK6UF.js";var $=t.enum(["sandbox","live"]),P=t.object({projectId:t.string().min(1),environment:$}).strict();var w=t.string().regex(/^(0|[1-9]\d{0,12})(\.\d{1,12})?$/),u=t.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e),z=t.string().regex(/^-?(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>{let n=e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e;return n==="-0"?"0":n}),y=u.refine(e=>/[1-9]/.test(e),"\u6570\u91CF\u5FC5\u987B\u5927\u4E8E 0"),I=t.string().min(1).max(64),T=t.string().min(1).regex(/^[a-zA-Z0-9_-]+$/),j=t.string().min(1).max(64).refine(e=>!e.includes("::"),"Dimension IDs cannot contain ::"),M=t.record(I,t.union([t.string().max(120),t.number().finite(),t.boolean()])).refine(e=>Object.keys(e).length<=16,"\u6700\u591A 16 \u4E2A\u8BA1\u4EF7\u5C5E\u6027").transform(e=>Object.fromEntries(Object.entries(e).map(([n,i])=>[n,String(i)]))),B=t.record(I,t.union([t.string().max(120),t.number().finite(),t.boolean()]).transform(String)).refine(e=>Object.keys(e).length<=8,"\u5339\u914D\u6761\u4EF6\u6700\u591A 8 \u4E2A\u5C5E\u6027"),d=e=>{let n=e.startsWith("-");n&&(e=e.slice(1));let[i,s=""]=e.split(".");if(i===void 0||i==="")throw new Error("Invalid decimal value");let p=BigInt(i)*BigInt("1000000")+BigInt(s.padEnd(6,"0"));return n?-p:p},k=t.array(t.object({upTo:y.nullable(),cost:u}).strict()).min(1).max(12).refine(e=>e.at(-1)?.upTo===null&&e.slice(0,-1).every((n,i)=>{let s=e[i-1]?.upTo;return n.upTo!==null&&(i===0||s!=null&&d(n.upTo)>d(s))}),"\u9636\u68AF\u4E0A\u9650\u5FC5\u987B\u9012\u589E\uFF0C\u6700\u540E\u4E00\u6863\u4E3A\u65E0\u9650"),D=t.object({key:j,match:B,priority:t.number().int().default(0),cost:u.optional(),tiers:k.optional()}).strict().refine(e=>e.cost!==void 0||e.tiers!==void 0,"\u7EF4\u5EA6\u9700\u8981\u6307\u5B9A\u5355\u4EF7\u6216\u9636\u68AF"),E=t.object({key:j,match:B,factor:y.optional(),add:z.optional()}).strict().refine(e=>e.factor!==void 0||e.add!==void 0,"A multiplier needs a factor or an add").transform(e=>({...e,factor:e.factor??"1",add:e.add??"0"})),A=t.object({units:y.default("1"),cost:u,tiers:k.optional(),dimensions:t.array(D).max(12).optional(),multipliers:t.array(E).max(4).optional()}).strict().superRefine((e,n)=>{let i=e.dimensions??[],s=e.multipliers??[];(new Set(i.map(o=>o.key)).size!==i.length||new Set(s.map(o=>o.key)).size!==s.length)&&n.addIssue({code:"custom",message:"\u7EF4\u5EA6\u548C\u500D\u7387\u7684 ID \u4E0D\u80FD\u91CD\u590D"});for(let[o,r]of i.entries())for(let c of i.slice(o+1))Object.keys(r.match).length===Object.keys(c.match).length&&r.priority===c.priority&&!Object.keys(r.match).some(a=>c.match[a]!==void 0&&c.match[a]!==r.match[a])&&n.addIssue({code:"custom",message:"\u7EF4\u5EA6\u53EF\u80FD\u540C\u65F6\u5339\u914D\uFF0C\u8BF7\u8C03\u6574\u4F18\u5148\u7EA7"});let p=[e.cost,...(e.tiers??[]).map(o=>o.cost),...i.flatMap(o=>[...o.cost===void 0?[]:[o.cost],...(o.tiers??[]).map(r=>r.cost)])],O=d(e.units);for(let o of p)for(let r=0;r<1<<s.length;r++){let c=s.filter((l,m)=>r&1<<m);if(c.some((l,m)=>c.slice(m+1).some(S=>Object.keys(l.match).some(h=>S.match[h]!==void 0&&S.match[h]!==l.match[h]))))continue;let a=d(o),f=BigInt("1"),x=BigInt("0");for(let[l,m]of s.entries())r&1<<l&&(a*=d(m.factor??"1"),f*=BigInt("1000000"),x+=d(m.add??"0"));let g=(a+x*f)*BigInt("1000000"),b=f*O;(g<BigInt("0")||g%b!==BigInt("0")||g/b>BigInt("999999999999999999"))&&n.addIssue({code:"custom",message:"\u6BCF\u4E2A\u4E1A\u52A1\u5355\u4F4D\u7684\u6700\u7EC8\u5355\u4EF7\u5FC5\u987B\u975E\u8D1F\u3001\u5728\u8303\u56F4\u5185\u4E14\u80FD\u7CBE\u786E\u8868\u793A\u4E3A\u6700\u591A 6 \u4F4D\u5C0F\u6570"})}}),_=A.safeExtend({featureKey:T});export{$ as a,P as b,w as c,u as d,z as e,T as f,M as g};
@@ -1 +0,0 @@
1
- import{$ as se,d as ee,k as te,o as ne,p as re,q as oe,t as O,v as ie,z as ae}from"./chunk-IOJVF52Q.js";import{a as F}from"./chunk-33ZVZOSC.js";import{A as Q,C as k,F as Y,I as h,J as D,K as C,L as A,da as ce,e as J,j as Z,l as W,p as I,q as S,s as R,v as X,w as H,y as w,z as P}from"./chunk-XDOKFAE6.js";import{a as T,f as K}from"./chunk-Y6HL2IY2.js";import{b as j}from"./chunk-OOD2VDDP.js";import{b as e}from"./chunk-RGEBK6UF.js";import{a as L,b as U}from"./chunk-CILM5XMH.js";var V=e.strictObject({eventsEnabled:e.boolean(),experimentViewsEnabled:e.boolean(),featureUsageEnabled:e.boolean()}),Ze=Object.freeze({eventsEnabled:!0,experimentViewsEnabled:!0,featureUsageEnabled:!0});function We(t,r){return r==="experiment_exposure"?t.experimentViewsEnabled:r==="feature_usage"?t.featureUsageEnabled:t.eventsEnabled}var z=e.tuple([e.number().min(0).max(1),e.number().min(0).max(1)]).refine(([t,r])=>t<=r),Se=e.strictObject({attribute:e.string().optional(),seed:e.string(),hashVersion:e.literal(2),ranges:e.array(z).max(100)}),we=e.strictObject({id:e.string().min(1).max(255),condition:C,gate:e.boolean().optional()}),Oe=e.strictObject({key:e.string().optional(),name:e.string().optional(),passthrough:e.boolean().optional()}),ue={condition:C.optional(),parentConditions:e.array(we).max(100).optional(),weights:e.array(e.number().min(0).max(1)).max(20).optional(),coverage:e.number().min(0).max(1).optional(),hashAttribute:e.string().optional(),fallbackAttribute:e.string().optional(),hashVersion:e.literal(2).optional(),disableStickyBucketing:e.boolean().optional(),bucketVersion:e.number().int().nonnegative().optional(),minBucketVersion:e.number().int().nonnegative().optional(),filters:e.array(Se).max(100).optional(),ranges:e.array(z).max(20).optional(),meta:e.array(Oe).max(20).optional(),seed:e.string().optional(),name:e.string().optional(),phase:e.string().optional()},pe=e.strictObject({...ue,key:e.string().min(1).max(255),variations:e.tuple([h,h]).rest(h).refine(t=>t.length<=20),urlPatterns:e.array(e.strictObject({include:e.boolean(),type:e.enum(["regex","simple"]),pattern:e.string()})).max(100).optional(),force:e.number().int().nonnegative().optional(),active:e.boolean().optional(),persistQueryString:e.boolean().optional()}),G=e.strictObject({value:h,variationId:e.number().int(),key:e.string(),name:e.string().optional(),bucket:e.number().optional(),passthrough:e.boolean().optional(),inExperiment:e.boolean(),hashUsed:e.boolean().optional(),hashAttribute:e.string(),hashValue:e.string(),featureId:e.string().nullable(),stickyBucketUsed:e.boolean().optional()}),je=e.strictObject({...ue,id:e.string().max(255).optional(),force:h.optional(),variations:e.array(h).min(2).max(20).optional(),key:e.string().optional(),range:z.optional(),tracks:e.array(e.strictObject({experiment:pe,result:G})).max(100).optional()}),Ie=e.strictObject({defaultValue:h.optional(),rules:e.array(je).max(500).optional()}),Pe=e.record(e.string(),e.union([e.strictObject({type:e.literal("hashed"),attributeKey:e.string(),values:e.array(e.string().regex(/^[a-f0-9]{64}$/))}),e.strictObject({type:e.literal("list"),attributeKey:e.string(),values:e.array(e.union([e.string(),e.number()]))}),e.strictObject({type:e.literal("condition"),condition:C})])),v=e.strictObject({scope:j,generation:e.string().regex(/^[a-f0-9]{64}$/),evaluatedAt:e.iso.datetime({offset:!0}),expiresAt:e.iso.datetime({offset:!0}).nullable(),features:e.record(e.string(),Ie),savedGroups:Pe,experiments:e.record(e.uuid(),pe)});var ke=v.extend({analyticsConfig:V,remoteFeatures:e.array(e.string().min(1).max(255)).max(500)}),it=ke.omit({evaluatedAt:!0,expiresAt:!0}).superRefine((t,r)=>{for(let a of t.remoteFeatures)Object.hasOwn(t.features,a)&&r.addIssue({code:"custom",path:["features",a],message:"Remote Feature definitions cannot be public"});for(let[a,o]of Object.entries(t.savedGroups))o.type==="list"&&r.addIssue({code:"custom",path:["savedGroups",a],message:"Raw Saved Group lists cannot be public"})}),at=e.strictObject({attributes:D,features:e.array(e.string().min(1).max(255)).max(500).optional(),customerId:e.uuid().optional()}),me=e.strictObject({value:h,source:e.enum(["unknownFeature","defaultValue","force","override","experiment","prerequisite","cyclicPrerequisite"]),on:e.boolean(),off:e.boolean(),ruleId:e.string(),experimentResult:G.optional()}),st=e.strictObject({generation:v.shape.generation,evaluatedAt:v.shape.evaluatedAt,expiresAt:v.shape.expiresAt,features:e.record(e.string(),me),merchandiseContext:e.strictObject({merchandiseId:e.uuid(),merchandise:D}).optional()}),de={eventUuid:e.uuid(),timestamp:e.iso.datetime({offset:!0}),merchandise:te.optional(),deviceId:e.string().min(1).max(255).optional(),sessionId:e.string().min(1).max(255).optional()},le={...de,generation:v.shape.generation},Ce=e.discriminatedUnion("kind",[e.strictObject({...de,kind:e.literal("custom"),name:e.string().min(1).max(255),properties:e.record(e.string(),h).default({})}),e.strictObject({...le,kind:e.literal("experiment_exposure"),experimentId:e.string().min(1).max(255),variationId:e.string().min(1).max(255)}),e.strictObject({...le,kind:e.literal("feature_usage"),feature:e.string().min(1).max(255),value:h,source:me.shape.source,ruleId:e.string().max(255),variationId:e.string().min(1).max(255).optional()})]),ct=e.strictObject({customerId:e.uuid().optional(),events:e.array(Ce).min(1).max(100)}),Ae=e.strictObject({eventUuid:e.uuid(),reason:e.enum(["invalid_event","invalid_merchandise","not_delivered","reserved_name"])}),ut=e.strictObject({inserted:e.number().int().nonnegative(),duplicates:e.number().int().nonnegative(),rejected:e.number().int().nonnegative(),skipped:e.number().int().nonnegative(),rejections:e.array(Ae).max(100),analyticsConfig:V});function fe(t,r){let a=new Set,o=new Set,c=new Set,p=[],g=new Map,f=new Map,d=new Map;function m(s){for(let n of A(s))i(n)}function i(s){if(c.has(s)||!Object.hasOwn(r.savedGroups,s))return;let n=r.savedGroups[s];n&&(c.add(s),d.set(s,n),p.push(()=>{!Array.isArray(n)&&n.type==="condition"&&m(n.condition)}))}function u(s){for(let n of["hashAttribute","fallbackAttribute"])if(s[n]!==void 0&&ae(s[n]))throw new Error(`Funnel GB ${n} uses a reserved flow namespace`);m(s.condition);for(let n of s.parentConditions??[])l(n.id),m(n.condition)}function l(s,n=!1){let b=Object.hasOwn(r.features,s)?r.features[s]:void 0;if(!b){if(n)throw new Error("Required GB Feature is unavailable");return}a.has(s)||(a.add(s),g.set(s,b),p.push(()=>{for(let x of b.rules??[]){u(x);for(let ve of x.tracks??[])u(ve.experiment)}}))}function y(s){let n=Object.hasOwn(r.experiments,s)?r.experiments[s]:void 0;if(!n)throw new Error("Required GB Experiment is unavailable");o.has(s)||(o.add(s),f.set(s,n),p.push(()=>u(n)))}for(let s of t.graph.nodes){s.type==="feature"&&l(s.featureKey,!0),s.type==="split"&&y(s.experimentId),s.type==="condition"&&s.cases.forEach(b=>m(b.condition)),s.type==="offering"&&s.configuration.source==="feature"&&l(s.configuration.featureKey,!0);let n=s.type==="output"?s.value:s.type==="end"?s.output:null;n?.type==="feature"&&l(n.featureKey,!0)}for(let s of p)s();return{...r,features:Object.fromEntries(g),experiments:Object.fromEntries(f),savedGroups:Object.fromEntries(d)}}var ge=e.object({defaultLocale:R,locales:e.record(R,e.object({name:e.string().max(80),description:e.string().max(500)}).strict())}).strict().superRefine((t,r)=>{let a=Object.keys(t.locales);(!a.length||a.length>20||!t.locales[t.defaultLocale])&&r.addIssue({code:"custom",message:"Invalid content languages"}),new TextEncoder().encode(JSON.stringify(t)).length>5e4&&r.addIssue({code:"custom",message:"Content exceeds 50 KB"})});var M=e.discriminatedUnion("type",[e.strictObject({type:e.literal("event"),event:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/)}),e.strictObject({type:e.literal("open_url"),url:e.url().refine(t=>new URL(t).protocol==="https:")})]),Fe=P,Ee=e.discriminatedUnion("type",[e.object({type:e.literal("checkout"),product:I}).strict(),e.object({type:e.literal("close")}).strict(),e.object({type:e.literal("action"),action:M}).strict()]),E=e.object({schemaVersion:e.literal(3),kind:e.literal("paywall"),name:e.string().trim().min(1).max(80),presentation:S,requirement:K.optional(),products:F,offeringVersionId:e.uuid().nullable(),offeringId:e.uuid(),screen:Fe,buttons:e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Ee)}).strict(),Pt=E.superRefine((t,r)=>{(t.screen.surface!=="paywall"||t.screen.actions.some(o=>!["event","navigate"].includes(o.type)||o.close))&&r.addIssue({code:"custom",message:"Paywall screen is incomplete"});for(let o of Re(t))r.addIssue({code:"custom",message:o});for(let o of _e(t))r.addIssue({code:"custom",message:o});for(let o of t.screen.actions){let c=o.properties.closeControl;c!==void 0&&(c!=="content"||t.buttons[o.id]?.type!=="close")&&r.addIssue({code:"custom",path:["screen","actions",o.id],message:'Only a close button can carry closeControl, and its value is "content"'})}for(let o of t.screen.actions){let c=o.properties.couponBinding;c!==void 0&&(typeof c!="string"||!X.safeParse(c).success||t.buttons[o.id]?.type!=="checkout"||Y(t.screen,c)?.type!=="text")&&r.addIssue({code:"custom",path:["screen","actions",o.id],message:"Choose a Coupon text binding for this checkout action"})}k(t.screen).some(o=>!o.complete)&&r.addIssue({code:"custom",message:"Paywall needs complete local content"}),(Object.keys(t.buttons).length!==t.screen.actions.filter(o=>o.type!=="navigate").length||t.screen.actions.some(o=>o.type!=="navigate"&&!Object.hasOwn(t.buttons,o.id)))&&r.addIssue({code:"custom",message:"Paywall buttons require matching node policies"}),Object.values(t.buttons).some(o=>o.type==="checkout")||r.addIssue({code:"custom",message:"A paywall requires a purchase or membership change button"})});function _e(t){let r=t.products.items.map(p=>p.productVersionId),a=Z(t.screen),o=new Set,c=[];(!r.length||!t.products.defaultProductVersionId||!r.includes(t.products.defaultProductVersionId))&&c.push("products"),t.offeringVersionId||c.push("offering"),t.products.grouping&&(!W(t.products.grouping,r)||t.products.grouping.tiers.some(p=>!t.products.grouping.assignments.some(g=>g.tierId===p.id)))&&c.push("grouping");for(let p of Object.values(t.buttons))if(p.type==="checkout"){let g=p.product;if(g.type==="fixed")o.add(g.productVersionId);else{g.allowedProductVersionIds.forEach(m=>o.add(m));let f=!1,d=a[g.pickerId];d&&(f=!0,(g.allowedProductVersionIds.some(m=>!d.ids.includes(m))||d.ids.some(m=>!g.allowedProductVersionIds.includes(m)))&&c.push("picker")),w(t.screen,m=>{if(m.id!==g.pickerId||m.type!=="plan_picker")return;f=!0,(JSON.stringify(m.planIds)!==JSON.stringify(r)||JSON.stringify(g.allowedProductVersionIds)!==JSON.stringify(r)||m.defaultPlan!==t.products.defaultProductVersionId)&&c.push("picker");let i=m.grouping?{tiers:m.grouping.tiers,assignments:m.grouping.assignments}:void 0;JSON.stringify(i)!==JSON.stringify(t.products.grouping)&&c.push("grouping")}),f||c.push("picker")}}return(!o.size||[...o].some(p=>!r.includes(p)))&&c.push("purchase"),w(t.screen,p=>{p.type==="stack"&&p.productSlot&&!p.bind?.plan&&c.push(`productBinding:${p.id}`),(p.type==="stack"||p.type==="button")&&p.bind?.plan&&!r.includes(p.bind.plan)&&c.push("binding"),p.type==="plan_picker"&&(!p.planIds?.length||p.planIds.some(g=>!r.includes(g)))&&c.push("binding")}),[...new Set(c)]}function Re(t){let r=[],a=t.screen.pages.at(-1),o=new Map;for(let f of t.screen.pages)o.set(f.id,[]),Q(f.root,d=>{let m=d.type==="button"?d.action:d.type==="stack"?d.purchaseAction:void 0;if(m){let i=t.screen.actions.find(l=>l.id===m);i?.type==="navigate"&&o.get(f.id).push(i.pageId);let u=t.buttons[m];f.id!==a.id&&u&&u.type!=="close"&&r.push(`purchaseScreen:${d.id}`)}f.id!==a.id&&(d.type==="plan_picker"||d.type==="stack"&&d.productSlot)&&r.push(`packageScreen:${d.id}`)});let c=new Set;function p(f){if(!c.has(f)){c.add(f);for(let d of o.get(f)??[])p(d)}}let g=t.screen.initialPageId??t.screen.pages[0]?.id;g?p(g):r.push("initialPage");for(let f of t.screen.pages)c.has(f.id)||r.push(`unreachableScreen:${f.id}`);return[...new Set(r)]}var ye=e.object({id:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),revision:e.number().int().nonnegative(),state:e.enum(["active","archived"]),publishedVersionId:e.uuid().nullable(),updatedAt:e.iso.datetime({offset:!0}),draft:E}).strict(),kt=e.object({rows:e.array(ye).max(200),nextCursor:e.uuid().nullable()}).strict(),Ct=ye.omit({draft:!0}).extend({name:e.string(),productCount:e.number().int().nonnegative()}).strict(),At=e.discriminatedUnion("action",[e.object({action:e.literal("save"),id:e.uuid().nullable(),revision:e.number().int().nonnegative(),document:E}).strict(),e.object({action:e.enum(["publish","archive"]),id:e.uuid(),revision:e.number().int().nonnegative()}).strict()]),Ft=e.object({paywalls:e.array(e.object({id:e.uuid(),paywallId:e.uuid(),version:e.number().int().positive(),name:e.string().min(1).max(80),presentation:S,buttons:E.shape.buttons}).strict()).max(500),limited:e.boolean()}).strict();var De=["customer_data","coupon_code"],be=e.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/),Ve=e.string().min(1).max(255).regex(/^[a-z0-9][a-z0-9-]*$/),_=(t,r)=>new Set(t.map(r)).size===t.length,ze=e.strictObject({currency:T,amountMinor:e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)}),Ge=e.strictObject({featureId:e.uuid(),name:e.string().trim().min(1).max(120),allowance:e.string().max(40).nullable(),access:e.boolean()}),Me=e.strictObject({stripe:e.strictObject({prices:e.array(ze).min(1).max(50)}).optional(),apple:e.strictObject({productIds:e.array(be).min(1).max(10)}).optional(),google:e.strictObject({products:e.array(e.strictObject({productId:be,basePlanId:Ve.nullable()})).min(1).max(10)}).optional()}).superRefine((t,r)=>{(t.stripe&&!_(t.stripe.prices,a=>a.currency)||t.apple&&!_(t.apple.productIds,a=>a)||t.google&&!_(t.google.products,a=>`${a.productId}:${a.basePlanId}`))&&r.addIssue({code:"custom",message:"Duplicate channel entry"})}),qe=e.strictObject({name:e.string().trim().min(1).max(80),interval:e.enum(["free","week","month","year","one_time"]),intervalCount:e.number().int().min(1).max(100),trial:e.strictObject({days:e.number().int().min(1).max(730),cardRequired:e.boolean()}).nullable(),benefits:e.array(Ge).max(50).refine(t=>_(t,r=>r.featureId),"Duplicate benefit"),channels:Me,prepaid:e.array(J).max(100).optional()}),Be=e.strictObject({digest:O,content:e.strictObject({discount:ne,duration:re,appliesTo:oe,displayCopy:ge.nullable(),firstPurchaseOnly:e.boolean(),qualificationRequired:e.boolean(),startsAt:e.iso.datetime().nullable(),endsAt:e.iso.datetime().nullable(),grantWindowHours:e.number().int().positive(),perCustomerLimit:e.number().int().positive()})}),Ne=e.discriminatedUnion("type",[e.strictObject({type:e.literal("checkout"),product:I}),e.strictObject({type:e.literal("close")}),e.strictObject({type:e.literal("action"),action:M})]),Lt=e.strictObject({kind:e.literal("paywall"),formatVersion:e.literal(1),name:e.string().trim().min(1).max(80),offeringVersionId:e.uuid(),presentation:S,screen:P,products:F,catalog:e.record(e.uuid(),qe),buttons:e.record(H,Ne),coupons:e.record(e.uuid(),Be)}).superRefine((t,r)=>{let a=n=>r.addIssue({code:"custom",message:n}),{screen:o}=t;ce(o,t.catalog).forEach(a),o.surface!=="paywall"&&a("Screen must be a Paywall"),ie(o,De).forEach(a),k(o).some(n=>!n.complete)&&a("Every published locale must be complete");let c=new Set,p=new Set,g=new Set;w(o,n=>{let b="bind"in n?n.bind:void 0;b?.promotionCode&&a("Promotion codes must not be published"),b?.plan&&c.add(b.plan),b?.coupon&&p.add(b.coupon),n.type==="plan_picker"&&(n.planIds?.forEach(x=>c.add(x)),n.defaultPlan&&c.add(n.defaultPlan)),n.type==="text"&&n.feature&&g.add(n.feature.id)});let f=t.products.items.map(n=>n.productVersionId),d=Object.keys(t.catalog);(f.length!==d.length||f.some(n=>!Object.hasOwn(t.catalog,n)))&&a("Catalog must contain exactly the displayed Products");let m=new Set(f);t.products.defaultProductVersionId!==null&&!m.has(t.products.defaultProductVersionId)&&a("Default Product must be displayed");for(let n of c)m.has(n)||a("Screen references a Product that is not displayed");for(let n of Object.values(t.catalog))!n.channels.stripe&&!n.channels.apple&&!n.channels.google&&a("A displayed Product needs at least one sales channel");let i=new Set(Object.values(t.catalog).flatMap(n=>n.benefits.map(b=>b.featureId)));for(let n of g)i.has(n)||a("Feature text must read a displayed benefit");let u=o.actions.filter(n=>n.type!=="navigate");o.actions.some(n=>n.type!=="event"&&n.type!=="navigate")&&a("Paywall actions are events or navigation"),(Object.keys(t.buttons).length!==u.length||u.some(n=>!Object.hasOwn(t.buttons,n.id)))&&a("Buttons must match the screen's actions");let y=!1;for(let n of Object.values(t.buttons)){if(n.type!=="checkout")continue;y=!0,(n.product.type==="fixed"?[n.product.productVersionId]:n.product.allowedProductVersionIds).some(x=>!m.has(x))&&a("Checkout may only sell displayed Products")}y||a("A Paywall needs a checkout button");let s=Object.keys(t.coupons);(s.length!==p.size||s.some(n=>!p.has(n)))&&a("Coupons must be exactly the bound Coupons")}),he=e.strictObject({state:e.enum(["published","archived"]),controlRevision:e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),currentVersionId:e.uuid(),versions:e.record(e.uuid(),e.strictObject({version:e.number().int().positive(),artifact:e.string().min(1),sourceDigest:e.string().regex(/^[a-f0-9]{64}$/)}))}).refine(t=>Object.keys(t.versions).length>0,"Reviewed Paywall Versions are required");var $e={manifestCdnSeconds:15,maxControlAgeMs:6e4,initializationMs:5e3,maxArtifactBytes:1048576,maxManifestBytes:524288,maxCacheBytes:32*1048576,retentionMs:7*864e5},q=e.string().regex(/^[a-f0-9]{64}$/),B=e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),Le=j.extend({environmentId:e.uuid()}),xe=e.strictObject({features:e.array(e.string()).max(500),experiments:e.record(e.uuid(),e.array(e.string()).max(20)),savedGroups:e.array(e.string()).max(1e3)}),Ue=e.strictObject({kind:e.enum(["funnel","paywall","gb_features","gb_page_experiments"]),formatVersion:e.number().int().positive(),url:e.string().min(1).max(2048),sha256:q,byteLength:e.number().int().positive().max($e.maxArtifactBytes),generation:q.optional()}),Te=e.strictObject({state:e.enum(["active","paused","archived"]),controlRevision:B,evaluationMode:e.enum(["local","remote"]),evaluationRevision:B,currentVersionId:e.uuid(),versions:e.record(e.uuid(),e.strictObject({artifact:e.string(),dependencies:xe,definitionDigest:O.optional(),couponDigests:e.record(e.uuid(),O).optional()}))}),en=e.strictObject({kind:e.literal("sdk_configuration"),schemaVersion:e.literal(1),scope:Le,revision:B,generation:q,policy:e.strictObject({refreshIntervalSeconds:e.number().positive().max(15),maxControlAgeSeconds:e.number().positive().max(60)}),gb:e.strictObject({features:e.string().nullable(),pageExperiments:e.string().nullable()}),artifacts:e.record(e.string(),Ue),funnels:e.record(e.uuid(),Te),paywalls:e.record(e.uuid(),he).optional()}).superRefine((t,r)=>{let a=(o,c)=>{o!==null&&t.artifacts[o]?.kind!==c&&r.addIssue({code:"custom",message:"Missing or wrong-kind configuration artifact"})};a(t.gb.features,"gb_features"),a(t.gb.pageExperiments,"gb_page_experiments");for(let o of Object.values(t.paywalls??{}))for(let c of Object.values(o.versions))a(c.artifact,"paywall");for(let o of Object.values(t.funnels)){o.evaluationMode==="remote"&&Object.keys(o.versions).length&&r.addIssue({code:"custom",message:"Remote Funnel graphs cannot be public"}),o.evaluationMode==="local"&&!o.versions[o.currentVersionId]&&r.addIssue({code:"custom",message:"Current Funnel Version is not retained"});for(let c of Object.values(o.versions))a(c.artifact,"funnel")}});function N(t){if(Array.isArray(t))return`[${t.map(N).join(",")}]`;if(t!==null&&typeof t=="object")return`{${Object.entries(t).sort(([a],[o])=>a<o?-1:a>o?1:0).map(([a,o])=>`${JSON.stringify(a)}:${N(o)}`).join(",")}}`;let r=JSON.stringify(t);if(r===void 0)throw new Error("Configuration must contain JSON values");return r}function Je(t){return L(U(typeof t=="string"?new TextEncoder().encode(t):t))}function tn(t){return Je(N(t))}var $=class extends Error{constructor(a,o){super(a);this.dependency=o}dependency};function nn(t,r){let a=i=>i.type==="feature"?i.featureKey:i.type==="end"&&i.output?.type==="feature"?i.output.featureKey:i.type==="output"&&i.value.type==="feature"?i.value.featureKey:void 0,o=(i,u)=>t.graph.nodes.find(l=>i==="experiment"?l.type==="split"&&l.experimentId===u:i==="feature"&&a(l)===u)?.name,c=(i,u,l=o(u.type,u.resource))=>new $(i,{...u,...l?{step:l}:{}});for(let i of Object.values(t.references)){let u=i.type==="flag"?!Object.hasOwn(r.features,i.key)||r.remoteFeatures.includes(i.key)?{type:"feature",resource:i.key}:null:i.type==="experiment"?Object.hasOwn(r.experiments,i.id)?null:{type:"experiment",resource:i.id}:i.type==="saved_group"&&!Object.hasOwn(r.savedGroups,i.id)?{type:"saved_group",resource:i.id}:null;if(u)throw c("Funnel dependency is absent from GB public delivery",{reason:"unavailable",...u})}let p=fe(t,{...r,evaluatedAt:new Date(0).toISOString(),expiresAt:null}),g=new Set(r.remoteFeatures);for(let i of t.graph.nodes){let u=a(i);if(!u)continue;let l=p.features[u],y=i.type==="feature"?t.variables[i.writes.value]:t.outputSchema,s={type:"feature",resource:u};if(!l||!y)throw c("Required public Feature declaration is unavailable",{reason:"unavailable",...s},i.name);if([l.defaultValue,...(l.rules??[]).flatMap(b=>[...Object.hasOwn(b,"force")?[b.force]:[],...b.variations??[],...(b.tracks??[]).flatMap(x=>x.experiment.variations)])].some(b=>b===void 0||!ee(y,b)))throw c("GB Feature values violate the Funnel type contract",{reason:"value_type",...s},i.name)}let f=new Set,d=(i,u)=>{for(let l of A(i)){if(f.has(l))continue;let y=r.savedGroups[l];if(!y)throw c("Required public Saved Group is unavailable",{reason:"unavailable",type:"saved_group",resource:l},u);f.add(l),!Array.isArray(y)&&y.type==="condition"&&d(y.condition,u)}},m=(i,u)=>{if(g.has(i)||!r.features[i])throw c("Local Funnel requires public Local prerequisites",{reason:"unavailable",type:"feature",resource:i},u)};for(let i of t.graph.nodes)if(i.type==="condition")for(let u of i.cases)d(u.condition,i.name);for(let[i,u]of Object.entries(p.features)){let l=o("feature",i);for(let y of u.rules??[]){d(y.condition,l);for(let s of[...y.parentConditions??[],...(y.tracks??[]).flatMap(n=>n.experiment.parentConditions??[])])m(s.id,l),d(s.condition,l);for(let s of y.tracks??[])d(s.experiment.condition,l)}}for(let[i,u]of Object.entries(p.experiments)){let l=o("experiment",i);d(u.condition,l);for(let y of u.parentConditions??[])m(y.id,l),d(y.condition,l)}for(let i of t.graph.nodes)if(i.type==="split"){let u=p.experiments[i.experimentId],l={type:"experiment",resource:i.experimentId};if(!u)throw c("Local Funnel requires a public Experiment",{reason:"unavailable",...l},i.name);for(let y of u.variations)if(typeof y!="string"||!Object.hasOwn(i.routes,y))throw c("Experiment variation has no declared Funnel route",{reason:"variation_route",...l},i.name)}return xe.parse({features:Object.keys(p.features).sort(),experiments:Object.fromEntries(Object.entries(p.experiments).map(([i,u])=>[i,u.variations.map(String)])),savedGroups:[...f].sort()})}function rn(t){return se.parse(t)}export{E as a,We as b,pe as c,Pe as d,v as e,ke as f,it as g,at as h,st as i,ct as j,ut as k,fe as l,Lt as m,$e as n,Le as o,Ue as p,en as q,N as r,Je as s,tn as t,nn as u,rn as v};
@@ -1 +0,0 @@
1
- import{b as Re}from"./chunk-ASDJTOGM.js";import{a as M}from"./chunk-67AY54E2.js";import{A as _e,E as W,G as ke,d as Pe,f as x,k as Se,v as Ee,w as be,y as Oe}from"./chunk-4TEZZZYK.js";import{a as we,b as ge,c as ye}from"./chunk-POCDWUD3.js";import{aa as U}from"./chunk-IOJVF52Q.js";import{a as X}from"./chunk-3NCMYTNG.js";import{g as Z}from"./chunk-VOKEZHAH.js";import{b as ve}from"./chunk-PZOQV6MU.js";import{b as $}from"./chunk-OOD2VDDP.js";import{a as l}from"./chunk-WLGLQJ6M.js";import{b as Ce}from"./chunk-RV6UAUK2.js";import{b as n}from"./chunk-RGEBK6UF.js";import{a as ue}from"./chunk-DSPLGTQI.js";var g=U.options,Ge=n.discriminatedUnion("operation",[g[1].omit({customerToken:!0}),g[2].omit({customerToken:!0}),g[3].omit({customerToken:!0}),g[4].omit({customerToken:!0}),g[5].omit({customerToken:!0}),g[6].omit({customerToken:!0}),g[7].omit({customerToken:!0}),g[8].omit({customerToken:!0}),Se.omit({customerToken:!0})]),ce=n.strictObject({receiptId:n.uuid(),operationId:n.uuid()}),Xe=n.discriminatedUnion("operation",[n.strictObject({operation:n.literal("find_purchase")}),n.strictObject({operation:n.literal("recover_start"),intent:n.enum(["lookup","resume","start"]),start:n.strictObject({requestId:g[0].shape.requestId,funnelId:g[0].shape.funnelId,locale:g[0].shape.locale,parameters:g[0].shape.parameters})}),n.strictObject({operation:n.literal("recover_run"),runId:n.uuid(),funnelId:n.uuid()}),n.strictObject({operation:n.literal("recover_purchase"),runId:n.uuid(),funnelId:n.uuid(),purchase:ce}),n.strictObject({operation:n.literal("terminate_checkout"),runId:n.uuid(),funnelId:n.uuid(),purchase:ce}),n.strictObject({operation:n.literal("settle_command"),runId:n.uuid(),funnelId:n.uuid(),requestId:n.uuid(),command:n.discriminatedUnion("operation",[g[3].omit({customerToken:!0}),g[4].omit({customerToken:!0}),g[5].omit({customerToken:!0}),g[6].omit({customerToken:!0}),g[7].omit({customerToken:!0})]).optional()}).refine(a=>!a.command||a.requestId===a.command.requestId),n.strictObject({operation:n.literal("run_command"),runId:n.uuid(),funnelId:n.uuid(),command:Ge})]),ee=n.strictObject({runId:n.uuid(),funnelId:n.uuid(),versionId:n.uuid(),startRequestId:n.uuid(),runExpiresAt:n.iso.datetime({offset:!0}),status:x.shape.run.shape.status}),N={scope:$,customerId:n.uuid()},Fe=n.discriminatedUnion("outcome",[n.strictObject({...N,outcome:n.literal("unknown"),target:n.null(),view:n.null(),access:n.null()}),n.strictObject({...N,outcome:n.literal("resolved"),target:ee,view:x.shape.run.nullable(),access:n.discriminatedUnion("type",[n.strictObject({type:n.literal("customer")}),n.strictObject({type:n.literal("operation_only"),cause:n.enum(["run_terminal","run_expired","run_revoked","issuer_unavailable"])})])})]).superRefine((a,d)=>{a.outcome==="resolved"&&(a.access.type==="customer"!=(a.view!==null)||a.view&&(a.view.id!==a.target.runId||a.view.source.id!==a.target.funnelId||a.view.source.versionId!==a.target.versionId||a.view.status!==a.target.status||a.view.runExpiresAt!==a.target.runExpiresAt||a.view.credentialExpiresAt!==null))&&d.addIssue({code:"custom",message:"Recovery view and original Run binding differ"})}),Ae=n.strictObject({...N,target:ee,view:x.shape.run.nullable(),settlement:n.strictObject({requestId:n.uuid(),state:n.enum(["pending","unknown","settled"]),acceptance:n.enum(["accepted","not_accepted","unknown"]),receiptPhase:n.enum(["accepted","processing","done"]).nullable(),basis:n.enum(["receipt","run_terminal","position_advanced","none"]),receiptId:n.uuid().nullable(),operationId:n.uuid().nullable()}),purchase:x.shape.purchase.unwrap().nullable()}).superRefine((a,d)=>{let p=a.settlement;(p.acceptance==="accepted"!=(p.receiptPhase!==null)||p.acceptance==="accepted"&&p.basis!=="receipt"||p.acceptance==="unknown"&&(p.state!=="unknown"||p.basis!=="none")||p.acceptance!=="accepted"&&(p.operationId!==null||p.receiptId!==null)||p.acceptance==="not_accepted"&&(p.state!=="settled"||!["run_terminal","position_advanced"].includes(p.basis))||a.purchase&&(a.purchase.receiptId!==p.receiptId||a.purchase.operation&&a.purchase.operation.operationId!==p.operationId||a.purchase.quote&&a.purchase.quote.operationId!==p.operationId)||a.view&&(a.view.id!==a.target.runId||a.view.source.id!==a.target.funnelId||a.view.source.versionId!==a.target.versionId||a.view.status!==a.target.status||a.view.runExpiresAt!==a.target.runExpiresAt||a.view.credentialExpiresAt!==null))&&d.addIssue({code:"custom",message:"Original command settlement binding differs"})}),qe=n.strictObject({...N,target:ee,purchase:x.shape.purchase.unwrap()}).superRefine((a,d)=>{(!a.purchase.operation||typeof a.purchase.canReselect!="boolean"||a.purchase.quote&&a.purchase.quote.operationId!==a.purchase.operation.operationId)&&d.addIssue({code:"custom",message:"Original purchase proof is incomplete"})}),Ne=n.discriminatedUnion("outcome",[n.strictObject({...N,outcome:n.literal("none")}),n.strictObject({...N,outcome:n.literal("blocked")}),n.strictObject({...N,outcome:n.literal("found"),target:ee,start:n.strictObject({locale:g[0].shape.locale,parameters:g[0].shape.parameters}),purchase:ce})]);var Me=U.options[0].refine(a=>!a.customer&&!a.customerData),ze=n.strictObject({receiptId:n.uuid(),operationId:n.uuid(),terminal:n.enum(["complete","native"]).nullable()}),je=n.strictObject({schemaVersion:n.literal(1),baseUrl:n.url(),scope:$,customerId:n.uuid(),sessionId:n.uuid(),start:Me,allowed:n.array(n.enum(["merchant","record_only","indiana","native"])),run:n.strictObject({id:n.uuid(),versionId:n.uuid(),status:Pe.shape.status,revision:n.number().int().nonnegative(),runExpiresAt:n.iso.datetime({offset:!0}).optional()}).optional(),purchases:n.array(ze).max(100),operationCommand:n.strictObject({operationId:n.uuid(),intent:n.literal("confirm")}).optional(),journal:n.strictObject({revision:n.number().int().nonnegative(),entry:Ee.nullable()})});function Te(a){return Oe({...a,namespace:"purchases",identity:[a.scope.projectId,a.scope.environment,a.customerId]})}function Ue(a){let d=new URL(a.baseUrl??Ce).href,p=()=>new l("PURCHASE_STORAGE_INVALID","Purchase recovery storage is unavailable or invalid; native fallback is not authorized");async function S(){a.assertCurrent();try{let C=await a.storage.read();if(a.assertCurrent(),!Number.isSafeInteger(C.revision)||C.revision<0)throw p();let u=C.entry===null?null:je.parse(C.entry);if(u&&(u.baseUrl!==d||u.customerId!==a.customerId||u.scope.projectId!==a.scope.projectId||u.scope.environment!==a.scope.environment))throw new l("SCOPE_MISMATCH","Purchase recovery belongs to another Customer or environment");if(u?.journal.entry&&(u.journal.entry.scope.projectId!==u.scope.projectId||u.journal.entry.scope.environment!==u.scope.environment||u.journal.entry.funnelId!==u.start.funnelId||u.journal.entry.runId!==u.run?.id||u.journal.entry.versionId!==u.run?.versionId)||u?.operationCommand&&!u.purchases.some(E=>E.operationId===u.operationCommand?.operationId))throw p();return{revision:C.revision,entry:u}}catch(C){throw C instanceof l?C:p()}}async function z(C){for(let u=0;u<8;u++){let E=await S(),O=C(structuredClone(E.entry));if(JSON.stringify(O)===JSON.stringify(E.entry))return O;O&&je.parse(O),a.assertCurrent();let R;try{R=await a.storage.write(E.revision,O)}catch{throw p()}if(a.assertCurrent(),R!==null){if(!Number.isSafeInteger(R)||R<=E.revision)throw p();return O}}throw new l("PURCHASE_STORAGE_CONFLICT","Another consumer changed this purchase; recover the original attempt")}return{read:S,update:z,baseUrl:d}}var Be=5*6e4;function Qe(a,d){let p=a.purchases.find(S=>S.type==="checkout");if(!a.actions.includes("continue_checkout")||p?.type!=="checkout"||d!==void 0&&p.operationId!==d)throw new l("PURCHASE_PENDING","No single resumable Checkout is confirmed");return p.checkoutUrl}function vt(a){let d={...a,scope:{...a.scope},executionPolicy:structuredClone(a.executionPolicy)},p=d.session.snapshot();if(!p)throw new l("CUSTOMER_SESSION_REQUIRED","Purchase recovery requires a verified Customer session");let{customerId:S,sessionId:z}=p,C=!1,u=null,E,O=null,R=!1,A,B,Q,k={mode:"idle",status:"idle",actions:["start"],purchases:[]},y=new Map,j=new Map,le=new AbortController,Y=new Set,D=ve(d),de=Re(D.request);function H(e){return{code:e instanceof l?e.code:"PURCHASE_RECOVERY_BLOCKED",message:e instanceof Error?e.message:"The original purchase requires server confirmation",...e instanceof l&&e.status!==void 0?{status:e.status}:{}}}function w(){if(C||d.session.snapshot()?.customerId!==S)throw new l("IDENTITY_CHANGED","The original purchase Customer changed")}let f=Ue({...d,customerId:S,assertCurrent:w,storage:d.storage??Te({baseUrl:d.baseUrl,scope:d.scope,customerId:S})}),xe=d.session.subscribeIdentity(pe);function pe(){C||(C=!0,clearTimeout(Q),le.abort(new l("IDENTITY_CHANGED","Purchase consumer was destroyed")),xe(),u?.reset(),u=null,O=null,D.dispose(),Y.clear(),y.clear(),j.clear())}function P(e){w();let t=JSON.stringify(e)!==JSON.stringify(k);k=e,clearTimeout(Q),(e.mode==="operation"||e.mode==="run"&&!e.actions.includes("close"))&&["waiting_result","fulfillment","recording"].includes(e.status)&&(Q=setTimeout(()=>{T().catch(()=>{})},5e3)),t&&ue(d.onRecovery,structuredClone(e));for(let r of t?Y:[]){if(C)break;ue(r,structuredClone(e))}return structuredClone(e)}function I(e){if(w(),!e||e.start.requestId!==E)throw new l("PURCHASE_STORAGE_CONFLICT","This purchase was superseded; the old consumer cannot dispatch")}function b(e){let t=[...e.purchases],r=e.journal.entry?.purchase;return r&&!t.some(o=>o.operationId===r.operationId)&&t.push({receiptId:r.receiptId,operationId:r.operationId,terminal:null}),t}function q(e){return e.run&&!["running","waiting"].includes(e.run.status)&&!e.journal.entry?.command&&!e.journal.entry?.closeCommand&&!e.operationCommand&&b(e).every(t=>t.terminal!==null)}function _(e,t){let r=e.journal.entry?.command??e.journal.entry?.closeCommand,o=b(e).map(v=>{let se=y.get(v.operationId);return v.terminal&&!se?{type:v.terminal,operationId:v.operationId}:X({quote:se?.quote??null,operation:se??null,requestId:r?.requestId??null,pending:!1,destroyed:!1,canReselect:j.get(v.operationId)===!0})}),c=o.filter(v=>!["complete","native"].includes(v.type)),i=c[0],s=c.length===1&&i?.operationId?y.get(i.operationId):void 0;if(s&&(i?.type==="checkout"||i?.type==="cancel"))try{W({allowed:e.allowed.filter(v=>d.executionPolicy.allowed.includes(v))},s.quote)}catch(v){return{mode:t,status:"blocked",actions:["refresh",...t==="run"&&e.run&&["running","waiting"].includes(e.run.status)?["close"]:[]],purchases:o,error:H(v)}}let m;if(t==="operation"&&!r&&i?.type==="cancel"&&s?.quote&&!s.problem&&!s.confirmedAt)try{W({allowed:e.allowed.filter(v=>d.executionPolicy.allowed.includes(v))},s.quote),Date.parse(s.quote.expiresAt)>Date.now()&&(m={operationId:s.operationId,quote:s.quote})}catch{}let h=o.length>0&&c.length===0,G=q(e)||t==="operation"&&h&&!r&&!e.operationCommand?"complete":i?.type==="checkout"?"checkout":i?.type==="fulfillment"?"fulfillment":i?.type==="recording"?"recording":r||e.operationCommand||i&&i.type!=="cancel"||t==="operation"&&!m?"waiting_result":"ready";return{mode:t,status:G,purchases:o,...m?{confirmation:structuredClone(m)}:{},actions:["refresh",...q(e)?["start"]:[],...t==="run"&&e.run&&["running","waiting"].includes(e.run.status)?["close"]:[],...e.operationCommand?["retry"]:m?["confirm"]:[],...c.length===1&&i?.type==="checkout"?["continue_checkout"]:[]]}}function te(e){let t=X({quote:e?.quote??null,operation:e??null,requestId:null,pending:!1,destroyed:!1,canReselect:e&&j.get(e.operationId)===!0});return t.type==="complete"||t.type==="native"?t.type:null}function ne(e){if(!e.operation)return;let t={...e.operation,...e.operation.quote?{}:e.quote?{quote:e.quote}:{}};if(t.merchantExecution&&t.merchantExecution.customerId!==S)throw new l("SCOPE_MISMATCH","Purchase execution belongs to another Customer");let r=Z(y.get(t.operationId)??null,t);y.set(t.operationId,r),r===t&&j.set(t.operationId,e.canReselect===!0)}async function De(e){w();for(let r of[e.purchase,e.run.paywall])r&&ne(r);let t=await f.update(r=>{if(I(r),r.run&&(r.run.id!==e.run.id||r.run.versionId!==e.run.source.versionId))throw new l("SCOPE_MISMATCH","The original purchase Run changed");let o=b(r);for(let c of[e.purchase,e.run.paywall]){let i=c?.operation?.operationId??c?.quote?.operationId;if(!c||!i)continue;let s=o.find(h=>h.operationId===i);if(s&&s.receiptId!==c.receiptId)throw new l("INVALID_RESPONSE","The original purchase Receipt changed");let m=te(y.get(i));s?s.terminal??=m:o.push({receiptId:c.receiptId,operationId:i,terminal:m})}return{...r,purchases:o,run:r.run&&(r.run.revision>e.run.revision||!["running","waiting"].includes(r.run.status)&&["running","waiting"].includes(e.run.status))?r.run:{id:e.run.id,versionId:e.run.source.versionId,status:e.run.status,revision:e.run.revision,runExpiresAt:e.run.runExpiresAt}}});I(t),t.run&&!["running","waiting"].includes(t.run.status)&&b(t).some(r=>!r.terminal)&&(t=await L(t,!t.journal.entry?.command&&!t.journal.entry?.closeCommand,new Set([e.purchase?.operation?.operationId,e.run.paywall?.operation?.operationId].filter(r=>!!r)))),I(t),P(_(t,"run"))}function He(){return{async read(){let{entry:e}=await f.read();return I(e),structuredClone(e.journal)},async write(e,t){let r=null;return await f.update(o=>{if(I(o),o.operationCommand&&t?.command&&t.command.operation!=="close")throw new l("PURCHASE_PENDING","Recover the original Operation command before dispatching a Run mutation");return r=null,o.journal.revision!==e?o:(r=e+1,{...o,journal:{revision:r,entry:t}})}),r}}}async function L(e,t=!1,r=new Set){I(e);let o=b(e);for(let i of o){if(i.terminal)continue;let s=r.has(i.operationId)?y.get(i.operationId):void 0;if(s??=await oe(e,i),w(),s.operationId!==i.operationId)throw new l("INVALID_RESPONSE","Original Operation changed");if(s.merchantExecution&&s.merchantExecution.customerId!==S)throw new l("SCOPE_MISMATCH","Purchase execution belongs to another Customer");if(t&&!e.operationCommand&&X({quote:s.quote??null,operation:s,requestId:null,pending:!1,destroyed:!1}).type==="cancel"){if({operation:s}=await de.attach({operationId:i.operationId,intent:"cancel"}),w(),s.operationId!==i.operationId)throw new l("INVALID_RESPONSE","Original cancellation Operation changed");s=await oe(e,i)}y.set(i.operationId,Z(y.get(i.operationId)??null,s))}let c=await f.update(i=>{I(i);let s=i.operationCommand&&y.get(i.operationCommand.operationId);return{...i,...s&&(s.confirmedAt||s.merchantExecution||s.status!=="pending")?{operationCommand:void 0}:{},purchases:b(i).map(m=>({...m,terminal:m.terminal??te(y.get(m.operationId))}))}});return I(c),c}async function V(e){w();let t=await D.request("funnels",e);return w(),t}async function Le(e){try{return await V(e)}catch(t){if(e.operation!=="recover_start"||e.intent!=="start"||!(t instanceof l)||t.status!==400||t.code!=="INVALID_REQUEST")throw t;return V({...e,intent:"resume"})}}async function Ve(){let e=M(Ne,await V({operation:"find_purchase"}));if(e.customerId!==S||e.scope.projectId!==d.scope.projectId||e.scope.environment!==d.scope.environment)throw new l("SCOPE_MISMATCH","Recovery Customer or environment changed");if(e.outcome!=="found")return e.outcome;let{target:t,purchase:r}=e;return await f.update(o=>o&&!q(o)?o:{schemaVersion:1,baseUrl:f.baseUrl,scope:d.scope,customerId:S,sessionId:z,start:{operation:"start",requestId:t.startRequestId,funnelId:t.funnelId,...e.start},allowed:[...d.executionPolicy.allowed],run:{id:t.runId,versionId:t.versionId,status:t.status,revision:0,runExpiresAt:t.runExpiresAt},purchases:[{...r,terminal:null}],journal:{revision:0,entry:null}}),"found"}let J;function re(e){let t=J;if(t&&(!t.outcome||e&&t.outcome==="none"&&Date.now()-t.at<Be))return t.job;let r={at:Date.now(),job:Ve().then(o=>(r.outcome=o,r.at=Date.now(),o),o=>{throw J===r&&(J=void 0),o})};return J=r,r.job}async function oe(e,t,r="recover_purchase"){let o=M(qe,await V({operation:r,runId:e.run.id,funnelId:e.start.funnelId,purchase:{receiptId:t.receiptId,operationId:t.operationId}}));if(ae(e,o),o.purchase.receiptId!==t.receiptId||o.purchase.operation?.operationId!==t.operationId)throw new l("INVALID_RESPONSE","Original purchase reference changed");return ne(o.purchase),y.get(t.operationId)}async function me(e){for(let t of[e.journal.entry?.command,e.journal.entry?.closeCommand]){if(!t)continue;let r=M(Ae,await V({operation:"settle_command",runId:e.run.id,funnelId:e.start.funnelId,requestId:t.requestId,...t.operation==="resume"?{}:{command:t}}));if(ae(e,r),r.settlement.requestId!==t.requestId)throw new l("INVALID_RESPONSE","Original command settlement changed");r.purchase&&ne(r.purchase);let o=await f.update(c=>{I(c);let i=b(c),{receiptId:s,operationId:m}=r.settlement;if(s&&m){let G=i.find(v=>v.operationId===m);if(G&&G.receiptId!==s)throw new l("INVALID_RESPONSE","Original Receipt changed");G||i.push({receiptId:s,operationId:m,terminal:te(y.get(m))})}let h=r.settlement.state==="settled"?be(c.journal.entry,t.requestId):c.journal.entry;return{...c,purchases:i,journal:h===c.journal.entry?c.journal:{revision:c.journal.revision+1,entry:h}}});I(o),e=o}return e}function ae(e,t){if(t.customerId!==S||t.scope.projectId!==d.scope.projectId||t.scope.environment!==d.scope.environment||t.target.funnelId!==e.start.funnelId||t.target.startRequestId!==e.start.requestId||e.run&&(t.target.runId!==e.run.id||t.target.versionId!==e.run.versionId))throw new l("SCOPE_MISMATCH","The original recovery binding changed")}async function ie(e,t){if(I(e),e.run&&(e=await me(e)),!b(e).length&&q(e))return P(_(e,"operation"));if(!b(e).length)return P({mode:"blocked",status:"blocked",actions:["refresh"],purchases:[],error:H(t)});R=!0;let r=await L(e);return P(_(r,"operation"))}async function K(e,t=!1,r=!0){if(E=e.start.requestId,O=structuredClone({requestId:e.start.requestId,funnelId:e.start.funnelId,locale:e.start.locale,parameters:e.start.parameters}),!u){let o=e.run?{operation:"recover_run",runId:e.run.id,funnelId:e.start.funnelId}:{operation:"recover_start",intent:t?"start":"lookup",start:{requestId:e.start.requestId,funnelId:e.start.funnelId,locale:e.start.locale,parameters:e.start.parameters}},c;try{c=await Le(o)}catch(h){if(!e.run&&h instanceof l&&(h.status===void 0||h.status>=500))return P({mode:"blocked",status:"blocked",actions:["refresh","retry"],purchases:k.purchases,error:H(h)});throw h}let i=M(Fe,c);if(i.customerId!==S||i.scope.projectId!==d.scope.projectId||i.scope.environment!==d.scope.environment)throw new l("SCOPE_MISMATCH","Recovery Customer or environment changed");if(i.outcome==="unknown")return P({mode:"blocked",status:"blocked",actions:["refresh","retry"],purchases:k.purchases,error:{code:"RESULT_UNKNOWN",message:"The original Start outcome remains unknown; retry only its original input"}});ae(e,i);let s=await f.update(h=>(I(h),{...h,run:{id:i.target.runId,versionId:i.target.versionId,status:i.target.status,revision:i.view?.revision??h.run?.revision??0,runExpiresAt:i.target.runExpiresAt}}));if(I(s),e=s,i.access.type==="operation_only")return ie(e,new l("RUN_RECONCILIATION_REQUIRED","Only the original command and Operation can be recovered"));e=await me(e);let m=i.view;if(m.locale!==e.start.locale||!_e(m.parameters,e.start.parameters))throw new l("INVALID_RESPONSE","The original Start input changed");u=ke({...d,customerRun:{runId:i.target.runId,customerId:S,startRequestId:e.start.requestId},funnelId:e.start.funnelId,funnelExecutionPolicy:{allowed:e.allowed.filter(h=>d.executionPolicy.allowed.includes(h))},funnelCommandStorage:He(),onAcceptedResponse:De},{scope:i.scope,run:m})}try{await u.get(),u.view?.pendingRequest?.requestId===e.start.requestId&&!u.pendingCommands?.length&&await u.resume(u.view.pendingRequest.requestId);for(let c of u.pendingCommands??[])c.operation!=="close"&&await u.settle?.(c.requestId);u.pendingCommands?.length&&await u.retry(),w();let o=(await f.read()).entry;return I(o),P(_(o,"run"))}catch(o){if(w(),r&&o instanceof l&&(o.status===401||o.status===409&&o.reason==="STATE_CHANGED")){u.reset(),u=null;let c=(await f.read()).entry;return I(c),K(c,!1,!1)}throw o}}function F(e,t="read",r){if(w(),A)return t==="read"||t===B?A:A.then(()=>F(e,t,r),()=>F(e,t,r));clearTimeout(Q);let o=e().catch(c=>{throw!C&&!r?.(c)&&P({mode:"blocked",status:"blocked",actions:["refresh"],purchases:k.purchases,error:H(c)}),c});return A=o,B=t,o.then(()=>{A===o&&(A=void 0,B=void 0)},()=>{A===o&&(A=void 0,B=void 0)}),o}function T(){return F(async()=>{let{entry:e}=await f.read();if(!e||q(e)){if(await re(!1)==="blocked")return fe();({entry:e}=await f.read())}return e?(E&&e.start.requestId!==E&&(u?.reset(),u=null,y.clear(),j.clear(),R=!1),R&&E===e.start.requestId?ie(e,k.error):K(e)):P({mode:"idle",status:"idle",actions:["start"],purchases:[]})})}function fe(){return P({mode:"blocked",status:"blocked",actions:["refresh"],purchases:[],error:H(new l("PURCHASE_PENDING","Check the outstanding purchases before starting another"))})}async function he(){let e=await T();return e.mode==="operation"&&!e.actions.includes("confirm")&&!e.actions.includes("retry")?e:F(async()=>{let t=(await f.read()).entry;if(I(t),!R){if(!u?.view?.paywall?.quote)throw new l("PURCHASE_PENDING","Read the original quote before confirming");let s=u.view.paywall.operation;if(s?.confirmedAt||s?.merchantExecution||s&&s.status!=="pending")return P(_(t,"run"));if(u.pendingCommands?.length)await u.retry();else{let h=u.view;await u.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:h.nodeId,visit:h.visit,revision:h.revision,input:{type:"paywall_confirm",operationId:h.paywall.quote.operationId}})}let m=(await f.read()).entry;return I(m),P(_(m,"run"))}let r=t.operationCommand?.operationId??k.confirmation?.operationId,o=r&&y.get(r);if(!r||!o||t.journal.entry?.command||t.journal.entry?.closeCommand)throw new l("PURCHASE_PENDING","The original Run command must be settled before Operation confirmation");W({allowed:t.allowed.filter(s=>d.executionPolicy.allowed.includes(s))},o.quote),await f.update(s=>{if(I(s),s.journal.entry?.command||s.journal.entry?.closeCommand||s.operationCommand&&s.operationCommand.operationId!==r)throw new l("PURCHASE_PENDING","Another original command is pending");return{...s,operationCommand:{operationId:r,intent:"confirm"}}});let c=await de.attach({operationId:r,intent:"confirm"});if(w(),c.operation.operationId!==r)throw new l("INVALID_RESPONSE","Original confirmation Operation changed");y.set(r,Z(o,c.operation));let i=(await f.read()).entry;return I(i),P(_(await L(i,!1,new Set([r])),"operation"))},"confirm")}async function Ie(){w();let{entry:e}=await f.read();return e?q(e)?"finished":"pending":"none"}return{get controller(){return u},get recovery(){return structuredClone(k)},get attempt(){return w(),structuredClone(O)},get identitySignal(){return le.signal},retained:Ie,async findPurchase(){let e=await Ie();if(e==="pending")return e;let t=await re(!0);return w(),t==="none"?e:t},async readPaywall(e){w();let t=we(e),[r,{readPaywallContent:o},{validateResourceCheck:c}]=await Promise.all([ge(D.request,"resolvePaywall"),import("./paywall-content-CHPX2P77.js"),import("./check-response-DRQCUWDW.js")]);w();let i=r.request.parse({selector:t.paywallVersionId?{type:"version",versionId:t.paywallVersionId}:{type:"paywall",paywallId:t.paywallId},commerce:t.commerce,locale:t.locale}),s=await ye(D.request,r,i);c(i,s.paywall.check,s.scope);let m=await o(d,s.paywall);if(w(),t.paywallVersionId?m.id!==t.paywallVersionId:m.paywallId!==t.paywallId)throw new l("INVALID_RESPONSE","The requested Paywall changed");return m},start(e){let t=U.parse({...structuredClone(e),operation:"start",requestId:e.requestId??crypto.randomUUID()});if(t.operation!=="start"||t.customer||t.customerData)throw new l("INVALID_REQUEST","A Customer-owned Funnel start is required");return F(async()=>{let r=(await f.read()).entry;if((!r||q(r))&&await re(!0)==="blocked")return fe();let o=await f.update(c=>{if(c&&!q(c)){if(c.start.funnelId!==t.funnelId)throw new l("PURCHASE_PENDING","Recover the original Funnel before starting another purchase");return c}return{schemaVersion:1,baseUrl:f.baseUrl,scope:d.scope,customerId:S,sessionId:z,start:t,allowed:[...d.executionPolicy.allowed],purchases:[],journal:{revision:0,entry:null}}});if(!o)throw new l("PURCHASE_STORAGE_INVALID","Original start was not retained");return E!==o.start.requestId&&(u?.reset(),u=null,y.clear(),j.clear(),R=!1),R?ie(o,k.error):K(o,!0)},`start:${t.funnelId}`)},refresh:T,confirm:he,retry:()=>R?he():F(async()=>{let{entry:e}=await f.read();return e?K(e,!0):P({mode:"idle",status:"idle",actions:["start"],purchases:[]})},"retry"),async close(){return u?.view?F(async()=>{if(!u?.view)throw new l("PURCHASE_PENDING","Recover the original Run before closing");if(u.pendingCommands?.find(r=>r.operation==="close"))await u.retry();else if(["running","waiting"].includes(u.view.status)){let r=u.view;await u.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:r.nodeId,visit:r.visit,revision:r.revision})}let t=(await f.read()).entry;return I(t),P(_(t,"run"))},"close"):T()},async continueCheckout(e,t){let r=t?await F(async()=>{let{entry:o}=await f.read();if(I(o),!o.run||!b(o).some(i=>i.operationId===t&&!i.terminal))throw new l("PURCHASE_PENDING","The original Checkout changed");let c=await L(o);return P(_(c,R?"operation":"run"))},`continue:${t}`,o=>o instanceof l&&o.code==="PURCHASE_PENDING"):await T();w(),await e(Qe(r,t))},async terminateCheckout(e){let t=await T();if(!t.purchases.find(o=>o.type==="checkout"&&o.operationId===e)||!t.actions.includes("continue_checkout"))throw new l("PURCHASE_PENDING","The original Checkout has changed");return F(async()=>{let{entry:o}=await f.read();I(o);let c=b(o).find(s=>s.operationId===e&&!s.terminal);if(!c||!o.run)throw new l("PURCHASE_PENDING","The original Checkout has changed");await oe(o,c,"terminate_checkout");let i=await L(o,!1,new Set([e]));return P(_(i,R?"operation":"run"))},`terminate:${e}`,o=>o instanceof l&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(o.code))},subscribe(e){return Y.add(e),()=>{Y.delete(e)}},destroy:pe}}export{Te as a,Qe as b,vt as c};
@@ -1 +0,0 @@
1
- import{b as $A}from"./chunk-FCDWCQYC.js";import{b as sA}from"./chunk-OOD2VDDP.js";import{a as P}from"./chunk-WLGLQJ6M.js";import{a as BA,c as jA,d as xA,e as MA,f as UA}from"./chunk-RULQQ7WI.js";import{a as zA,b as FA}from"./chunk-RV6UAUK2.js";function I(A){return typeof A=="string"?A:String(A)}var Se=/[\ud800-\udbff](?![\udc00-\udfff])|(^|[^\ud800-\udbff])[\udc00-\udfff]/g;function Ie(A){return A.replace(Se,"$1\uFFFD")}function mA(A,e){if(typeof A!="object"||A==null){let t="";throw t+="The provided value is not an object",new TypeError(t)}return A}function ZA(A){if(A!=null&&(typeof A=="object"||typeof A=="function")){let e=A[Symbol.iterator];if(e==null)return;if(typeof e!="function")throw new TypeError("The provided value is not iterable");let t=e.call(A);if(!t||typeof t!="object")throw new TypeError("Result of the Symbol.iterator method is not an object");return t}}function QA(A){let e;if(Array.isArray(A)){let t=A.map(I);if(t.length===2)return t}else if((e=ZA(A))!=null){let t=mA(e.next()),n=mA(e.next());if(!t.done&&!n.done)return[I(t.value),I(n.value)]}throw new TypeError("Each query pair must be an iterable [name, value] tuple")}var GA="0123456789ABCDEF",Ce=/(?:%[0-9A-Fa-f]{2})+/g;function M(A){return`%${GA[A>>4&15]}${GA[15&A]}`}function Ae(A,e,t=!1){return A>=55296&&A<=57343&&(A=65533),A<=127?t&&A===32?"+":e(A)?M(A):String.fromCharCode(A):A<=2047?M(192|A>>6)+M(128|63&A):A<=65535?M(224|A>>12)+M(128|A>>6&63)+M(128|63&A):M(240|A>>18)+M(128|A>>12&63)+M(128|A>>6&63)+M(128|63&A)}function yA(A){return A>=48&&A<=57?A-48:A>=65&&A<=70?A-65+10:A>=97&&A<=102?A-97+10:-1}function PA(A,e=!1){let t=0;for(;t<A.length;t++){let n=A.charCodeAt(t);if(n===37||e&&n===43)break}return t===A.length?A:(e?A.replace(/\+/g," "):A).replace(Ce,n=>{try{return decodeURIComponent(n)}catch{return"\uFFFD".repeat(n.length/3)}})}function AA(A){return A<=31||A>126}function be(A){switch(A){case 32:case 34:case 60:case 62:case 96:return!0;default:return AA(A)}}function TA(A){switch(A){case 32:case 34:case 35:case 60:case 62:return!0;default:return AA(A)}}function Ee(A){return TA(A)||A===39}function DA(A){switch(A){case 63:case 94:case 96:case 123:case 125:return!0;default:return TA(A)}}function cA(A){switch(A){case 47:case 58:case 59:case 61:case 64:case 91:case 92:case 93:case 124:return!0;default:return DA(A)}}function KA(A){switch(A){case 33:case 39:case 40:case 41:case 126:return!0;default:return(function(t){switch(t){case 36:case 37:case 38:case 43:case 44:return!0;default:return cA(t)}})(A)}}function ee(A,e){return Ae(A=A||0,e)}function U(A,e,t=!1){let n=0;for(;n<A.length;n++){let u=A.charCodeAt(n);if(u>=128||t&&u===32||e(u))break}if(n===A.length)return A;let r=A.slice(0,n);for(;n<A.length;n++){let u=A.charCodeAt(n),l=u;if(u>=55296&&u<=56319&&n+1<A.length){let a=A.charCodeAt(n+1);a>=56320&&a<=57343&&(l=(u-55296<<10)+a-56320+65536,n++)}r+=Ae(l,e,t)}return r}function vA(A){let e=[],t=0,n=0;for(;n<=A.length;){if(n=A.indexOf("&",t),n<0&&(n=A.length),n!==t){let r=A.slice(t,n),u=r.indexOf("=");u<0&&(u=r.length),e.push([PA(r.slice(0,u),!0),PA(r.slice(u+1),!0)])}if(t=n+1,n===A.length)break}return e}function SA(A){let e="";for(let t=0;t<A.length;t++){let n=U(A[t][0],KA,!0),r=U(A[t][1],KA,!0);e+=t!==0?`&${n}=${r}`:`${n}=${r}`}return e}var Te=[2191,2191,3164,3164,3292,3292,6863,6877,6880,6891,8385,8385,11158,11158,42958,42959,42962,42962,42964,42964,42993,42993,64451,64466,64912,64913,64968,64974,67904,67929,69317,69319,69328,69336,69370,69371,72544,72551,73136,73179,73184,73193,93856,93880,93883,93907,94194,94198,100344,100351,101641,101662,101760,101874,118010,118012,118458,118480,118496,118512,124608,124638,124640,124661,124670,124671,128728,128728,128887,128890,129232,129240,129620,129623,129674,129674,129678,129678,129736,129736,129741,129741,129770,129770,129775,129775,130042,130042,177978,177983,183970,183981,205744,210041],ve=[7296,7297,7298,7299,7300,7301,7302,7303,7304,42958,42962,42964,42993],Oe=["\u0432","\u0434","\u043E","\u0441","\u0442","\u0442","\u044A","\u0463","\uA64B","\uA7CF","\uA7D3","\uA7D5","s"],Re=[2381,2381,2509,2509,2637,2637,2765,2765,2893,2893,3021,3021,3149,3149,3277,3277,3387,3388,3405,3405,3530,3530,3642,3642,3770,3770,3972,3972,4153,4154,5908,5909,5940,5940,6098,6098,6752,6752,6980,6980,7082,7083,7154,7155,11647,11647,43014,43014,43052,43052,43204,43204,43347,43347,43456,43456,43766,43766,44013,44013,68159,68159,69702,69702,69744,69744,69759,69759,69817,69817,69939,69940,70080,70080,70197,70197,70378,70378,70477,70477,70606,70608,70722,70722,70850,70850,71103,71103,71231,71231,71350,71350,71467,71467,71737,71737,71997,71998,72160,72160,72244,72244,72263,72263,72345,72345,72767,72767,73028,73029,73111,73111,73537,73538,90415,90415];function ke(A){for(let e=0;e<A.length;e++){let t=A.codePointAt(e);if(t>65535&&e++,t<=32||t===37||t===127||t>=55296&&t<=57343||t>=128&&t<=159||t>=64976&&t<=65007||!(65534&~t)||t===65533)return!0}return!1}var[qe,Ne,Le,YA]=[[[],"0,6,7,8,m,w,10,1b,1d,1f,72,73,7k,8k,dt,2rk","AAAAAAAAAAAAAAAAAAAAAP////8AAAAAAAAAAAAAAAA/AAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAADAAABwfwAAAAAAAMADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhAAAAQAAAAAAAAQCAAABAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgACAAAAAAAAAAAAAAAAD//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAP///////////////wAAAAAAAAAAAAAAAAAAAAA="],[[],"6,7,8,o,4o,7e,7f,7h,7i,7j,dl","AAAAAEF9+P/+BwAAAMAA//8AAPz/////BlADAAAAAJwAAPz///8AAADA//H/5+X8AAAAAAAAAAAA/P///wcAAAAAAAAAAAAAPv0vAD0BAABA/gAA/5/5/f8BAAAAAAAAgAAAAP//////////////AYD/////BQAAAAAAAAAAAAAAAAAAAAAAAP///////wcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD8g+N8B+AAAAAAAAAAAAAAAAAAAAAAAAP//AwAAYAAAAAAAAAAAAAD/////CwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANgAAAAAAAAAAAAAAAAA//8fAB4AAAD//wMAAAAAAH3/HgwAAAAAAAD//////////w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="],[[],"6,7,8,o,4o,7e,7f,7h,7i,7j,dl","AAAAAP3////+BwAAAMDu//////////////8vAADAAJwAAP3///8AAADg////////AAAAAAAAAAAA/P///wcAAAAAAAAAAAAA////Ab0H//9H/gAA/9////8BAAAAAAAAgAAAAP//////////////AYD/////BQAAAAAAAAAAAAAAAAAAAAAAAP///////wcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAL/G//8T+AAAAAAAAAAAAAAAAAAAAAAAAP//AwAAfgAAAAAAAAAAAAD+////DwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANwAAAAAAAAAAAAAAAAA//8fAB4AAAD//wMAAAAAAH3/Hg4AAAAAAAD//////////w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="],[[],"0,3,4,5,6,7,8,9,a,b,c,d,e,f,g,j,n,o,p,q,r,s,t,w,18,19,1c,4m,4o,4p,4q,4r,6z,72,73,75,76,77,7e,7h,7i,7j,7k,7l,7m,7n,7o,7p,7q,7r,7s,7t,7u,7v,7w,7x,7y,7z,8k,9t,a2,a3,a7,cc,cv,cx,cy,d6,dc,dd,de,dg,dh,di,dk,dl,2rk,2rl","AAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAD//////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD4AwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/v////+/tgAAAAAAAAAAAP8XAAAAAAD4//8AAAEAAAAAAAAAAAAAAMCfnz0AAACAAgAAAP///wcAAAAAAAAAAAAAwP8BAAAAAAAA+A8gAADA++8+AAAAAAAOAAAAAAAAgP8AAAAAAPz///v///8HAAAAAAAAFP4h/gAMAAAAAgAAAAAAABAeIAAADAAAQAYAAAAAAAAQhjkCAAAAIwAGAAAAAAAAEL4hAAAMAAD8AgAAAAAAAJAeIGAADAAAAAQAAAAAAAAAASAAAAAAAAARAAAAAAAA0ME9YAAMAAAAAgAAAAAAAJBAMAAADAAAAAMAAAAAAAAYHiAAAAwAAAACAAAAAAAAAAAEXAAAAAAAAAAAAAAA8geAfwAAAAAAAAAAAAAAAPIfAH8AAAAAAAAAAAADAACgAgAAAAAAAP5/3+D//v///x9AAAAAAAAAAAAAAAAA4P1mAAAAwwEAHgBkIAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAMAAAADAAAAAwAAAAAAAAAsD9A/g8gAAAAAAC4AAAAAAAAAAAAAAAAAABgAAAAAAIAAAAAAAAAAAAAAAAAAIcBBA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAJAAAAAAAAQH/lH/ifAAAAAAAA//////8//w8AAA8AAAAAANAXBAAAAAD4DwADAAAAPDsAAAAAAABAowMAAAAAAADwzwAAAAAAAAAAAAAAAAAAAAAAAAD3//0hEAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////wDIAAAAfAAAAAAAAB/8AAAAAAAAAAAAAAAA/////wEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAwAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAA/////wAAAAAAPAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAID3PwAAAMAAAAAAAAAAAAAAAwBECAAAYBAAAAAAAAAAAAAAAAAAAAAAAAAwAAAA//8DgAAAAADAPwAAgP8DAAAAAAAHAAAAAADIMwAAAAAgAAAAAAAAAAB+ZgAIEAAAAAAAEAAAAAAAAJ3BAgAAAAAwQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAICEAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//8AAP//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAMAHAAAAAAAAAAAAAAAAAAAAAG7wAAAAAACHAAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAPAAAAAAAAAAAD4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAA/AAAAAAAAAAAwP8BAAAAAAA8AAAAAAAAAAAAAAAAAAAAAgAAAAAAAP9/AAAAAAAZgAMAAAAAAHgGBAAAAAAAAAAHAAAAgO8fAAAAAAAAAAgAAwAAAAAAwH8AngAAAAAAAAAAAAAAgNNAAgAAAAAAAAAAAAAAAAAAAAAAAID4BwAAAwAAAAAAABgBAAAAwB8fAAAAAAAAAAD4AUAFAAYAAAAAAAAAAAAA/1wAAEAAAAAAAAAAAAAA+IUNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8sAEAADAAAAAAAAAAAAAA+KcBAAAAAAAAAAAAAAAAKL8AAAAAAAAAAAAAAACgvA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgP8GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFgIAAAAAAAAAAAAAAAAAAAAAADwDAEAAAD+BwAAAAD4eYAAfg4AAAAAAPx/AwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf78AAAAAAAAAAAAA/P///G0AAAAAAAAAAAAAAAAAAAB+tL8AAAAAAAAAAACjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAwAcFAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//4H/PwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMD/4wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHwAAAAAAAAB/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAcAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAPAAAAAAAAAAAAAAD//////z///38AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAD+P/nDwAAADwAAAAAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////9/+P//////HyAAEAAA+P7/AAAAAAAAAAAAAH////nbBwAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAfwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASMAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAfwAAAAAAAAAAAAAAAADwDwAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAA////////////////AAAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////wAA"]].map(function([e,t,n]){return[e,t.split(",").map(r=>parseInt(r,36)),Uint8Array.from(atob(n),r=>r.charCodeAt(0))]});function He(A,e){return e===931||e===1010||e===120531||e===120589||e===120647||e===120705||e===120763?"\u03C3":e>=5112&&e<=5117?String.fromCodePoint(e-8):e>=43888&&e<=43967?String.fromCodePoint(e-38864):e>=93856&&e<=93880?String.fromCodePoint(e+27):e===837||e===890||e>=8064&&e<=8111||e>=8114&&e<=8188?A.normalize("NFD").replace(/\u0345/g,"\u03B9").normalize("NFC").toLowerCase():""}function te(A,e){for(let t=0;t<A.length;t+=2)if(e>=A[t]&&e<=A[t+1])return!0;return!1}function W(A,e){let[t,n,r]=A,u=e>>8;for(let h=0;h<t.length;h+=2)if(u>=t[h]&&u<=t[h+1])return!0;let l=n.indexOf(u);if(l<0)return!1;let a=255&e;return!!(r[32*l+(a>>3)]&1<<(7&a))}function _e(A){let e=Array.from(A,t=>t.codePointAt(0));for(let t=0;t<e.length;t++){let n=e[t];if(n!==8204&&n!==8205||t>0&&te(Re,e[t-1]))continue;if(n===8205)return!1;let r=t-1;for(;r>=0&&W(YA,e[r]);)r--;let u=t+1;for(;u<e.length&&W(YA,e[u]);)u++;if(!(r>=0&&u<e.length&&W(Ne,e[r])&&W(Le,e[u])))return!1}return!0}var Be=/(?![\p{Mark}\p{Decimal_Number}])[\p{Script=Arabic}\p{Script=Hebrew}]/u,je=/\p{Script=Latin}/u;function xe(A){return!Be.test(A)||!je.test(A)}var F=36,iA=1,IA=26,Me=38,Ue=700,$e=72,ze=128,Fe=2147483647;function VA(A){return String.fromCharCode(A+22+75*+(A<26))}function Qe(A,e,t){let n=0;for(A=t?Math.floor(A/Ue):A>>1,A+=Math.floor(A/e);A>(F-iA)*IA>>1;n+=F)A=Math.floor(A/(F-iA));return Math.floor(n+(F-iA+1)*A/(A+Me))}function Ge(A){let e=Array.from(A,h=>h.codePointAt(0)),t="",n=0;for(let h=0;h<e.length;h++){let f=e[h];f<128&&(t+=String.fromCharCode(f),n++)}let r=n;r&&(t+="-");let u=ze,l=0,a=$e;for(;n<e.length;){let h=Fe;for(let f=0;f<e.length;f++){let g=e[f];g>=u&&g<h&&(h=g)}l+=(h-u)*(n+1),u=h;for(let f=0;f<e.length;f++){let g=e[f];if(g<u&&l++,g===u){let p=l;for(let m=F;;m+=F){let y=m<=a?iA:m>=a+IA?IA:m-a;if(p<y)break;t+=VA(y+(p-y)%(F-y)),p=Math.floor((p-y)/(F-y))}t+=VA(p),a=Qe(l,n+1,n===r),l=0,n++}}l++,u++}return t}function pA(A){let e=10;if(A.length>=2&&A[0]==="0"&&(A[1]==="x"||A[1]==="X"))A=A.slice(2),e=16;else if(A.length>=2&&A[0]==="0")A=A.slice(1),e=8;else if(A==="")return-1;let t=0;for(let n=0;n<A.length;n++){let r=yA(A.charCodeAt(n));if(r>=e||r<0)return-1;t=t*e+r}return t}function XA(A){switch(A){case".":case"%2e":case"%2E":return!0;default:return!1}}function ne(A,e){return(A>=65&&A<=90||A>=97&&A<=122)&&(e===58||e===124)}function re(A){return A.length===2&&ne(A.codePointAt(0),A.codePointAt(1))}function JA(A){return A.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|<|>|\?|@|\[|\\|\]|\^|\|/u)!==-1}function b(A){switch(A){case"ftp":case"http":case"https":case"ws":case"wss":case"file":return!0;default:return!1}}function se(A){switch(A){case"ftp":return 21;case"http":case"ws":return 80;case"https":case"wss":return 443;default:return null}}function CA(A,e){if(A[0]==="[")return A[A.length-1]==="]"?(function(n){let r=[0,0,0,0,0,0,0,0],u=null,l=0,a=0,h=Array.from(n,f=>f.codePointAt(0));if(h[a]===58){if(h[a+1]!==58)return null;a+=2,l++,u=l}for(;a<h.length;){if(l===8)return null;if(h[a]===58){if(u!==null)return null;a++,l++,u=l;continue}let f=0,g=0,p=0;for(;p<4&&(f=yA(h[a]))>=0;)g=(g<<4)+f,a++,p++;if(h[a]===46){if(p===0||l>6)return null;a-=p;let m=0;for(;h[a]!==void 0;){let y=0;if(m>0)if(h[a]===46&&m<4)a++;else return null;if(h[a]==null||h[a]<48||h[a]>57)return null;for(;h[a]>=48&&h[a]<=57;){if(y=10*y+yA(h[a]),y>255)return null;a++}r[l]=256*r[l]+y,m++,m%2==0&&l++}if(m!==4)return null;break}else if(h[a]===58){if(h[++a]===void 0)return null}else if(h[a]!==void 0)return null;r[l]=g,l++}if(u!==null){let f=l-u;for(l=7;l!==0&&f>0;){let g=r[u+f-1];r[u+f-1]=r[l],r[l]=g,l--,f--}}else if(u===null&&l!==8)return null;return r})(A.substring(1,A.length-1)):null;if(e)return(function(n){return JA(n)?null:U(n,AA)})(A);{let t=(function(r){let u=!1,l=!1;for(let h=0;h<r.length;h++){let f=r.charCodeAt(h);if(f<=32||f===37||f===127)return null;if(f>=128){u=!0;break}f>=65&&f<=90&&(l=!0)}if(!u)return r!==""?l?r.toLowerCase():r:null;if((function(f){for(let g of f){let p=g.codePointAt(0);if(/[\p{Cn}\p{Co}\p{Cs}\p{Noncharacter_Code_Point}]/u.test(g)&&!te(Te,p)||W(qe,p))return!0}return!1})(r))return null;let a=(r=(function(f){let g="";for(let p of f){let m=p.codePointAt(0);if(m!==8204&&m!==8205&&/\p{Default_Ignorable_Code_Point}/u.test(p))continue;let y=He(p,m);if(y){g+=y;continue}let k=ve.indexOf(m);g+=k<0?p:Oe[k]}return g})(r).normalize("NFKC").replace(/[\u3002\uff0e\uff61]/g,".").toLowerCase()).split(".");for(let h=0;h<a.length;h++){let f=a[h];if(f==="")continue;let g=/[^\0-\x7f]/.test(f);if(ke(f)||g&&(/^\p{Mark}/u.test(f)||!_e(f)||!xe(f)||f.startsWith("xn--")))return null;g&&(a[h]=`xn--${Ge(f)}`)}return(r=a.join("."))!==""?r:null})(A.indexOf("%")===-1?A:PA(A));return t===null||JA(t)?null:(function(r){let u=r.length,l=r.lastIndexOf(".",u-2)+1;if(r.charCodeAt(u-1)===46&&u--,u<=l)return!1;if(pA(r.slice(l,u))>=0)return!0;for(;l<u;l++){let a=r.charCodeAt(l);if(a<48||a>57)return!1}return!0})(t)?(function(r){let u=r.split("."),l=u.length;if(u[l-1]||l--,l>4)return null;let a=0;for(let f=0;f<l-1;f++){let g=pA(u[f]);if(g<0||g>255)return null;a+=g*(1<<8*(3-f))}let h=pA(u[l-1]);return h<0||h>=256**(5-l)?null:(a+=h,a)})(t):t}}function bA(A){return typeof A=="number"?(function(t){let r="";return r+=`${(t>>>24&255).toString(10)}.`,r+=`${(t>>>16&255).toString(10)}.`,r+=`${(t>>>8&255).toString(10)}.`,r+=(t&255).toString(10),r})(A):Array.isArray(A)?`[${(function(t){let n=(function(a){let h=-1,f=-1,g=1,p=0;for(let m=0;m<a.length;++m)a[m]!==0?(p>g&&(h=f,g=p),f=-1,p=0):(f===-1&&(f=m),++p);return p>g?f:h})(t),r="",u=!1;for(let l=0;l<=7;++l)if(!(u&&t[l]===0)){if(u&&(u=!1),n===l){r+=l===0?"::":":",u=!0;continue}r+=t[l].toString(16),l!==7&&(r+=":")}return r})(A)}]`:A}function oe(A){A.path.length>0&&(A.path.length!==1||A.scheme!=="file"||!(function(t){return/^[A-Za-z]:$/u.test(t)})(A.path[0]))&&A.path.pop()}function ie(A){return A.username!==""||A.password!==""}function gA(A){return A.host===null||A.host===""||A.scheme==="file"}var s=0,o="",w="",D=null,i,lA=!1,uA=!1,G=!1,E;function H(A,e,t,n){e||(A=(function(l){let a=0,h=l.length;for(;a<h&&!(l.charCodeAt(a)>32);++a);for(;h>a&&!(l.charCodeAt(h-1)>32);--h);return l.substring(a,h)})(A)),A=(function(l){let a=0;for(;a<l.length;a++){let f=l.charCodeAt(a);if(f===9||f===10||f===13)break}if(a===l.length)return l;let h=l.slice(0,a);for(;a<l.length;a++){let f=l.charCodeAt(a);f!==9&&f!==10&&f!==13&&(h+=l[a])}return h})(A),s=0,o=A,w="",D=t||null,i=e||{scheme:"",username:"",password:"",host:null,port:null,path:[],query:null,fragment:null,opaquePath:!1},lA=!1,uA=!1,G=!1,E=n||0;let r=Ke;switch(n){case 3:case 4:r=aA;break;case 5:r=RA;break;case 6:r=K;break;case 7:r=Q;break;case 8:r=$}return r(c(A,s))!==1?i:null}function d(A,e){return s+=s===A?j(e):1,s<=o.length}function c(A,e){return e<A.length?A.codePointAt(e):void 0}function j(A){return A!=null&&A>65535?2:1}function le(A){return A==null?"":A<=65535?String.fromCharCode(A):String.fromCodePoint(A)}var Ke=A=>{let e=s;if(A!=null&&(A>=65&&A<=90||A>=97&&A<=122)){let t=s+1;for(A=o.charCodeAt(t);A===43||A===45||A===46||A>=65&&A<=90||A>=97&&A<=122||A>=48&&A<=57;)t++,A=o.charCodeAt(t);return w=o.slice(s,t).toLowerCase(),s=t,Ye(t<o.length?A:void 0)}else return E?1:(--s,d(e,A)?ue(c(o,s)):0)},Ye=A=>{let e=s;if(A===58){if(E){if(b(i.scheme)!==b(w))return 0;if((ie(i)||i.port!==null)&&w==="file")return 0;if(i.scheme==="file"&&i.host==="")return 0}return i.scheme=w,E?(i.port===se(i.scheme)&&(i.port=null),0):(w="",i.scheme==="file"?d(e,A)?kA(c(o,s)):0:b(i.scheme)&&D!==null&&D.scheme===i.scheme?d(e,A)?Ve(c(o,s)):0:b(i.scheme)?d(e,A)?Je(c(o,s)):0:c(o,s+1)===47?(s++,d(e,A)?Xe(c(o,s)):0):(i.path=[""],i.opaquePath=!0,d(e,A)?ae(c(o,s)):0))}else return E?1:(w="",s=-1,d(e,A)?ue(c(o,s)):0)},ue=A=>{let e=s;return D===null||D.opaquePath&&A!==35?1:D.opaquePath&&A===35?(i.scheme=D.scheme,i.path=D.path.slice(),i.opaquePath=D.opaquePath,i.query=D.query,i.fragment="",d(e,A)?$(c(o,s)):0):D.scheme==="file"?(s--,d(e,A)?kA(c(o,s)):0):(s--,d(e,A)?OA(c(o,s)):0)},Ve=A=>{let e=s;return A===47&&c(o,s+1)===47?(++s,d(e,A)?hA(c(o,s)):0):(s--,d(e,A)?OA(c(o,s)):0)},Xe=A=>{let e=s;return A===47?d(e,A)?J(c(o,s)):0:(s--,d(e,A)?x(c(o,s)):0)},OA=A=>{let e=s;return i.scheme=D.scheme,A===47||b(i.scheme)&&A===92?d(e,A)?WA(c(o,s)):0:(i.username=D.username,i.password=D.password,i.host=D.host,i.port=D.port,i.path=D.path.slice(),i.query=D.query,A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?$(c(o,s)):0):A!=null?(i.query=null,i.path.pop(),s--,d(e,A)?x(c(o,s)):0):d(e,A)?OA(c(o,s)):0)},WA=A=>{let e=s;return b(i.scheme)&&(A===47||A===92)?d(e,A)?hA(c(o,s)):0:A===47?d(e,A)?J(c(o,s)):0:(i.username=D.username,i.password=D.password,i.host=D.host,i.port=D.port,s--,d(e,A)?x(c(o,s)):0)},Je=A=>{let e=s;return A===47&&c(o,s+1)===47?s++:s--,d(e,A)?hA(c(o,s)):0},hA=A=>{let e=s;return A!==47&&A!==92?(s--,d(e,A)?J(c(o,s)):0):d(e,A)?hA(c(o,s)):0},J=A=>{let e=s;if(A!=null&&A!==64&&A!==35&&A!==47&&A!==63&&(A!==92||!b(i.scheme))){let t=s+j(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===64||n===35||n===47||n===63||n===92&&b(i.scheme))break;t+=j(n)}return w+=o.slice(s,t),s=t-1,d(e,A)?J(c(o,s)):0}if(A===64){lA&&(w=`%40${w}`),lA=!0;for(let t=0;t<w.length;t++){let n=w.codePointAt(t);if(n===58&&!uA){uA=!0;continue}let r=ee(n,cA);uA?i.password+=r:i.username+=r,n!=null&&n>65535&&t++}return w="",d(e,A)?J(c(o,s)):0}else return A==null||A===35||A===47||A===63||A===92&&b(i.scheme)?lA&&w===""?1:(s-=w.length+1,w="",d(e,A)?aA(c(o,s)):0):(w+=le(A),d(e,A)?J(c(o,s)):0)},aA=A=>{let e=s;if(E&&i.scheme==="file")return s--,d(e,A)?qA(c(o,s)):0;if(A!=null&&A!==58&&A!==35&&A!==47&&A!==63&&(A!==92||!b(i.scheme))){let t=s+j(A);for(A===91?G=!0:A===93&&(G=!1);t<o.length;){let n=c(o,t);if(n==null||!G&&n===58||n===35||n===47||n===63||n===92&&b(i.scheme))break;n===91?G=!0:n===93&&(G=!1),t+=j(n)}return w+=o.slice(s,t),s=t-1,d(e,A)?aA(c(o,s)):0}else if(A===58&&!G){if(w===""||E===4)return 1;let t=CA(w,!b(i.scheme));return t===null?1:(i.host=bA(t),w="",d(e,A)?RA(c(o,s)):0)}else if(A==null||A===35||A===47||A===63||A===92&&b(i.scheme)){if(s--,b(i.scheme)&&w==="")return 1;if(E&&w===""&&(ie(i)||i.port!==null))return 1;let t=CA(w,!b(i.scheme));return t===null?1:(i.host=bA(t),w="",E?0:d(e,A)?K(c(o,s)):0)}else return w+=le(A),d(e,A)?aA(c(o,s)):0},RA=A=>{let e=s;if(A!=null&&A>=48&&A<=57){let t=s+1;for(;t<o.length;){let n=o.charCodeAt(t);if(n<48||n>57)break;t++}return w+=o.slice(s,t),s=t-1,d(e,A)?RA(c(o,s)):0}else if(E||A==null||A===35||A===47||A===63||A===92&&b(i.scheme)){if(w!==""){let t=parseInt(w,10);if(t>65535)return 1;if(i.port=t===se(i.scheme)?null:t,w="",E)return 0}return E?1:(s--,d(e,A)?K(c(o,s)):0)}else return 1};function ce(A,e){let t=A.length-e;if(t<2)return!1;if(ne(c(A,e),c(A,e+1))){if(t===2)return!0;{let n=c(A,e+2);return n===47||n===92||n===63||n===35}}else return!1}var kA=A=>{let e=s;return i.scheme="file",i.host="",A===47||A===92?d(e,A)?We(c(o,s)):0:D?.scheme==="file"?(i.host=D.host,i.path=D.path.slice(),i.opaquePath=D.opaquePath,i.query=D.query,A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?$(c(o,s)):0):A!=null?(i.query=null,ce(o,s)?i.path=[]:oe(i),s--,d(e,A)?x(c(o,s)):0):d(e,A)?kA(c(o,s)):0):(s--,d(e,A)?x(c(o,s)):0)},We=A=>{let e=s;return A===47||A===92?d(e,A)?qA(c(o,s)):0:(D!==null&&D.scheme==="file"&&(!ce(o,s)&&(function(n){if(n.length===2){let r=n.codePointAt(0),u=n.codePointAt(1);return(r>=65&&r<=90||r>=97&&r<=122)&&u===58}else return!1})(D.path[0])&&i.path.push(D.path[0]),i.host=D.host),s--,d(e,A)?x(c(o,s)):0)},qA=A=>{let e=s;if(A!=null&&A!==47&&A!==92&&A!==63&&A!==35){let t=s+j(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===47||n===92||n===63||n===35)break;t+=j(n)}return w+=o.slice(s,t),s=t-1,d(e,A)?qA(c(o,s)):0}else if(A==null||A===47||A===92||A===63||A===35){if(s--,!E&&re(w))return d(e,A)?x(c(o,s)):0;if(w==="")return i.host="",E?0:d(e,A)?K(c(o,s)):0;{let t=CA(w,!b(i.scheme));return t===null?1:(t==="localhost"&&(t=""),i.host=bA(t),w="",E?0:d(e,A)?K(c(o,s)):0)}}return 1},K=A=>{let e=s;return b(i.scheme)?(A!==92&&A!==47&&s--,d(e,A)?x(c(o,s)):0):!E&&A===63?(i.query="",d(e,A)?Q(c(o,s)):0):!E&&A===35?(i.fragment="",d(e,A)?$(c(o,s)):0):A!=null?(A!==47&&s--,d(e,A)?x(c(o,s)):0):(E&&i.host===null&&i.path.push(""),d(e,A)?K(c(o,s)):0)},x=A=>{let e=s;if(A!=null&&A!==47&&(!b(i.scheme)||A!==92)&&(E||A!==63&&A!==35)){let t=s+j(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===47||b(i.scheme)&&n===92||!E&&(n===63||n===35))break;t+=j(n)}w+=U(o.slice(s,t),DA),s=t,A=c(o,t)}if(A==null||A===47||b(i.scheme)&&A===92||!E&&(A===63||A===35)){let t=b(i.scheme)&&A===92;return(function(r){switch(r){case"..":case"%2e.":case"%2E.":case".%2e":case".%2E":case"%2e%2e":case"%2E%2e":case"%2e%2E":case"%2E%2E":return!0;default:return!1}})(w)?(oe(i),A!==47&&!t&&i.path.push("")):XA(w)&&A!==47&&!t?i.path.push(""):XA(w)||(i.scheme==="file"&&i.path.length===0&&re(w)&&(w=`${w[0]}:`),i.path.push(w)),w="",A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?$(c(o,s)):0):d(e,A)?x(c(o,s)):0}else return w+=ee(A,DA),d(e,A)?x(c(o,s)):0},ae=A=>{let e=s;if(A===63)return i.query="",d(e,A)?Q(c(o,s)):0;if(A===35)return i.fragment="",d(e,A)?$(c(o,s)):0;if(A!=null){let t=s+j(A);for(;t<o.length;){let r=c(o,t);if(r===63||r===35)break;t+=j(r)}let n=o.slice(s,t);if(t<o.length&&n.charCodeAt(n.length-1)===32?i.path[0]+=U(n.slice(0,-1),AA)+"%20":i.path[0]+=U(n,AA),s=t,(A=c(o,t))===63)return i.query="",d(e,A)?Q(c(o,s)):0;if(A===35)return i.fragment="",d(e,A)?$(c(o,s)):0}return d(e,A)?ae(c(o,s)):0},Q=A=>{let e=s,t=s;if(A!=null){if(E)t=o.length;else{let r=o.indexOf("#",s);t=r===-1?o.length:r}let n=b(i.scheme)?Ee:TA;i.query+=U(o.slice(s,t),n)}return s=t,c(o,t)===35&&!E?(i.fragment="",d(e,A)?$(c(o,s)):0):d(e,A)?Q(c(o,s)):0},$=A=>{let e=s;return A!=null&&(i.fragment+=U(o.slice(s),be),s=o.length),d(e,A)?$(c(o,s)):0};function EA(A){if(A.opaquePath)return A.path[0];{let e="";for(let t of A.path)e+=`/${t}`;return e}}function fe(A){switch(A.scheme){case"blob":{let e=H(EA(A),null,null,0);return e===null||e.scheme!=="http"&&e.scheme!=="https"?"null":fe(e)}case"ftp":case"http":case"https":case"ws":case"wss":return(function(t){let n=`${t.scheme}://`;return n+=t.host,t.port!==null&&(n+=`:${t.port}`),n})(A);default:return"null"}}var S=Symbol("URLImpl"),eA=class A{constructor(e,t){if(e===void 0&&t===void 0)throw new TypeError('The "url" argument must be specified.');e=I(e),t!=null&&(t=I(t));let n=null;if(t!=null&&(n=H(t,null,null,0),n==null))throw new TypeError(`Invalid base URL: ${t}`);let r=H(e,null,n,0);if(r==null)throw new TypeError(`Invalid URL: ${e}`);this[S]={url:r,query:null}}static createObjectURL(e){throw new TypeError("URL.createObjetURL is unsupported")}static revokeObjectURL(e){}static parse(e,t){e=I(e),t!==void 0&&(t=I(t));try{return new A(e,t)}catch{return null}}static canParse(e,t){e=I(e),t!==void 0&&(t=I(t));let n=null;return t!=null&&(n=H(t,null,null,0),n==null)?!1:H(e,null,n,0)!=null}get href(){return(function(t){let n=`${t.scheme}:`;return t.host!==null&&(n+="//",(t.username!==""||t.password!=="")&&(n+=t.username,t.password!==""&&(n+=`:${t.password}`),n+="@"),n+=t.host,t.port!==null&&(n+=`:${t.port}`)),t.host===null&&!t.opaquePath&&t.path.length>1&&t.path[0]===""&&(n+="/."),n+=EA(t),t.query!==null&&(n+=`?${t.query}`),t.fragment!==null&&(n+=`#${t.fragment}`),n})(this[S].url)}set href(e){let t=H(e=I(e),null,null,0);if(t==null)throw new TypeError(`Invalid URL: ${e}`);this[S].url=t,this[S].query&&wA(this[S].query,t.query)}get origin(){return fe(this[S].url)}get protocol(){return`${this[S].url.scheme}:`}set protocol(e){H(`${e=I(e)}:`,this[S].url,null,2)}get username(){return this[S].url.username}set username(e){e=I(e),gA(this[S].url)||(function(n,r){n.username=U(r,cA)})(this[S].url,e)}get password(){return this[S].url.password}set password(e){e=I(e),gA(this[S].url)||(function(n,r){n.password=U(r,cA)})(this[S].url,e)}get host(){let{url:e}=this[S];return e.host==null?"":e.port==null?e.host:`${e.host}:${e.port}`}set host(e){e=I(e),this[S].url.opaquePath||H(e,this[S].url,null,3)}get hostname(){let{url:e}=this[S];return e.host!=null?e.host:""}set hostname(e){e=I(e),this[S].url.opaquePath||H(e,this[S].url,null,4)}get port(){let{url:e}=this[S];return e.port!=null?`${e.port}`:""}set port(e){e=I(e);let{url:t}=this[S];gA(t)||(e?H(e,t,null,5):t.port=null)}get pathname(){return EA(this[S].url)}set pathname(e){e=I(e);let{url:t}=this[S];t.opaquePath||(t.path=[],H(e,t,null,6))}get search(){let{url:e}=this[S];return e.query?`?${e.query}`:""}set search(e){e=I(e);let{url:t,query:n}=this[S];if(!e)t.query=null,n&&wA(n,null);else{let r=e[0]==="?"?e.substring(1):e;t.query="",H(r,t,null,7),n&&wA(n,t.query)}}get searchParams(){let e=this[S],t=e.query;return t==null&&(t=e.query=(function(r,u){let l=new fA;return l[C].url=r,l[C].serialized=u==null,u&&(l[C].list=vA(u)),l})(this,e.url.query)),t}get hash(){let{url:e}=this[S];return e.fragment?`#${e.fragment}`:""}set hash(e){e=I(e);let{url:t}=this[S];if(!e)t.fragment=null;else{let n=e[0]==="#"?e.substring(1):e;t.fragment="",H(n,t,null,8)}}toJSON(){return this.href}toString(){return this.href}};Object.defineProperty(eA.prototype,Symbol.toStringTag,{value:"URL",configurable:!0});var C=Symbol("URLSearchParamsImpl"),Ze=Symbol.dispose||Symbol.for("dispose");function wA(A,e){e?A[C].list=vA(e):A[C].list.length=0,A[C].serialized=e==null}function oA(A){if(A.url){let e=SA(A.list);(function(n,r){n[S].url.query=r})(A.url,e||null),A.serialized=!0}}var At=typeof Iterator<"u"?Iterator:Object,Z=class extends At{constructor(e,t){super(),this[C]={ptr:e,map:t,index:0}}next(){let e=this[C];return e.index<e.ptr.list.length?{value:e.map(e.ptr.list[e.index++]),done:!1}:{value:void 0,done:!0}}[Symbol.iterator](){return this}[Ze](){}},fA=class{constructor(e){let t=this[C]={list:[],url:null,serialized:!0},n;if(Array.isArray(e))for(let r=0;r<e.length;r++)t.list.push(QA(e[r]));else if((n=ZA(e))!=null){let r;for(;!(r=mA(n.next())).done;)t.list.push(QA(r.value))}else if((typeof e=="object"||typeof e=="function")&&e!=null){let r=Object.keys(e);for(let u=0;u<r.length;u++){let l=r[u],a=Ie(l),h=I(e[l]),f=t.list.find(g=>g[0]===a);f?f[1]=h:t.list.push([a,h])}}else if(e!==void 0){let r=I(e);r=r[0]==="?"?r.substring(1):r,t.list=vA(r)}}get size(){return this[C].list.length}append(e,t){e=I(e),t=I(t),this[C].list.push([e,t]);let n=this[C];n.url&&n.serialized?(function(u,l){let a=u[S].url;a.query=a.query?`${a.query}&${l}`:l})(n.url,SA([[e,t]])):oA(n)}delete(e,t){e=I(e),t=t!=null?I(t):void 0;let{list:n}=this[C],r=0;for(;r<n.length;)n[r][0]===e&&(t==null||n[r][1]===t)?n.splice(r,1):r++;oA(this[C])}get(e){e=I(e);let{list:t}=this[C];for(let n=0;n<t.length;n++)if(t[n][0]===e)return t[n][1];return null}getAll(e){e=I(e);let t=[],{list:n}=this[C];for(let r=0;r<n.length;r++)n[r][0]===e&&t.push(n[r][1]);return t}has(e,t){e=I(e),t=t!=null?I(t):void 0;let{list:n}=this[C];for(let r=0;r<n.length;r++)if(n[r][0]===e&&(t==null||n[r][1]===t))return!0;return!1}set(e,t){e=I(e),t=I(t);let{list:n}=this[C],r=!1,u=!1,l=0;for(;l<n.length;)n[l][0]===e?r?(n.splice(l,1),u=!0):(r=!0,n[l][1]!==t&&(n[l][1]=t,u=!0),l++):l++;r||(n.push([e,t]),u=!0),u&&oA(this[C])}sort(){this[C].list.sort((e,t)=>e[0]<t[0]?-1:e[0]>t[0]?1:0),oA(this[C])}forEach(e,t){if(typeof e!="function")throw new TypeError('The "callback" argument must be of type function');let{list:n}=this[C];for(let r=0;r<n.length;r++)e.call(t,n[r][1],n[r][0],this)}entries(){return new Z(this[C],e=>e)}keys(){return new Z(this[C],e=>e[0])}values(){return new Z(this[C],e=>e[1])}toString(){return SA(this[C].list)}[Symbol.iterator](){return this.entries()}};Object.defineProperty(fA.prototype,Symbol.toStringTag,{value:"URLSearchParams",configurable:!0});var NA="X-Indiana-Protocol",he="X-Indiana-SDK-Version";var LA={current:"0.10"};function de(A){let e,t=()=>typeof e=="string"?e:e?.accessToken,n=0,r,u=new Map,l=()=>{for(let p of[...u.keys()])try{p()}catch{}};function a(p){let m=++n;r=void 0,e=void 0;for(let y of[...u.values()])try{y?.()}catch{}m===n&&(e=p,l())}let h=()=>a();function f(p,m=!1){let y=$A.safeParse(p);if(!y.success||m&&Date.parse(y.data.expiresAt)<=Date.now()||Date.parse(y.data.refreshExpiresAt)<=Date.now()||Date.parse(y.data.refreshExpiresAt)<Date.parse(y.data.expiresAt))throw new P("INVALID_RESPONSE","Invalid customer session credentials");return y.data}async function g(){if(r)return r;let p=typeof e=="object"?e:void 0,m=n;if(!p||Date.parse(p.refreshExpiresAt)<=Date.now())throw p&&h(),new P("UNAUTHENTICATED","Customer authentication is required",401);let y=(async()=>{try{let k=await A(p.refreshToken);if(m!==n)throw new P("IDENTITY_CHANGED","Customer identity changed during refresh");let Y=f(k,!0);if(Y.customerId!==p.customerId||Y.sessionId!==p.sessionId)throw new P("SCOPE_MISMATCH","Refresh changed the customer session");return e=Y,{...Y}}catch(k){throw m!==n?new P("IDENTITY_CHANGED","Customer identity changed during refresh"):(k instanceof P&&k.status===401&&h(),k)}})();r=y;try{return await y}finally{r===y&&(r=void 0)}}return{identify(p){let m=typeof p=="string"?p:f(p),y=typeof m=="string"?m:m.accessToken;if(!y.trim()||/\s/.test(y)||y.length>4096)throw new P("INVALID_TOKEN","A server-issued token is required");a(m)},reset:h,subscribeIdentity(p,m){return u.set(p,m),()=>{u.delete(p)}},access(){let p=typeof e=="object"?e:void 0;if(p&&Date.parse(p.expiresAt)<=Date.now()+3e4){let y=n;return g().then(()=>{let k=t();if(y!==n||!k)throw new P("IDENTITY_CHANGED","Customer identity changed during refresh");return k})}let m=t();if(!m)throw new P("NOT_IDENTIFIED","Identify a customer session before making a request");return m},peek:t,snapshot:()=>typeof e=="object"?{...e}:void 0,refresh:g}}var pe=Symbol("IndianaNoContent");function gt(A,e,t=eA){let n=A.configuration?.scope,r=A.scope??(n&&{projectId:n.projectId,environment:n.environment}),u=r?sA.parse(r):void 0;if(u&&n&&(u.projectId!==n.projectId||u.environment!==n.environment))throw new P("SCOPE_MISMATCH","Configuration belongs to another App/environment");let l=new t(A.baseUrl??FA);if(l.username||l.password||l.search||l.hash)throw new P("INVALID_URL","baseUrl must not contain credentials, query, or fragment");if(l.protocol!=="https:"&&!(l.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(l.hostname)))throw new P("INVALID_URL","Use HTTPS, or HTTP on localhost during development");let a=A.fetch??globalThis.fetch.bind(globalThis),h=A.timeoutMs??1e4;if(!Number.isFinite(h)||h<1||h>12e4)throw new P("INVALID_TIMEOUT","timeoutMs must be between 1 and 120000");let f=!1,g=0,p=null,m=new Set,y=A.session??de(async v=>{let R=await tA("customer-sessions/refresh",{},"POST",{},v);if(!R||typeof R!="object")throw new P("INVALID_RESPONSE","Invalid refresh response");let{requestId:_,scope:B,...V}=R;return V});function k(){g+=1,p=null;for(let v of m)v.abort();m.clear()}let Y=y.subscribeIdentity(k);function ge(){f||y.reset()}async function tA(v,R={},_="POST",B={},V){let N=B.installationDetach===!0;if(N&&(v!=="push/installations/detach"||_!=="POST"))throw new P("INVALID_REQUEST","Installation authority only detaches this installation");if(!V&&!N)throw new P("NOT_IDENTIFIED","Call identify with a server-issued customer token first");let X=g,L=new AbortController;N||m.add(L);let nA=()=>!N&&X!==g?new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):new P("TIMEOUT","The request timed out"),dA,ye=new Promise((O,q)=>{dA=()=>q(nA()),L.signal.addEventListener("abort",dA,{once:!0})}),Pe=setTimeout(()=>L.abort(),B.timeoutMs??h),De=async()=>{let O=await a(`${l.href.replace(/\/$/,"")}/api/v1/${v}`,{method:_,headers:{...B.headers,"Content-Type":"application/json",...N?{}:{Authorization:`Bearer ${V}`},[NA]:LA.current,[he]:zA.version,...u?{"X-Indiana-Project":u.projectId,"X-Indiana-Environment":u.environment}:{}},body:_==="POST"?JSON.stringify(R):void 0,signal:L.signal,credentials:"omit",cache:_==="POST"&&typeof document<"u"?"default":"no-store",redirect:"error",...B.keepalive?{keepalive:!0}:{}});if(L.signal.aborted)throw nA();let q;try{q=O.status===204?pe:await O.json()}catch{throw L.signal.aborted?nA():new P(O.ok?"INVALID_RESPONSE":"HTTP_ERROR","The gateway returned an unreadable response",O.status,O.headers.get("X-Request-Id")??void 0)}if(L.signal.aborted)throw nA();if(!N&&X!==g)throw new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight");if(!O.ok){let T=MA.safeParse(et(q)),z=T.success&&(!BA.safeParse(T.data.error.code).success||xA(T.data.error.code,O.status)),HA=z?T.data.error.code:"HTTP_ERROR",_A=UA(HA,O.status,{retryAfter:O.headers.get("Retry-After"),recovery:z?T.data.error.recovery:void 0,reason:z?T.data.error.reason:void 0});throw new P(HA,z?T.data.error.message:"The request failed",O.status,O.headers.get("X-Request-Id")??(T.success?T.data.requestId:void 0),{..._A,...T.success&&T.data.error.retryable===!1?{retryable:!1}:{},..._A.retryAfterSeconds===void 0&&T.success&&T.data.error.retryAfterSeconds!==void 0?{retryAfterSeconds:T.data.error.retryAfterSeconds}:{}})}if(O.headers.get(NA)!==LA.current)throw new P("PROTOCOL_MISMATCH","Response protocol does not match this SDK");if(u&&q!==pe){let T=q&&typeof q=="object"&&"scope"in q?q:q&&typeof q=="object"&&"configuration"in q?q.configuration:null;if(!T||typeof T!="object"||!("scope"in T))throw new P("INVALID_RESPONSE","Response is missing its App/environment scope");let z=sA.safeParse(T.scope);if(!z.success||z.data.projectId!==u.projectId||z.data.environment!==u.environment)throw new P("SCOPE_MISMATCH","Response scope does not match this SDK instance")}let rA=O.headers.get("X-Indiana-Telemetry-Subject");if(rA){if(!/^[a-f0-9]{64}$/.test(rA))throw new P("INVALID_RESPONSE","Invalid telemetry identity");p!==rA&&(p=rA,e?.(p))}return q};try{return await Promise.race([De(),ye])}catch(O){throw!N&&X!==g?new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):O instanceof P?O:new P(L.signal.aborted?"TIMEOUT":"NETWORK_ERROR",L.signal.aborted?"The request timed out":"Unable to read the response")}finally{clearTimeout(Pe),L.signal.removeEventListener("abort",dA),m.delete(L)}}function we(v,R={},_="POST",B={}){if(f)return Promise.reject(new P("CLOSED","SDK client was destroyed"));if(B.installationDetach)return tA(v,R,_,B);let V=g;try{let N=y.access(),X=L=>{if(V!==g)throw new P("IDENTITY_CHANGED","Customer identity changed before dispatch");return tA(v,R,_,B,L)};return typeof N=="string"?X(N):N.then(X)}catch(N){return Promise.reject(N)}}let me=Object.assign(we,{captureIdentity(){let v=g,R=f,_=!!y.peek();return()=>{if(R)throw new P("CLOSED","SDK client was destroyed");if(!_)throw new P("NOT_IDENTIFIED","Call identify with a server-issued customer token first");if(v!==g)throw new P("IDENTITY_CHANGED","Customer identity changed before dispatch")}}});return{session:y,requestWithCredential(v,R,_,B={}){return f?Promise.reject(new P("CLOSED","SDK client was destroyed")):tA(v,R,"POST",B,_)},subjectKey:()=>p,identify(v){if(f)throw new P("CLOSED","SDK client was destroyed");if(u&&typeof v=="object"&&"scope"in v){let R=sA.safeParse(v.scope);if(!R.success||R.data.projectId!==u.projectId||R.data.environment!==u.environment)throw new P("SCOPE_MISMATCH","Customer session belongs to another App/environment")}y.identify(v)},reset:ge,dispose(){f||(f=!0,Y(),k())},request:me}}function et(A){if(!A||typeof A!="object"||!("error"in A))return A;let e=A.error;if(!e||typeof e!="object"||!("reason"in e)||jA.safeParse(e.reason).success)return A;let{reason:t,...n}=e;return{...A,error:n}}export{eA as a,gt as b};
@@ -1 +0,0 @@
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-6PG3AS3G.js";import{j as O,o as q,p as B}from"./chunk-IOJVF52Q.js";import{a as D,b as g,c as k,d as N}from"./chunk-XDOKFAE6.js";import{a as s,d as U}from"./chunk-Y6HL2IY2.js";import{b as t}from"./chunk-RGEBK6UF.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 +0,0 @@
1
- import{b as r}from"./chunk-RGEBK6UF.js";var I=r.enum(["INVALID_PROTOCOL_VERSION","UNSUPPORTED_PROTOCOL_VERSION","PROTOCOL_RETIRED","UNAUTHENTICATED","FORBIDDEN","SCOPE_MISMATCH","INVALID_REQUEST","NOT_FOUND","CONFLICT","PAYLOAD_TOO_LARGE","RATE_LIMITED","SERVICE_UNAVAILABLE","NOT_CONFIGURED","CAPABILITY_UNAVAILABLE","INTERNAL_ERROR"]),L=r.enum([...I.options,"INVALID_SERVER_RESPONSE","RESPONSE_TOO_LARGE","AMBIGUOUS_AUTHENTICATION","BROWSER_REQUIRED","INVALID_REDIRECT_URI","AUTHORIZATION_UNAVAILABLE","UNREGISTERED_CLIENT","MANAGEMENT_OPERATION_FAILED","SENSITIVE_OUTPUT_REQUIRED"]),C=r.enum([...I.options,"stale_revision"]),s=r.enum(["fix_request","authenticate","check_permissions","check_scope","resolve_conflict","reload_state","retry_same_request","configure_integration","check_availability","upgrade_sdk","recover_operation","contact_support"]),c=r.enum(["CAPABILITY_NOT_ENABLED","INTEGRATION_MISSING","PROVIDER_CREDENTIAL_REJECTED","PRICE_BINDING_REQUIRED","IDEMPOTENCY_CONFLICT","RESULT_UNKNOWN","STATE_CHANGED","IDENTITY_CONTEXT_CHANGED","CUSTOMER_BINDING_CONFLICT","RUN_CONTRACT_MISMATCH","OPERATION_IN_PROGRESS","FUNNEL_VERSION_RETIRED","FUNNEL_PAUSED"]),A={INVALID_PROTOCOL_VERSION:{status:400,recovery:"fix_request"},UNSUPPORTED_PROTOCOL_VERSION:{status:400,recovery:"upgrade_sdk"},PROTOCOL_RETIRED:{status:410,recovery:"upgrade_sdk"},UNAUTHENTICATED:{status:401,recovery:"authenticate"},FORBIDDEN:{status:403,recovery:"check_permissions"},SCOPE_MISMATCH:{status:403,recovery:"check_scope"},INVALID_REQUEST:{status:400,recovery:"fix_request"},NOT_FOUND:{status:404,recovery:"fix_request"},CONFLICT:{status:409,recovery:"resolve_conflict"},PAYLOAD_TOO_LARGE:{status:413,recovery:"fix_request"},RATE_LIMITED:{status:429,recovery:"retry_same_request"},SERVICE_UNAVAILABLE:{status:503,recovery:"retry_same_request"},NOT_CONFIGURED:{status:501,recovery:"configure_integration"},CAPABILITY_UNAVAILABLE:{status:501,recovery:"check_availability"},INTERNAL_ERROR:{status:500,recovery:"recover_operation"}};var N={TIMEOUT:"recover_operation",NETWORK_ERROR:"recover_operation",HTTP_ERROR:"recover_operation",INVALID_RESPONSE:"recover_operation",NOT_IDENTIFIED:"authenticate",CUSTOMER_SESSION_REQUIRED:"authenticate",INVALID_TOKEN:"authenticate",INVALID_URL:"fix_request",INVALID_TIMEOUT:"fix_request",SERVER_ONLY:"fix_request",PROTOCOL_MISMATCH:"upgrade_sdk",IDENTITY_CHANGED:"reload_state",INVALID_STATE:"reload_state",EVENT_QUEUE_FULL:"retry_same_request",COMMAND_PENDING:"recover_operation",PURCHASE_PENDING:"recover_operation",DECISION_PENDING:"recover_operation",DECISION_ACCEPTANCE_UNKNOWN:"recover_operation",RUN_RECONCILIATION_REQUIRED:"recover_operation",DECISION_FAILED:"contact_support",COMMAND_STORAGE_CONFLICT:"resolve_conflict",COMMAND_STORAGE_INVALID:"fix_request",PURCHASE_STORAGE_CONFLICT:"resolve_conflict",PURCHASE_STORAGE_INVALID:"recover_operation",EXECUTION_POLICY_REFUSED:"fix_request",CONFIGURATION_UNAVAILABLE:"check_availability",CONFIGURATION_EXPIRED:"reload_state",CONFIGURATION_CHANGED:"reload_state",CONFIGURATION_DISPOSED:"reload_state",UNSUPPORTED_SCHEMA:"upgrade_sdk",FUNNEL_STOPPED:"check_availability",PAYWALL_UNAVAILABLE:"check_availability",EVALUATION_MODE:"reload_state",SERVER_REQUIRED:"fix_request",STICKY_SAVE_FAILED:"retry_same_request",TRANSITION_LIMIT:"resolve_conflict",PRECONDITION_FAILED:"reload_state",PRODUCT_UNAVAILABLE:"fix_request",COUPON_UNAVAILABLE:"reload_state",PURCHASE_HANDLER_REQUIRED:"fix_request",EVENT_HANDLER_REQUIRED:"fix_request",CLOSED:"fix_request",BRIDGE_UNAVAILABLE:"check_availability",INVALID_CONFIGURATION:"fix_request",NATIVE_OPERATION_FAILED:"contact_support",AI_PRICE_UNAVAILABLE:"fix_request",AI_USAGE_UNAVAILABLE:"recover_operation",AI_PROVIDER_ERROR:"check_availability",AI_BALANCE_REJECTED:"resolve_conflict"};function i(e,E){if(e==="CONFLICT"&&E===425)return{retryable:!0,recovery:"retry_same_request"};if(e==="CONFLICT"&&E===412)return{retryable:!1,recovery:"reload_state"};if(e==="INVALID_SERVER_RESPONSE")return{retryable:!1,recovery:"recover_operation"};if(e==="AMBIGUOUS_AUTHENTICATION"||e==="SENSITIVE_OUTPUT_REQUIRED")return{retryable:!1,recovery:"fix_request"};if(Object.hasOwn(N,e)){let o=N[e];return{retryable:o==="retry_same_request",recovery:o}}let t=I.safeParse(e);return t.success?{retryable:e==="RATE_LIMITED"||e==="SERVICE_UNAVAILABLE",recovery:A[t.data].recovery}:{retryable:!1,recovery:"contact_support"}}function D(e,E){let t=I.safeParse(e);if(t.success)return e==="CONFLICT"?[409,412,425].includes(E):e==="SERVICE_UNAVAILABLE"?[408,502,503,504].includes(E):e==="INVALID_REQUEST"?[400,405,415,422].includes(E):e==="NOT_CONFIGURED"?[501,503].includes(E):A[t.data].status===E;let o={INVALID_SERVER_RESPONSE:[502],RESPONSE_TOO_LARGE:[502],AMBIGUOUS_AUTHENTICATION:[400],SENSITIVE_OUTPUT_REQUIRED:[400],BROWSER_REQUIRED:[403],INVALID_REDIRECT_URI:[403],AUTHORIZATION_UNAVAILABLE:[400],UNREGISTERED_CLIENT:[403],MANAGEMENT_OPERATION_FAILED:[400,422,500]};return Object.hasOwn(o,e)&&(o[e]?.includes(E)??!1)}function O(e,E=Date.now()){if(e===null)return;let t=e.trim();if(/^\d+$/.test(t)){let _=Number(t);return Number.isSafeInteger(_)?_:void 0}if(!/^[A-Za-z]{3}, \d{2} [A-Za-z]{3} \d{4} \d{2}:\d{2}:\d{2} GMT$/.test(t))return;let o=Date.parse(t);return Number.isFinite(o)?Math.max(0,Math.ceil((o-E)/1e3)):void 0}var R=r.object({retryable:r.boolean(),recovery:s,reason:c.optional(),retryAfterSeconds:r.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional()}),T=r.object({requestId:r.uuid().optional(),error:r.object({code:r.string().regex(/^[A-Z][A-Z0-9_]{0,95}$/),message:r.string(),...R.partial().shape})}),S=r.object({error:T.shape.error.extend({requestId:r.uuid().optional()})}),U=r.object({error:r.string(),code:r.string().regex(/^[A-Za-z][A-Za-z0-9_]{0,95}$/),requestId:r.uuid(),...R.shape});function l(e,E,t={}){let o=i(e,E),_=t.reason==="RESULT_UNKNOWN"?"recover_operation":t.recovery??o.recovery,a=o.retryable&&t.retryable!==!1&&_!=="recover_operation",n=a?O(t.retryAfter??null):void 0;return{...o,retryable:a,recovery:_,...n===void 0?{}:{retryAfterSeconds:n},...t.reason?{reason:t.reason}:{}}}export{I as a,s as b,c,D as d,T as e,l as f};
@@ -1 +0,0 @@
1
- import{b as e}from"./chunk-RGEBK6UF.js";var c=e.enum(["replace","stack_native"]);export{c as a};