@tinkerlandai/longplay-sdk 0.10.36 → 0.10.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +8 -0
- package/README.zh-CN.md +8 -0
- package/dist/check-response-Q7GOBUGJ.js +1 -0
- package/dist/chunk-2LND3R7K.js +1 -0
- package/dist/{chunk-ZYF6TRJ3.js → chunk-4E326NPY.js} +1 -1
- package/dist/chunk-5IGASP6C.js +10 -0
- package/dist/{chunk-35VG2IYD.js → chunk-64ETX3AY.js} +1 -1
- package/dist/{chunk-5XIKN35D.js → chunk-6QOJRLVM.js} +1 -1
- package/dist/{chunk-BTPEXSNY.js → chunk-6WEHTOED.js} +1 -1
- package/dist/{chunk-RHWZRHK7.js → chunk-7PXJUHDS.js} +1 -1
- package/dist/{chunk-XE7GU6FZ.js → chunk-BDC7B4KM.js} +1 -1
- package/dist/{chunk-M3GGR53D.js → chunk-DK5PHPSO.js} +1 -1
- package/dist/{chunk-BL7E4RZ2.js → chunk-DSLJUN3P.js} +1 -1
- package/dist/{chunk-YQX27SBG.js → chunk-DTWSDNYI.js} +1 -1
- package/dist/{chunk-RHF4NFCZ.js → chunk-EEYDOVVS.js} +1 -1
- package/dist/chunk-G7Y7LPOB.js +1 -0
- package/dist/{chunk-R3YVDRTB.js → chunk-GEPX4AUR.js} +1 -1
- package/dist/{chunk-HS56A4IK.js → chunk-H2I37CQ4.js} +1 -1
- package/dist/{chunk-QHJWVLJC.js → chunk-HJVEVJXS.js} +1 -1
- package/dist/chunk-I7QTCEYR.js +1 -0
- package/dist/{chunk-MHWPEMX7.js → chunk-IHB275C3.js} +1 -1
- package/dist/{chunk-UVUFJO2V.js → chunk-IV6LKRYM.js} +1 -1
- package/dist/chunk-JBDNNV3P.js +1 -0
- package/dist/{chunk-I6D25FWU.js → chunk-JXTJT2EW.js} +1 -1
- package/dist/{chunk-DHT3AWJQ.js → chunk-K3VQKR4G.js} +1 -1
- package/dist/chunk-KQF4BVOL.js +1 -0
- package/dist/{chunk-5XKFUFXK.js → chunk-KTBXAATX.js} +1 -1
- package/dist/{chunk-VWMFR22O.js → chunk-L54MODP5.js} +1 -1
- package/dist/{chunk-XQTCEQXI.js → chunk-NK55HFFF.js} +1 -1
- package/dist/{chunk-TIQS5DUF.js → chunk-O5VA3E5D.js} +1 -1
- package/dist/{chunk-UHTTCVSL.js → chunk-PLOUC66F.js} +1 -1
- package/dist/chunk-Q7K66FTS.js +1 -0
- package/dist/{chunk-LVG5ED52.js → chunk-QZRJ3ZXU.js} +1 -1
- package/dist/{chunk-VKG6BB3Z.js → chunk-RK7XOT3F.js} +1 -1
- package/dist/chunk-SY7AYEDO.js +1 -0
- package/dist/{chunk-U4WUX3WB.js → chunk-TLV3NVUU.js} +1 -1
- package/dist/{chunk-2KKLY323.js → chunk-UAJTQ23E.js} +1 -1
- package/dist/{chunk-LAGGWYH3.js → chunk-UD7XPHE4.js} +1 -1
- package/dist/{chunk-IOBB6KFK.js → chunk-UFTLA3ZI.js} +1 -1
- package/dist/{chunk-HVVJGLYZ.js → chunk-WP3SZU24.js} +1 -1
- package/dist/chunk-WQZOT22S.js +1 -0
- package/dist/{chunk-MYBUQFTC.js → chunk-XBCKVHOT.js} +1 -1
- package/dist/chunk-Y5RT7PAD.js +1 -0
- package/dist/{chunk-2HSD2SEU.js → chunk-YYXINZ4A.js} +1 -1
- package/dist/content-B4CC4O23.js +1 -0
- package/dist/{funnel-host-purchase-M7MM33EC.js → funnel-host-purchase-AGBJG3RK.js} +1 -1
- package/dist/funnel-paywall-prerender-HHAQBIIB.js +1 -0
- package/dist/funnel-runtime-host-IJDKXLST.js +1 -0
- package/dist/index.d.ts +23 -3
- package/dist/index.js +1 -1
- package/dist/merchant-bridge-contracts-KVOFRPKV.js +1 -0
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.js +1 -1
- package/dist/operation-contracts-G4C7ZLEH.js +1 -0
- package/dist/page.js +1 -1
- package/dist/paywall-TVCH6VQT.js +1 -0
- package/dist/paywall-content-QSTCRYU5.js +1 -0
- package/dist/paywall-session-UBQYU5XD.js +1 -0
- package/dist/popup.d.ts +1 -1
- package/dist/popup.js +1 -1
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-Q3VSMB2N.js +1 -0
- package/dist/server.js +1 -1
- package/dist/visual.js +1 -1
- package/package.json +10 -9
- package/dist/check-response-DHY6T5Z2.js +0 -1
- package/dist/chunk-7ZEXY4GC.js +0 -1
- package/dist/chunk-C4GBV32U.js +0 -10
- package/dist/chunk-CGXNU5BC.js +0 -1
- package/dist/chunk-DB4EO3JG.js +0 -1
- package/dist/chunk-GLYFT5WW.js +0 -1
- package/dist/chunk-HYE2YQYM.js +0 -1
- package/dist/chunk-JOIPLLHK.js +0 -1
- package/dist/chunk-OL2AI6DA.js +0 -1
- package/dist/chunk-W3K5ARMY.js +0 -1
- package/dist/chunk-WRLVPHPE.js +0 -1
- package/dist/content-RGKTEV23.js +0 -1
- package/dist/funnel-paywall-prerender-OSBI4VMY.js +0 -1
- package/dist/funnel-runtime-host-AMJXEASH.js +0 -1
- package/dist/merchant-bridge-contracts-GJQVKEAG.js +0 -1
- package/dist/operation-contracts-MFK2KORK.js +0 -1
- package/dist/paywall-ATZ2IZPS.js +0 -1
- package/dist/paywall-content-XERXGNND.js +0 -1
- package/dist/paywall-session-EMMF6IYS.js +0 -1
- package/dist/screen-renderer-B7LUTPTJ.js +0 -1
- /package/dist/{chunk-ZYN4CRHS.js → chunk-42UXYMRZ.js} +0 -0
package/dist/chunk-GLYFT5WW.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as ge}from"./chunk-WRLVPHPE.js";import{a as Le}from"./chunk-ZYF6TRJ3.js";import{A as xe,B as et,E as Se,H as v,I as N,J as $,K as W,L as Q,Y as tt,Z as X,_ as B,f as Ze,g as We,h as Qe,q as Xe,s as be,t as Ye,x as H,y as J,z as Z}from"./chunk-QHJWVLJC.js";import{a as he,b as He,c as Je}from"./chunk-XE7GU6FZ.js";import{b as U}from"./chunk-DHT3AWJQ.js";import{b as e}from"./chunk-ZYN4CRHS.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 Mt(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 Tt(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):Mt(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 Pn(t,r="zh-CN",n="month"){let s=ve(r),i=Tt(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})])}),Tn=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 Un(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 Bn(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 Ut(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 Bt=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),$t=e.strictObject({id:e.string().trim().min(1).max(255),name:e.string().trim().min(1).max(255),status:Bt,metadata:Gt}),ir=$t.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})}),or=e.union([e.strictObject({id:e.string().trim().min(1).max(255)}),e.strictObject({internalId:e.uuid()})]),sr=e.enum(["customer","merchandise","context"]),ar=e.enum(["system","stored","request"]),cr=e.enum(["customer","merchandise","mixed"]),st=t=>t==="merchandiseId"||t==="merchandise"||t.startsWith("merchandise.");function Ce(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"&&Ce(i.condition,r,n))return!0}return!1}var yr=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()],qt=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:$})])})]),Lt=e.discriminatedUnion("type",[...ut,e.strictObject({type:e.literal("merchandise"),scope:e.strictObject({type:e.enum(["all","selected","condition"])})})]),Ht=e.strictObject({firstPurchaseOnly:e.boolean(),condition:$}),gr=e.object({name:e.string().trim().min(1).max(80),description:e.string().max(500),discount:at,duration:ct,nativeDiscountPolicy:ge.optional(),appliesTo:qt,eligibility:Ht,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=>!Ce(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"]}),hr=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:Lt}).strict()}).strict(),br=e.enum(["claim_disabled","unavailable","inactive","outside_window","not_targeted","not_first_purchase","limit_reached","sold_out"]);var Jt=e.string().regex(/^[a-f0-9]{64}$/),Zt=Ze.pick({text:!0,label:!0,alt:!0,html:!0,couponId:!0,countdownAt:!0,missing:!0}),pt=e.strictObject({couponDigests:e.record(e.uuid(),Jt),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:Zt})),plans:e.object({}).strict(),pickers:e.object({}).strict()}).omit({paywall:!0}))});var dt=e.enum(["funnel-run/1","funnel-process/1"]),jr="funnel-process/1";var Ae=v,Wt=["parameters","answers","results","variables"];function Qt(t){return Wt.some(r=>t===r||t.startsWith(r+"."))}function Xt(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])=>!Qt(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"),Yt=E,yt=e.strictObject({type:e.literal("external_task"),endpointId:e.uuid(),taskKey:_e,inputs:e.record(_e,Yt).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 Tr=e.strictObject({outcome:e.enum(["success","failure"]),data:ft});var Ur=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()})]),Br=e.strictObject({scope:U,runId:e.uuid(),eventId:e.uuid(),accepted:e.boolean()}),en=e.record(mt,Ae),Gr=e.strictObject({scope:U,runId:e.uuid(),results:en});var tn=["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=>![...tn,"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("")]),nn=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"),Hr=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:nn.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(),Jr=e.object({customer:bt,changed:e.boolean(),replayed:e.boolean()}).strict(),rn=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()]),on=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"),sn=e.object({lookup:rn}).strict(),Zr=sn.extend({requestId:e.uuid(),patch:on}).strict(),Wr=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(),Qr=e.object({customers:bt.array(),hasMore:e.boolean(),total:e.number().int().nonnegative().nullable(),evaluatedAt:e.iso.datetime()}).strict();var ni=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()}),an=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=an.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)})]),cn=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}),un={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")},pi=e.discriminatedUnion("operation",[e.strictObject({operation:e.literal("decide"),...un}).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()})]),di=e.strictObject({scope:U,decisionId:e.uuid(),requestId:e.uuid(),status:e.enum(["pending","completed","failed"]),decision:cn.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"),mi=e.strictObject({scope:U,decisionId:e.uuid(),eventId:e.uuid(),source:e.literal("caller_reported")});function ln(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 pn(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(pn(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=ln(n,r);if(i.length)throw new Error(i.join("; "));return n}var bi=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()})]),xi=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"})}),Si=e.record(e.uuid(),Ke).refine(t=>Object.keys(t).length<=20,"At most 20 native store selections");var Ii=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 dn=["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}",mn=e.string().regex(new RegExp(`^${Ve}/${Ve}/${Ve}/manifest\\.json$`)),kt=e.strictObject({kind:e.literal("gcs-resumable"),url:e.url(),bucket:e.enum(dn),objectKey:mn,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),C=e.string().regex(/^[a-f0-9]{64}$/),pe=e.strictObject({versionId:e.uuid(),manifestDigest:C,sourceGraphDigest:C,pageKey:S,stateKey:S,documentKey:S,documentHash:C,elementKey:S.optional(),nodeId:S.optional(),contentHash:C.optional(),renderKey:S.optional()}),Ct=e.strictObject({pageKey:S,documentKey:S,expectedDocumentHash:C,renderKey:S.optional(),nodeId:S,elementKey:S,expectedContentHash:C,property:e.enum(["text","fontSize","color"]),value:e.union([e.string().max(4e3),e.number().finite()])}),Ri=e.strictObject({versionId:e.uuid(),manifestDigest:C,sourceGraphDigest:C,pageKey:S,stateKey:S,documentKey:S,documentHash:C,renderKey:S.optional(),patches:e.array(Ct.omit({pageKey:!0,documentKey:!0,expectedDocumentHash:!0,renderKey:!0})).min(1).max(200)}),fn=/^[a-z][a-z0-9-]{0,39}$/,q=e.string().regex(fn),Pe=e.enum(["web","ios","android"]),Di=e.discriminatedUnion("action",[e.strictObject({action:e.literal("register"),requestId:e.uuid(),client:q,platform:Pe,label:e.string().trim().min(1).max(100),sha256:C,bytes:e.number().int().min(1),transferBytes:e.number().int().min(1)}),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:C.nullable(),editorUrl:e.string().url().max(2048),patches:e.array(Ct).max(200)})]),Fe=e.strictObject({id:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),clientKey:q,platform:Pe,label:e.string(),sha256:C,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())}),yn=e.strictObject({key:q,platform:Pe,currentId:e.uuid().nullable()}),zi=e.strictObject({rows:e.array(Fe).max(100),nextCursor:e.uuid().nullable(),clients:e.array(yn).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()}),Ei=e.strictObject({asOf:e.iso.datetime({offset:!0}),reclamation:e.literal("manual-review-required"),buckets:e.strictObject({source:Ne,runtime:Ne,previews:Ne})}),Ki=e.strictObject({version:Fe,actorId:e.uuid(),claims:e.record(e.string(),e.json())}),Vi=e.strictObject({version:Fe,upload:kt.nullable()}),Ni=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:C,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"})}),Pi=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()}),Fi=e.strictObject({enabled:e.boolean(),allowedOrigins:e.array(e.string())});var gn=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()}),At=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:gn.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},_t="00000000-0000-0000-0000-000000000000";var Rt=e.strictObject({type:e.literal("bundle"),paywall:E.optional(),offering:E.optional(),coupons:E,data:E}),hn=t=>e.strictObject({type:e.literal(t),id:e.uuid()}),Ji=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 Zi=e.strictObject({type:e.literal("bundle"),offering:hn("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 Dt=e.union([e.string(),e.number().finite(),e.boolean(),e.null()]),bn=e.union([Dt,e.array(Dt).min(1).max(20)]),xn=e.record(R,bn).refine(t=>Object.keys(t).length<=10),zt=e.strictObject({path:R,type:e.enum(["string","number","boolean","strings"]),nullable:e.boolean().optional(),aggregation:e.enum(["count","exists"]).optional(),where:xn.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 Sn=["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"],Et=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),vn=E,Kt=e.discriminatedUnion("type",[yt,e.strictObject({type:e.literal("claim_offer"),coupon:E}),e.strictObject({type:e.literal("event"),event:Et}),e.strictObject({type:e.literal("api"),operation:e.enum(Sn),inputs:e.record(R,vn).refine(t=>Object.keys(t).length<=40),outputs:e.record(Et,zt).refine(t=>Object.keys(t).length<=20)})]);var b=ne,wn=e.string().regex(/^[a-zA-Z0-9_.-]{1,128}$/),A={id:b,name:e.string().trim().min(1).max(80),position:e.strictObject({x:e.number().finite(),y:e.number().finite()}).optional()},In={success:b,cancel:b,unavailable:b,failure:b},On=e.url().max(2048).refine(t=>{try{return new URL(t).protocol==="https:"}catch{return!1}},{message:"External pages require HTTPS"}),jn=e.enum(["same_window","new_window"]),kn=e.discriminatedUnion("type",[e.strictObject({...A,type:e.literal("entry"),next:b,triggers:e.array(At).max(20).refine(t=>new Set(t.map(r=>r.id)).size===t.length,"Entry trigger IDs must be unique").optional()}),e.strictObject({...A,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({...A,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({...A,type:e.literal("coupon"),couponId:e.uuid(),writes:e.strictObject({value:I}),next:b}),e.strictObject({...A,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({...A,type:e.literal("output"),value:e.discriminatedUnion("type",[...Ee.options,Rt,e.strictObject({type:e.literal("selection"),screenId:b,offeringKey:I})])}),e.strictObject({...A,type:e.literal("condition"),cases:e.array(e.strictObject({condition:$,target:b})).min(1).max(50),default:b}),e.strictObject({...A,type:e.literal("feature"),featureKey:e.string().min(1).max(128),writes:e.strictObject({value:I}),next:b}),e.strictObject({...A,type:e.literal("split"),experimentId:e.uuid(),applyPageExperiment:e.literal(!0).optional(),routes:e.record(wn,b).refine(t=>Object.keys(t).length>=2&&Object.keys(t).length<=20),notParticipating:b}),e.strictObject({...A,type:e.literal("action"),...In,execution:gt,action:Kt,writes:Ie.optional()}),e.strictObject({...A,type:e.literal("external_page"),appManifest:pe.optional(),url:On,openIn:jn,opened:b,failed:b}),e.strictObject({...A,type:e.literal("end"),outcome:e.enum(["completed","closed","ineligible","failed"]),output:Ee.optional()}),e.strictObject({...A,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(kn).min(1).max(D.flowNodes)}),Te=Me.superRefine((t,r)=>{Cn(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 Cn(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 Vt(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 G=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"),Co=e.enum(["local_segment","evaluation","presentation","timer","event","operation"]),Ge=e.enum(["entry","presentation","decision","configuration","capability","wait","terminal"]),$e=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()})]),Ao=e.strictObject({schemaVersion:e.literal(1),kind:Ge,selector:$e.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"),_o=e.strictObject({schemaVersion:e.literal(1),kind:Ge,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"),Ro=e.strictObject({schemaVersion:e.literal(1),operations:e.record(G,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:G,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}),Do=e.discriminatedUnion("type",[e.strictObject({type:e.literal("node_entered"),details:e.strictObject({kind:Ge})}),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:G,eventName:G,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:G,reference:e.strictObject({type:G,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}$/),An=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(An).max(D.pages),references:e.record(_,$e).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)})},Qo=e.strictObject({...qe,graph:Me});function _n(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===_t:ye(n))}function Rn(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}),_n(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 Nt(t,r){for(let{message:n,reason:s,path:i}of Rn(t))r.addIssue({code:"custom",message:n,path:i,params:{reason:s}})}function Pt(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=[...Vt(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(Ft=>Ft.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 Dn=e.strictObject({...qe,graph:Te}).superRefine(Pt),zn=e.strictObject({...qe,graph:Te,displayName:e.string().trim().min(1).max(80)}).superRefine(Pt),Xo=zn.superRefine(Nt),Yo=Dn.superRefine(Nt),fe=e.string().regex(Le),L={requestId:e.uuid(),nodeId:_,visit:e.number().int().nonnegative(),revision:e.number().int().nonnegative(),customerToken:fe.optional()},En=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"])})]),Kn=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(),es=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:Kn.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:En}),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,Un as e,Bn as f,Ut as g,ot as h,M as i,Ke as j,or as k,Mt as l,Tt as m,Pn as n,at as o,ct as p,Lt as q,lt as r,br as s,Jt as t,jr as u,ln as v,Ii as w,Ri as x,gn as y,Qt as z,Xt as A,Ur as B,Br as C,Gr as D,an as E,tn as F,nn as G,Hr as H,ae as I,ce as J,ue as K,le as L,bt as M,Jr as N,sn as O,Zr as P,Wr as Q,Qr as R,Ee as S,un as T,pi as U,di as V,mi as W,On as X,jn as Y,Ao as Z,_o as _,zn as $,es as aa};
|
package/dist/chunk-HYE2YQYM.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{f as ue,g as se}from"./chunk-5XKFUFXK.js";import{b as on}from"./chunk-R3YVDRTB.js";import{d as tn,e as pe}from"./chunk-U4WUX3WB.js";import{c as Be,d as Ke,e as J,l as nn}from"./chunk-JOIPLLHK.js";import{$ as de,A as $e,E as Ye,S as Ze,X as We,Y as Xe,Z as $,_ as en,a as j,aa as U,b as qe,c as Me,d as je,e as G,f as Ge,g as Ue,i as X,w as ee,x as ze,y as Je}from"./chunk-GLYFT5WW.js";import{b as an}from"./chunk-3NCMYTNG.js";import{b as ne}from"./chunk-HVVJGLYZ.js";import{a as W}from"./chunk-ZYF6TRJ3.js";import{$ as ce,H as L,I as De,J as Le,Y as He,Z as le,_ as Qe,g as Oe,m as Ae,q as Te,y as ae}from"./chunk-QHJWVLJC.js";import{b as D}from"./chunk-DHT3AWJQ.js";import{a as f}from"./chunk-TIQS5DUF.js";import{b as rn}from"./chunk-RHF4NFCZ.js";import{b as n}from"./chunk-ZYN4CRHS.js";import{c as _e,d as ke,e as Ve,f as z}from"./chunk-O4KXODTJ.js";import{a as Pe,b as Ne}from"./chunk-CILM5XMH.js";function un(e){return Cn({...e,namespace:"commands",identity:[e.runToken]})}function Cn(e){let t,u,r=()=>new f("COMMAND_STORAGE_INVALID","Durable command storage is unavailable"),i=Promise.resolve().then(async()=>{if(t=e.storage??globalThis.localStorage,u=e.locks??globalThis.navigator?.locks,!t||!u||!globalThis.crypto?.subtle)throw r();let d=new TextEncoder().encode(JSON.stringify([new URL(e.baseUrl??rn).href,...e.identity])),a=new Uint8Array(await crypto.subtle.digest("SHA-256",d));return`indiana.funnel.${e.namespace}.v1.`+Array.from(a,o=>o.toString(16).padStart(2,"0")).join("")});i.catch(()=>{});async function p(d){try{let a=await i;return await u.request(a,{mode:"exclusive"},()=>d(a))}catch(a){throw a instanceof f?a:r()}}function c(d){let a=t.getItem(d);if(a===null)return{revision:0,entry:null};if(a.length>1048576)throw r();let o=JSON.parse(a);if(!o||typeof o!="object"||!("revision"in o)||!("entry"in o)||!Number.isSafeInteger(o.revision)||Number(o.revision)<0)throw r();return{revision:Number(o.revision),entry:o.entry}}return{read:()=>p(c),write:(d,a)=>p(o=>{if(c(o).revision!==d)return null;if(!Number.isSafeInteger(d+1))throw r();let y=JSON.stringify({revision:d+1,entry:a});if(y.length>1048576)throw r();return t.setItem(o,y),d+1})}}var sn=n.strictObject({type:n.literal("funnel"),id:n.uuid(),versionId:n.uuid()});var q=n.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Pn=n.enum(["running","waiting","completed","closed","ineligible","failed"]),Nn=n.discriminatedUnion("type",[Ye,n.strictObject({type:n.literal("wait"),receiptId:n.uuid(),kind:n.enum(["timer","event","operation"]),deadline:n.iso.datetime({offset:!0}).nullable(),eventName:q.optional()}),n.strictObject({type:n.literal("open_url"),receiptId:n.uuid(),url:We,openIn:Xe}),n.strictObject({type:n.literal("event"),receiptId:n.uuid(),event:q})]),On={id:q,presentation:Te,outputs:n.array(q).max(250),inputs:ce,values:n.record(n.string(),L).optional(),offeringKey:j.optional(),capabilities:Oe,customerData:Ae,dataCursors:n.record(q,He.nullable())},An=n.strictObject({...On,content:n.strictObject({type:n.literal("document"),document:ae})}),me=n.strictObject({id:n.uuid(),source:sn,revision:n.number().int().nonnegative(),visit:n.number().int().nonnegative(),nodeId:q,nodeType:n.enum(["entry","screen","condition","split","feature","action","external_page","wait","end","offering","coupon","coupons","output"]),status:Pn,stopped:n.boolean(),canBack:n.boolean(),authenticated:n.boolean(),locale:n.string().min(1).max(35),answers:le,parameters:Qe,variables:n.record(n.string(),L),output:L.nullable(),screen:An.nullable(),paywall:n.strictObject({receiptId:n.uuid(),resolution:n.union([tn,pe]),quote:ue.nullable(),operation:se.nullable(),purchaseRequestId:n.uuid().nullable(),selectionGeneration:n.number().int().nonnegative().optional(),canReselect:n.boolean().optional()}).nullable(),instruction:Nn.nullable(),pendingRequest:n.strictObject({requestId:n.uuid(),authenticationRequired:n.boolean()}).nullable(),runExpiresAt:n.iso.datetime({offset:!0}),credentialExpiresAt:n.iso.datetime({offset:!0}).nullable()}),Tn=n.strictObject({scope:D,run:me,settlement:n.strictObject({requestId:n.uuid(),state:n.enum(["pending","unknown","settled"]),operationId:n.uuid().nullable(),receiptId:n.uuid().nullable().optional()}).optional(),purchase:n.strictObject({receiptId:n.uuid(),quote:ue.nullable(),operation:se.nullable(),canReselect:n.boolean().optional()}).optional(),review:n.strictObject({activeOperationId:n.uuid().nullable(),pages:n.array(n.strictObject({receiptId:n.uuid(),nodeId:q,visit:n.number().int().nonnegative()})).max(100),page:n.strictObject({receiptId:n.uuid(),nodeId:q,visit:n.number().int().nonnegative(),document:ae,answers:le,inputs:ce,values:n.record(n.string(),L).optional()}).nullable(),coupons:n.array(n.strictObject({grantId:n.uuid(),status:n.enum(["issued","reserved","redeemed","expired","revoked","unknown"]),expiresAt:n.string().nullable()})).max(100),purchases:n.array(n.strictObject({receiptId:n.uuid(),operationId:n.uuid(),status:n.enum(["pending","complete","cancelled","failed","unknown"])})).max(100)}).optional(),runToken:n.string().regex(/^gg_fr_[A-Za-z0-9_-]{43}$/).optional(),customerId:n.uuid().optional()}),ln=Tn.extend({run:me.extend({paywall:me.shape.paywall.unwrap().extend({resolution:pe}).nullable()})});var cn="X-Indiana-Server-Key";var H=class extends Error{constructor(t){super(t),this.name="FunnelCalculationError"}};function fe(e,t,u){let r={},i,p,c,d="next",a;switch(e.type){case"entry":a=e.next;break;case"condition":{let o=e.cases.findIndex(g=>ke(t.attributes??{},g.condition,t.savedGroups??{}));d=o<0?"default":`case:${o}`,a=o<0?e.default:e.cases[o].target;break}case"feature":if(!Object.hasOwn(t.features??{},e.featureKey))throw new H("Required GB Feature is unavailable");i=z(e.featureKey,t),c=i.value,Object.assign(r,G(e,{value:c})),a=e.next;break;case"split":{let o=u[e.experimentId];if(!o)throw new H("Required GB Experiment is unavailable");if(p=Ve(o,t),c=p.value,d=p.inExperiment&&!p.passthrough&&typeof c=="string"?c:"notParticipating",a=d==="notParticipating"?e.notParticipating:e.routes[d],!a)throw new H("Experiment Variation has no published route");break}case"offering":{let o=e.configuration.source==="fixed"?e.configuration.versionId:z(e.configuration.featureKey,t).value;c={type:"offering_version",id:n.uuid().parse(o)},Object.assign(r,G(e,{value:c})),a=e.next;break}case"coupon":case"coupons":c=e.type==="coupons"?e.couponIds.map(o=>({type:"reward",id:o})):{type:"reward",id:e.couponId},Object.assign(r,G(e,{value:c})),a=e.next;break}return{port:d,target:a,projections:r,...c===void 0?{}:{value:c},...i?{feature:i}:{},...p?{experiment:p}:{}}}function dn(e,t,u){n.uuid().parse(e),n.number().int().nonnegative().parse(t);let r=Pe(Ne(new TextEncoder().encode(JSON.stringify([e,t,u])))).slice(0,32);return`${r.slice(0,8)}-${r.slice(8,12)}-5${r.slice(13,16)}-a${r.slice(17,20)}-${r.slice(20)}`}var _n=n.strictObject({selector:n.string().min(1).max(2048),action:n.enum(["set","append","remove"]),attribute:n.string().min(1).max(128).refine(e=>["html","class","style","position","href","src","alt","title","id","role","hidden"].includes(e)||/^(aria|data)-[a-z0-9_-]+$/.test(e)),value:n.string().max(5e4).optional(),parentSelector:n.string().max(2048).optional(),insertBeforeSelector:n.string().max(2048).optional()}),kn=n.strictObject({variation:n.string().min(1).max(128),description:n.string().max(2e3).default(""),css:n.string().max(1e5).default(""),js:n.string().max(1e5).default(""),domMutations:n.array(_n).max(200).default([]),iam:ze.optional(),renderGuard:ee.optional()}),ge=kn.omit({variation:!0,description:!0,iam:!0}),Vn=Be.omit({variations:!0,active:!0}).extend({changeId:n.string().regex(/^[a-f0-9]{64}$/),variations:n.tuple([ge,ge]).rest(ge).refine(e=>e.length<=20)}),pn=n.strictObject({trackExposures:n.boolean(),environmentId:n.uuid(),generation:n.string().regex(/^[a-f0-9]{64}$/),experiments:n.array(Vn).max(100),savedGroups:Ke});var Q=n.string().regex(/^[a-f0-9]{64}$/),jt=n.strictObject({iam:Q,executionContracts:n.union([n.tuple([n.literal("funnel-run/1")]),n.tuple([n.literal("funnel-process/1")])]).default(["funnel-run/1"])}),Dn=n.strictObject({release:Q,render:ee,button:n.strictObject({selector:n.string().min(1).max(512),elementKey:n.string().min(1).max(256),tag:n.enum(["button","a","input"])}).nullable()}),Gt=n.strictObject({scope:D.extend({environmentId:n.uuid()}),release:Q,validatedAt:n.iso.datetime({offset:!0}),validUntil:n.iso.datetime({offset:!0}),entries:n.array(n.strictObject({id:n.uuid(),funnelId:n.uuid(),versionId:n.uuid(),event:n.enum(["screen_enter","button_click"]),delivery:Je.optional(),target:Dn})).max(4e3)}),Ut=n.strictObject({operation:n.literal("entry_start"),funnelId:n.uuid(),versionId:n.uuid(),entryId:n.uuid(),release:Q,requestId:n.uuid(),locale:n.string().min(1).max(35).default("en")}),Bt=n.strictObject({scope:D,suppressed:n.literal(!0),reason:n.enum(["frequency","in_progress"]),retryAt:n.iso.datetime({offset:!0}).nullable()}),Kt=n.strictObject({experimentId:n.uuid(),splitNodeId:n.string().min(1).max(128)}),Ln=n.strictObject({experimentId:n.uuid(),experimentKey:n.string().min(1).max(128),variationKey:n.string().min(1).max(128),inExperiment:n.boolean(),generation:n.string().min(1).max(256)}),ye=n.strictObject({operation:n.literal("page_experiments"),release:Q,usedReceiptIds:n.array(n.uuid()).max(20).default([]),customerToken:n.string().regex(W).optional()}),mn=n.strictObject({scope:D,runId:n.uuid(),assignments:n.array(Ln.extend({receiptId:n.uuid()})).max(100),payload:pn});var B=n.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),gn=n.strictObject({entry:B,nodes:n.array(n.strictObject({id:B,type:n.enum(["entry","screen","condition","split","feature","action","external_page","wait","end","offering","coupon","coupons","output"]),outputs:n.record(n.string(),B),writes:n.record(j,j),resources:n.strictObject({screenId:B.optional(),paywallVersionId:n.uuid().optional(),couponId:n.uuid().optional(),couponIds:n.array(n.uuid()).max(20).optional(),experimentId:n.uuid().optional(),featureKey:n.string().optional(),offeringVersionId:n.uuid().optional()})})).min(1).max(500)}),fn={scope:D,funnelId:n.uuid(),versionId:n.uuid(),evaluationRevision:n.number().int().nonnegative(),expiresAt:n.iso.datetime({offset:!0}).nullable(),topology:gn},te=n.discriminatedUnion("evaluationMode",[n.strictObject({...fn,evaluationMode:n.literal("local"),growth:J,conditions:n.record(B,n.array(n.strictObject({condition:Le,port:n.string()})))}),n.strictObject({...fn,evaluationMode:n.literal("remote")})]),qn=te.options[0].extend({evaluation:n.strictObject({maxTransitions:n.number().int().min(1).max(1e4),variables:n.record(j,Me),outputSchema:qe,terminals:n.record(B,n.strictObject({outcome:n.enum(["completed","closed","ineligible","failed"]),output:Ze.nullable()}))})});function Mn(e){return gn.parse({entry:e.graph.entry,nodes:e.graph.nodes.map(t=>{let u={},r={};switch(t.type){case"entry":case"feature":case"offering":case"coupon":case"coupons":u.next=t.next;break;case"screen":Object.assign(u,t.outputs),r.screenId=t.screenId;{let p=e.screens.find(c=>c.id===t.screenId);p?.type==="paywall"&&(r.paywallVersionId=p.paywallVersionId)}break;case"condition":t.cases.forEach((p,c)=>{u[`case:${c}`]=p.target}),u.default=t.default;break;case"split":Object.assign(u,t.routes),u.notParticipating=t.notParticipating,r.experimentId=t.experimentId;break;case"action":for(let p of["success","cancel","unavailable","failure"])u[p]=t[p];t.action.type==="claim_offer"&&t.action.coupon.source==="literal"&&t.action.coupon.value&&typeof t.action.coupon.value=="object"&&!Array.isArray(t.action.coupon.value)&&(r.couponId=n.uuid().parse(t.action.coupon.value.id));break;case"external_page":u.opened=t.opened,u.failed=t.failed;break;case"wait":t.wait.type==="duration"?u.elapsed=t.wait.elapsed:(u.received=t.wait.received,u.timeout=t.wait.timeout);break;case"end":case"output":break}t.type==="feature"&&(r.featureKey=t.featureKey),t.type==="offering"&&t.configuration.source==="feature"&&(r.featureKey=t.configuration.featureKey);let i=t.type==="output"?t.value:t.type==="end"?t.output:void 0;return i?.type==="feature"&&(r.featureKey=i.featureKey),t.type==="coupon"&&(r.couponId=t.couponId),t.type==="coupons"&&(r.couponIds=t.couponIds),t.type==="offering"&&t.configuration.source==="fixed"&&(r.offeringVersionId=t.configuration.versionId),{id:t.id,type:t.type,outputs:u,resources:r,writes:"writes"in t?t.writes??{}:{}}})})}function ve(e){let t=de.parse(e.document),u=e.evaluationMode==="local"?J.parse(e.payload):null;if(u&&(u.scope.projectId!==e.scope.projectId||u.scope.environment!==e.scope.environment))throw new Error("GB payload belongs to another App or environment");let r={scope:e.scope,funnelId:e.funnelId,versionId:e.versionId,evaluationRevision:e.evaluationRevision,evaluationMode:e.evaluationMode,expiresAt:u?.expiresAt??null,topology:Mn(t)};return te.parse(e.evaluationMode==="remote"?r:{...r,growth:nn(t,u),conditions:Object.fromEntries(t.graph.nodes.filter(i=>i.type==="condition").map(i=>[i.id,i.cases.map((p,c)=>({condition:p.condition,port:`case:${c}`}))]))})}function er(e){let t=ve(e);if(t.evaluationMode!=="local")throw new Error("Remote Funnel cannot disclose local rules");let u=de.parse(e.document);return qn.parse({...t,evaluation:{maxTransitions:u.execution.maxTransitions,variables:u.variables,outputSchema:u.outputSchema,terminals:Object.fromEntries(u.graph.nodes.flatMap(r=>{let i=r.type==="end"?r.output:r.type==="output"?r.value:void 0;return r.type!=="end"&&r.type!=="output"?[]:i&&i.type!=="literal"&&i.type!=="feature"&&i.type!=="variable"?[]:[[r.id,{outcome:r.type==="end"?r.outcome:"completed",output:i??null}]]}))}})}var he=32,jn=522240;function we(e){if(["entry","condition","feature","split","offering","coupon","coupons"].includes(e.type))return!0;if(e.type!=="end"&&e.type!=="output")return!1;let t=e.type==="end"?e.output:e.value;return t?.type!=="bundle"&&t?.type!=="selection"}var Gn=n.strictObject({nodeId:n.string().min(1).max(64),visit:n.number().int().nonnegative(),revision:n.number().int().nonnegative()}),Ie=n.record(n.string(),L),Un=n.strictObject({id:n.uuid(),nodeId:n.string().min(1).max(64),visit:n.number().int().nonnegative(),input:n.strictObject({schemaVersion:$.shape.schemaVersion,kind:$.shape.kind,selector:$.shape.selector,contract:$.shape.contract}),context:Ie,removed:n.array(n.string()).max(100),attributes:Ie,removedAttributes:n.array(n.string()).max(100),result:en,offeringVersionId:n.uuid().nullable(),events:n.strictObject({entered:n.string().regex(/^[1-9][0-9]{0,18}$/),decision:n.string().regex(/^[1-9][0-9]{0,18}$/).nullable()})}),ar=n.strictObject({schemaVersion:n.literal(1),mode:n.enum(["local","remote"]),versionId:n.uuid(),generation:n.number().int().positive(),base:Gn,context:Ie,steps:n.array(Un).min(1).max(he)}).refine(e=>X(e)<=jn,"Segment exceeds its byte budget");var Bn=/^(parameters(?:\.|$)|answers(?:\.|$)|results(?:\.|$)|variables(?:\.|$)|funnelParticipantId$)/;function Y(e){return Array.isArray(e)?e.some(Y):!e||typeof e!="object"?!1:Object.entries(e).some(([t,u])=>t.startsWith("$")?["$and","$or","$nor","$not"].includes(t)&&Y(u):!Bn.test(t))}function yn(e,t,u,r){if(e.executionContract!=="funnel-process/1"||r)return null;if(["offering","coupon","coupons"].includes(t.type)||t.type==="action"&&t.action.type!=="event"||t.type==="screen"&&(t.offering||e.screens.some(d=>d.id===t.screenId&&d.type==="paywall")))return"customer_required";let i=t.type==="end"?t.output:t.type==="output"?t.value:void 0;if(i&&["bundle","selection","offering"].includes(i.type)||t.type==="condition"&&t.cases.some(d=>Y(d.condition)))return"customer_required";let p=JSON.stringify([t,t.type==="screen"?e.screens.find(d=>d.id===t.screenId):null]);for(let[d,a]of Object.entries(e.variables))if(a.source.type==="attribute"&&a.source.key!=="funnelParticipantId"&&(p.includes(`variables.${d}`)||p.includes(JSON.stringify(d))))return"customer_required";if(t.type==="split"){let d=u.experiments?.[t.experimentId];if((d?.hashAttribute??"id")!=="funnelParticipantId"||Y(d?.condition)||d?.parentConditions?.length)return"customer_experiment_required"}let c=t.type==="feature"?t.featureKey:i?.type==="feature"?i.featureKey:void 0;return c&&u.features?.[c]?.rules?.some(d=>(d.hashAttribute??"id")!=="funnelParticipantId"||Y(d.condition)||d.parentConditions?.length)?"customer_experiment_required":null}var be=class extends Error{constructor(u,r){super(r);this.code=u;this.name="FunnelLocalCalculationError"}code},re=(e,t)=>new be(e,t),Kn=e=>({experiments:e.experiments,features:e.features});function xe(e,t=re){let u=new Map(e.topology.nodes.map(c=>[c.id,c])),r=_e(e.growth.savedGroups),i=Kn(e.growth);function p(c,d){if(!Object.hasOwn(e.growth.features,c))throw t("INVALID_RESPONSE","Required GB Feature is unavailable");return z(c,d).value}return{nodes:u,savedGroups:r,features:i.features,feature:p,evaluate(c,d){let a=u.get(c);if(!a)throw t("NOT_FOUND","Funnel node is unavailable");let o,g;if(a.type==="condition"){let I=e.conditions[a.id];if(!I)throw t("INVALID_RESPONSE","Local condition rules are unavailable");o=fe({id:a.id,name:a.id,type:"condition",cases:I.map(h=>({condition:h.condition,target:a.outputs[h.port]})),default:a.outputs.default},d,i.experiments).port}else if(a.type==="feature"){if(!a.resources.featureKey)throw t("INVALID_RESPONSE","Feature reference is unavailable");g=p(a.resources.featureKey,d),o="next"}else if(a.type==="split"){if(!(a.resources.experimentId?e.growth.experiments[a.resources.experimentId]:void 0))throw t("INVALID_RESPONSE","Experiment reference is unavailable");let h=fe({id:a.id,name:a.id,type:"split",experimentId:a.resources.experimentId,routes:a.outputs,notParticipating:a.outputs.notParticipating},d,i.experiments);g=h.value,o=h.port}else if(["offering","end","output"].includes(a.type)&&a.resources.featureKey)g=p(a.resources.featureKey,d),o=a.type==="offering"?"next":"value";else throw t("SERVER_REQUIRED","This node is driven by the authoritative Funnel runtime");let y=a.outputs[o]??(o==="value"?a.id:void 0);if(!y)throw t("INVALID_RESPONSE","Evaluated node exit is unavailable");return{nodeId:c,port:o,target:y,...g===void 0?{}:{value:g}}}}}function hr(e,t,u,r=re){return Re(e,r)(t,u)}function Re(e,t){let u=te.parse(e);if(u.evaluationMode!=="local")throw t("EVALUATION_MODE","Remote nodes are evaluated by Grow");let r=u.expiresAt?Date.parse(u.expiresAt):null,i=()=>{if(r!==null&&r<=Date.now())throw t("CONFIGURATION_EXPIRED","Refresh local rules at the scheduled transition")};i();let p=xe(u,t);return(c,d)=>(i(),zn(p,c,d))}function zn(e,t,u){let r=De.parse(u.attributes??{}),{saveStickyBucketAssignmentDoc:i,onFeatureUsage:p,onExperimentViewed:c}=u,d={attributes:r,...i?{saveStickyBucketAssignmentDoc:a=>i(structuredClone(a))}:{},...p?{onFeatureUsage:(a,o)=>p(a,structuredClone(o))}:{},...c?{onExperimentViewed:(a,o)=>c(structuredClone(a),structuredClone(o))}:{},features:e.features,savedGroups:e.savedGroups,...u.stickyBucketAssignmentDocs?{stickyBucketAssignmentDocs:structuredClone(u.stickyBucketAssignmentDocs)}:{}};return e.evaluate(t,d)}function wr(e,t,u,r=re){return vn(Re(e,r),t,u)}function vn(e,t,u){let r=[],i=[],p=[],c=e(t,{...u.attributes?{attributes:u.attributes}:{},stickyBucketAssignmentDocs:u.sticky,saveStickyBucketAssignmentDoc(d){let a=r.findIndex(y=>y.next.attributeName===d.attributeName&&y.next.attributeValue===d.attributeValue),o=d.attributeName+"||"+d.attributeValue,g={expected:u.sticky[o]??null,next:d};a<0?r.push(g):r[a]=g},onExperimentViewed(d,a){a.inExperiment&&a.hashUsed&&!a.passthrough&&i.push(L.parse({key:d.key,variationId:a.variationId,keyUsed:a.key,hashAttribute:a.hashAttribute,hashValue:a.hashValue}))},onFeatureUsage(d,a){p.push(L.parse({feature:d,value:a.value,source:a.source,...a.ruleId?{ruleId:a.ruleId}:{}}))}});return{port:c.port,...c.value===void 0?{}:{value:c.value},sticky:r,exposures:i,features:p}}function In(e,t,u,r=re){let i=u,p=new Map(t.graph.nodes.map(O=>[O.id,O])),c=structuredClone(u.variables),d=structuredClone(i.sticky),a=[],o=u.nodeId,g=u.visit,y=!1,I,h=O=>yn(t,O,e.evaluationMode==="local"?e.growth:{features:{},experiments:{}},i.attributes.funnelCustomerBound===!0),b=O=>(I??=Re(e,r),vn(I,O,{attributes:$e({declarations:t.variables,attributes:i.attributes,parameters:u.parameters,answers:u.answers,results:c,savedGroups:{}}),sticky:d}));for(let O=0;O<he;O++){let s=p.get(o);if(!s||!we(s)||h(s))break;if(g>=t.execution.maxTransitions&&(g>t.execution.maxTransitions||s.type!=="end"&&s.type!=="output")){if(!a.length)throw r("TRANSITION_LIMIT","Local Funnel transition budget exceeded");break}let m,x;if(["condition","feature","split"].includes(s.type)||s.type==="offering"&&s.configuration.source==="feature")m=b(s.id),s.type==="offering"&&(m.value={type:"offering_version",id:String(m.value)}),s.type==="condition"?x=m.port==="default"?s.default:s.cases[Number(m.port.slice(5))]?.target:s.type==="split"?x=m.port==="notParticipating"?s.notParticipating:s.routes[m.port]:(s.type==="feature"||s.type==="offering")&&(x=s.next);else if(m={port:"next",sticky:[],exposures:[],features:[]},(s.type==="entry"||s.type==="coupon"||s.type==="coupons")&&(x=s.next),s.type==="offering"&&s.configuration.source==="fixed"&&(m.value={type:"offering_version",id:s.configuration.versionId},x=s.next),s.type==="end"||s.type==="output"){let R=s.type==="end"?s.output:s.value;if(m=R?.type==="feature"?b(s.id):{...m,port:"value",value:R?.type==="literal"?R.value:R?.type==="variable"?Ue({source:"variable",key:R.key,...R.path?{path:R.path}:{}},{declarations:t.variables,answers:u.answers,results:c,parameters:u.parameters,attributes:i.attributes,savedGroups:{}}):null},R&&(m.value===void 0||!je(t.outputSchema,m.value)))throw r("INVALID_RESPONSE","Local terminal violates its declared output")}let C=[...a,{nodeId:o,result:m}];if(X({steps:C})>6e4){if(!a.length)throw r("INVALID_REQUEST","Local step exceeds its command budget");break}if(a.push({nodeId:o,result:m}),s.type==="feature"||s.type==="offering"||s.type==="coupon"||s.type==="coupons"){let R=s.type==="coupons"?s.couponIds.map(V=>({type:"reward",id:V})):s.type==="coupon"?{type:"reward",id:s.couponId}:m.value;if(R===void 0)throw r("INVALID_RESPONSE","Node output is missing");let _=G(s,{value:R});Ge(t.variables,s,_),Object.assign(c,_)}for(let R of m.sticky)d[`${R.next.attributeName}||${R.next.attributeValue}`]=structuredClone(R.next);if(s.type==="end"||s.type==="output"){y=!0;break}if(!x)throw r("INVALID_RESPONSE","Local pure exit is unavailable");o=x,g++}let T=p.get(o);return{steps:a,...!y&&T&&(!we(T)||h(T))?{boundary:{nodeId:o,visit:g}}:{}}}function hn(e,t){let u=ln.safeParse(t);if(!u.success)throw new f("INVALID_RESPONSE","Funnel response contract changed");let r=u.data;if(e.scope&&(r.scope.projectId!==e.scope.projectId||r.scope.environment!==e.scope.environment))throw new f("SCOPE_MISMATCH","Funnel scope changed");return r}var Se=(e,t)=>new f(e,t);function Cr(e){return xe(e,Se)}var Jn=3,$n=2e3;function Hn(e){return e instanceof TypeError||e instanceof f&&/^(?:CONFIGURATION_UNAVAILABLE|CONFIGURATION_HTTP_(?:429|5\d\d)|TEMPORARY_UNAVAILABLE)$/i.test(e.code)}async function Qn(e){for(let t=1;;t++)try{return await e.refresh()}catch(u){if(t===Jn||!Hn(u))throw u;await new Promise(r=>setTimeout(r,t*$n))}}async function Fe(e,t,{predict:u=!0}={}){let r=t.instruction;if(r?.type!=="evaluate_segment")throw new Error("Local segment instruction required");if(!e)throw new f("CONFIGURATION_UNAVAILABLE","Local execution requires public configuration");if(e.scope.environmentId!==r.environmentId)throw new f("SCOPE_MISMATCH","Evaluation environment changed");let i=null,p;if(u)try{let c=await e.funnel(t.source.id,t.source.versionId);p=c.manifest.generation,i=Yn(e,t,c)}catch{i=null}return p??=e.snapshot?.generation??(await Qn(e)).generation,{advance:{policyRevision:r.policyRevision,generation:p},prediction:i}}function Yn(e,t,u){let r=t.instruction;if(r?.type!=="evaluate_segment"||!u.growth||u.control.evaluationMode!=="local"||u.control.evaluationRevision!==r.policyRevision)return null;let{analyticsConfig:i,remoteFeatures:p,...c}=u.growth,d=ve({scope:{projectId:e.scope.projectId,environment:e.scope.environment},funnelId:t.source.id,versionId:t.source.versionId,evaluationMode:"local",evaluationRevision:r.policyRevision,document:u.document,payload:J.parse(c)}),a=Zn(d,u.document,{...t,...r}),o=a.steps.at(-1),g=a.boundary??(o?.result.port==="value"?{nodeId:o.nodeId,visit:t.visit+a.steps.length-1}:null);return g?{runId:t.id,from:{nodeId:t.nodeId,visit:t.visit,revision:t.revision},nodeId:g.nodeId,visit:g.visit,terminal:!a.boundary}:null}function Zn(e,t,u){return In(e,t,u,Se)}var wn=U.refine(e=>!["start","get","review"].includes(e.operation)&&!("customerToken"in e),"Persist only the original mutation, without credentials").transform(e=>{if(e.operation==="start"||e.operation==="get"||e.operation==="review")throw new f("COMMAND_STORAGE_INVALID","Stored mutation required");return e}),bn=n.strictObject({schemaVersion:n.literal(1),scope:D,runId:n.uuid(),funnelId:n.uuid(),versionId:n.uuid(),processBindingIds:n.record(n.uuid(),n.uuid().nullable()).optional(),command:wn.optional(),closeCommand:wn.refine(e=>e.operation==="close").optional(),purchase:n.strictObject({receiptId:n.uuid(),operationId:n.uuid(),generation:n.number().int().nonnegative()}).optional(),closed:n.literal(!0).optional()}).refine(e=>!e.closeCommand||e.command&&e.command.operation!=="close"&&e.command.requestId!==e.closeCommand.requestId,"Close requires a separate request identity").refine(e=>e.command!==void 0||e.purchase!==void 0,"A recovery record requires an original obligation"),A=()=>new f("COMMAND_STORAGE_CONFLICT","Another host changed this Run's pending command"),oe=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function Z(e,t){if(!e||!t)return e;if(e.processBindingIds&&Object.hasOwn(e.processBindingIds,t)){let u={...e.processBindingIds};delete u[t],e={...e,processBindingIds:u}}return e.command?.requestId===t?e.closeCommand?{...e,command:e.closeCommand,closeCommand:void 0}:e.purchase?{...e,command:void 0}:null:e.closeCommand?.requestId===t?{...e,closeCommand:void 0}:e}function xn(e){let t=0,u=null,r=a=>JSON.stringify([a.scope,a.runId,a.funnelId,a.versionId]),i=Promise.resolve();async function p(){let a=await e.read();if(!Number.isSafeInteger(a.revision)||a.revision<0)throw new f("COMMAND_STORAGE_INVALID","Invalid command storage revision");return{revision:a.revision,entry:a.entry===null?null:bn.parse(a.entry)}}function c(a){let o=i.then(a);return i=o.catch(()=>{}),o}async function d(a){for(let o=0;o<4;o++){let g=await p();if(g.entry&&u!==null&&r(g.entry)!==u)throw A();let y=a(g.entry,g.revision);if(oe(g.entry,y)){t=g.revision;return}let I=await e.write(g.revision,y);if(I!==null){if(!Number.isSafeInteger(I)||I<=g.revision)throw A();t=I;return}}throw A()}return{bind(a){let o=JSON.stringify([a.scope,a.runId,a.funnelId,a.versionId]);if(u!==null&&u!==o)throw A();u=o},async load(){let a=await p();return t=a.revision,u=a.entry?r(a.entry):null,a.entry},retain(a){let o=bn.parse(a),g=o.command;return!g||u!==null&&r(o)!==u?Promise.reject(A()):(u??=r(o),c(()=>d((y,I)=>{if(y&&!oe(r(y),r(o)))throw A();if(y&&o.processBindingIds){for(let[h,b]of Object.entries(o.processBindingIds))if(y.processBindingIds&&Object.hasOwn(y.processBindingIds,h)&&y.processBindingIds[h]!==b)throw A();y={...y,processBindingIds:{...y.processBindingIds,...o.processBindingIds}}}if(!y){if(I!==t&&g.operation!=="close")throw A();return o}if(!y.command)return{...y,command:g,...g.operation==="close"?{closed:!0}:{}};if(g.operation==="close"&&y.command.operation!=="close"){if(y.command.requestId===g.requestId||y.closeCommand&&!oe(y.closeCommand,g))throw A();return{...y,closeCommand:g,closed:!0}}if(!oe(y.command,g))throw A();return y})))},observePurchase(a,o,g,y){return c(()=>d((I,h)=>{if(!I&&h!==t||I&&r(I)!==r({...a,schemaVersion:1}))throw A();if(I?.purchase&&I.purchase.generation>o.generation)return Z(I,y);if(I?.purchase&&I.purchase.generation===o.generation&&I.purchase.operationId!==o.operationId)throw A();return g?!I?.purchase||I.purchase.operationId!==o.operationId?Z(I,y):Z(I.command?{...I,purchase:void 0}:null,y):Z({schemaVersion:1,...a,...I,purchase:o},y)}))},settle(a){return c(()=>d(o=>Z(o,a)))}}}function jr(e,t){return t.type==="id"?e.customerId===t.value:e.externalUserId===t.value}function ie(e,t){if(e===t)return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,p)=>ie(i,t[p]));if(!e||!t||typeof e!="object"||typeof t!="object")return!1;let u=Object.entries(e),r=Object.entries(t);return u.length===r.length&&u.every(([i,p])=>Object.hasOwn(t,i)&&ie(p,Reflect.get(t,i)))}function Rn(e,t){let u=t&&{...t},r=null,i=0,p=-1,c=0,d=new AbortController;function a(){c++,d.abort(new f("IDENTITY_CHANGED","Run identity changed")),d=new AbortController}let o=!1,g,y=0,I=new Set;return{get scope(){return u},bindScope(h){if(u&&(u.projectId!==h.projectId||u.environment!==h.environment))throw new f("SCOPE_MISMATCH","Run scope changed");u??={...h}},get view(){return r},get currentView(){return p===c?r:null},get viewAgeMs(){return r&&p===c?performance.now()-i:void 0},get generation(){return c},get signal(){return d.signal},get disposed(){return o},get customerToken(){return g},get readSequence(){return y},nextRead(){return++y},assertCurrent(h,b="Run identity changed during the request"){if(h!==c||o)throw new f("IDENTITY_CHANGED",b)},assertRun(h){if(r&&(h.id!==r.id||h.source.type!==r.source.type||h.source.id!==r.source.id||h.source.versionId!==r.source.versionId||h.locale!==r.locale||!ie(h.parameters,r.parameters)))throw new f("INVALID_RESPONSE","Run version changed");if(e&&h.source.id!==e)throw new f("INVALID_RESPONSE","Run belongs to another Funnel")},publish(h,b,T,O,s){if(!(h.operation==="review"&&r&&r!==T&&b.run.revision<=r.revision)&&!(r&&b.run.revision===r.revision&&O!==void 0&&O<y)&&(h.operation==="review"&&!b.run.stopped&&["running","waiting"].includes(b.run.status)&&r&&p===c&&b.run.nodeId===r.nodeId&&b.run.visit===r.visit&&b.run.revision===r.revision&&(b.run.screen=r.screen,(r.paywall?.quote?.operationId===b.review?.activeOperationId||!r.paywall?.quote&&b.review?.activeOperationId===null)&&(b.run.paywall=r.paywall)),!(r?.paywall&&b.run.paywall&&r.paywall.receiptId===b.run.paywall.receiptId&&(b.run.paywall.selectionGeneration??0)<(r.paywall.selectionGeneration??0)))){if(!r||b.run.revision>=r.revision)r=b.run,i=performance.now(),p=c;else if(!s)return;if(r&&p===c)for(let m of I)try{m(structuredClone(r))}catch{}}},identify(h){if(o)throw new f("IDENTITY_CHANGED","Controller was reset");if(!W.test(h))throw new f("INVALID_TOKEN","Customer credential required");a(),g=h},subscribe(h){return I.add(h),()=>I.delete(h)},reset(){o||(o=!0,a(),g=void 0,r=null,I.clear())}}}var Ee=/^gg_sk_[A-Za-z0-9_-]{32,128}$/;function $r(e,t,u="A server API key is required"){if(typeof window<"u")throw new f("SERVER_ONLY",t);if(!Ee.test(e))throw new f("INVALID_TOKEN",u)}function Hr(e){let t=ne(e);return t.identify(e.apiKey),t}function Sn(e,t){if(!e)return;let u=t?.execution,r=u?.provider==="merchant"?"merchant":u?.provider==="stripe"?u.executor==="merchant"?"record_only":"indiana":t&&["apple","google"].includes(t.provider)?"native":t?.provider==="stripe"?"indiana":void 0;if(!r||!e.allowed.includes(r))throw new f("EXECUTION_POLICY_REFUSED","The original quote does not permit the declared purchase execution")}function M(e){let{customerToken:t,...u}=e;return u}var Wn=e=>!(e instanceof f&&e.code==="EXECUTION_POLICY_REFUSED")&&(!(e instanceof f)||e.status===void 0||e.status>=500||[401,425].includes(e.status)||e.recovery==="recover_operation");function Fn({journal:e,state:t,call:u,processIdentity:r}){let i=null,p=null,c=!1,d={command:null,close:null},a=new Set,o,g=null,y=e?e.load().then(s=>{if(t.disposed)throw new f("IDENTITY_CHANGED","Controller was reset during command restoration");if(g=s,!s)return;if(r){if([s.command,s.closeCommand].some(x=>x&&!Object.hasOwn(s.processBindingIds??{},x.requestId)))throw new f("COMMAND_STORAGE_INVALID","The original process identity is missing");r.restore(s.processBindingIds??{})}if(t.scope&&(s.scope.projectId!==t.scope.projectId||s.scope.environment!==t.scope.environment))throw new f("SCOPE_MISMATCH","Pending command belongs to another scope");if(o=s.purchase,c=s.closed===!0,!s.command)return;let m=s.command;i=m.operation==="close"?null:m,p=m.operation==="close"?m:s.closeCommand?.operation==="close"?s.closeCommand:null,p&&(c=!0);for(let x of[i,p])x&&a.add(x.requestId)}):Promise.resolve();y.catch(()=>{});async function I(s){e&&await y;let m=t.generation;if(e){if(!t.view||!t.scope)throw new f("COMMAND_STORAGE_INVALID","Read the original scoped Run before persisting a mutation");await e.retain({schemaVersion:1,scope:t.scope,runId:t.view.id,funnelId:t.view.source.id,versionId:t.view.source.versionId,command:M(s),...r?{processBindingIds:{[s.requestId]:r.binding(s.requestId)}}:{}})}if(m!==t.generation||i!==s&&p!==s)throw new f("IDENTITY_CHANGED","Run changed before command dispatch");let x=a.has(s.requestId);a.add(s.requestId);try{return await u(s)}catch(C){let R=s.operation==="submit"&&s.input.type==="paywall_quote",_=!x&&!Wn(C),V=!1;if(R&&_&&m===t.generation&&i===s&&C instanceof f&&C.status!==void 0){let l=await T(s.requestId).catch(()=>{});V=l?.settlement?.state==="unknown"&&l.settlement.operationId===null}throw m===t.generation&&(i===s||p===s)&&_&&(!R||!(C instanceof f)||C.status===void 0||V)&&(e&&await e.settle(s.requestId),m===t.generation&&O(s)),C}}function h(s){let m=U.parse(s);if(m.operation==="start"||m.operation==="get"||m.operation==="review")throw new f("INVALID_REQUEST","Mutation required");if(c&&m.operation!=="close"){if(i?.requestId===m.requestId)return T(m.requestId);throw new f("COMMAND_PENDING","Close preserves the original recovery record; settle it by identity")}if(m.operation==="close"){if(i?.requestId===m.requestId)throw new f("INVALID_REQUEST","Close requires its own request identity");if(c=!0,p&&JSON.stringify(M(p))!==JSON.stringify(M(m)))throw new f("COMMAND_PENDING","Retry the original Close");return p??=m,d.close?d.close:b(p,"close")}if(i){if(JSON.stringify(M(i))!==JSON.stringify(M(m)))throw new f("COMMAND_PENDING","Retry the original command before sending another");if(d.command)return d.command}else i=m;return b(i,"command")}function b(s,m){let x=I(s);d[m]=x;let C=()=>{d[m]===x&&(d[m]=null)};return x.then(C,C),x}function T(s){return u({operation:"get",settlementRequestId:s})}function O(s){return!s||i!==s&&p!==s?!1:(i===s&&(i=null),p===s&&(p=null),a.delete(s.requestId),!i&&!p&&(g=null),!0)}return{ready:y,get pending(){return i},get closing(){return p},get closeRequested(){return c},get inFlight(){return d.command},get closeFlight(){return d.close},get purchase(){return o},assertBinding(s){if(g&&(s.run.id!==g.runId||s.run.source.id!==g.funnelId||s.run.source.versionId!==g.versionId))throw new f("SCOPE_MISMATCH","Stored command belongs to another Run or Version")},async observe(s,m,x,C){let R=s.operation==="get"?s.settlementRequestId:"requestId"in s&&s.operation!=="start"?s.requestId:void 0,_=R&&m.settlement?.state==="settled"&&m.run.pendingRequest?.requestId!==R&&(s.operation==="get"||!c||s.operation==="close"||!["running","waiting"].includes(m.run.status))?R:void 0,V=i?.requestId===_?i:p?.requestId===_?p:void 0;e?.bind({scope:m.scope,runId:m.run.id,funnelId:m.run.source.id,versionId:m.run.source.versionId});let l=m.run.paywall,v=l??m.purchase,P=v?.operation,E=m.settlement&&(!l||l.purchaseRequestId===m.settlement.requestId)&&(!o||o.operationId===m.settlement.operationId)?m.settlement:void 0,S=P?.operationId??v?.quote?.operationId??E?.operationId,F=v?.receiptId??E?.receiptId,w=l?.selectionGeneration??o?.generation??0;if(e&&S&&F&&s.operation!=="review"&&(!t.view||m.run.revision>=t.view.revision)&&(C===void 0||C>=t.readSequence)&&(!o||w>=o.generation)){let N={receiptId:F,operationId:S,generation:w},k=an(P,v?.canReselect===!0);await e.observePurchase({scope:m.scope,runId:m.run.id,funnelId:m.run.source.id,versionId:m.run.source.versionId},N,k,_),t.assertCurrent(x),(!o||N.generation>=o.generation)&&(C===void 0||C>=t.readSequence)&&(k?o?.operationId===N.operationId&&(o=void 0):o=N)}else e&&_&&await e.settle(_);return t.assertCurrent(x),_?O(V):!1},stop(){c=!0},submit:h,settle:T,reset(){c=!0,i=null,p=null,o=void 0,g=null,d.close=null,a.clear(),d.command=null}}}function Xn(e){e={...e};let t=e.initialResponse;delete e.initialResponse;let u=e.funnelExecutionPolicy&&structuredClone(e.funnelExecutionPolicy);if(!e.customerRun&&(typeof e.runToken!="string"||!/^gg_fr_[A-Za-z0-9_-]{43}$/.test(e.runToken)))throw new f("INVALID_TOKEN","Run credential required");if(e.customerRun&&(!e.session||!e.scope||!e.funnelId||!e.funnelCommandStorage||e.serverKey))throw new f("INVALID_REQUEST","Customer recovery requires its scoped session and durable journal");if(e.serverKey&&(typeof window<"u"||!Ee.test(e.serverKey)))throw new f("SERVER_ONLY","Run Server-Key proof belongs to the merchant backend");if(e.serverKey&&e.session)throw new f("INVALID_REQUEST","Choose Customer session or Server-Key proof for this Run");let r=ne({...e,session:void 0,timeoutMs:e.timeoutMs??35e3}),i=Rn(e.funnelId,e.scope??e.configuration?.scope),p=e.session?.subscribeIdentity(b),c=null,d=e.funnelCommandStorage??(!e.customerRun&&typeof window<"u"&&window.isSecureContext?un(e):void 0),a=d&&xn(d),o=Fn({journal:a,state:i,call:T,processIdentity:e.process}),g=0,y=new Map;function I(){g++,y.clear(),t=void 0}async function h(l){let v=l.operation==="resume"?o.pending?.operation==="resume"?null:o.pending:l;if(u&&l.operation==="resume"&&!v&&l.requestId!==e.customerRun?.startRequestId)throw new f("EXECUTION_POLICY_REFUSED","The original command is required to verify execution permission before resuming");if(v?.operation==="submit"&&v.input.type==="paywall_confirm"){let N=i.view?.paywall;Sn(u,N?.quote?.operationId===v.input.operationId?N.quote:void 0)}if(e.process)return e.process.request(l);let P=i.generation;i.assertCurrent(P);let E=performance.now()+(e.timeoutMs??35e3),S=i.customerToken??("customerToken"in l?l.customerToken:void 0);if(e.session){let N=i.signal,k,K=()=>{},En=new Promise((et,Ce)=>{K=()=>Ce(N.reason),N.addEventListener("abort",K,{once:!0}),k=setTimeout(()=>Ce(new f("TIMEOUT","The request timed out")),Math.max(1,E-performance.now()))});try{S=await Promise.race([Promise.resolve().then(()=>(i.assertCurrent(P),e.session.access())),En])}finally{clearTimeout(k),N.removeEventListener("abort",K)}}i.assertCurrent(P);let F={...l,...S?{customerToken:S}:{}},w=l.operation==="page_experiments"?ye.parse(F):U.parse(F);if(e.customerRun){if(e.session?.snapshot()?.customerId!==e.customerRun.customerId||!S)throw new f("IDENTITY_CHANGED","Original recovery Customer changed");let N={...w};return"customerToken"in N&&delete N.customerToken,r.requestWithCredential("funnels",{operation:"run_command",runId:e.customerRun.runId,funnelId:e.funnelId,command:N},S,{timeoutMs:Math.max(1,E-performance.now())})}return r.requestWithCredential("funnels",w,e.runToken,{headers:e.serverKey&&!S?{[cn]:e.serverKey}:void 0,timeoutMs:Math.max(1,E-performance.now())})}function b(){I(),p?.(),i.reset(),o.reset(),c=null,r.dispose()}async function T(l,v){let P=t;t=void 0;let E=i.generation,S=()=>i.assertCurrent(E);a&&await o.ready,S();let F=i.view,w=hn(e,P!==void 0&&l.operation==="get"&&!l.data&&!l.purchase&&!l.settlementRequestId?P:await h(l));if(l.operation==="review"&&!w.review)throw new f("INVALID_RESPONSE","Historical projection is missing");if(e.customerRun&&w.run.id!==e.customerRun.runId)throw new f("INVALID_RESPONSE","Original recovery Run changed");if(l.operation==="get"&&l.purchase&&w.purchase&&(w.purchase.receiptId!==l.purchase.receiptId||(w.purchase.operation?.operationId??w.purchase.quote?.operationId)!==l.purchase.operationId))throw new f("INVALID_RESPONSE","The requested original purchase changed");if(S(),w.runToken&&w.runToken!==e.runToken)throw new f("INVALID_RESPONSE","Run credential changed");let N=l.operation==="get"?l.settlementRequestId:"requestId"in l&&l.operation!=="start"?l.requestId:void 0;if(N&&w.settlement?.requestId!==N)throw new f("INVALID_RESPONSE","Exact command settlement is missing or belongs to another command");o.assertBinding(w),i.assertRun(w.run),i.bindScope(w.scope);let k=await o.observe(l,w,E,v);return(!i.view||w.run.revision>=i.view.revision)&&(v===void 0||v>=i.readSequence)&&(await e.onAcceptedResponse?.(w),S()),!w.run.stopped&&["running","waiting"].includes(w.run.status)&&l.operation==="get"&&l.settlementRequestId||(S(),["running","waiting"].includes(w.run.status)||o.stop(),i.publish(l,w,F,v,k)),w}function O(l){let v=i.generation;I();let P=l(),E=()=>{i.generation===v&&I()};return P.then(E,E),P}let s=l=>O(()=>o.submit(l)),m=null,x=new WeakMap;function C(l){let v=x.get(l);if(v)return v;let P=_(l);return x.set(l,P),P}let R=!1;async function _(l){let v=await l;if(v.run.instruction?.type!=="evaluate_segment")return v;if(m)return m;R=!0;let P=i.generation,E=(async()=>{for(let S=0;S<32&&v.run.instruction?.type==="evaluate_segment";S++){if(o.pending||o.closeRequested)return v;let F=v.run;if(v.run.instruction?.type==="evaluate_segment"){let{advance:N}=await Fe(e.configuration,F,{predict:!1});if(P!==i.generation)throw new f("IDENTITY_CHANGED","Run identity changed during segment calculation");if(o.pending||o.closeRequested)return v;if(i.view&&(i.view.revision!==F.revision||i.view.visit!==F.visit||i.view.nodeId!==F.nodeId))return T({operation:"get"});let k=!0;Fe(e.configuration,F).then(({prediction:K})=>{k&&P===i.generation&&!o.closeRequested&&i.view?.id===F.id&&!i.view.stopped&&i.view.nodeId===F.nodeId&&i.view.visit===F.visit&&i.view.revision===F.revision&&(c=K)}).catch(()=>{});try{v=await s({operation:"commit_segment",requestId:dn(F.id,F.visit,`segment:${F.revision}`),nodeId:F.nodeId,visit:F.visit,revision:F.revision,...N})}finally{k=!1,c=null}}}return v})();m=E;try{return await E}finally{m===E&&(m=null)}}let V={get configuration(){return R?e.configuration:void 0},get configurationReady(){return!0},get view(){let l=i.currentView;return l?structuredClone(l):null},get viewAgeMs(){return i.viewAgeMs},get pendingCommand(){let l=o.closing??o.pending;return l?structuredClone(M(l)):null},get pendingCommands(){return[o.pending,o.closing].filter(l=>l!==null).map(l=>structuredClone(M(l)))},get pendingPurchase(){return o.purchase?structuredClone(o.purchase):null},get hasDurableJournal(){return a!==void 0},get prediction(){let l=i.view;return c&&l&&!l.stopped&&["running","waiting"].includes(l.status)&&l.id===c.runId&&l.nodeId===c.from.nodeId&&l.visit===c.from.visit&&l.revision===c.from.revision&&!o.closeRequested?structuredClone(c):null},settle:(...l)=>O(()=>o.settle(...l)),get webViewUrl(){return"bundled"},resolvePaywall(l){return on(e,l)},async pageExperiments(l,v=[]){let P=i.generation;i.assertCurrent(P);let E=i.view?.id;if(!E)throw new f("INVALID_REQUEST","Read the Run before its page experiments");let S=mn.parse(await h(ye.parse({operation:"page_experiments",release:l,usedReceiptIds:v})));if(i.assertCurrent(P),S.runId!==E||S.scope.projectId!==i.scope?.projectId||S.scope.environment!==i.scope?.environment)throw new f("SCOPE_MISMATCH","Page experiment Run changed");return S},review(l){return T({operation:"review",...l?{receiptId:l}:{}},i.nextRead())},async get(l,v){let P=i.generation;l=l&&structuredClone(l),v=v&&{...v},a&&await o.ready,i.assertCurrent(P),v??=o.purchase&&{receiptId:o.purchase.receiptId,operationId:o.purchase.operationId};let E=JSON.stringify([i.generation,g,l??null,v??null]),S=y.get(E);if(S)return S.then(k=>structuredClone(k));let F=i.nextRead(),w=C(T({operation:"get",...l?{data:l}:{},...v?{purchase:v}:{}},F));y.set(E,w);let N=()=>{y.get(E)===w&&y.delete(E)};return w.then(N,N),w.then(k=>structuredClone(k))},resume(l=i.view?.pendingRequest?.requestId){return l?o.closeRequested?V.settle(l):o.pending?.requestId===l?C(s(o.pending)):C(s({operation:"resume",requestId:l})):Promise.reject(new f("INVALID_REQUEST","No interrupted command is available"))},submit(l){return C(s(l))},async retry(){if(o.closeFlight)return o.closeFlight;if(o.closing)return s(o.closing);if(o.closeRequested&&o.pending)return V.settle(o.pending.requestId);if(o.inFlight)return C(o.inFlight);if(!o.pending)throw new f("INVALID_REQUEST","No command is pending");let l=o.pending;if(l.operation==="submit"&&l.input.type==="paywall_quote"){let v=i.generation;if(await V.settle(l.requestId),i.assertCurrent(v),!o.pending)return V.get();if(o.pending!==l||o.closeRequested)throw new f("COMMAND_PENDING","The original quote is being recovered")}return C(s(l))},identify(l){let v=i.customerToken?void 0:t;I(),i.identify(l),t=v,c=null,r.reset()},get identitySignal(){return i.signal},subscribe:i.subscribe,reset:b};return V}function vo(e,t){return Xn({...e,runToken:"",initialResponse:t})}export{dn as a,sn as b,Nn as c,me as d,Tn as e,ln as f,Dn as g,Gt as h,Ut as i,Bt as j,ye as k,mn as l,te as m,qn as n,er as o,hr as p,wr as q,hn as r,Se as s,Cr as t,Zn as u,bn as v,Z as w,un as x,Cn as y,jr as z,ie as A,Ee as B,$r as C,Hr as D,Sn as E,Xn as F,vo as G};
|
package/dist/chunk-JOIPLLHK.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as ie,d as Q,k as Y,o as ee,p as te,q as ne,t as O,v as re,z as oe}from"./chunk-GLYFT5WW.js";import{a as F}from"./chunk-35VG2IYD.js";import{B as k,H as h,I as D,J as C,K as A,ca as ae,e as J,j as Z,l as W,p as I,q as S,s as R,v as X,x as w,y as P,z as H}from"./chunk-QHJWVLJC.js";import{a as T,f as K}from"./chunk-XE7GU6FZ.js";import{b as j}from"./chunk-DHT3AWJQ.js";import{b as e}from"./chunk-ZYN4CRHS.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()}),Je=Object.freeze({eventsEnabled:!0,experimentViewsEnabled:!0,featureUsageEnabled:!0});function Ke(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),xe=e.strictObject({attribute:e.string().optional(),seed:e.string(),hashVersion:e.literal(2),ranges:e.array(z).max(100)}),ve=e.strictObject({id:e.string().min(1).max(255),condition:C,gate:e.boolean().optional()}),Se=e.strictObject({key:e.string().optional(),name:e.string().optional(),passthrough:e.boolean().optional()}),se={condition:C.optional(),parentConditions:e.array(ve).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(xe).max(100).optional(),ranges:e.array(z).max(20).optional(),meta:e.array(Se).max(20).optional(),seed:e.string().optional(),name:e.string().optional(),phase:e.string().optional()},ce=e.strictObject({...se,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()}),we=e.strictObject({...se,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:ce,result:G})).max(100).optional()}),Oe=e.strictObject({defaultValue:h.optional(),rules:e.array(we).max(500).optional()}),je=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(),Oe),savedGroups:je,experiments:e.record(e.uuid(),ce)});var Ie=v.extend({analyticsConfig:V,remoteFeatures:e.array(e.string().min(1).max(255)).max(500)}),rt=Ie.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"})}),ot=e.strictObject({attributes:D,features:e.array(e.string().min(1).max(255)).max(500).optional(),customerId:e.uuid().optional()}),pe=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()}),it=e.strictObject({generation:v.shape.generation,evaluatedAt:v.shape.evaluatedAt,expiresAt:v.shape.expiresAt,features:e.record(e.string(),pe),merchandiseContext:e.strictObject({merchandiseId:e.uuid(),merchandise:D}).optional()}),le={eventUuid:e.uuid(),timestamp:e.iso.datetime({offset:!0}),merchandise:Y.optional(),deviceId:e.string().min(1).max(255).optional(),sessionId:e.string().min(1).max(255).optional()},ue={...le,generation:v.shape.generation},Pe=e.discriminatedUnion("kind",[e.strictObject({...le,kind:e.literal("custom"),name:e.string().min(1).max(255),properties:e.record(e.string(),h).default({})}),e.strictObject({...ue,kind:e.literal("experiment_exposure"),experimentId:e.string().min(1).max(255),variationId:e.string().min(1).max(255)}),e.strictObject({...ue,kind:e.literal("feature_usage"),feature:e.string().min(1).max(255),value:h,source:pe.shape.source,ruleId:e.string().max(255),variationId:e.string().min(1).max(255).optional()})]),at=e.strictObject({customerId:e.uuid().optional(),events:e.array(Pe).min(1).max(100)}),ke=e.strictObject({eventUuid:e.uuid(),reason:e.enum(["invalid_event","invalid_merchandise","not_delivered","reserved_name"])}),st=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(ke).max(100),analyticsConfig:V});function me(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&&oe(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 he of x.tracks??[])u(he.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 de=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:")})]),Ce=P,Ae=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:Ce,buttons:e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Ae)}).strict(),jt=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 Ee(t))r.addIssue({code:"custom",message:o});for(let o of Fe(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"'})}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 Fe(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 Ee(t){let r=[],a=t.screen.pages.at(-1),o=new Map;for(let f of t.screen.pages)o.set(f.id,[]),H(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 fe=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(),It=e.object({rows:e.array(fe).max(200),nextCursor:e.uuid().nullable()}).strict(),Pt=fe.omit({draft:!0}).extend({name:e.string(),productCount:e.number().int().nonnegative()}).strict(),kt=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()]),Ct=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 _e=["customer_data","coupon_code"],ge=e.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/),Re=e.string().min(1).max(255).regex(/^[a-z0-9][a-z0-9-]*$/),_=(t,r)=>new Set(t.map(r)).size===t.length,De=e.strictObject({currency:T,amountMinor:e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)}),Ve=e.strictObject({featureId:e.uuid(),name:e.string().trim().min(1).max(120),allowance:e.string().max(40).nullable(),access:e.boolean()}),ze=e.strictObject({stripe:e.strictObject({prices:e.array(De).min(1).max(50)}).optional(),apple:e.strictObject({productIds:e.array(ge).min(1).max(10)}).optional(),google:e.strictObject({products:e.array(e.strictObject({productId:ge,basePlanId:Re.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"})}),Ge=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(Ve).max(50).refine(t=>_(t,r=>r.featureId),"Duplicate benefit"),channels:ze,prepaid:e.array(J).max(100).optional()}),Me=e.strictObject({digest:O,content:e.strictObject({discount:ee,duration:te,appliesTo:ne,displayCopy:de.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()})}),qe=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})]),Nt=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(),Ge),buttons:e.record(X,qe),coupons:e.record(e.uuid(),Me)}).superRefine((t,r)=>{let a=n=>r.addIssue({code:"custom",message:n}),{screen:o}=t;ae(o,t.catalog).forEach(a),o.surface!=="paywall"&&a("Screen must be a Paywall"),re(o,_e).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")}),ye=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 Be={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),Ne=j.extend({environmentId:e.uuid()}),be=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)}),$e=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(Be.maxArtifactBytes),generation:q.optional()}),Le=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:be,definitionDigest:O.optional(),couponDigests:e.record(e.uuid(),O).optional()}))}),Qt=e.strictObject({kind:e.literal("sdk_configuration"),schemaVersion:e.literal(1),scope:Ne,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(),$e),funnels:e.record(e.uuid(),Le),paywalls:e.record(e.uuid(),ye).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 Ue(t){return L(U(typeof t=="string"?new TextEncoder().encode(t):t))}function Yt(t){return Ue(N(t))}var $=class extends Error{constructor(a,o){super(a);this.dependency=o}dependency};function en(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=me(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||!Q(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 be.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 tn(t){return ie.parse(t)}export{E as a,Ke as b,ce as c,je as d,v as e,Ie as f,rt as g,ot as h,it as i,at as j,st as k,me as l,Nt as m,Be as n,Ne as o,$e as p,Qt as q,N as r,Ue as s,Yt as t,en as u,tn as v};
|
package/dist/chunk-OL2AI6DA.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as Vn,b as Mn,c as ln,d as un,e as Me,f as Un,h as $n,i as xn,j as Gn,k as Qn}from"./chunk-I6D25FWU.js";import{b as Jn}from"./chunk-DB4EO3JG.js";import{b as En,c as zn}from"./chunk-VWMFR22O.js";import{a as On}from"./chunk-W32FI2A2.js";import{c as Sn,e as An,f as _n,h as Ln,i as Ae,j as Ze,k as Hn,l as Ke}from"./chunk-YQX27SBG.js";import{aa as Xe}from"./chunk-GLYFT5WW.js";import{a as Ve,d as qn}from"./chunk-3NCMYTNG.js";import{b as Pn}from"./chunk-35VG2IYD.js";import{a as Dn,c as kn,d as Tn,e as Nn,f as Fn}from"./chunk-CGXNU5BC.js";import{E as Cn,da as Rn}from"./chunk-QHJWVLJC.js";import{a as w}from"./chunk-TIQS5DUF.js";import{a as be}from"./chunk-DSPLGTQI.js";async function dn(t){let{session:I,load:C}=tt(t);try{return await C(),I}catch(e){throw I.destroy(),e}}function tt(t){let I=t.view;if(!I?.paywall)throw new w("INVALID_REQUEST","The current node is not a Paywall");let C=I.paywall.receiptId,e=I.nodeId,m=I.visit,k=I.paywall.resolution,o=I.paywall,F="document"in k?{document:k.document,offering:k.offering,capabilities:k.capabilities}:null;function c(){let i=o.resolution;return"document"in i?i:F&&{...i,document:F.document,offering:F.offering,capabilities:Dn(i.capabilities,F.capabilities)}}function b(i){if(!kn(i,k))throw new w("INVALID_RESPONSE","The pinned Paywall binding changed")}let P=!1,M=new Set,ne=null;function f(){let i=c();if(i&&!P)for(let u of M)be(u,structuredClone(i))}async function L(){T();let i=c();if(i)return structuredClone(i);if(!ne){let u=(async()=>{if("document"in o.resolution||!t.resolvePaywall)throw new w("INVALID_RESPONSE","Public Paywall reader is unavailable");let g=await En(t,o.resolution);return T(),b(g),F={document:g.document,offering:g.offering,capabilities:g.capabilities},f(),c()})();ne=u;let a=()=>{ne===u&&(ne=null)};u.then(a,a)}return ne.then(u=>structuredClone(u))}let s=new AbortController,O=(t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])).find(i=>i.operation==="submit"&&i.nodeId===e&&i.visit===m&&i.input.type==="paywall_quote")?.requestId??I.paywall.purchaseRequestId,Y=0,Q=null,G=new Set,E=null,J=new Map;function D(i){if(i.purchase&&i.purchase.receiptId!==C)throw new w("INVALID_RESPONSE","Purchase receipt changed");let u=i.run.paywall;return i.purchase??(u?.receiptId===C?u:null)}function T(){if(P)throw new w("IDENTITY_CHANGED","Paywall presentation has closed")}function N(i,u,a){if(T(),u!==Y||a!==void 0&&o.quote?.operationId!==a)return!1;let g=o.selectionGeneration??0,d=i.run.paywall;if(d?.receiptId===C){if((d.selectionGeneration??0)<(o.selectionGeneration??0))return!1;b(d.resolution)}let l=D(i),H=d?.receiptId===C&&(d.selectionGeneration??0)>g,V=H?l?.quote??null:l?.quote??o.quote,S=l?.operation??(V?.operationId===o.quote?.operationId?o.operation:null);return V&&S&&Tn(S,{operationId:V.operationId},"Purchase operation changed"),(H||V?.operationId!==o.quote?.operationId)&&(Y++,d?.receiptId===C&&(O=d.purchaseRequestId)),d?.canReselect===!0&&d.purchaseRequestId===E&&!(t.pendingCommands??[t.pendingCommand]).some(te=>te?.requestId===E)&&(E=null),o={...o,...d?.receiptId===C?d:{},...a!==void 0&&!H&&l?.canReselect!==void 0?{canReselect:l.canReselect}:{},quote:V,operation:Fn(o.operation,S,!0)},f(),!0}function ce(i,u,a){return new Promise((g,d)=>{let l=!1,H=()=>{clearTimeout(ke),s.signal.removeEventListener("abort",te)},V=Re=>{l||(l=!0,H(),g(Re))},S=Re=>{l||(l=!0,H(),d(Re))},te=()=>S(new w("IDENTITY_CHANGED","Paywall presentation has closed")),ke=setTimeout(()=>S(new w("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,a)),Math.max(0,u-Date.now()));s.signal.addEventListener("abort",te,{once:!0}),s.signal.aborted&&te(),i.then(V,S)})}function pe(i){return new Promise(u=>{let a=()=>{clearTimeout(g),s.signal.removeEventListener("abort",a),u()},g=setTimeout(a,i);s.signal.addEventListener("abort",a,{once:!0}),s.signal.aborted&&a()})}function B(i,u){T();let a=J.get(i)??t.pendingCommands?.find(l=>l.requestId===i)??t.pendingCommand;if(a?.operation==="submit"&&a.requestId===i&&a.nodeId===e&&a.visit===m){u.type==="paywall_quote"&&a.input.type==="paywall_quote"&&a.input.predecessor&&!u.predecessor&&(u={...u,predecessor:a.input.predecessor});let l=Xe.parse(a),H=Xe.parse({...a,input:u});if(l.operation!=="submit"||H.operation!=="submit"||JSON.stringify(l.input)!==JSON.stringify(H.input))throw new w("CONFLICT","A purchase request cannot change its input");return J.set(i,l),l}let g=t.view;if(!g||g.nodeId!==e||g.visit!==m||g.paywall?.receiptId!==C)throw new w("PRECONDITION_FAILED","The Paywall visit has changed");let d=Xe.parse({operation:"submit",requestId:i,nodeId:e,visit:m,revision:g.revision,input:structuredClone(u)});if(d.operation!=="submit")throw new w("INVALID_REQUEST","A purchase submission is required");return J.set(i,d),d}async function Ce(i,u){T();let{requestId:a,input:g}=i,d=Date.now()+3e4;G.add(a);try{let l=await ce(t.submit(i),d,a);for(;l.run.pendingRequest?.requestId===a&&Date.now()<d&&!P&&(await pe(Math.min(1e3,d-Date.now())),!(P||Date.now()>=d));)l=await ce(t.resume(a),d,a);if(P)throw new w("IDENTITY_CHANGED","Paywall presentation has closed");if(l.run.pendingRequest?.requestId===a)throw new w("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,a);if(!N(l,u,g.type==="paywall_confirm"||g.type==="paywall_cancel"?g.operationId:void 0))throw new w("PRECONDITION_FAILED","The purchase selection has changed");E===a&&(E=null)}catch(l){if(E=a,g.type==="paywall_quote"&&t.settle&&!P&&l instanceof w&&l.status!==void 0&&![401,425].includes(l.status)&&!l.retryable&&l.recovery!=="recover_operation")try{if((await ce(t.settle(a),d,a)).settlement?.state==="settled"){let V=await ce(t.get(),d,a);N(V,u)&&V.run.paywall?.purchaseRequestId===a&&o.canReselect===!0&&J.delete(a)}}catch{}throw l instanceof w&&l.code==="COMMAND_PENDING"&&l.status===void 0&&J.delete(a),l}finally{G.delete(a)}}async function X(i){if(!o.quote)throw new w("INVALID_REQUEST","A quoted purchase is required");let u=i==="confirm"?"paywall_confirm":"paywall_cancel",a=[...J.values(),...t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])].find(d=>d.operation==="submit"&&d.input.type===u&&"operationId"in d.input&&d.input.operationId===o.quote.operationId),g=a?.operation==="submit"&&a.input.type===u&&"operationId"in a.input&&a.input.operationId===o.quote.operationId?a.requestId:crypto.randomUUID();if(await Ce(B(g,{type:i==="confirm"?"paywall_confirm":"paywall_cancel",operationId:o.quote.operationId}),Y),!o.operation)throw new w("INVALID_RESPONSE","The accepted purchase result is missing");return structuredClone(o.operation)}let U={get view(){return structuredClone(c())},get quote(){return o.quote?structuredClone(o.quote):null},get operation(){return o.operation?structuredClone(o.operation):null},get webViewUrl(){return t.webViewUrl},get locale(){return t.view?.locale??I.locale},get canReselect(){return o.canReselect===!0&&E===null},get recovery(){let i=t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[]),u=t.pendingPurchase;if(u&&(u.receiptId!==C||u.operationId!==o.quote?.operationId))return{type:"recover",operationId:u.operationId,requestId:i[0]?.requestId??null};let a=Ve({quote:o.quote,operation:o.operation,requestId:i[0]?.requestId??E??O,pending:G.size>0||i.length>0||E!==null,destroyed:P,canReselect:o.canReselect});return a.type==="recover"&&a.requestId===null&&!P&&t.hasDurableJournal===!0&&!o.quote&&!o.operation&&(o.selectionGeneration??0)===0&&!u&&!i.length&&!G.size&&!O?{type:"native",operationId:null}:a},get pendingCancellation(){return!P&&(t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])).some(i=>i.operation==="submit"&&i.nodeId===e&&i.visit===m&&i.input.type==="paywall_cancel"&&i.input.operationId===o.quote?.operationId)},subscribe(i){return P?()=>{}:(M.add(i),()=>M.delete(i))},async refresh(){T();let i=Y,u=await t.get();if(N(u,i),u.run.paywall?.receiptId!==C)throw new w("PRECONDITION_FAILED","Paywall presentation has changed");return L()},preview(i){let u=c();if(!u)return Promise.reject(new w("PRECONDITION_FAILED","Load the Paywall presentation first"));if(O&&O!==i.requestId&&(Q||o.canReselect!==!0))return Promise.reject(new w("COMMAND_PENDING","Retry the original purchase before starting another"));let a=u.document.buttons[i.actionId],g=a?.type==="checkout"?Pn(a.product,i.selection,u.capabilities):null;if(!g)return Promise.reject(new w("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));let d=Rn(u.document.screen,g,i.selection,u.capabilities),l=O!==i.requestId&&(o.selectionGeneration??0)>0?{operationId:o.quote?.operationId??null,generation:o.selectionGeneration??0}:void 0;if(l&&o.canReselect!==!0)return Promise.reject(new w("COMMAND_PENDING","Original purchase requires authoritative termination"));let H;try{H=B(i.requestId,{type:"paywall_quote",actionId:i.actionId,productVersionId:g,...Object.keys(d).length?{featureQuantities:d}:{},...l?{predecessor:l}:{},...i.offerId?{offerId:i.offerId}:{},...i.nativeOffer?{nativeOffer:i.nativeOffer}:{}})}catch(te){return Promise.reject(te)}if(O===i.requestId&&Q)return Q;O!==i.requestId&&Y++;let V=Y;O=i.requestId;let S=(async()=>{if(await Ce(H,V),!o.quote)throw new w("INVALID_RESPONSE","The accepted quote is missing");return Nn(o.quote,{productVersionId:g,featureQuantities:d},"The selected purchase changed"),structuredClone(o.quote)})();return Q=S,S.then(()=>{Q===S&&(Q=null)},te=>{Q===S&&(Q=null),O===i.requestId&&t.pendingCommand?.requestId!==i.requestId&&te instanceof w&&te.status!==void 0&&te.status<500&&![401,425].includes(te.status)&&(O=null)}),S},confirm:()=>X("confirm"),cancel:()=>X("cancel"),async read(){if(T(),!o.quote)throw new w("INVALID_REQUEST","A quoted purchase is required");let i=o.quote.operationId,u=Y,a=t.pendingCommands?.find(V=>V.operation==="submit"&&(V.input.type==="paywall_confirm"||V.input.type==="paywall_cancel")&&V.input.operationId===i)??t.pendingCommand;a?.operation==="submit"&&(a.input.type==="paywall_confirm"||a.input.type==="paywall_cancel")&&a.input.operationId===i&&await t.settle?.(a.requestId);let g=await t.get(void 0,{receiptId:C,operationId:i});T();let d=D(g);if(d?.quote&&d.quote.operationId!==i||d?.operation&&d.operation.operationId!==i)throw new w("INVALID_RESPONSE","Purchase operation changed");let l=N(g,u,i),H=l?o.operation:d?.operation;if(!H)throw new w("INVALID_RESPONSE","The current purchase result is missing");return l&&G.size===0&&!(t.pendingCommands?.length??(t.pendingCommand?1:0))&&(E=null),structuredClone(H)},destroy(){P=!0,j(),M.clear(),s.abort(),J.clear()}},j=t.subscribe(i=>{P||i.nodeId!==e||i.visit!==m||i.paywall?.receiptId!==C||(i.paywall.selectionGeneration??0)<(o.selectionGeneration??0)||(b(i.paywall.resolution),o={...o,resolution:i.paywall.resolution},f())});return{session:U,load:L}}function Bn(t){let I=new Set,C=new Set,e=null;async function m(c,b){let P=!1;for(;!t.stopped&&t.key===c&&t.client.pendingCommand?.requestId===b;){if(!t.client.settle)throw new w("COMMAND_PENDING","The original display acknowledgement is still pending");await t.client.settle(b),P=!0,t.client.pendingCommand?.requestId===b&&await new Promise(M=>setTimeout(M,1500))}t.stopped||t.key!==c||(P&&await t.client.get(),!(t.stopped||t.key!==c)&&I.add(c))}function k(c,b){e=b;let P=()=>{e===b&&(e=null),C.delete(c)};return b.then(P,M=>{P(),t.busy||t.fail(M)}),b}function o(c){if(t.reviewing||I.has(c)||C.has(c)||t.stopped)return;C.add(c);let b=async()=>{if(t.reviewing||t.stopped||t.key!==c||I.has(c)){C.delete(c);return}if(t.busy||t.client.pendingCommand){setTimeout(()=>{b()},250);return}let P=(async()=>{if(t.staleRead){if(await t.staleRead,t.stopped||t.key!==c)return;if(t.client.pendingCommand){setTimeout(()=>{b()},250);return}}let M=t.client.view,ne=t.expected(),f=ne.requestId;try{await t.client.submit({operation:"shown",...ne})}catch(L){if(!(L instanceof w)||L.code!=="CONFLICT"||L.status!==409||t.client.pendingCommand)throw L;await t.client.get();let s=t.client.view;if(t.stopped||t.reviewing||t.key!==c||!s||!M||s.id!==M.id||s.source.versionId!==M.source.versionId||s.nodeId!==ne.nodeId||s.visit!==ne.visit||s.revision<=ne.revision||s.stopped||!s.screen&&(!s.paywall||s.paywall.receiptId!==M.paywall?.receiptId)||!["running","waiting"].includes(s.status)||t.client.pendingCommand)throw L;let R=t.expected();f=R.requestId,await t.client.submit({operation:"shown",...R})}await m(c,f)})();k(c,P)};b()}function F(){if(e)return e;let c=t.client.pendingCommand;if(c?.operation!=="shown")return null;let b=t.key;return C.add(b),k(b,(async()=>{await t.client.retry(),await m(b,c.requestId)})())}return{report:o,settled:F,get inFlight(){return e}}}function jn(t){let I={},C=new Map;async function e(m){let k=t.client.view,o=k?.screen,F=o?.customerData.nodes[m.nodeId];if(t.stopped||t.busy||!k||!o||!F)return;if(!["refresh","next","previous","filter","sources_next","sources_previous"].includes(m.action)){let L=t.document,s=L?Cn(L,m.nodeId):null,R=s?.type==="customer_data"?s.data.outputs?.[m.action]:void 0;R&&o.outputs.includes(R)?await t.perform(()=>t.client.submit({operation:"submit",...t.expected(),input:{type:"screen",output:R,answers:t.answers,selection:m.value?{[m.nodeId]:m.value}:{}}})):await t.onIntent?.(m,k);return}let b=m.action.startsWith("sources_")?F.resources.find(L=>L.key===m.value):null;if(m.action.startsWith("sources_")&&!b)throw new w("INVALID_REQUEST","Choose a current resource");let P=`${k.visit}:${m.nodeId}:${b?.key??""}`,M=C.get(P)??[null],f=I[m.nodeId]??{page:1,after:null,filter:"all",...b?{resourceKey:b.key}:{}};if(m.action==="filter"){let L=m.value;if(!L||!(F.source==="offer_history"?["all","issued","reserved","redeemed","expired","revoked"]:["all","purchase","refund","source","usage","debt","settlement"]).includes(L))throw new w("INVALID_REQUEST","Unknown data filter");f={page:1,after:null,filter:L},M.splice(0,M.length,null)}else if(m.action==="next"||m.action==="sources_next"){let L=b?.sources.at(-1),s=b?L?{kind:"ledger",cursor:{at:L.detail[0],id:L.id,type:"source"}}:null:o.dataCursors[m.nodeId];if(!s||!b&&!F.hasNext)return;M[f.page]=s,f={...f,page:f.page+1,after:s}}else if(m.action==="previous"||m.action==="sources_previous"){if(f.page<=1)return;f={...f,page:f.page-1,after:M[f.page-2]??null}}C.set(P,M),I={...I,[m.nodeId]:f},await t.perform(()=>t.client.get({nodeId:k.nodeId,visit:k.visit,revision:k.revision,components:I}))}return{get queries(){return I},intent:e,reset(){I={},C.clear()}}}function Wn(t){let{doc:I,holder:C,reviewHolder:e,mountScreenPreview:m}=t,k=!1,o,F=0,c=null,b="",P,M=new Map,ne=s=>s?`${s.id}:${s.nodeId}:${s.visit}:${s.revision}:${s.paywall?.quote?.operationId??""}`:"";async function f(s){if(t.stopped||!t.client.review||k&&s===o&&P?.active)return;let R=!k||s!==o;k||(b=ne(t.client.view),M.set(b,structuredClone(t.answers))),k=!0,o=s,C.hidden=!0,t.suspend(!0),e.hidden=!1;let O=++F;R&&(P?.finish("dismissed"),c?.destroy(),c=null,e.replaceChildren(),P=Ze(e,t.loadingOptions,"funnel",()=>{L()}));let Y=R?P:void 0;try{if(Y?.start(!1,t.client.view?.locale),O!==F||t.stopped)return;let Q=t.client.review(s),G=await(Y?.wait(Q,Ae)??Q);if(t.stopped||O!==F||!k)return;if(!G.review)throw new w("INVALID_RESPONSE","Historical projection is missing");c?.destroy(),c=null,Y||e.replaceChildren();let E=I.createElement("div"),J=Y?Ke(E,e):()=>{};e.append(E);let D=G.run.locale.startsWith("zh"),T=t.chrome;E.style.cssText=T.history;let N=I.createElement("p");N.textContent=D?"\u53EA\u8BFB\u56DE\u770B":"Read-only history",N.style.cssText=T.historyTitle,E.append(N);let ce=I.createElement("p");ce.style.cssText=T.historyNote,ce.textContent=G.review.pages.length?D?"\u9009\u62E9\u4E00\u9875\u67E5\u770B\u5F53\u65F6\u7684\u5185\u5BB9\uFF0C\u56DE\u770B\u4E0D\u4F1A\u6539\u52A8\u4EFB\u4F55\u4FE1\u606F\u3002":"Choose a page to see it as it was. Nothing here can be changed.":D?"\u8FD8\u6CA1\u6709\u53EF\u56DE\u770B\u7684\u9875\u9762\u3002":"There are no earlier pages yet.",E.append(ce);let pe=G.review.page?.receiptId,B=I.createElement("div");B.style.cssText=T.historyPages;for(let[U,j]of G.review.pages.entries()){let i=I.createElement("button");i.type="button",i.textContent=D?`\u7B2C ${U+1} \u9875`:`Page ${U+1}`;let u=pe!==void 0&&j.receiptId===pe;i.style.cssText=u?T.primary:T.secondary,u&&i.setAttribute("aria-current","page"),Me(i,()=>t.chrome.focus),i.onclick=()=>{f(j.receiptId)},B.append(i)}if(B.childElementCount&&E.append(B),G.review.page){let U=G.review.page,j=I.createElement("div");j.inert=!0,j.style.cssText=T.historyPage,E.append(j),c=m(j,{mode:"live",rendererUrl:t.client.webViewUrl,title:U.document.name,onAction:()=>{},onAnswers:()=>{},onCustomerDataIntent:()=>{},onRendered:()=>{O===F&&!t.stopped&&Y?.present(J)},onError:u=>{if(O!==F||t.stopped)return;let a=new Error(u);Y?.finish("error",a),c?.destroy(),c=null,E.remove(),t.fail(a)},onEscape:()=>{L()}});let i=c;if(i.update(U.document,G.run.locale,{serverInput:{bindings:U.inputs,answers:U.answers,values:U.values}}),await i.ready,t.stopped||O!==F||!k)return}let Ce=D?{issued:"\u5DF2\u9886\u53D6",reserved:"\u5DF2\u9884\u7559",redeemed:"\u5DF2\u4F7F\u7528",expired:"\u5DF2\u8FC7\u671F",revoked:"\u5DF2\u64A4\u9500",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4"}:{issued:"Issued",reserved:"Reserved",redeemed:"Used",expired:"Expired",revoked:"Revoked",unknown:"Status unconfirmed"},X=I.createElement("div");X.style.cssText=T.historyRecords;for(let U of[...G.review.coupons.map((j,i)=>`${D?"\u4F18\u60E0\u5238":"Coupon"} ${i+1}: ${Ce[j.status]}`),...G.review.purchases.map((j,i)=>`${D?"\u8D2D\u4E70":"Purchase"} ${i+1}: ${Qn(j.status,D)}`)]){let j=I.createElement("p");j.textContent=U,j.style.margin="0",X.append(j)}X.childElementCount&&E.append(X),G.review.page||Y?.present(J),t.client.view&&await t.enqueue(t.client.view)}catch(Q){if(O!==F||t.stopped)return;Y?.finish("error",Q),c?.destroy(),c=null,e.replaceChildren(),t.fail(Q)}}async function L(){if(!k||t.stopped||!t.client.review)return;let s=++F;P?.finish("dismissed");try{if(await t.client.review(),t.stopped||s!==F)return;k=!1,F++,P?.finish("dismissed"),c?.destroy(),c=null,e.replaceChildren(),e.hidden=!0,C.hidden=!1;let R=t.client.view;ne(R)!==b?(M.set(b,structuredClone(t.answers)),t.resetScreen()):(M.delete(b),t.suspend(!1)),R&&await t.enqueue(R)}catch(R){if(s!==F||t.stopped)return;c?.destroy(),c=null,e.replaceChildren(),t.fail(R)}}return{get active(){return k},get receipt(){return o},open:f,exit:L,get drafts(){return new Map([...M].map(([s,R])=>[s,structuredClone(R)]))},stop(){k=!1,F++,P?.finish("dismissed"),c?.destroy(),c=null,e.replaceChildren(),e.hidden=!0,C.hidden=!1}}}var cn=5e3;async function it(t,I,C){let e=I,m=e.prepared&&Jn(e.prepared),k=()=>{};function o(){e.prepared&&e.prepared.state!=="adopted"&&m?.release()}let F=()=>e.prepared?.state==="shown"&&!!m?.modal,c=e.client.identitySignal,b;try{b=await Promise.all([import("./screen-renderer-B7LUTPTJ.js"),import("./paywall-ATZ2IZPS.js")]),e.signal?.throwIfAborted(),c?.throwIfAborted()}catch(n){throw o(),n}let[{mountScreenPreview:P},{showPaywall:M}]=b,ne=(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&e.appManifestRelease?zn({client:e.client,appManifestRelease:e.appManifestRelease,onError:e.onError}):void 0;ne?.start();let f=t.ownerDocument,L=Ln(f),s=f.createElement("section"),R=f.createElement("div"),O=f.createElement("div"),Y=f.createElement("div"),Q=f.createElement("button");Y.hidden=!0,Q.type="button";let G=f.createElement("p"),E=f.createElement("p"),J=f.createElement("button"),D=f.createElement("button"),T=f.createElement("button"),N=f.createElement("dialog"),ce;s.dataset.indianaFunnel="",s.setAttribute("aria-busy","false"),G.setAttribute("role","status"),E.setAttribute("role","alert"),E.hidden=!0,J.type=D.type=T.type="button",O.append(J,Q,G,E,T,D),s.append(R,Y,O),t.append(s);let pe=Mn,B=ln(pe),Ce="",X=(f.documentElement.lang||"").startsWith("zh"),U,j="",i;for(let n of[J,Q,T,D])Me(n,()=>B.focus);function u(){let n=X?"\u5173\u95ED":"Close";D.parentElement===N?(D.textContent="\xD7",D.setAttribute("aria-label",n),_n(D,pe)):(D.textContent=n,D.removeAttribute("aria-label"),D.style.cssText=B.link+";margin-inline-start:auto")}function a(n){let r=n?.screen?.content.document.theme??pe,p=JSON.stringify([r.primary,r.background,r.text,r.radius,r.font,D.parentElement===N]);if(p===Ce)return;Ce=p,pe=r;let _=D.parentElement===N;B=ln(pe,_),s.style.cssText=B.root+";min-width:0"+(_?";display:flex;flex-direction:column;min-height:100%":""),O.style.cssText=B.bar+(_?";margin-top:auto":""),J.style.cssText=Q.style.cssText=B.secondary,T.style.cssText=B.primary,G.style.cssText=B.status,E.style.cssText=B.alert,u(),un(J)}function g(){O.hidden=J.hidden&&Q.hidden&&T.hidden&&E.hidden&&!G.textContent&&(D.hidden||D.parentElement!==O),U?.responsive&&i!==void 0&&U.setContentHeight(i+O.getBoundingClientRect().height)}a();let d=null,l=null,H=null,V="",S="",te=!1,ke="",Re="",Ue="",h=!1,le=0,$e=!1,pn="",en=null,nn=Promise.resolve(),fn=!e.client.view,z=C,Te,_e,xe="",Ge,ue=!1,Ee=null,he=!1,Qe=()=>e.client.pendingCommand?.operation==="close",de=null,Z=null,mn=On({document:f,run:async()=>{(!l?.observing||e.client.pendingCommand)&&await rn()},delay:()=>{if(!(h||!H||!["running","waiting"].includes(H.status)&&!e.client.pendingCommand)&&!(l?.observing&&!e.client.pendingCommand))return H.pendingRequest||e.client.pendingCommand?1500:cn},hiddenDelay:()=>!h&&e.client.pendingCommand?15e3:void 0}),K=null;function tn(){return Z&&e.client.hasDurableJournal===!0&&K?.acknowledged===!0&&K.operationId===Z.operationId&&e.client.view?.id===K.runId&&e.client.view?.status==="closed"&&e.client.view.revision===K.revision+1&&!(e.client.pendingCommands?.length??(e.client.pendingCommand?1:0))&&!e.client.pendingPurchase?Z:null}function wn(n){let r=n.run.paywall;if(K&&n.settlement?.requestId===K.requestId&&n.settlement.state==="settled"&&n.settlement.operationId===null&&n.run.id===K.runId&&n.run.status==="closed"&&!n.run.pendingRequest&&n.run.revision===K.revision+1&&n.run.nodeId===K.nodeId&&n.run.visit===K.visit&&r?.receiptId===K.receiptId&&r.selectionGeneration===K.selectionGeneration&&(r.quote?.operationId??null)===K.operationId&&(r.operation?.operationId??r.quote?.operationId??null)===K.operationId){let p=K.operationId===null&&r.selectionGeneration===0&&!r.quote&&!r.operation&&!r.purchaseRequestId,_=Ve({quote:r.quote,operation:r.operation,requestId:r.purchaseRequestId,pending:!1,destroyed:!1,canReselect:r.canReselect});(p||r.canReselect===!0&&_.type==="native")&&(K.acknowledged=!0)}}let qe=null,Je=new Set,we={},Ne=!1,fe=(n,r=null)=>{h||(qe=r,Ne=!1,E.textContent=Un(n,X),E.hidden=!1,T.hidden=e.client.pendingCommand===null,g(),be(e.onError,n))},yn=()=>{h||(qe=null,E.textContent=xn(X),E.hidden=!1,T.hidden=!0,g())};function De(){let n=e.client.view;if(!n)throw new w("INVALID_REQUEST","No current Run is available");return{requestId:crypto.randomUUID(),nodeId:n.nodeId,visit:n.visit,revision:n.revision}}let A=Wn({client:e.client,doc:f,holder:R,reviewHolder:Y,mountScreenPreview:P,loadingOptions:e,get chrome(){return B},get stopped(){return h},get answers(){return we},suspend(n){l?.setSuspended(n)},resetScreen(){V="",S="",ke=""},enqueue:ye,fail:fe}),Le=Bn({client:e.client,expected:De,fail:fe,get stopped(){return h},get reviewing(){return A.active},get key(){return V},get busy(){return le},get staleRead(){return en}}),ze=jn({client:e.client,expected:De,perform:Oe,onIntent:e.onCustomerDataIntent,get stopped(){return h},get busy(){return le},get document(){return d?.document},get answers(){return we}}),Be=n=>`${n.id}:${n.nodeId}:${n.visit}`,Fe=n=>n&&(n.screen||n.paywall)?Be(n):"";function Pe(){let n=e.client.view;J.disabled=!A.active&&(le>0||!!e.client.pendingCommand||!n?.canBack||n.stopped||!["running","waiting"].includes(n.status)||!Fe(n)||S!==Fe(n)),J.hidden=!A.active&&!n?.canBack,un(J);let r=!!l&&!A.active;D.hidden=r&&!z?.active,Q.hidden=!e.client.review||r&&!n?.canBack,r&&(G.textContent=""),g()}async function gn(n){if(!n)return;let r=e.client.view;await n;let p=e.client.view;if(!r||!p||p.id!==r.id||p.nodeId!==r.nodeId||p.visit!==r.visit||p.stopped||!["running","waiting"].includes(p.status))throw new w("PRECONDITION_FAILED","The screen changed while its display was acknowledged")}async function Oe(n,r=!1,p){if(!((le||he||de||Z)&&!r||h||A.active&&!r)){le++,s.setAttribute("aria-busy","true"),E.hidden=!0,qe=null,Ne=!1,Pe();try{if(r||await gn(Le.inFlight),h)return;let _=await n();h||await ye(e.client.view??_.run)}catch(_){p?.(_)&&e.client.pendingCommand===null?yn():fe(_,e.client.pendingCommand?.requestId??null)}finally{le=Math.max(0,le-1),s.setAttribute("aria-busy",String(le>0)),h||(T.hidden=e.client.pendingCommand===null,Pe())}}}function He(){mn.schedule()}async function rn(){if(!(h||$e||le)){if(A.active){await A.open(A.receipt);return}$e=!0;try{let n=e.client.pendingCommand;n&&e.client.settle&&await e.client.settle(n.requestId);let r=e.client.view,p=ze.queries,_=await e.client.get(r?.screen&&Object.keys(p).length?{nodeId:r.nodeId,visit:r.visit,revision:r.revision,components:p}:void 0);Ne&&!h&&(Ne=!1,E.hidden=!0,g()),!h&&p===ze.queries&&await ye(e.client.view??_.run)}catch(n){fe(n),Ne=!h}finally{$e=!1}}}function je(n,r,p){if(z?.active){let ae=z;return ae.setDismissHandler(()=>hn(ae)),ae}let _=Ze(t,e,"funnel",()=>hn(_),Vn);return z=_,_.start(n,r,p),_}function hn(n){h||ue||(ue=!0,n.finish("dismissed"),ve(),s.hidden=!0,e.client.view?Ie().finally(re):re())}function on(){clearTimeout(Ge?.timeout),Ge=void 0}function ve(){on(),Te?.abort(),Te=void 0,d?.destroy(),d=null,l?.destroy(),l=null,_e?.(),_e=void 0,N.open&&N.close(),R.replaceChildren(),R.style.cssText="",i=void 0,V="",S="",te=!1,ke="",Ue=""}function vn(){let n=f.defaultView;U?.responsive&&n&&d?.resizeViewport?.(n.innerHeight,n.innerWidth)}function sn(){U?.destroy(),U=void 0,j=""}function We(n){let r=n.screen?.presentation;if(!r||r.type==="inline"){N.open&&N.close(),sn(),D.parentElement!==O&&O.append(D),s.parentElement!==t&&t.append(s);for(let ae of["flex","display","flex-direction","justify-content"])R.style.removeProperty(ae);a(n),g();return}s.parentElement!==N&&(N.append(D,s),t.append(N)),R.style.flex="1 0 auto",R.style.display="flex",R.style.flexDirection="column",R.style.justifyContent="center",a(n);let p=n.screen.content.document,_=JSON.stringify([r,Ce]);if(_!==j){sn(),j=_;let ae={sm:420,md:640,lg:900},ge="size"in r&&!r.backdrop?",0 0 0 100vmax #16142566":"";N.style.cssText=`box-sizing:border-box;padding:0;border:0;overflow:auto;background:${pe.background};color:${pe.text};`+(r.type==="fullscreen"?"width:100vw;height:100dvh;max-width:100vw;max-height:100dvh;margin:0;border-radius:0":`width:${ae[r.size]}px;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);box-shadow:0 24px 80px #0003${ge};`+(r.type==="sheet"?"margin:auto auto 0;border-radius:14px 14px 0 0":"border-radius:14px")),U=Sn(N,{presentation:r,theme:p.theme,pages:p.pages},vn),U.latch()}g(),N.setAttribute("aria-label",(ce?.screen===n.screen?.content.document.name?ce?.label:void 0)??d?.document?.name??n.screen?.content.document.name??"Funnel")}async function Yn(n){if(h||ue||he&&(Qe()||["running","waiting"].includes(n.status))||(H=n,qe&&e.client.pendingCommand?.requestId!==qe&&(E.hidden=!0,qe=null),X=n.locale.startsWith("zh"),Q.textContent=X?"\u56DE\u770B":"History",J.textContent=A.active?X?"\u8FD4\u56DE\u5F53\u524D":"Return to current":X?"\u8FD4\u56DE":"Back",u(),T.textContent=X?"\u91CD\u8BD5":"Retry",T.hidden=e.client.pendingCommand===null,G.textContent=n.pendingRequest?X?"\u6B63\u5728\u5904\u7406":"Processing":n.instruction?.type==="wait"?X?"\u7B49\u5F85\u4E2D":"Waiting":"",Pe(),pn!==`${n.revision}:${n.visit}:${n.status}:${n.stopped}`&&(pn=`${n.revision}:${n.visit}:${n.status}:${n.stopped}`,be(e.onState,structuredClone(n))),h||ue))return;if((!n.pendingRequest||he&&n.status==="closed")&&["closed","ineligible","failed"].includes(n.status)){re();return}if(n.stopped&&F()){re();return}if(n.stopped||e.client.configurationReady===!1){A.stop(),o(),ve(),z?.finish("skipped"),s.hidden=!0,He();return}if(s.hidden=!1,A.active){He();return}let r=Fe(n),p=e.client.view;if(p&&p.revision>n.revision&&Fe(p)!==r)return;let _=!n.instruction&&!n.pendingRequest&&n.nodeType==="screen"&&["running","waiting"].includes(n.status);r!==V&&(V&&z?.finish("dismissed"),ve(),V=r,we={...n.answers},ze.reset());let ae=Be(n);if(xe===ae){s.hidden=!0;return}if(_&&!r){s.hidden=!0;let $=e.prepared?.state==="shown"?null:je(!0,n.locale);!h&&!ue&&Ge?.key!==ae&&(on(),Ge={key:ae,timeout:setTimeout(()=>{let y=e.client.view;if(h||!$?.active&&e.prepared?.state!=="shown"||!y||Be(y)!==ae)return;xe=ae;let W=new Error("Funnel screen preparation timed out");$?.finish("error",W),o(),ve(),fe(W)},Ae)}),He();return}on();let ee=$=>{let y=e.client.view;return!h&&!ue&&!Ee&&!$.aborted&&e.client.configurationReady!==!1&&!!y&&!y.stopped&&!["closed","ineligible","failed"].includes(y.status)&&Fe(y)===r},ge=($,y)=>{ee(y)&&(xe=r,z?.finish("error",$),ve(),s.hidden=!0,fe($))};if(r||((n.instruction&&n.instruction.type!=="evaluate_segment"||!["running","waiting"].includes(n.status))&&o(),We(n),n.instruction?.type!=="event"&&n.instruction?.type!=="open_url"&&z?.finish("skipped")),n.screen){o();let $=n.screen.content;if(!d){let x=n.screen.presentation.type!=="inline",oe=je(x,n.locale);if(h||ue)return;let ie=(Te=new AbortController).signal;We(n),_e=x?Hn(N):Ke(s,t),d=P(R,{mode:"live",rendererUrl:e.client.webViewUrl,title:$.document.name,...x?{hostPresentation:()=>U?.type??n.screen.presentation.type}:{},onResize:v=>{i=v,U?.responsive&&U.setContentHeight(v+O.getBoundingClientRect().height)},onAction(v,me={},nt={}){if(A.active||!ee(ie)||S!==r)return;we={...we,...nt};let an=n.screen?.inputs??[],bn=Object.fromEntries(an.filter(({variable:Se})=>Object.hasOwn(we,Se)).map(({variable:Se})=>[Se,we[Se]]));if(Gn(an,bn).length){yn();return}Oe(()=>e.client.submit({operation:"submit",...De(),input:{type:"screen",output:v,answers:bn,selection:me}}),!1,Se=>$n(Se,an))},onAnswers:v=>{A.active||!ee(ie)||S!==r||(we={...we,...v})},onCustomerDataIntent:v=>{A.active||!ee(ie)||S!==r||ze.intent(v).catch(fe)},onEscape:()=>{!ee(ie)||S!==r||A.active||de||Z||Ie()},onError:v=>{let me=new Error(v);S===r?fe(me):ge(me,ie)},onRendered:v=>{if(!(!ee(ie)||S===r))try{oe.present(me=>{_e?.(),_e=void 0,v&&(ce={screen:$.document.name,label:v},N.setAttribute("aria-label",v)),x&&(N.showModal(),U?.responsive&&N.focus({preventScroll:!0}),!me&&e.loading!=="host"&&An(N,U?.type??n.screen.presentation.type,U?.responsive)),S=r,te=x,Pe()}),ee(ie)&&Le.report(r)}catch(me){ge(me,ie)}}}),vn()}let y={capabilities:n.screen.capabilities,customerData:n.screen.customerData,parameters:n.parameters,serverInput:{bindings:n.screen.inputs,answers:we,values:n.screen.values}},W=JSON.stringify([$,n.locale,y.parameters,n.screen.inputs,n.screen.values]);if(W!==ke)d.update($.document,n.locale,y),ke=W,Re=JSON.stringify(y.capabilities),Ue=JSON.stringify(y.customerData);else{let x=JSON.stringify(y.capabilities);x!==Re&&(d.updateCapabilities(y.capabilities),Re=x),JSON.stringify(y.customerData)!==Ue&&(d.updateCustomerData(y.customerData),Ue=JSON.stringify(y.customerData))}let se=d;if(se)try{await(z?.wait(se.ready)??se.ready)}catch(x){Te&&ge(x,Te.signal)}}else if(n.paywall&&!l){let $=n.paywall.resolution,y="document"in $?$.document:null,W=m,se=null,x=(Te=new AbortController).signal,oe={loading:"host",signal:x,canInteract:()=>ee(x)&&!A.active&&!de&&!Z,beforeAction:async()=>{le++;try{await gn(Le.settled()),E.hidden=!0,qe=null,Ne=!1,g()}finally{le=Math.max(0,le-1)}},start:()=>dn(e.client),onObservationChange:He,onPurchase:e.onPurchase,onCheckoutUrl:e.onCheckoutUrl,resumeCheckout:e.resumeCheckout,allowNewPurchase:e.allowNewPurchase,checkoutNavigation:e.checkoutNavigation,terminateCheckout:e.terminateCheckout,confirmOnHostedCheckout:e.confirmOnHostedCheckout,resolveOfferId:e.resolveOfferId,onEvent:e.onEvent,onOpenUrl:v=>e.onOpenUrl?e.onOpenUrl({receiptId:n.paywall.receiptId,url:v,openIn:"same_window"}):f.defaultView?.location.assign(v),onAction:async v=>{if(A.active)return;let me=await e.client.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:n.nodeId,visit:n.visit,revision:e.client.view?.revision??n.revision,input:{type:"screen",output:v,answers:{}}});await ye(e.client.view??me.run)},onError:v=>{S===r?fe(v):ge(v,x)}},ie={quoteError:v=>be(e.onError,v),present(v){ee(x)&&(se?.present(()=>{v(),S=r,te=!!R.querySelector("dialog[open]"),Pe()}),ee(x)&&Le.report(r))},async dismiss(){if(!(h||x.aborted||A.active||de||Z||!he&&!ee(x))){if(he=!0,(e.resumeCheckout||e.terminateCheckout)&&et()){H=e.client.view,re();return}await Ie()}}};if(W){let v=await W.adopt(n,{options:oe,handoff:ie,start:()=>dn(e.client)});v&&ee(x)&&!h?(We(n),l=v,z?.active&&z.present(()=>{}),S=r,te=W.modal,Pe(),Le.report(r),A.active&&l.setSuspended(!0)):(v?.destroy(),o())}if(h||ue)return;if(!l){if(se=je(!0,n.locale,y),h||ue)return;We(n);let v=await M(R,oe,ie).catch(me=>(ge(me,x),null));!ee(x)&&!(he&&!h&&!x.aborted)?v?.host?.destroy():v&&(l=v.host,l?.setSuspended(A.active))}}if(h||ue)return;Pe();let q=n.instruction;if(q&&(q.type==="open_url"||q.type==="event")&&!Je.has(q.receiptId)){let $=f.createElement("button");$.type="button",$.style.cssText=B.primary,Me($,()=>B.focus),R.style.cssText=B.stage,$.textContent=q.type==="open_url"?`${X?"\u524D\u5F80":"Continue to"} ${new URL(q.url).host}`:X?"\u7EE7\u7EED":"Continue",$.onclick=()=>{let y=De(),W=q.type==="open_url"&&!e.onOpenUrl&&q.openIn==="new_window"?Xn(q.url):null;Oe(async()=>{let se="success";if(q.type==="open_url")if(e.onOpenUrl)try{se=await e.onOpenUrl({receiptId:q.receiptId,url:q.url,openIn:q.openIn})===!1?"failed":"opened"}catch(oe){be(e.onError,oe),se="failed"}else se=q.openIn==="new_window"&&!W?"failed":"opened";if(q.type==="event"){if(!e.onEvent)throw new w("EVENT_HANDLER_REQUIRED","Provide the event handler");await e.onEvent(q.event)}if(h||e.client.view?.nodeId!==y.nodeId||e.client.view.visit!==y.visit)throw new w("PRECONDITION_FAILED","The client action visit changed");let x=await e.client.submit({operation:"submit",...y,input:{type:"client_action",receiptId:q.receiptId,outcome:se}});return Je.add(q.receiptId),q.type==="open_url"&&!e.onOpenUrl&&q.openIn==="same_window"&&f.defaultView?.location.assign(q.url),x})},z?.active?z.present(()=>R.replaceChildren($)):R.replaceChildren($)}!n.pendingRequest&&n.status==="completed"&&!Je.has(`complete:${n.id}`)&&(Je.add(`complete:${n.id}`),be(e.onComplete,structuredClone(n))),He()}function Xn(n){let r=f.defaultView?.open(n,"_blank")??null;return r&&(r.opener=null),r}function ye(n){return Pe(),nn=nn.catch(()=>{}).then(async()=>{try{await Yn(n)}catch(r){throw z?.active&&(xe=Be(n),z.finish("error",r),ve(),s.hidden=!0),r}}),nn}let Zn=e.client.subscribe(n=>{if(!fn){if(n.stopped&&(te||F())&&!he){H=n,re();return}!he&&(n.stopped||e.client.configurationReady===!1||V&&S!==V&&(Fe(n)!==V||["closed","ineligible","failed"].includes(n.status)))&&(ve(),z?.finish("dismissed"),s.hidden=!0),ye(n).catch(fe)}}),Kn=e.client.subscribeError?.(fe);function et(){let n=e.client.view,r=n?.paywall;return!!r?.operation&&!!n&&["running","waiting"].includes(n.status)&&qn(Ve({quote:r.quote,operation:r.operation,requestId:r.purchaseRequestId,pending:!1,destroyed:!1,canReselect:r.canReselect}))}function Ie(n){if(Ee)return Ee;if(h||!n&&(de||Z))return Promise.resolve();let r=!n&&Qe();return!r&&e.client.view&&!["running","waiting"].includes(e.client.view.status)?(H=e.client.view,re(),Promise.resolve()):(Ee=Oe(async()=>{let p=r?await e.client.retry():await e.client.submit({operation:"close",...n??De()});return n&&wn(p),p},!0).then(()=>{let p=e.client.view;p?.status==="closed"&&!Qe()&&(H=p,re())}).finally(()=>{Ee=null}),Ee)}function re(){ne?.destroy(),!h&&(h=!0,k(),o(),e.signal?.removeEventListener("abort",re),c?.removeEventListener("abort",re),z?.finish("dismissed"),mn.destroy(),Zn(),Kn?.(),ve(),sn(),A.stop(),N.remove(),s.remove(),L(),be(e.onDismiss,H?structuredClone(H):null))}J.onclick=()=>{if(!J.disabled){if(A.active){A.exit();return}Oe(()=>e.client.submit({operation:"back",...De()}))}},Q.onclick=()=>{A.open()},D.onclick=()=>{z?.active?z.dismiss():de||Ie()},T.onclick=()=>{Qe()?Ie():Oe(()=>e.client.retry())},N.addEventListener("cancel",n=>{n.preventDefault(),z?.active?z.dismiss():de||Ie()}),e.signal?.addEventListener("abort",re,{once:!0}),c?.addEventListener("abort",re,{once:!0});let Ye=!1;m&&(k=m.onClose(()=>{h||ue||(ue=!0,z?.finish("dismissed"),ve(),s.hidden=!0,e.client.view?Ie().finally(re):Ye=!0)}));let In={destroy:re,refresh:rn,get recovery(){let n=tn();if(n)return n;if(!h&&!le&&!he&&!de&&l){let r=l.recovery;if(r.type!=="native")return r}return{type:"recover",operationId:e.client.pendingPurchase?.operationId??e.client.view?.paywall?.quote?.operationId??Z?.operationId??null,requestId:e.client.pendingCommand?.requestId??null}},prepareFallback(){if(de)return de;let n=tn();if(n)return Promise.resolve(n);let r=e.client.pendingPurchase?.operationId??e.client.view?.paywall?.quote?.operationId??Z?.operationId??null,p=()=>({type:"recover",operationId:r,requestId:e.client.pendingCommand?.requestId??null});if(e.client.hasDurableJournal!==!0){let q=l?.recovery;return Promise.resolve(q&&q.type!=="native"&&q.type!=="cancel"?q:p())}let _=(e.client.pendingCommands??(e.client.pendingCommand?[e.client.pendingCommand]:[])).some(q=>q.operation==="close");if(h&&!(_||Z&&e.client.view?.status==="closed")||le||$e||Ee||A.active||!l&&!Z&&!_)return Promise.resolve(p());let ae=l,ee=(async()=>{try{if(!Z&&_){let y=await e.client.retry();return await ye(e.client.view??y.run),p()}if(!Z){let y=await ae.prepareFallback();if(y.type!=="native")return y;if(e.client.hasDurableJournal!==!0)return p();Z=y}let q=e.client.pendingCommands??(e.client.pendingCommand?[e.client.pendingCommand]:[]);if(q.length){let y=q.find(se=>se.operation==="close");if(!y||!K||y.requestId!==K.requestId)return p();let W=await e.client.retry();wn(W),await ye(e.client.view??W.run)}else{let y=e.client.view,W=y?.paywall;if(!y||!W||W.selectionGeneration===void 0||(W.quote?.operationId??null)!==Z.operationId||Z.operationId!==null&&W.canReselect!==!0)return p();let se=W.selectionGeneration,x=await e.client.get();await ye(e.client.view??x.run);let oe=e.client.view,ie=oe?.paywall;if(!oe||!ie||!["running","waiting"].includes(oe.status)||oe.stopped||oe.id!==y.id||oe.nodeId!==y.nodeId||oe.visit!==y.visit||ie.receiptId!==W.receiptId||ie.selectionGeneration!==se||(ie.quote?.operationId??null)!==Z.operationId||Z.operationId!==null&&ie.canReselect!==!0||e.client.pendingPurchase||(e.client.pendingCommands?.length??(e.client.pendingCommand?1:0)))return p();let v=De();K={runId:oe.id,operationId:Z.operationId,revision:v.revision,requestId:v.requestId,nodeId:oe.nodeId,visit:oe.visit,receiptId:ie.receiptId,selectionGeneration:se,acknowledged:!1},await Ie(v)}let $=tn();return $?(re(),$):p()}catch(q){return fe(q),p()}})();de=ee;let ge=()=>{de===ee&&(de=null)};return ee.then(ge,ge),ee},review:A.open,exitReview:A.exit,get unappliedDrafts(){return A.drafts}};try{let n=e.client.view;if(n)((e.client.viewAgeMs??cn)>=cn||n.instruction?.type==="evaluate_segment")&&(en=rn().finally(()=>{en=null})),await ye(n);else{if(s.hidden=!0,h)throw new DOMException("Presentation cancelled","AbortError");let r=Ye||e.prepared?.state==="shown"?null:je(e.client.view?.screen?.presentation.type!=="inline",e.client.view?.locale);if(h||ue&&!Ye)throw new DOMException("Presentation cancelled","AbortError");let p=e.client.get(),_=await(r?r.wait(p,Ae):rt(p,Ae));if(fn=!1,Ye)return h||await Ie().finally(re),In;await ye(e.client.view??_.run)}}catch(n){throw z?.finish("error",n),re(),n}return In}function rt(t,I){let C;return Promise.race([t,new Promise((e,m)=>{C=setTimeout(()=>m(new Error("Presentation data timed out")),I)})]).finally(()=>clearTimeout(C))}function xt(t,I,C){return it(t,I,C)}export{it as a,xt as b};
|
package/dist/chunk-W3K5ARMY.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{p as n,s as t}from"./chunk-HYE2YQYM.js";function u(o,e,a){return n(o,e,a,t)}export{u as a};
|
package/dist/chunk-WRLVPHPE.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as e}from"./chunk-ZYN4CRHS.js";var c=e.enum(["replace","stack_native"]);export{c as a};
|
package/dist/content-RGKTEV23.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as ie}from"./chunk-C4GBV32U.js";import{a as Z,c as ee,e as te,f as ne,h as N,j as re,k as oe,l as se}from"./chunk-YQX27SBG.js";import{b as X}from"./chunk-XQTCEQXI.js";import{r as V}from"./chunk-JOIPLLHK.js";import"./chunk-GLYFT5WW.js";import"./chunk-WRLVPHPE.js";import"./chunk-35VG2IYD.js";import"./chunk-HVVJGLYZ.js";import"./chunk-ZYF6TRJ3.js";import{$ as K,C as G,H as R,_ as Y,r as $}from"./chunk-QHJWVLJC.js";import"./chunk-XE7GU6FZ.js";import"./chunk-LAGGWYH3.js";import"./chunk-DHT3AWJQ.js";import{a as p}from"./chunk-TIQS5DUF.js";import"./chunk-7ZEXY4GC.js";import"./chunk-RHF4NFCZ.js";import{b as u}from"./chunk-ZYN4CRHS.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as h}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";var z=new WeakMap;function ce(s){let t={string:u.string(),number:u.number().finite(),boolean:u.boolean(),strings:u.array(u.string()),json:R}[s.type];return s.nullable?t.nullable():t}function ae(s,t){let f=u.record(u.string(),R).parse(s);if(Object.keys(f).length>40)throw new p("INVALID_REQUEST","Too many content inputs");for(let[m,r]of Object.entries(f))Y.parse({[m]:r});if(Object.keys(f).some(m=>!Object.hasOwn(t.inputs,m)))throw new p("INVALID_REQUEST","Undeclared content input");for(let[m,r]of Object.entries(t.inputs))if(Object.hasOwn(f,m))ce(r).parse(f[m]);else if(r.required)throw new p("INVALID_REQUEST",`Missing content input ${m}`);return f}async function Ae(s,t){return le(s,t,!1)}async function Se(s,t){return le(s,t,!0)}async function le(s,t,f){t.signal?.throwIfAborted();let m=X.parse(t.content),r=m.document;if(t.closeControl==="content"&&!r.screen.actions.some(e=>e.type==="event"&&e.close))throw new p("INVALID_REQUEST","An authored Close control requires a declared Close action");if(z.has(s))throw new p("CONFLICT","Content is already mounted in this container");let y=ae(t.inputs??{},r.contract),T=new Set(u.array(u.string()).max(40).parse(t.mutableInputs??[]));if(T.size!==(t.mutableInputs?.length??0)||[...T].some(e=>!Object.hasOwn(r.contract.inputs,e)))throw new p("INVALID_REQUEST","Mutable content inputs must name unique declared inputs");for(let e of Object.keys(r.contract.outputs))if(typeof t.actions[e]!="function")throw new p("INVALID_REQUEST",`Missing host handler for ${e}`);let M=K.parse(t.bindings??[]),d=s.ownerDocument,ue=s.clientHeight||d.defaultView?.innerHeight||800,P,w,a,_,x=r.kind==="popup",n=x?d.createElement("dialog"):null,c=d.createElement("div");if(c.dataset.indianaContent=r.kind,c.setAttribute("aria-label",r.name),c.style.cssText="width:100%;min-width:0",n){n.setAttribute("aria-label",r.name);let e=r.screen.presentation;n.style.cssText="box-sizing:border-box;padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto",e.type==="modal"||e.type==="sheet"?(n.style.width=`${$[e.size]}px`,e.type==="sheet"&&(n.style.margin="auto auto 0")):n.style.width="100vw",a=ee(n,r.screen,()=>{w?.resizeViewport(d.defaultView?.innerHeight||800,d.defaultView?.innerWidth||1024)}),n.append(c),s.append(n)}else s.append(c);let i=!1,A=!1,E=!1,S=!1,de=n?oe(n):se(c,s),D=re(s,t,r.kind,()=>{k()&&(b(),h(t.onDismiss))}),q,H,L=new Promise((e,o)=>{q=e,H=o});L.catch(()=>{});let g=null,I=structuredClone(r.screen),W=G(I,[t.locale,...d.defaultView?.navigator.languages??[]]),j=t.capabilities;I.actions=I.actions.map(e=>e.type==="event"?{...e,close:!1}:e);function b(){i||(i=!0,t.signal?.removeEventListener("abort",b),D.finish("dismissed"),H(new Error("Content preparation cancelled")),a?.destroy(),_?.(),w?.destroy(),n?.close(),n?.remove(),c.remove(),z.delete(s),n&&P?.())}let v=()=>{!E||!k()||(b(),h(t.onDismiss))};function k(){try{return t.canDismiss?.()!==!1}catch(e){return h(t.onError,e),!1}}if(n&&t.closeControl!=="content"){let e=d.createElement("button");e.type="button",e.textContent="\xD7",e.setAttribute("aria-label",t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),ne(e,r.screen.theme),e.addEventListener("click",v),n.prepend(e)}n&&a?.responsive&&(_=Z(n,v,k,t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),n.addEventListener("click",e=>{if(e.target!==n)return;let o=n.getBoundingClientRect();(e.clientX<o.left||e.clientX>o.right||e.clientY<o.top||e.clientY>o.bottom)&&v()})),n?.addEventListener("cancel",e=>{e.preventDefault(),v()}),n?.addEventListener("keydown",e=>{e.key==="Escape"&&(e.preventDefault(),v())});async function F(){if(i||!E||A||!g)return;let e=g;A=!0,c.setAttribute("aria-busy","true");try{await t.actions[e.actionId](structuredClone(e)),g=null}catch(o){i||h(t.onError,o)}finally{A=!1,i||c.removeAttribute("aria-busy")}}function J(){if(i)throw new p("CONFLICT","Content host has been destroyed");E||!S||(P??=N(d),D.present(e=>{de(),n&&(a?.latch(),n.showModal(),a?.responsive&&n.focus({preventScroll:!0}),!e&&t.loading!=="host"&&te(n,a?.type??r.screen.presentation.type,a?.responsive)),E=!0}))}function U(e){D.finish("error",e),H(e instanceof Error?e:new Error(String(e))),b()}let Q={destroy:b,show:J,get pendingAction(){return g?structuredClone(g):null},retryAction:F,updateInputs(e){if(i)throw new p("CONFLICT","Content host has been destroyed");let o=u.record(u.string(),R).parse(e),C=ae({...y,...o},r.contract);for(let l of Object.keys(o))if(!T.has(l)&&(!Object.hasOwn(y,l)||V(y[l])!==V(C[l])))throw new p("PRECONDITION_FAILED","This content input is frozen; prepare a new presentation");V(y)!==V(C)&&(w?.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:C}}),y=C)},updateCapabilities(e){if(i)return;let o=structuredClone(e);w?.updateCapabilities(o),j=o}};z.set(s,Q),t.signal?.addEventListener("abort",b,{once:!0});try{if(t.signal?.throwIfAborted(),f||(P=N(d),D.start(x,t.locale??r.screen.strings.defaultLocale),i&&await L),w=ie(c,{mode:"live",rendererUrl:t.rendererUrl,title:r.name,viewportHeight:r.kind==="page"?ue:a?.responsive?d.defaultView?.innerHeight||800:void 0,...a?.responsive?{viewportWidth:d.defaultView?.innerWidth||1024,hostPresentation:()=>a.type}:{},onResize:e=>{i||a?.responsive&&(c.style.height=`${e}px`,c.style.overflow="clip",a.setContentHeight(e))},onRendered:e=>{if(!i&&(e&&n?.setAttribute("aria-label",e),!S))try{S=!0,f||J(),q()}catch(o){U(o),h(t.onError,o)}},onError:e=>{if(i)return;let o=new Error(e);S||U(o),h(t.onError,o)},onEscape:x?v:void 0,onAction:(e,o,C)=>{if(i||!E||A||g)return;let l=r.screen.actions.find(O=>O.id===e),B=r.contract.outputs[e];if(!(l?.type!=="event"||!B)&&!(l.close&&!k()))try{let O=ce(B).parse(Object.hasOwn(l.properties,"value")?l.properties.value:l.properties);g=structuredClone({requestId:crypto.randomUUID(),contentVersionId:m.id,actionId:e,event:l.event,value:O,selection:o??{},answers:C??{},requestedClose:l.close}),F()}catch(O){h(t.onError,O)}}}),w.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:y}}),await Promise.race([w.ready,L]),f&&await L,i)throw new Error("Content preparation cancelled");return Q}catch(e){throw U(e),e}}export{Ae as mountContent,Se as prepareContent};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c}from"./chunk-DB4EO3JG.js";import"./chunk-CGXNU5BC.js";import"./chunk-TIQS5DUF.js";import"./chunk-7ZEXY4GC.js";import"./chunk-ZYN4CRHS.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{a as PRERENDER_MAX_AGE_MS,b as preparedInternals,c as prerenderFunnelPurchase};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-OL2AI6DA.js";import"./chunk-I6D25FWU.js";import"./chunk-DB4EO3JG.js";import"./chunk-VWMFR22O.js";import"./chunk-W32FI2A2.js";import"./chunk-YQX27SBG.js";import"./chunk-GLYFT5WW.js";import"./chunk-WRLVPHPE.js";import"./chunk-3NCMYTNG.js";import"./chunk-35VG2IYD.js";import"./chunk-CGXNU5BC.js";import"./chunk-HVVJGLYZ.js";import"./chunk-ZYF6TRJ3.js";import"./chunk-QHJWVLJC.js";import"./chunk-XE7GU6FZ.js";import"./chunk-LAGGWYH3.js";import"./chunk-DHT3AWJQ.js";import"./chunk-TIQS5DUF.js";import"./chunk-7ZEXY4GC.js";import"./chunk-SLUA7ABW.js";import"./chunk-LVG5ED52.js";import"./chunk-RHF4NFCZ.js";import"./chunk-ZYN4CRHS.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{a as showFunnelRun,b as showObservedFunnelRun};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{N as r,O as m,h as e}from"./chunk-2KKLY323.js";import"./chunk-WRLVPHPE.js";import"./chunk-ZYF6TRJ3.js";import"./chunk-LAGGWYH3.js";import"./chunk-DHT3AWJQ.js";import"./chunk-7ZEXY4GC.js";import"./chunk-ZYN4CRHS.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{m as merchantBridgeCommerceSchema,r as merchantBridgeOperationSchema,e as merchantOperationLookupSchema};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as o}from"./chunk-UHTTCVSL.js";import"./chunk-XQTCEQXI.js";import"./chunk-2HSD2SEU.js";import"./chunk-5XKFUFXK.js";import"./chunk-2KKLY323.js";import"./chunk-U4WUX3WB.js";import"./chunk-JOIPLLHK.js";import"./chunk-GLYFT5WW.js";import"./chunk-WRLVPHPE.js";import"./chunk-35VG2IYD.js";import"./chunk-RHWZRHK7.js";import"./chunk-ZYF6TRJ3.js";import"./chunk-QHJWVLJC.js";import"./chunk-XE7GU6FZ.js";import"./chunk-LAGGWYH3.js";import"./chunk-DHT3AWJQ.js";import"./chunk-7ZEXY4GC.js";import"./chunk-ZYN4CRHS.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{o as apiOperations};
|