@tinkerlandai/longplay-sdk 0.10.8 → 0.10.13
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 +28 -0
- package/README.md +40 -4
- package/README.zh-CN.md +3 -1
- package/dist/{ai-usage-Btwg1nD7.d.ts → ai-usage-C-OZBxgW.d.ts} +1 -1
- package/dist/{api-5gAz4-Sb.d.ts → api-Bf_aRlXs.d.ts} +82 -0
- package/dist/chunk-33FQUT3Z.js +179 -0
- package/dist/chunk-3JDJD4NY.js +1 -0
- package/dist/chunk-ADSQZ7T3.js +1 -0
- package/dist/chunk-AHDMDMHB.js +1 -0
- package/dist/chunk-AY3DAC2V.js +4 -0
- package/dist/chunk-KQ4MS4LR.js +6 -0
- package/dist/chunk-OBZSDWLC.js +1 -0
- package/dist/chunk-OZZMZH7X.js +1 -0
- package/dist/chunk-RGWFBLW4.js +1 -0
- package/dist/chunk-RK6UEQF2.js +1 -0
- package/dist/chunk-VQBQAKJD.js +1 -0
- package/dist/chunk-VSJOHWDL.js +17 -0
- package/dist/chunk-VSMITXQD.js +1 -0
- package/dist/chunk-YT7TSF3I.js +1 -0
- package/dist/{configuration-sync-CywDxRkX.d.ts → configuration-sync-D2n_gGj6.d.ts} +1 -0
- package/dist/content-6JUK2IAJ.js +1 -0
- package/dist/{funnel-local-client-B4Z3dvNf.d.ts → funnel-local-client-DJq2K7an.d.ts} +8869 -93
- package/dist/{funnel-node-evaluation-P5B4fPfJ.d.ts → funnel-node-evaluation-CJSkUkbv.d.ts} +36 -0
- package/dist/{funnel-resource-client-BhbXsB2q.d.ts → funnel-process-client-C_UhTH8g.d.ts} +5132 -41
- package/dist/funnel-runtime-host-X5AMUCP2.js +1 -0
- package/dist/index.d.ts +102 -77
- package/dist/index.js +1 -1
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.d.ts +2 -2
- package/dist/openrouter.js +1 -1
- package/dist/page.d.ts +1 -1
- package/dist/page.js +1 -1
- package/dist/paywall-KSTKKKEA.js +1 -0
- package/dist/popup.js +1 -1
- package/dist/react-native.d.ts +109 -106
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-NHJ6OQTF.js +1 -0
- package/dist/server.d.ts +10677 -25
- package/dist/server.js +1 -1
- package/dist/{visual-dom-OIXANRP3.js → visual-dom-7IF7ITAK.js} +1 -1
- package/dist/visual.js +1 -1
- package/package.json +10 -9
- package/dist/chunk-5JJZSH23.js +0 -179
- package/dist/chunk-5ZS3TNC4.js +0 -1
- package/dist/chunk-7DXL3LHT.js +0 -1
- package/dist/chunk-7XVAFQEE.js +0 -1
- package/dist/chunk-ACF2FBUB.js +0 -1
- package/dist/chunk-CBVZUTNH.js +0 -1
- package/dist/chunk-DCV6IS2Z.js +0 -4
- package/dist/chunk-EI2VRDYJ.js +0 -1
- package/dist/chunk-G56XGVMS.js +0 -1
- package/dist/chunk-GJRXHH6G.js +0 -1
- package/dist/chunk-R26BYN3U.js +0 -1
- package/dist/chunk-RP2P3FU4.js +0 -1
- package/dist/chunk-SBPTOOYB.js +0 -1
- package/dist/chunk-U4UEOR5W.js +0 -6
- package/dist/chunk-XSVQHPQT.js +0 -17
- package/dist/content-XXVHMKKL.js +0 -1
- package/dist/funnel-runtime-host-PBJ63LOE.js +0 -1
- package/dist/paywall-CDR4GZMX.js +0 -1
- package/dist/screen-renderer-NLB3FAQJ.js +0 -1
- /package/dist/{chunk-AK3IJ6FZ.js → chunk-OJM6ORHE.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as P}from"./chunk-OZZMZH7X.js";import{a as sA,bb as zA,cb as FA,h as pA,i as xA,j as gA,o as $A}from"./chunk-KQ4MS4LR.js";import{a as MA,d as jA,e as UA,f as _A}from"./chunk-VSJOHWDL.js";function S(A){return typeof A=="string"?A:String(A)}var ye=/[\ud800-\udbff](?![\udc00-\udfff])|(^|[^\ud800-\udbff])[\udc00-\udfff]/g;function Pe(A){return A.replace(ye,"$1\uFFFD")}function PA(A,e){if(typeof A!="object"||A==null){let t="";throw t+="The provided value is not an object",new TypeError(t)}return A}function ZA(A){if(A!=null&&(typeof A=="object"||typeof A=="function")){let e=A[Symbol.iterator];if(e==null)return;if(typeof e!="function")throw new TypeError("The provided value is not iterable");let t=e.call(A);if(!t||typeof t!="object")throw new TypeError("Result of the Symbol.iterator method is not an object");return t}}function QA(A){let e;if(Array.isArray(A)){let t=A.map(S);if(t.length===2)return t}else if((e=ZA(A))!=null){let t=PA(e.next()),n=PA(e.next());if(!t.done&&!n.done)return[S(t.value),S(n.value)]}throw new TypeError("Each query pair must be an iterable [name, value] tuple")}var GA="0123456789ABCDEF",De=/(?:%[0-9A-Fa-f]{2})+/g;function U(A){return`%${GA[A>>4&15]}${GA[15&A]}`}function Ae(A,e,t=!1){return A>=55296&&A<=57343&&(A=65533),A<=127?t&&A===32?"+":e(A)?U(A):String.fromCharCode(A):A<=2047?U(192|A>>6)+U(128|63&A):A<=65535?U(224|A>>12)+U(128|A>>6&63)+U(128|63&A):U(240|A>>18)+U(128|A>>12&63)+U(128|A>>6&63)+U(128|63&A)}function DA(A){return A>=48&&A<=57?A-48:A>=65&&A<=70?A-65+10:A>=97&&A<=102?A-97+10:-1}function bA(A,e=!1){let t=0;for(;t<A.length;t++){let n=A.charCodeAt(t);if(n===37||e&&n===43)break}return t===A.length?A:(e?A.replace(/\+/g," "):A).replace(De,n=>{try{return decodeURIComponent(n)}catch{return"\uFFFD".repeat(n.length/3)}})}function AA(A){return A<=31||A>126}function be(A){switch(A){case 32:case 34:case 60:case 62:case 96:return!0;default:return AA(A)}}function qA(A){switch(A){case 32:case 34:case 35:case 60:case 62:return!0;default:return AA(A)}}function Se(A){return qA(A)||A===39}function SA(A){switch(A){case 63:case 94:case 96:case 123:case 125:return!0;default:return qA(A)}}function cA(A){switch(A){case 47:case 58:case 59:case 61:case 64:case 91:case 92:case 93:case 124:return!0;default:return SA(A)}}function YA(A){switch(A){case 33:case 39:case 40:case 41:case 126:return!0;default:return(function(t){switch(t){case 36:case 37:case 38:case 43:case 44:return!0;default:return cA(t)}})(A)}}function ee(A,e){return Ae(A=A||0,e)}function _(A,e,t=!1){let n=0;for(;n<A.length;n++){let u=A.charCodeAt(n);if(u>=128||t&&u===32||e(u))break}if(n===A.length)return A;let r=A.slice(0,n);for(;n<A.length;n++){let u=A.charCodeAt(n),l=u;if(u>=55296&&u<=56319&&n+1<A.length){let a=A.charCodeAt(n+1);a>=56320&&a<=57343&&(l=(u-55296<<10)+a-56320+65536,n++)}r+=Ae(l,e,t)}return r}function NA(A){let e=[],t=0,n=0;for(;n<=A.length;){if(n=A.indexOf("&",t),n<0&&(n=A.length),n!==t){let r=A.slice(t,n),u=r.indexOf("=");u<0&&(u=r.length),e.push([bA(r.slice(0,u),!0),bA(r.slice(u+1),!0)])}if(t=n+1,n===A.length)break}return e}function CA(A){let e="";for(let t=0;t<A.length;t++){let n=_(A[t][0],YA,!0),r=_(A[t][1],YA,!0);e+=t!==0?`&${n}=${r}`:`${n}=${r}`}return e}var Ce=[2191,2191,3164,3164,3292,3292,6863,6877,6880,6891,8385,8385,11158,11158,42958,42959,42962,42962,42964,42964,42993,42993,64451,64466,64912,64913,64968,64974,67904,67929,69317,69319,69328,69336,69370,69371,72544,72551,73136,73179,73184,73193,93856,93880,93883,93907,94194,94198,100344,100351,101641,101662,101760,101874,118010,118012,118458,118480,118496,118512,124608,124638,124640,124661,124670,124671,128728,128728,128887,128890,129232,129240,129620,129623,129674,129674,129678,129678,129736,129736,129741,129741,129770,129770,129775,129775,130042,130042,177978,177983,183970,183981,205744,210041],Ie=[7296,7297,7298,7299,7300,7301,7302,7303,7304,42958,42962,42964,42993],Ee=["\u0432","\u0434","\u043E","\u0441","\u0442","\u0442","\u044A","\u0463","\uA64B","\uA7CF","\uA7D3","\uA7D5","s"],ve=[2381,2381,2509,2509,2637,2637,2765,2765,2893,2893,3021,3021,3149,3149,3277,3277,3387,3388,3405,3405,3530,3530,3642,3642,3770,3770,3972,3972,4153,4154,5908,5909,5940,5940,6098,6098,6752,6752,6980,6980,7082,7083,7154,7155,11647,11647,43014,43014,43052,43052,43204,43204,43347,43347,43456,43456,43766,43766,44013,44013,68159,68159,69702,69702,69744,69744,69759,69759,69817,69817,69939,69940,70080,70080,70197,70197,70378,70378,70477,70477,70606,70608,70722,70722,70850,70850,71103,71103,71231,71231,71350,71350,71467,71467,71737,71737,71997,71998,72160,72160,72244,72244,72263,72263,72345,72345,72767,72767,73028,73029,73111,73111,73537,73538,90415,90415];function Te(A){for(let e=0;e<A.length;e++){let t=A.codePointAt(e);if(t>65535&&e++,t<=32||t===37||t===127||t>=55296&&t<=57343||t>=128&&t<=159||t>=64976&&t<=65007||!(65534&~t)||t===65533)return!0}return!1}var[qe,Ne,Oe,VA]=[[[],"0,6,7,8,m,w,10,1b,1d,1f,72,73,7k,8k,dt,2rk","AAAAAAAAAAAAAAAAAAAAAP////8AAAAAAAAAAAAAAAA/AAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAADAAABwfwAAAAAAAMADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhAAAAQAAAAAAAAQCAAABAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgACAAAAAAAAAAAAAAAAD//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAP///////////////wAAAAAAAAAAAAAAAAAAAAA="],[[],"6,7,8,o,4o,7e,7f,7h,7i,7j,dl","AAAAAEF9+P/+BwAAAMAA//8AAPz/////BlADAAAAAJwAAPz///8AAADA//H/5+X8AAAAAAAAAAAA/P///wcAAAAAAAAAAAAAPv0vAD0BAABA/gAA/5/5/f8BAAAAAAAAgAAAAP//////////////AYD/////BQAAAAAAAAAAAAAAAAAAAAAAAP///////wcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD8g+N8B+AAAAAAAAAAAAAAAAAAAAAAAAP//AwAAYAAAAAAAAAAAAAD/////CwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANgAAAAAAAAAAAAAAAAA//8fAB4AAAD//wMAAAAAAH3/HgwAAAAAAAD//////////w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="],[[],"6,7,8,o,4o,7e,7f,7h,7i,7j,dl","AAAAAP3////+BwAAAMDu//////////////8vAADAAJwAAP3///8AAADg////////AAAAAAAAAAAA/P///wcAAAAAAAAAAAAA////Ab0H//9H/gAA/9////8BAAAAAAAAgAAAAP//////////////AYD/////BQAAAAAAAAAAAAAAAAAAAAAAAP///////wcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAL/G//8T+AAAAAAAAAAAAAAAAAAAAAAAAP//AwAAfgAAAAAAAAAAAAD+////DwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANwAAAAAAAAAAAAAAAAA//8fAB4AAAD//wMAAAAAAH3/Hg4AAAAAAAD//////////w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="],[[],"0,3,4,5,6,7,8,9,a,b,c,d,e,f,g,j,n,o,p,q,r,s,t,w,18,19,1c,4m,4o,4p,4q,4r,6z,72,73,75,76,77,7e,7h,7i,7j,7k,7l,7m,7n,7o,7p,7q,7r,7s,7t,7u,7v,7w,7x,7y,7z,8k,9t,a2,a3,a7,cc,cv,cx,cy,d6,dc,dd,de,dg,dh,di,dk,dl,2rk,2rl","AAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAD//////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD4AwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/v////+/tgAAAAAAAAAAAP8XAAAAAAD4//8AAAEAAAAAAAAAAAAAAMCfnz0AAACAAgAAAP///wcAAAAAAAAAAAAAwP8BAAAAAAAA+A8gAADA++8+AAAAAAAOAAAAAAAAgP8AAAAAAPz///v///8HAAAAAAAAFP4h/gAMAAAAAgAAAAAAABAeIAAADAAAQAYAAAAAAAAQhjkCAAAAIwAGAAAAAAAAEL4hAAAMAAD8AgAAAAAAAJAeIGAADAAAAAQAAAAAAAAAASAAAAAAAAARAAAAAAAA0ME9YAAMAAAAAgAAAAAAAJBAMAAADAAAAAMAAAAAAAAYHiAAAAwAAAACAAAAAAAAAAAEXAAAAAAAAAAAAAAA8geAfwAAAAAAAAAAAAAAAPIfAH8AAAAAAAAAAAADAACgAgAAAAAAAP5/3+D//v///x9AAAAAAAAAAAAAAAAA4P1mAAAAwwEAHgBkIAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAMAAAADAAAAAwAAAAAAAAAsD9A/g8gAAAAAAC4AAAAAAAAAAAAAAAAAABgAAAAAAIAAAAAAAAAAAAAAAAAAIcBBA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAJAAAAAAAAQH/lH/ifAAAAAAAA//////8//w8AAA8AAAAAANAXBAAAAAD4DwADAAAAPDsAAAAAAABAowMAAAAAAADwzwAAAAAAAAAAAAAAAAAAAAAAAAD3//0hEAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////wDIAAAAfAAAAAAAAB/8AAAAAAAAAAAAAAAA/////wEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAwAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAA/////wAAAAAAPAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAID3PwAAAMAAAAAAAAAAAAAAAwBECAAAYBAAAAAAAAAAAAAAAAAAAAAAAAAwAAAA//8DgAAAAADAPwAAgP8DAAAAAAAHAAAAAADIMwAAAAAgAAAAAAAAAAB+ZgAIEAAAAAAAEAAAAAAAAJ3BAgAAAAAwQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAICEAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//8AAP//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAMAHAAAAAAAAAAAAAAAAAAAAAG7wAAAAAACHAAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAPAAAAAAAAAAAD4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAA/AAAAAAAAAAAwP8BAAAAAAA8AAAAAAAAAAAAAAAAAAAAAgAAAAAAAP9/AAAAAAAZgAMAAAAAAHgGBAAAAAAAAAAHAAAAgO8fAAAAAAAAAAgAAwAAAAAAwH8AngAAAAAAAAAAAAAAgNNAAgAAAAAAAAAAAAAAAAAAAAAAAID4BwAAAwAAAAAAABgBAAAAwB8fAAAAAAAAAAD4AUAFAAYAAAAAAAAAAAAA/1wAAEAAAAAAAAAAAAAA+IUNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8sAEAADAAAAAAAAAAAAAA+KcBAAAAAAAAAAAAAAAAKL8AAAAAAAAAAAAAAACgvA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgP8GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFgIAAAAAAAAAAAAAAAAAAAAAADwDAEAAAD+BwAAAAD4eYAAfg4AAAAAAPx/AwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf78AAAAAAAAAAAAA/P///G0AAAAAAAAAAAAAAAAAAAB+tL8AAAAAAAAAAACjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAwAcFAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//4H/PwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMD/4wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHwAAAAAAAAB/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAcAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAPAAAAAAAAAAAAAAD//////z///38AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAD+P/nDwAAADwAAAAAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////9/+P//////HyAAEAAA+P7/AAAAAAAAAAAAAH////nbBwAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAfwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASMAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAfwAAAAAAAAAAAAAAAADwDwAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAA////////////////AAAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////wAA"]].map(function([e,t,n]){return[e,t.split(",").map(r=>parseInt(r,36)),Uint8Array.from(atob(n),r=>r.charCodeAt(0))]});function Re(A,e){return e===931||e===1010||e===120531||e===120589||e===120647||e===120705||e===120763?"\u03C3":e>=5112&&e<=5117?String.fromCodePoint(e-8):e>=43888&&e<=43967?String.fromCodePoint(e-38864):e>=93856&&e<=93880?String.fromCodePoint(e+27):e===837||e===890||e>=8064&&e<=8111||e>=8114&&e<=8188?A.normalize("NFD").replace(/\u0345/g,"\u03B9").normalize("NFC").toLowerCase():""}function te(A,e){for(let t=0;t<A.length;t+=2)if(e>=A[t]&&e<=A[t+1])return!0;return!1}function X(A,e){let[t,n,r]=A,u=e>>8;for(let f=0;f<t.length;f+=2)if(u>=t[f]&&u<=t[f+1])return!0;let l=n.indexOf(u);if(l<0)return!1;let a=255&e;return!!(r[32*l+(a>>3)]&1<<(7&a))}function ke(A){let e=Array.from(A,t=>t.codePointAt(0));for(let t=0;t<e.length;t++){let n=e[t];if(n!==8204&&n!==8205||t>0&&te(ve,e[t-1]))continue;if(n===8205)return!1;let r=t-1;for(;r>=0&&X(VA,e[r]);)r--;let u=t+1;for(;u<e.length&&X(VA,e[u]);)u++;if(!(r>=0&&u<e.length&&X(Ne,e[r])&&X(Oe,e[u])))return!1}return!0}var Le=/(?![\p{Mark}\p{Decimal_Number}])[\p{Script=Arabic}\p{Script=Hebrew}]/u,Be=/\p{Script=Latin}/u;function He(A){return!Le.test(A)||!Be.test(A)}var F=36,iA=1,IA=26,Me=38,je=700,Ue=72,_e=128,xe=2147483647;function KA(A){return String.fromCharCode(A+22+75*+(A<26))}function $e(A,e,t){let n=0;for(A=t?Math.floor(A/je):A>>1,A+=Math.floor(A/e);A>(F-iA)*IA>>1;n+=F)A=Math.floor(A/(F-iA));return Math.floor(n+(F-iA+1)*A/(A+Me))}function ze(A){let e=Array.from(A,f=>f.codePointAt(0)),t="",n=0;for(let f=0;f<e.length;f++){let h=e[f];h<128&&(t+=String.fromCharCode(h),n++)}let r=n;r&&(t+="-");let u=_e,l=0,a=Ue;for(;n<e.length;){let f=xe;for(let h=0;h<e.length;h++){let w=e[h];w>=u&&w<f&&(f=w)}l+=(f-u)*(n+1),u=f;for(let h=0;h<e.length;h++){let w=e[h];if(w<u&&l++,w===u){let p=l;for(let m=F;;m+=F){let y=m<=a?iA:m>=a+IA?IA:m-a;if(p<y)break;t+=KA(y+(p-y)%(F-y)),p=Math.floor((p-y)/(F-y))}t+=KA(p),a=$e(l,n+1,n===r),l=0,n++}}l++,u++}return t}function wA(A){let e=10;if(A.length>=2&&A[0]==="0"&&(A[1]==="x"||A[1]==="X"))A=A.slice(2),e=16;else if(A.length>=2&&A[0]==="0")A=A.slice(1),e=8;else if(A==="")return-1;let t=0;for(let n=0;n<A.length;n++){let r=DA(A.charCodeAt(n));if(r>=e||r<0)return-1;t=t*e+r}return t}function JA(A){switch(A){case".":case"%2e":case"%2E":return!0;default:return!1}}function ne(A,e){return(A>=65&&A<=90||A>=97&&A<=122)&&(e===58||e===124)}function re(A){return A.length===2&&ne(A.codePointAt(0),A.codePointAt(1))}function WA(A){return A.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|<|>|\?|@|\[|\\|\]|\^|\|/u)!==-1}function I(A){switch(A){case"ftp":case"http":case"https":case"ws":case"wss":case"file":return!0;default:return!1}}function se(A){switch(A){case"ftp":return 21;case"http":case"ws":return 80;case"https":case"wss":return 443;default:return null}}function EA(A,e){if(A[0]==="[")return A[A.length-1]==="]"?(function(n){let r=[0,0,0,0,0,0,0,0],u=null,l=0,a=0,f=Array.from(n,h=>h.codePointAt(0));if(f[a]===58){if(f[a+1]!==58)return null;a+=2,l++,u=l}for(;a<f.length;){if(l===8)return null;if(f[a]===58){if(u!==null)return null;a++,l++,u=l;continue}let h=0,w=0,p=0;for(;p<4&&(h=DA(f[a]))>=0;)w=(w<<4)+h,a++,p++;if(f[a]===46){if(p===0||l>6)return null;a-=p;let m=0;for(;f[a]!==void 0;){let y=0;if(m>0)if(f[a]===46&&m<4)a++;else return null;if(f[a]==null||f[a]<48||f[a]>57)return null;for(;f[a]>=48&&f[a]<=57;){if(y=10*y+DA(f[a]),y>255)return null;a++}r[l]=256*r[l]+y,m++,m%2==0&&l++}if(m!==4)return null;break}else if(f[a]===58){if(f[++a]===void 0)return null}else if(f[a]!==void 0)return null;r[l]=w,l++}if(u!==null){let h=l-u;for(l=7;l!==0&&h>0;){let w=r[u+h-1];r[u+h-1]=r[l],r[l]=w,l--,h--}}else if(u===null&&l!==8)return null;return r})(A.substring(1,A.length-1)):null;if(e)return(function(n){return WA(n)?null:_(n,AA)})(A);{let t=(function(r){let u=!1,l=!1;for(let f=0;f<r.length;f++){let h=r.charCodeAt(f);if(h<=32||h===37||h===127)return null;if(h>=128){u=!0;break}h>=65&&h<=90&&(l=!0)}if(!u)return r!==""?l?r.toLowerCase():r:null;if((function(h){for(let w of h){let p=w.codePointAt(0);if(/[\p{Cn}\p{Co}\p{Cs}\p{Noncharacter_Code_Point}]/u.test(w)&&!te(Ce,p)||X(qe,p))return!0}return!1})(r))return null;let a=(r=(function(h){let w="";for(let p of h){let m=p.codePointAt(0);if(m!==8204&&m!==8205&&/\p{Default_Ignorable_Code_Point}/u.test(p))continue;let y=Re(p,m);if(y){w+=y;continue}let N=Ie.indexOf(m);w+=N<0?p:Ee[N]}return w})(r).normalize("NFKC").replace(/[\u3002\uff0e\uff61]/g,".").toLowerCase()).split(".");for(let f=0;f<a.length;f++){let h=a[f];if(h==="")continue;let w=/[^\0-\x7f]/.test(h);if(Te(h)||w&&(/^\p{Mark}/u.test(h)||!ke(h)||!He(h)||h.startsWith("xn--")))return null;w&&(a[f]=`xn--${ze(h)}`)}return(r=a.join("."))!==""?r:null})(A.indexOf("%")===-1?A:bA(A));return t===null||WA(t)?null:(function(r){let u=r.length,l=r.lastIndexOf(".",u-2)+1;if(r.charCodeAt(u-1)===46&&u--,u<=l)return!1;if(wA(r.slice(l,u))>=0)return!0;for(;l<u;l++){let a=r.charCodeAt(l);if(a<48||a>57)return!1}return!0})(t)?(function(r){let u=r.split("."),l=u.length;if(u[l-1]||l--,l>4)return null;let a=0;for(let h=0;h<l-1;h++){let w=wA(u[h]);if(w<0||w>255)return null;a+=w*(1<<8*(3-h))}let f=wA(u[l-1]);return f<0||f>=256**(5-l)?null:(a+=f,a)})(t):t}}function vA(A){return typeof A=="number"?(function(t){let r="";return r+=`${(t>>>24&255).toString(10)}.`,r+=`${(t>>>16&255).toString(10)}.`,r+=`${(t>>>8&255).toString(10)}.`,r+=(t&255).toString(10),r})(A):Array.isArray(A)?`[${(function(t){let n=(function(a){let f=-1,h=-1,w=1,p=0;for(let m=0;m<a.length;++m)a[m]!==0?(p>w&&(f=h,w=p),h=-1,p=0):(h===-1&&(h=m),++p);return p>w?h:f})(t),r="",u=!1;for(let l=0;l<=7;++l)if(!(u&&t[l]===0)){if(u&&(u=!1),n===l){r+=l===0?"::":":",u=!0;continue}r+=t[l].toString(16),l!==7&&(r+=":")}return r})(A)}]`:A}function oe(A){A.path.length>0&&(A.path.length!==1||A.scheme!=="file"||!(function(t){return/^[A-Za-z]:$/u.test(t)})(A.path[0]))&&A.path.pop()}function ie(A){return A.username!==""||A.password!==""}function mA(A){return A.host===null||A.host===""||A.scheme==="file"}var s=0,o="",g="",D=null,i,lA=!1,uA=!1,G=!1,E;function B(A,e,t,n){e||(A=(function(l){let a=0,f=l.length;for(;a<f&&!(l.charCodeAt(a)>32);++a);for(;f>a&&!(l.charCodeAt(f-1)>32);--f);return l.substring(a,f)})(A)),A=(function(l){let a=0;for(;a<l.length;a++){let h=l.charCodeAt(a);if(h===9||h===10||h===13)break}if(a===l.length)return l;let f=l.slice(0,a);for(;a<l.length;a++){let h=l.charCodeAt(a);h!==9&&h!==10&&h!==13&&(f+=l[a])}return f})(A),s=0,o=A,g="",D=t||null,i=e||{scheme:"",username:"",password:"",host:null,port:null,path:[],query:null,fragment:null,opaquePath:!1},lA=!1,uA=!1,G=!1,E=n||0;let r=Fe;switch(n){case 3:case 4:r=aA;break;case 5:r=RA;break;case 6:r=Y;break;case 7:r=Q;break;case 8:r=x}return r(c(A,s))!==1?i:null}function d(A,e){return s+=s===A?M(e):1,s<=o.length}function c(A,e){return e<A.length?A.codePointAt(e):void 0}function M(A){return A!=null&&A>65535?2:1}function le(A){return A==null?"":A<=65535?String.fromCharCode(A):String.fromCodePoint(A)}var Fe=A=>{let e=s;if(A!=null&&(A>=65&&A<=90||A>=97&&A<=122)){let t=s+1;for(A=o.charCodeAt(t);A===43||A===45||A===46||A>=65&&A<=90||A>=97&&A<=122||A>=48&&A<=57;)t++,A=o.charCodeAt(t);return g=o.slice(s,t).toLowerCase(),s=t,Qe(t<o.length?A:void 0)}else return E?1:(--s,d(e,A)?ue(c(o,s)):0)},Qe=A=>{let e=s;if(A===58){if(E){if(I(i.scheme)!==I(g))return 0;if((ie(i)||i.port!==null)&&g==="file")return 0;if(i.scheme==="file"&&i.host==="")return 0}return i.scheme=g,E?(i.port===se(i.scheme)&&(i.port=null),0):(g="",i.scheme==="file"?d(e,A)?kA(c(o,s)):0:I(i.scheme)&&D!==null&&D.scheme===i.scheme?d(e,A)?Ge(c(o,s)):0:I(i.scheme)?d(e,A)?Ve(c(o,s)):0:c(o,s+1)===47?(s++,d(e,A)?Ye(c(o,s)):0):(i.path=[""],i.opaquePath=!0,d(e,A)?ae(c(o,s)):0))}else return E?1:(g="",s=-1,d(e,A)?ue(c(o,s)):0)},ue=A=>{let e=s;return D===null||D.opaquePath&&A!==35?1:D.opaquePath&&A===35?(i.scheme=D.scheme,i.path=D.path.slice(),i.opaquePath=D.opaquePath,i.query=D.query,i.fragment="",d(e,A)?x(c(o,s)):0):D.scheme==="file"?(s--,d(e,A)?kA(c(o,s)):0):(s--,d(e,A)?OA(c(o,s)):0)},Ge=A=>{let e=s;return A===47&&c(o,s+1)===47?(++s,d(e,A)?hA(c(o,s)):0):(s--,d(e,A)?OA(c(o,s)):0)},Ye=A=>{let e=s;return A===47?d(e,A)?W(c(o,s)):0:(s--,d(e,A)?j(c(o,s)):0)},OA=A=>{let e=s;return i.scheme=D.scheme,A===47||I(i.scheme)&&A===92?d(e,A)?XA(c(o,s)):0:(i.username=D.username,i.password=D.password,i.host=D.host,i.port=D.port,i.path=D.path.slice(),i.query=D.query,A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?x(c(o,s)):0):A!=null?(i.query=null,i.path.pop(),s--,d(e,A)?j(c(o,s)):0):d(e,A)?OA(c(o,s)):0)},XA=A=>{let e=s;return I(i.scheme)&&(A===47||A===92)?d(e,A)?hA(c(o,s)):0:A===47?d(e,A)?W(c(o,s)):0:(i.username=D.username,i.password=D.password,i.host=D.host,i.port=D.port,s--,d(e,A)?j(c(o,s)):0)},Ve=A=>{let e=s;return A===47&&c(o,s+1)===47?s++:s--,d(e,A)?hA(c(o,s)):0},hA=A=>{let e=s;return A!==47&&A!==92?(s--,d(e,A)?W(c(o,s)):0):d(e,A)?hA(c(o,s)):0},W=A=>{let e=s;if(A!=null&&A!==64&&A!==35&&A!==47&&A!==63&&(A!==92||!I(i.scheme))){let t=s+M(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===64||n===35||n===47||n===63||n===92&&I(i.scheme))break;t+=M(n)}return g+=o.slice(s,t),s=t-1,d(e,A)?W(c(o,s)):0}if(A===64){lA&&(g=`%40${g}`),lA=!0;for(let t=0;t<g.length;t++){let n=g.codePointAt(t);if(n===58&&!uA){uA=!0;continue}let r=ee(n,cA);uA?i.password+=r:i.username+=r,n!=null&&n>65535&&t++}return g="",d(e,A)?W(c(o,s)):0}else return A==null||A===35||A===47||A===63||A===92&&I(i.scheme)?lA&&g===""?1:(s-=g.length+1,g="",d(e,A)?aA(c(o,s)):0):(g+=le(A),d(e,A)?W(c(o,s)):0)},aA=A=>{let e=s;if(E&&i.scheme==="file")return s--,d(e,A)?LA(c(o,s)):0;if(A!=null&&A!==58&&A!==35&&A!==47&&A!==63&&(A!==92||!I(i.scheme))){let t=s+M(A);for(A===91?G=!0:A===93&&(G=!1);t<o.length;){let n=c(o,t);if(n==null||!G&&n===58||n===35||n===47||n===63||n===92&&I(i.scheme))break;n===91?G=!0:n===93&&(G=!1),t+=M(n)}return g+=o.slice(s,t),s=t-1,d(e,A)?aA(c(o,s)):0}else if(A===58&&!G){if(g===""||E===4)return 1;let t=EA(g,!I(i.scheme));return t===null?1:(i.host=vA(t),g="",d(e,A)?RA(c(o,s)):0)}else if(A==null||A===35||A===47||A===63||A===92&&I(i.scheme)){if(s--,I(i.scheme)&&g==="")return 1;if(E&&g===""&&(ie(i)||i.port!==null))return 1;let t=EA(g,!I(i.scheme));return t===null?1:(i.host=vA(t),g="",E?0:d(e,A)?Y(c(o,s)):0)}else return g+=le(A),d(e,A)?aA(c(o,s)):0},RA=A=>{let e=s;if(A!=null&&A>=48&&A<=57){let t=s+1;for(;t<o.length;){let n=o.charCodeAt(t);if(n<48||n>57)break;t++}return g+=o.slice(s,t),s=t-1,d(e,A)?RA(c(o,s)):0}else if(E||A==null||A===35||A===47||A===63||A===92&&I(i.scheme)){if(g!==""){let t=parseInt(g,10);if(t>65535)return 1;if(i.port=t===se(i.scheme)?null:t,g="",E)return 0}return E?1:(s--,d(e,A)?Y(c(o,s)):0)}else return 1};function ce(A,e){let t=A.length-e;if(t<2)return!1;if(ne(c(A,e),c(A,e+1))){if(t===2)return!0;{let n=c(A,e+2);return n===47||n===92||n===63||n===35}}else return!1}var kA=A=>{let e=s;return i.scheme="file",i.host="",A===47||A===92?d(e,A)?Ke(c(o,s)):0:D?.scheme==="file"?(i.host=D.host,i.path=D.path.slice(),i.opaquePath=D.opaquePath,i.query=D.query,A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?x(c(o,s)):0):A!=null?(i.query=null,ce(o,s)?i.path=[]:oe(i),s--,d(e,A)?j(c(o,s)):0):d(e,A)?kA(c(o,s)):0):(s--,d(e,A)?j(c(o,s)):0)},Ke=A=>{let e=s;return A===47||A===92?d(e,A)?LA(c(o,s)):0:(D!==null&&D.scheme==="file"&&(!ce(o,s)&&(function(n){if(n.length===2){let r=n.codePointAt(0),u=n.codePointAt(1);return(r>=65&&r<=90||r>=97&&r<=122)&&u===58}else return!1})(D.path[0])&&i.path.push(D.path[0]),i.host=D.host),s--,d(e,A)?j(c(o,s)):0)},LA=A=>{let e=s;if(A!=null&&A!==47&&A!==92&&A!==63&&A!==35){let t=s+M(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===47||n===92||n===63||n===35)break;t+=M(n)}return g+=o.slice(s,t),s=t-1,d(e,A)?LA(c(o,s)):0}else if(A==null||A===47||A===92||A===63||A===35){if(s--,!E&&re(g))return d(e,A)?j(c(o,s)):0;if(g==="")return i.host="",E?0:d(e,A)?Y(c(o,s)):0;{let t=EA(g,!I(i.scheme));return t===null?1:(t==="localhost"&&(t=""),i.host=vA(t),g="",E?0:d(e,A)?Y(c(o,s)):0)}}return 1},Y=A=>{let e=s;return I(i.scheme)?(A!==92&&A!==47&&s--,d(e,A)?j(c(o,s)):0):!E&&A===63?(i.query="",d(e,A)?Q(c(o,s)):0):!E&&A===35?(i.fragment="",d(e,A)?x(c(o,s)):0):A!=null?(A!==47&&s--,d(e,A)?j(c(o,s)):0):(E&&i.host===null&&i.path.push(""),d(e,A)?Y(c(o,s)):0)},j=A=>{let e=s;if(A!=null&&A!==47&&(!I(i.scheme)||A!==92)&&(E||A!==63&&A!==35)){let t=s+M(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===47||I(i.scheme)&&n===92||!E&&(n===63||n===35))break;t+=M(n)}g+=_(o.slice(s,t),SA),s=t,A=c(o,t)}if(A==null||A===47||I(i.scheme)&&A===92||!E&&(A===63||A===35)){let t=I(i.scheme)&&A===92;return(function(r){switch(r){case"..":case"%2e.":case"%2E.":case".%2e":case".%2E":case"%2e%2e":case"%2E%2e":case"%2e%2E":case"%2E%2E":return!0;default:return!1}})(g)?(oe(i),A!==47&&!t&&i.path.push("")):JA(g)&&A!==47&&!t?i.path.push(""):JA(g)||(i.scheme==="file"&&i.path.length===0&&re(g)&&(g=`${g[0]}:`),i.path.push(g)),g="",A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?x(c(o,s)):0):d(e,A)?j(c(o,s)):0}else return g+=ee(A,SA),d(e,A)?j(c(o,s)):0},ae=A=>{let e=s;if(A===63)return i.query="",d(e,A)?Q(c(o,s)):0;if(A===35)return i.fragment="",d(e,A)?x(c(o,s)):0;if(A!=null){let t=s+M(A);for(;t<o.length;){let r=c(o,t);if(r===63||r===35)break;t+=M(r)}let n=o.slice(s,t);if(t<o.length&&n.charCodeAt(n.length-1)===32?i.path[0]+=_(n.slice(0,-1),AA)+"%20":i.path[0]+=_(n,AA),s=t,(A=c(o,t))===63)return i.query="",d(e,A)?Q(c(o,s)):0;if(A===35)return i.fragment="",d(e,A)?x(c(o,s)):0}return d(e,A)?ae(c(o,s)):0},Q=A=>{let e=s,t=s;if(A!=null){if(E)t=o.length;else{let r=o.indexOf("#",s);t=r===-1?o.length:r}let n=I(i.scheme)?Se:qA;i.query+=_(o.slice(s,t),n)}return s=t,c(o,t)===35&&!E?(i.fragment="",d(e,A)?x(c(o,s)):0):d(e,A)?Q(c(o,s)):0},x=A=>{let e=s;return A!=null&&(i.fragment+=_(o.slice(s),be),s=o.length),d(e,A)?x(c(o,s)):0};function TA(A){if(A.opaquePath)return A.path[0];{let e="";for(let t of A.path)e+=`/${t}`;return e}}function fe(A){switch(A.scheme){case"blob":{let e=B(TA(A),null,null,0);return e===null||e.scheme!=="http"&&e.scheme!=="https"?"null":fe(e)}case"ftp":case"http":case"https":case"ws":case"wss":return(function(t){let n=`${t.scheme}://`;return n+=t.host,t.port!==null&&(n+=`:${t.port}`),n})(A);default:return"null"}}var b=Symbol("URLImpl"),eA=class A{constructor(e,t){if(e===void 0&&t===void 0)throw new TypeError('The "url" argument must be specified.');e=S(e),t!=null&&(t=S(t));let n=null;if(t!=null&&(n=B(t,null,null,0),n==null))throw new TypeError(`Invalid base URL: ${t}`);let r=B(e,null,n,0);if(r==null)throw new TypeError(`Invalid URL: ${e}`);this[b]={url:r,query:null}}static createObjectURL(e){throw new TypeError("URL.createObjetURL is unsupported")}static revokeObjectURL(e){}static parse(e,t){e=S(e),t!==void 0&&(t=S(t));try{return new A(e,t)}catch{return null}}static canParse(e,t){e=S(e),t!==void 0&&(t=S(t));let n=null;return t!=null&&(n=B(t,null,null,0),n==null)?!1:B(e,null,n,0)!=null}get href(){return(function(t){let n=`${t.scheme}:`;return t.host!==null&&(n+="//",(t.username!==""||t.password!=="")&&(n+=t.username,t.password!==""&&(n+=`:${t.password}`),n+="@"),n+=t.host,t.port!==null&&(n+=`:${t.port}`)),t.host===null&&!t.opaquePath&&t.path.length>1&&t.path[0]===""&&(n+="/."),n+=TA(t),t.query!==null&&(n+=`?${t.query}`),t.fragment!==null&&(n+=`#${t.fragment}`),n})(this[b].url)}set href(e){let t=B(e=S(e),null,null,0);if(t==null)throw new TypeError(`Invalid URL: ${e}`);this[b].url=t,this[b].query&&yA(this[b].query,t.query)}get origin(){return fe(this[b].url)}get protocol(){return`${this[b].url.scheme}:`}set protocol(e){B(`${e=S(e)}:`,this[b].url,null,2)}get username(){return this[b].url.username}set username(e){e=S(e),mA(this[b].url)||(function(n,r){n.username=_(r,cA)})(this[b].url,e)}get password(){return this[b].url.password}set password(e){e=S(e),mA(this[b].url)||(function(n,r){n.password=_(r,cA)})(this[b].url,e)}get host(){let{url:e}=this[b];return e.host==null?"":e.port==null?e.host:`${e.host}:${e.port}`}set host(e){e=S(e),this[b].url.opaquePath||B(e,this[b].url,null,3)}get hostname(){let{url:e}=this[b];return e.host!=null?e.host:""}set hostname(e){e=S(e),this[b].url.opaquePath||B(e,this[b].url,null,4)}get port(){let{url:e}=this[b];return e.port!=null?`${e.port}`:""}set port(e){e=S(e);let{url:t}=this[b];mA(t)||(e?B(e,t,null,5):t.port=null)}get pathname(){return TA(this[b].url)}set pathname(e){e=S(e);let{url:t}=this[b];t.opaquePath||(t.path=[],B(e,t,null,6))}get search(){let{url:e}=this[b];return e.query?`?${e.query}`:""}set search(e){e=S(e);let{url:t,query:n}=this[b];if(!e)t.query=null,n&&yA(n,null);else{let r=e[0]==="?"?e.substring(1):e;t.query="",B(r,t,null,7),n&&yA(n,t.query)}}get searchParams(){let e=this[b],t=e.query;return t==null&&(t=e.query=(function(r,u){let l=new fA;return l[C].url=r,l[C].serialized=u==null,u&&(l[C].list=NA(u)),l})(this,e.url.query)),t}get hash(){let{url:e}=this[b];return e.fragment?`#${e.fragment}`:""}set hash(e){e=S(e);let{url:t}=this[b];if(!e)t.fragment=null;else{let n=e[0]==="#"?e.substring(1):e;t.fragment="",B(n,t,null,8)}}toJSON(){return this.href}toString(){return this.href}};Object.defineProperty(eA.prototype,Symbol.toStringTag,{value:"URL",configurable:!0});var C=Symbol("URLSearchParamsImpl"),Je=Symbol.dispose||Symbol.for("dispose");function yA(A,e){e?A[C].list=NA(e):A[C].list.length=0,A[C].serialized=e==null}function oA(A){if(A.url){let e=CA(A.list);(function(n,r){n[b].url.query=r})(A.url,e||null),A.serialized=!0}}var We=typeof Iterator<"u"?Iterator:Object,Z=class extends We{constructor(e,t){super(),this[C]={ptr:e,map:t,index:0}}next(){let e=this[C];return e.index<e.ptr.list.length?{value:e.map(e.ptr.list[e.index++]),done:!1}:{value:void 0,done:!0}}[Symbol.iterator](){return this}[Je](){}},fA=class{constructor(e){let t=this[C]={list:[],url:null,serialized:!0},n;if(Array.isArray(e))for(let r=0;r<e.length;r++)t.list.push(QA(e[r]));else if((n=ZA(e))!=null){let r;for(;!(r=PA(n.next())).done;)t.list.push(QA(r.value))}else if((typeof e=="object"||typeof e=="function")&&e!=null){let r=Object.keys(e);for(let u=0;u<r.length;u++){let l=r[u],a=Pe(l),f=S(e[l]),h=t.list.find(w=>w[0]===a);h?h[1]=f:t.list.push([a,f])}}else if(e!==void 0){let r=S(e);r=r[0]==="?"?r.substring(1):r,t.list=NA(r)}}get size(){return this[C].list.length}append(e,t){e=S(e),t=S(t),this[C].list.push([e,t]);let n=this[C];n.url&&n.serialized?(function(u,l){let a=u[b].url;a.query=a.query?`${a.query}&${l}`:l})(n.url,CA([[e,t]])):oA(n)}delete(e,t){e=S(e),t=t!=null?S(t):void 0;let{list:n}=this[C],r=0;for(;r<n.length;)n[r][0]===e&&(t==null||n[r][1]===t)?n.splice(r,1):r++;oA(this[C])}get(e){e=S(e);let{list:t}=this[C];for(let n=0;n<t.length;n++)if(t[n][0]===e)return t[n][1];return null}getAll(e){e=S(e);let t=[],{list:n}=this[C];for(let r=0;r<n.length;r++)n[r][0]===e&&t.push(n[r][1]);return t}has(e,t){e=S(e),t=t!=null?S(t):void 0;let{list:n}=this[C];for(let r=0;r<n.length;r++)if(n[r][0]===e&&(t==null||n[r][1]===t))return!0;return!1}set(e,t){e=S(e),t=S(t);let{list:n}=this[C],r=!1,u=!1,l=0;for(;l<n.length;)n[l][0]===e?r?(n.splice(l,1),u=!0):(r=!0,n[l][1]!==t&&(n[l][1]=t,u=!0),l++):l++;r||(n.push([e,t]),u=!0),u&&oA(this[C])}sort(){this[C].list.sort((e,t)=>e[0]<t[0]?-1:e[0]>t[0]?1:0),oA(this[C])}forEach(e,t){if(typeof e!="function")throw new TypeError('The "callback" argument must be of type function');let{list:n}=this[C];for(let r=0;r<n.length;r++)e.call(t,n[r][1],n[r][0],this)}entries(){return new Z(this[C],e=>e)}keys(){return new Z(this[C],e=>e[0])}values(){return new Z(this[C],e=>e[1])}toString(){return CA(this[C].list)}[Symbol.iterator](){return this.entries()}};Object.defineProperty(fA.prototype,Symbol.toStringTag,{value:"URLSearchParams",configurable:!0});function he(A){let e,t=()=>typeof e=="string"?e:e?.accessToken,n=0,r,u=new Map,l=()=>{for(let p of[...u.keys()])try{p()}catch{}};function a(p){let m=++n;r=void 0,e=void 0;for(let y of[...u.values()])try{y?.()}catch{}m===n&&(e=p,l())}let f=()=>a();function h(p,m=!1){let y=$A.safeParse(p);if(!y.success||m&&Date.parse(y.data.expiresAt)<=Date.now()||Date.parse(y.data.refreshExpiresAt)<=Date.now()||Date.parse(y.data.refreshExpiresAt)<Date.parse(y.data.expiresAt))throw new P("INVALID_RESPONSE","Invalid customer session credentials");return y.data}async function w(){if(r)return r;let p=typeof e=="object"?e:void 0,m=n;if(!p||Date.parse(p.refreshExpiresAt)<=Date.now())throw p&&f(),new P("UNAUTHENTICATED","Customer authentication is required",401);let y=(async()=>{try{let N=await A(p.refreshToken);if(m!==n)throw new P("IDENTITY_CHANGED","Customer identity changed during refresh");let V=h(N,!0);if(V.customerId!==p.customerId||V.sessionId!==p.sessionId)throw new P("SCOPE_MISMATCH","Refresh changed the customer session");return e=V,{...V}}catch(N){throw m!==n?new P("IDENTITY_CHANGED","Customer identity changed during refresh"):(N instanceof P&&N.status===401&&f(),N)}})();r=y;try{return await y}finally{r===y&&(r=void 0)}}return{identify(p){let m=typeof p=="string"?p:h(p),y=typeof m=="string"?m:m.accessToken;if(!y.trim()||/\s/.test(y)||y.length>4096)throw new P("INVALID_TOKEN","A server-issued token is required");a(m)},reset:f,subscribeIdentity(p,m){return u.set(p,m),()=>{u.delete(p)}},access(){let p=typeof e=="object"?e:void 0;if(p&&Date.parse(p.expiresAt)<=Date.now()+3e4){let y=n;return w().then(()=>{let N=t();if(y!==n||!N)throw new P("IDENTITY_CHANGED","Customer identity changed during refresh");return N})}let m=t();if(!m)throw new P("NOT_IDENTIFIED","Identify a customer session before making a request");return m},peek:t,snapshot:()=>typeof e=="object"?{...e}:void 0,refresh:w}}var de=Symbol("IndianaNoContent");function ut(A,e,t=eA){let n=A.configuration?.scope,r=A.scope??(n&&{projectId:n.projectId,environment:n.environment}),u=r?sA.parse(r):void 0;if(u&&n&&(u.projectId!==n.projectId||u.environment!==n.environment))throw new P("SCOPE_MISMATCH","Configuration belongs to another App/environment");let l=new t(A.baseUrl??FA);if(l.username||l.password||l.search||l.hash)throw new P("INVALID_URL","baseUrl must not contain credentials, query, or fragment");if(l.protocol!=="https:"&&!(l.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(l.hostname)))throw new P("INVALID_URL","Use HTTPS, or HTTP on localhost during development");let a=A.fetch??globalThis.fetch.bind(globalThis),f=A.timeoutMs??1e4;if(!Number.isFinite(f)||f<1||f>12e4)throw new P("INVALID_TIMEOUT","timeoutMs must be between 1 and 120000");let h=!1,w=0,p=null,m=new Set,y=A.session??he(async q=>{let O=await tA("customer-sessions/refresh",{},"POST",{},q);if(!O||typeof O!="object")throw new P("INVALID_RESPONSE","Invalid refresh response");let{requestId:$,scope:H,...K}=O;return K});function N(){w+=1,p=null;for(let q of m)q.abort();m.clear()}let V=y.subscribeIdentity(N);function pe(){h||y.reset()}async function tA(q,O={},$="POST",H={},K){let k=H.installationDetach===!0;if(k&&(q!=="push/installations/detach"||$!=="POST"))throw new P("INVALID_REQUEST","Installation authority only detaches this installation");if(!K&&!k)throw new P("NOT_IDENTIFIED","Call identify with a server-issued customer token first");let J=w,L=new AbortController;k||m.add(L);let nA=()=>!k&&J!==w?new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):new P("TIMEOUT","Longplay request timed out"),dA,ge=new Promise((T,R)=>{dA=()=>R(nA()),L.signal.addEventListener("abort",dA,{once:!0})}),we=setTimeout(()=>L.abort(),H.timeoutMs??f),me=async()=>{let T=await a(`${l.href.replace(/\/$/,"")}/api/v1/${q}`,{method:$,headers:{...H.headers,"Content-Type":"application/json",...k?{}:{Authorization:`Bearer ${K}`},[pA]:gA.current,[xA]:zA.version,...u?{"X-Indiana-Project":u.projectId,"X-Indiana-Environment":u.environment}:{}},body:$==="POST"?JSON.stringify(O):void 0,signal:L.signal,credentials:"omit",cache:"no-store",redirect:"error",...H.keepalive?{keepalive:!0}:{}});if(L.signal.aborted)throw nA();let R;try{R=T.status===204?de:await T.json()}catch{throw L.signal.aborted?nA():new P(T.ok?"INVALID_RESPONSE":"HTTP_ERROR","The gateway returned an unreadable response",T.status,T.headers.get("X-Request-Id")??void 0)}if(L.signal.aborted)throw nA();if(!k&&J!==w)throw new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight");if(!T.ok){let v=UA.safeParse(R),z=v.success&&(!MA.safeParse(v.data.error.code).success||jA(v.data.error.code,T.status)),BA=z?v.data.error.code:"HTTP_ERROR",HA=_A(BA,T.status,{retryAfter:T.headers.get("Retry-After"),recovery:z?v.data.error.recovery:void 0,reason:z?v.data.error.reason:void 0});throw new P(BA,z?v.data.error.message:"Longplay request failed",T.status,T.headers.get("X-Request-Id")??(v.success?v.data.requestId:void 0),{...HA,...v.success&&v.data.error.retryable===!1?{retryable:!1}:{},...HA.retryAfterSeconds===void 0&&v.success&&v.data.error.retryAfterSeconds!==void 0?{retryAfterSeconds:v.data.error.retryAfterSeconds}:{}})}if(T.headers.get(pA)!==gA.current)throw new P("PROTOCOL_MISMATCH","Response protocol does not match this SDK");if(u&&R!==de){let v=R&&typeof R=="object"&&"scope"in R?R:R&&typeof R=="object"&&"configuration"in R?R.configuration:null;if(!v||typeof v!="object"||!("scope"in v))throw new P("INVALID_RESPONSE","Response is missing its App/environment scope");let z=sA.safeParse(v.scope);if(!z.success||z.data.projectId!==u.projectId||z.data.environment!==u.environment)throw new P("SCOPE_MISMATCH","Response scope does not match this SDK instance")}let rA=T.headers.get("X-Indiana-Telemetry-Subject");if(rA){if(!/^[a-f0-9]{64}$/.test(rA))throw new P("INVALID_RESPONSE","Invalid telemetry identity");p!==rA&&(p=rA,e?.(p))}return R};try{return await Promise.race([me(),ge])}catch(T){throw!k&&J!==w?new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):T instanceof P?T:new P(L.signal.aborted?"TIMEOUT":"NETWORK_ERROR",L.signal.aborted?"Longplay request timed out":"Unable to read the Longplay response")}finally{clearTimeout(we),L.signal.removeEventListener("abort",dA),m.delete(L)}}return{session:y,requestWithCredential(q,O,$,H={}){return h?Promise.reject(new P("CLOSED","SDK client was destroyed")):tA(q,O,"POST",H,$)},subjectKey:()=>p,identify(q){if(h)throw new P("CLOSED","SDK client was destroyed");if(u&&typeof q=="object"&&"scope"in q){let O=sA.safeParse(q.scope);if(!O.success||O.data.projectId!==u.projectId||O.data.environment!==u.environment)throw new P("SCOPE_MISMATCH","Customer session belongs to another App/environment")}y.identify(q)},reset:pe,dispose(){h||(h=!0,V(),N())},request(q,O={},$="POST",H={}){if(h)return Promise.reject(new P("CLOSED","SDK client was destroyed"));if(H.installationDetach)return tA(q,O,$,H);let K=w;try{let k=y.access(),J=L=>{if(K!==w)throw new P("IDENTITY_CHANGED","Customer identity changed before dispatch");return tA(q,O,$,H,L)};return typeof k=="string"?J(k):k.then(J)}catch(k){return Promise.reject(k)}}}}export{eA as a,ut as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as o}from"./chunk-VSJOHWDL.js";var n=class extends Error{constructor(t,s,y,i,r){super(s);this.code=t;this.status=y;this.requestId=i;this.name="IndianaError",this.reason=r?.reason;let e=o(t,y??0,{...r,retryAfter:r?.retryAfterSeconds===void 0?void 0:String(r.retryAfterSeconds)});this.retryable=e.retryable,this.recovery=e.recovery,this.retryAfterSeconds=e.retryAfterSeconds}code;status;requestId;commandRequestId;retryable;recovery;retryAfterSeconds;reason};export{n as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as u}from"./chunk-DSPLGTQI.js";import{cb as d}from"./chunk-KQ4MS4LR.js";function m(e){if(!/^[A-Za-z0-9_-]{1,64}$/.test(e))throw new Error("Invalid device cookie name");let t="";for(let i of document.cookie.split(";"))if(i.trim().startsWith(`${e}=`))try{t=decodeURIComponent(i.trim().slice(e.length+1))}catch{}return/^[A-Za-z0-9_-]{8,128}$/.test(t)||(t=crypto.randomUUID(),document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${400*24*3600}; SameSite=Lax`),t}function y(){try{let e=sessionStorage.getItem("indiana_sid");return e||(e=crypto.randomUUID(),sessionStorage.setItem("indiana_sid",e)),e}catch{return}}function g(e=d){let t=new URL(e);if(t.protocol!=="https:"&&!(t.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(t.hostname))||t.username||t.password||t.search||t.hash)throw new Error("baseUrl must be an https origin without credentials");return t.origin}var o=new Set,s;function S(e){let t=()=>e();if(o.add(t),!s){let i=!0,a=history.pushState,p=history.replaceState,r=()=>{if(i)for(let n of[...o])o.has(n)&&u(n)},c=function(...n){a.apply(this,n),r()},h=function(...n){p.apply(this,n),r()};history.pushState=c,history.replaceState=h,addEventListener("popstate",r),addEventListener("hashchange",r),s=()=>{i=!1,history.pushState===c&&(history.pushState=a),history.replaceState===h&&(history.replaceState=p),removeEventListener("popstate",r),removeEventListener("hashchange",r)}}return()=>{o.delete(t)&&(o.size||(s?.(),s=void 0))}}export{m as a,y as b,g as c,S as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ja as g}from"./chunk-KQ4MS4LR.js";async function u(t,r,e){if(Number(t.headers.get("content-length"))>r)throw t.body?.cancel().catch(()=>{}),e.error("limit");let o=t.body?.getReader();if(!o)throw e.error("missing");let i=[],s=0,c=!1,a=()=>{},b=new Promise((n,f)=>{a=()=>f(e.signal?.reason),e.signal?.addEventListener("abort",a,{once:!0}),e.signal?.aborted&&a()});try{for(;;){let n=await Promise.race([o.read(),b]);if(n.done){c=!0;break}if(s+=n.value.length,s>r)throw e.error("limit");i.push(n.value)}}finally{e.signal?.removeEventListener("abort",a),c||o.cancel().catch(()=>{}),o.releaseLock()}e.signal?.throwIfAborted();let l=new Uint8Array(s),d=0;for(let n of i)l.set(n,d),d+=n.length;return l}async function m(t,r,e){return new TextDecoder("utf-8",{fatal:!0}).decode(await u(t,r,e))}function y(t,r){let e=typeof t=="string"?new TextEncoder().encode(t):t;return e.byteLength===r.byteLength&&g(e)===r.sha256}export{u as a,m as b,y as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as dn,c as fn,d as mn,e as pn}from"./chunk-VSMITXQD.js";import{a as te,b as Y}from"./chunk-OBZSDWLC.js";import{a as m}from"./chunk-OZZMZH7X.js";import{a as ln,b as cn,c as Ce}from"./chunk-RK6UEQF2.js";import{$a as un,Ea as Te,Fa as tn,R as Ge,T as Re,Ta as rn,U as Be,Ua as on,V as je,W as Je,Xa as an,Ya as sn,a as Ue,cb as le,da as Q,ea as ze,fa as B,ga as Ke,ha as Oe,ia as L,ka as Qe,la as Ye,ma as $e,n as ue,na as We,oa as Ze,ua as ne,va as Xe,ya as en,za as nn}from"./chunk-KQ4MS4LR.js";import{B as ve,Ca as He,v as qe,y as ke}from"./chunk-VSJOHWDL.js";function Mn(e){let n=null,r=null,s=0,l=0,y=new Set,f=null,i=null,p=new Set,a=()=>{for(let o of p)try{o()}catch{}},u={attributes:ve.parse(e.attributes??{}),onFeatureUsage:e.onFeatureUsage?(o,t)=>{!y.has(o)&&(!n||!("analyticsConfig"in n)||n.analyticsConfig.featureUsageEnabled)&&e.onFeatureUsage(o,structuredClone(t),structuredClone(u.attributes))}:void 0,onExperimentViewed:e.onExperimentViewed?(o,t)=>(!n||!("analyticsConfig"in n)||n.analyticsConfig.experimentViewsEnabled)&&e.onExperimentViewed(structuredClone(o),structuredClone(t),structuredClone(u.attributes)):void 0,stickyBucketAssignmentDocs:structuredClone(e.stickyBucketAssignmentDocs),saveStickyBucketAssignmentDoc:e.saveStickyBucketAssignmentDoc?o=>e.saveStickyBucketAssignmentDoc(structuredClone(o)):void 0,trackedFeatureUsage:{},trackedExperiments:new Set},c=()=>({value:null,source:"unknownFeature",on:!1,off:!0,ruleId:""});function d(o,t=new Set){return y.has(o)?!f||!f.features[o]||["unknownFeature","cyclicPrerequisite"].includes(f.features[o].source):t.has(o)?!1:(t.add(o),(n?.features[o]?.rules??[]).some(I=>[...I.parentConditions??[],...(I.tracks??[]).flatMap(b=>b.experiment.parentConditions??[])].some(b=>d(b.id,t))))}let h=o=>{if(e.assertUsable?.(n?.generation),!n)throw new Error("Initialize the Feature client before evaluation");if(n.expiresAt&&Date.parse(n.expiresAt)<=Date.now())throw new Error("Feature configuration expired; refresh before evaluation");return f?.expiresAt&&Date.parse(f.expiresAt)<=Date.now()&&(f=null,u.features=n.features),y.has(o)?!f||f.expiresAt&&Date.parse(f.expiresAt)<=Date.now()?c():structuredClone(f.features[o]??c()):e.evaluateRemote&&(u.attributes?.merchandise||u.attributes?.merchandiseId)&&!f||d(o)?c():structuredClone(ke(o,u))};async function A(){if(!n||!y.size&&!u.attributes?.merchandise&&!u.attributes?.merchandiseId)return;if(!e.evaluateRemote){if(y.size)throw new Error("Remote Feature evaluation requires a server loader");return}let o=l;if(i?.revision===o)return i.loading;let t=s,I=n,b=[...y],S=(async()=>{let P=Je.parse(await e.evaluateRemote({attributes:structuredClone(u.attributes),features:b}));if(!(t!==s||o!==l||I!==n)){if(e.assertUsable?.(I.generation),P.generation!==I.generation)throw new Error("Feature configuration changed; refresh before evaluation");if(b.some(v=>!Object.hasOwn(P.features,v))||Object.keys(P.features).some(v=>!y.has(v)))throw new Error("Invalid remote Feature results");if(u.attributes?.merchandise||u.attributes?.merchandiseId){if(!P.merchandiseContext)throw new Error("Server did not resolve merchandise context");u.attributes=ve.parse({...u.attributes,...P.merchandiseContext})}f=structuredClone(P),u.features={...I.features,...Object.fromEntries(Object.entries(f.features).map(([v,D])=>[v,{defaultValue:D.value}]))},a()}})();i={revision:o,loading:S};try{await S}finally{i?.loading===S&&(i=null)}}function F(){A().catch(o=>{try{e.onError?.(o)}catch{}})}async function T(){if(r)return r;let o=s,t=(async()=>{let I=await e.load(),b="remoteFeatures"in I?Be.parse(I):null,S=b??Re.parse(I);if(S.scope.projectId!==e.scope.projectId||S.scope.environment!==e.scope.environment)throw new Error("Feature payload scope changed");if(o!==s)throw new Error("Feature client was reset");if(e.assertUsable&&n?.generation===S.generation){let{evaluatedAt:v,expiresAt:D,...V}=n,{evaluatedAt:M,expiresAt:H,...k}=S;if(L(V)!==L(k))throw new Error("Immutable Feature generation changed content");return n.evaluatedAt=S.evaluatedAt,n.expiresAt=S.expiresAt,a(),(!f||f.expiresAt&&Date.parse(f.expiresAt)<=Date.now())&&F(),structuredClone(n)}let P=new Set(b?.remoteFeatures??[]);if([...P].some(v=>Object.hasOwn(S.features,v)))throw new Error("Remote Feature definitions must not be delivered locally");return n&&"analyticsConfig"in n&&"analyticsConfig"in S&&!n.analyticsConfig.experimentViewsEnabled&&b?.analyticsConfig.experimentViewsEnabled&&u.trackedExperiments?.clear(),n=structuredClone(S),y=P,f=null,i=null,l++,u.features=n.features,u.savedGroups=qe(n.savedGroups),u.trackedFeatureUsage={},a(),F(),structuredClone(n)})();r=t;try{return await t}finally{r===t&&(r=null)}}return{init:T,refresh:T,refreshRemote:A,get generation(){return n?.generation??null},get expiresAt(){return n?.expiresAt??null},subscribe(o){return p.add(o),()=>{p.delete(o)}},setAttributes(o){let t=ve.parse(o);(u.attributes?.merchandise||u.attributes?.merchandiseId||o.merchandise||o.merchandiseId)&&u.trackedExperiments?.clear(),u.attributes=t,l++,f=null,i=null,u.features=n?.features??{},u.trackedFeatureUsage={},a(),F()},evalFeature:h,isOn(o){return h(o).on},isOff(o){return h(o).off},getFeatureValue(o,t){let I=h(o).value;return structuredClone(I===null?t:I)},reset(){s++,l++,r=null,i=null,n=null,f=null,y.clear(),u.features={},u.savedGroups={},u.stickyBucketAssignmentDocs={},u.attributes={},u.trackedFeatureUsage={},u.trackedExperiments?.clear(),a()}}}function gn(e){let n,r,s=()=>new m("COMMAND_STORAGE_INVALID","Durable command storage is unavailable"),l=Promise.resolve().then(async()=>{if(n=e.storage??globalThis.localStorage,r=e.locks??globalThis.navigator?.locks,!n||!r||!globalThis.crypto?.subtle)throw s();let i=new TextEncoder().encode(JSON.stringify([new URL(e.baseUrl??le).href,e.runToken])),p=new Uint8Array(await crypto.subtle.digest("SHA-256",i));return"indiana.funnel.commands.v1."+Array.from(p,a=>a.toString(16).padStart(2,"0")).join("")});l.catch(()=>{});async function y(i){try{let p=await l;return await r.request(p,{mode:"exclusive"},()=>i(p))}catch(p){throw p instanceof m?p:s()}}function f(i){let p=n.getItem(i);if(p===null)return{revision:0,entry:null};if(p.length>1048576)throw s();let a=JSON.parse(p);if(!a||typeof a!="object"||!("revision"in a)||!("entry"in a)||!Number.isSafeInteger(a.revision)||Number(a.revision)<0)throw s();return{revision:Number(a.revision),entry:a.entry}}return{read:()=>y(f),write:(i,p)=>y(a=>{if(f(a).revision!==i)return null;if(!Number.isSafeInteger(i+1))throw s();return n.setItem(a,JSON.stringify({revision:i+1,entry:p})),i+1})}}function be(e,n){let r=en.safeParse(n);if(!r.success)throw new m("INVALID_RESPONSE","Funnel response contract changed");let s=r.data;if(e.scope&&(s.scope.projectId!==e.scope.projectId||s.scope.environment!==e.scope.environment))throw new m("SCOPE_MISMATCH","Funnel scope changed");return s}async function Pe(e,n){let r=We.parse(n),{artifact:s,environmentId:l}=r.content,y=new te(e.baseUrl??le).origin,f=new te(s.url,y);if(f.origin!==y||f.username||f.password||f.search||f.hash||f.pathname!==`/api/v1/configuration/${l}/artifacts/${s.sha256}`)throw new m("INVALID_RESPONSE","Public Paywall locator is not trusted");let i=new AbortController,p,a=new Promise((c,d)=>{p=setTimeout(()=>{let h=new m("TIMEOUT","Public Paywall read timed out");i.abort(h),d(h)},B.initializationMs)}),u=(async()=>{let c=await(e.fetch??globalThis.fetch)(f,{method:"GET",credentials:"omit",redirect:"error",cache:"default",signal:i.signal});if(i.signal.aborted&&(c.body?.cancel().catch(()=>{}),i.signal.throwIfAborted()),!c.ok||!c.headers.get("content-type")?.toLowerCase().startsWith("application/json")||Number(c.headers.get("content-length"))>s.byteLength)throw c.body?.cancel().catch(()=>{}),new m("INVALID_RESPONSE","Public Paywall is unavailable");let d=await ln(c,s.byteLength,{signal:i.signal,error:h=>new m("INVALID_RESPONSE",h==="missing"?"Public Paywall body is missing":"Public Paywall exceeds its byte limit")});if(!Ce(d,s))throw new m("INVALID_RESPONSE","Public Paywall digest or size changed");return Ze(r,JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(d)))})();try{return await Promise.race([u,a])}finally{clearTimeout(p)}}var _e=(e,n)=>new m(e,n);function Xn(e){return sn(e,_e)}async function De(e,n,{predict:r=!0}={}){let s=n.instruction;if(s?.type!=="evaluate_segment")throw new Error("Local segment instruction required");if(!e)throw new m("CONFIGURATION_UNAVAILABLE","Local execution requires public configuration");if(e.scope.environmentId!==s.environmentId)throw new m("SCOPE_MISMATCH","Evaluation environment changed");let l=null,y;if(r)try{let f=await e.funnel(n.source.id,n.source.versionId);y=f.manifest.generation,l=An(e,n,f)}catch{l=null}return y??=e.snapshot?.generation??(await e.refresh()).generation,{advance:{policyRevision:s.policyRevision,generation:y},prediction:l}}function An(e,n,r){let s=n.instruction;if(s?.type!=="evaluate_segment"||!r.growth||r.control.evaluationMode!=="local"||r.control.evaluationRevision!==s.policyRevision)return null;let{analyticsConfig:l,remoteFeatures:y,...f}=r.growth,i=rn({scope:{projectId:e.scope.projectId,environment:e.scope.environment},funnelId:n.source.id,versionId:n.source.versionId,evaluationMode:"local",evaluationRevision:s.policyRevision,document:r.document,payload:Re.parse(f)}),p=Nn(i,r.document,{...n,...s}),a=p.steps.at(-1),u=p.boundary??(a?.result.port==="value"?{nodeId:a.nodeId,visit:n.visit+p.steps.length-1}:null);return u?{runId:n.id,from:{nodeId:n.nodeId,visit:n.visit,revision:n.revision},nodeId:u.nodeId,visit:u.visit,terminal:!p.boundary}:null}function Nn(e,n,r){return un(e,n,r,_e)}import{z as j}from"zod";var yn=Q.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 m("COMMAND_STORAGE_INVALID","Stored mutation required");return e}),wn=j.strictObject({schemaVersion:j.literal(1),scope:Ue,runId:j.uuid(),funnelId:j.uuid(),versionId:j.uuid(),processBindingIds:j.record(j.uuid(),j.uuid().nullable()).optional(),command:yn.optional(),closeCommand:yn.refine(e=>e.operation==="close").optional(),purchase:j.strictObject({receiptId:j.uuid(),operationId:j.uuid(),generation:j.number().int().nonnegative()}).optional(),closed:j.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"),q=()=>new m("COMMAND_STORAGE_CONFLICT","Another host changed this Run's pending command"),Se=(e,n)=>JSON.stringify(e)===JSON.stringify(n);function In(e){let n=0,r=null,s=a=>JSON.stringify([a.scope,a.runId,a.funnelId,a.versionId]),l=Promise.resolve();async function y(){let a=await e.read();if(!Number.isSafeInteger(a.revision)||a.revision<0)throw new m("COMMAND_STORAGE_INVALID","Invalid command storage revision");return{revision:a.revision,entry:a.entry===null?null:wn.parse(a.entry)}}function f(a){let u=l.then(a);return l=u.catch(()=>{}),u}async function i(a){for(let u=0;u<4;u++){let c=await y();if(c.entry&&r!==null&&s(c.entry)!==r)throw q();let d=a(c.entry,c.revision);if(Se(c.entry,d)){n=c.revision;return}let h=await e.write(c.revision,d);if(h!==null){if(!Number.isSafeInteger(h)||h<=c.revision)throw q();n=h;return}}throw q()}function p(a,u){if(!a||!u)return a;if(a.processBindingIds&&Object.hasOwn(a.processBindingIds,u)){let c={...a.processBindingIds};delete c[u],a={...a,processBindingIds:c}}return a.command?.requestId===u?a.closeCommand?{...a,command:a.closeCommand,closeCommand:void 0}:a.purchase?{...a,command:void 0}:null:a.closeCommand?.requestId===u?{...a,closeCommand:void 0}:a}return{bind(a){let u=JSON.stringify([a.scope,a.runId,a.funnelId,a.versionId]);if(r!==null&&r!==u)throw q();r=u},async load(){let a=await y();return n=a.revision,r=a.entry?s(a.entry):null,a.entry},retain(a){let u=wn.parse(a),c=u.command;return!c||r!==null&&s(u)!==r?Promise.reject(q()):(r??=s(u),f(()=>i((d,h)=>{if(d&&!Se(s(d),s(u)))throw q();if(d&&u.processBindingIds){for(let[A,F]of Object.entries(u.processBindingIds))if(d.processBindingIds&&Object.hasOwn(d.processBindingIds,A)&&d.processBindingIds[A]!==F)throw q();d={...d,processBindingIds:{...d.processBindingIds,...u.processBindingIds}}}if(!d){if(h!==n&&c.operation!=="close")throw q();return u}if(!d.command)return{...d,command:c,...c.operation==="close"?{closed:!0}:{}};if(c.operation==="close"&&d.command.operation!=="close"){if(d.command.requestId===c.requestId||d.closeCommand&&!Se(d.closeCommand,c))throw q();return{...d,closeCommand:c,closed:!0}}if(!Se(d.command,c))throw q();return d})))},observePurchase(a,u,c,d){return f(()=>i((h,A)=>{if(!h&&A!==n||h&&s(h)!==s({...a,schemaVersion:1}))throw q();if(h?.purchase&&h.purchase.generation>u.generation)return p(h,d);if(h?.purchase&&h.purchase.generation===u.generation&&h.purchase.operationId!==u.operationId)throw q();return c?!h?.purchase||h.purchase.operationId!==u.operationId?p(h,d):p(h.command?{...h,purchase:void 0}:null,d):p({schemaVersion:1,...a,...h,purchase:u},d)}))},settle(a){return f(()=>i(u=>p(u,a)))}}}function lt(e,n){return n.type==="id"?e.customerId===n.value:e.externalUserId===n.value}function ce(e,n){if(e===n)return!0;if(Array.isArray(e)||Array.isArray(n))return Array.isArray(e)&&Array.isArray(n)&&e.length===n.length&&e.every((l,y)=>ce(l,n[y]));if(!e||!n||typeof e!="object"||typeof n!="object")return!1;let r=Object.entries(e),s=Object.entries(n);return r.length===s.length&&r.every(([l,y])=>Object.hasOwn(n,l)&&ce(y,Reflect.get(n,l)))}function hn(e,n){let r=n&&{...n},s=null,l=0,y=new AbortController;function f(){l++,y.abort(new m("IDENTITY_CHANGED","Run identity changed")),y=new AbortController}let i=!1,p,a=0,u=new Set;return{get scope(){return r},bindScope(c){if(r&&(r.projectId!==c.projectId||r.environment!==c.environment))throw new m("SCOPE_MISMATCH","Run scope changed");r??={...c}},get view(){return s},get generation(){return l},get signal(){return y.signal},get disposed(){return i},get customerToken(){return p},get readSequence(){return a},nextRead(){return++a},assertCurrent(c,d="Run identity changed during the request"){if(c!==l||i)throw new m("IDENTITY_CHANGED",d)},assertRun(c){if(s&&(c.id!==s.id||c.source.type!==s.source.type||c.source.id!==s.source.id||c.source.versionId!==s.source.versionId||c.locale!==s.locale||!ce(c.parameters,s.parameters)))throw new m("INVALID_RESPONSE","Run version changed");if(e&&c.source.id!==e)throw new m("INVALID_RESPONSE","Run belongs to another Funnel")},publish(c,d,h,A,F){if(!(c.operation==="review"&&s&&s!==h&&d.run.revision<=s.revision)&&!(s&&d.run.revision===s.revision&&A!==void 0&&A<a)&&(c.operation==="review"&&!d.run.stopped&&["running","waiting"].includes(d.run.status)&&s&&d.run.nodeId===s.nodeId&&d.run.visit===s.visit&&d.run.revision===s.revision&&(d.run.screen=s.screen,(s.paywall?.quote?.operationId===d.review?.activeOperationId||!s.paywall?.quote&&d.review?.activeOperationId===null)&&(d.run.paywall=s.paywall)),!(s?.paywall&&d.run.paywall&&s.paywall.receiptId===d.run.paywall.receiptId&&(d.run.paywall.selectionGeneration??0)<(s.paywall.selectionGeneration??0)))){if(!s||d.run.revision>=s.revision)s=d.run;else if(!F)return;if(s)for(let T of u)try{T(structuredClone(s))}catch{}}},identify(c){if(i)throw new m("IDENTITY_CHANGED","Controller was reset");if(!ue.test(c))throw new m("INVALID_TOKEN","Customer credential required");f(),p=c},subscribe(c){return u.add(c),()=>u.delete(c)},reset(){i||(i=!0,f(),p=void 0,s=null,u.clear())}}}var re=/^gg_sk_[A-Za-z0-9_-]{32,128}$/;function yt(e,n,r="A server API key is required"){if(typeof window<"u")throw new m("SERVER_ONLY",n);if(!re.test(e))throw new m("INVALID_TOKEN",r)}function wt(e){let n=Y(e);return n.identify(e.apiKey),n}function $(e){let{customerToken:n,...r}=e;return r}var On=e=>!(e instanceof m)||e.status===void 0||e.status>=500||[401,425].includes(e.status)||e.recovery==="recover_operation";function vn({journal:e,state:n,call:r,processIdentity:s}){let l=null,y=null,f=!1,i={command:null,close:null},p=new Set,a,u=null,c=e?e.load().then(o=>{if(n.disposed)throw new m("IDENTITY_CHANGED","Controller was reset during command restoration");if(u=o,!o)return;if(s){if([o.command,o.closeCommand].some(I=>I&&!Object.hasOwn(o.processBindingIds??{},I.requestId)))throw new m("COMMAND_STORAGE_INVALID","The original process identity is missing");s.restore(o.processBindingIds??{})}if(n.scope&&(o.scope.projectId!==n.scope.projectId||o.scope.environment!==n.scope.environment))throw new m("SCOPE_MISMATCH","Pending command belongs to another scope");if(a=o.purchase,f=o.closed===!0,!o.command)return;let t=o.command;l=t.operation==="close"?null:t,y=t.operation==="close"?t:o.closeCommand?.operation==="close"?o.closeCommand:null,y&&(f=!0);for(let I of[l,y])I&&p.add(I.requestId)}):Promise.resolve();c.catch(()=>{});async function d(o){e&&await c;let t=n.generation;if(e){if(!n.view||!n.scope)throw new m("COMMAND_STORAGE_INVALID","Read the original scoped Run before persisting a mutation");await e.retain({schemaVersion:1,scope:n.scope,runId:n.view.id,funnelId:n.view.source.id,versionId:n.view.source.versionId,command:$(o),...s?{processBindingIds:{[o.requestId]:s.binding(o.requestId)}}:{}})}if(t!==n.generation||l!==o&&y!==o)throw new m("IDENTITY_CHANGED","Run changed before command dispatch");let I=p.has(o.requestId);p.add(o.requestId);try{return await r(o)}catch(b){throw t===n.generation&&(l===o||y===o)&&!I&&!On(b)&&(e&&await e.settle(o.requestId),t===n.generation&&T(o)),b}}function h(o){let t=Q.parse(o);if(t.operation==="start"||t.operation==="get"||t.operation==="review")throw new m("INVALID_REQUEST","Mutation required");if(f&&t.operation!=="close"){if(l?.requestId===t.requestId)return F(t.requestId);throw new m("COMMAND_PENDING","Close preserves the original recovery record; settle it by identity")}if(t.operation==="close"){if(l?.requestId===t.requestId)throw new m("INVALID_REQUEST","Close requires its own request identity");if(f=!0,y&&JSON.stringify($(y))!==JSON.stringify($(t)))throw new m("COMMAND_PENDING","Retry the original Close");return y??=t,i.close?i.close:A(y,"close")}if(l){if(JSON.stringify($(l))!==JSON.stringify($(t)))throw new m("COMMAND_PENDING","Retry the original command before sending another");if(i.command)return i.command}else l=t;return A(l,"command")}function A(o,t){let I=d(o);i[t]=I;let b=()=>{i[t]===I&&(i[t]=null)};return I.then(b,b),I}function F(o){return r({operation:"get",settlementRequestId:o})}function T(o){return!o||l!==o&&y!==o?!1:(l===o&&(l=null),y===o&&(y=null),p.delete(o.requestId),!l&&!y&&(u=null),!0)}return{ready:c,get pending(){return l},get closing(){return y},get closeRequested(){return f},get inFlight(){return i.command},get closeFlight(){return i.close},get purchase(){return a},assertBinding(o){if(u&&(o.run.id!==u.runId||o.run.source.id!==u.funnelId||o.run.source.versionId!==u.versionId))throw new m("SCOPE_MISMATCH","Stored command belongs to another Run or Version")},async observe(o,t,I,b){let S=o.operation==="get"?o.settlementRequestId:"requestId"in o&&o.operation!=="start"?o.requestId:void 0,P=S&&t.settlement?.state==="settled"&&t.run.pendingRequest?.requestId!==S&&(o.operation==="get"||!f||o.operation==="close"||!["running","waiting"].includes(t.run.status))?S:void 0,v=l?.requestId===P?l:y?.requestId===P?y:void 0;e?.bind({scope:t.scope,runId:t.run.id,funnelId:t.run.source.id,versionId:t.run.source.versionId});let D=t.run.paywall,V=D??t.purchase,M=V?.operation,H=t.settlement&&(!D||D.purchaseRequestId===t.settlement.requestId)&&(!a||a.operationId===t.settlement.operationId)?t.settlement:void 0,k=M?.operationId??V?.quote?.operationId??H?.operationId,J=V?.receiptId??H?.receiptId,de=D?.selectionGeneration??a?.generation??0;if(e&&k&&J&&o.operation!=="review"&&(!n.view||t.run.revision>=n.view.revision)&&(b===void 0||b>=n.readSequence)&&(!a||de>=a.generation)){let Z={receiptId:J,operationId:k,generation:de},fe=M?.status==="complete"||V?.canReselect===!0;await e.observePurchase({scope:t.scope,runId:t.run.id,funnelId:t.run.source.id,versionId:t.run.source.versionId},Z,fe,P),n.assertCurrent(I),(!a||Z.generation>=a.generation)&&(b===void 0||b>=n.readSequence)&&(fe?a?.operationId===Z.operationId&&(a=void 0):a=Z)}else e&&P&&await e.settle(P);return n.assertCurrent(I),P?T(v):!1},stop(){f=!0},submit:h,settle:F,reset(){f=!0,l=null,y=null,a=void 0,u=null,i.close=null,p.clear(),i.command=null}}}function Rn(e){if(e={...e},typeof e.runToken!="string"||!/^gg_fr_[A-Za-z0-9_-]{43}$/.test(e.runToken))throw new m("INVALID_TOKEN","Run credential required");if(e.serverKey&&(typeof window<"u"||!re.test(e.serverKey)))throw new m("SERVER_ONLY","Run Server-Key proof belongs to the merchant backend");if(e.serverKey&&e.session)throw new m("INVALID_REQUEST","Choose Customer session or Server-Key proof for this Run");let n=Y({...e,session:void 0,timeoutMs:e.timeoutMs??35e3}),r=hn(e.funnelId,e.scope??e.configuration?.scope),s=e.session?.subscribeIdentity(a),l=null,y=e.funnelCommandStorage??(typeof window<"u"&&window.isSecureContext?gn(e):void 0),f=y&&In(y),i=vn({journal:f,state:r,call:u,processIdentity:e.process});async function p(t){if(e.process)return e.process.request(t);let I=r.generation;r.assertCurrent(I);let b=performance.now()+(e.timeoutMs??35e3),S=r.customerToken??("customerToken"in t?t.customerToken:void 0);if(e.session){let D=r.signal,V,M=()=>{},H=new Promise((k,J)=>{M=()=>J(D.reason),D.addEventListener("abort",M,{once:!0}),V=setTimeout(()=>J(new m("TIMEOUT","Longplay request timed out")),Math.max(1,b-performance.now()))});try{S=await Promise.race([Promise.resolve().then(()=>(r.assertCurrent(I),e.session.access())),H])}finally{clearTimeout(V),D.removeEventListener("abort",M)}}r.assertCurrent(I);let P={...t,...S?{customerToken:S}:{}},v=t.operation==="page_experiments"?Te.parse(P):Q.parse(P);return n.requestWithCredential("funnels",v,e.runToken,{headers:e.serverKey&&!S?{[nn]:e.serverKey}:void 0,timeoutMs:Math.max(1,b-performance.now())})}function a(){s?.(),r.reset(),i.reset(),l=null,n.dispose()}async function u(t,I){let b=r.generation,S=()=>r.assertCurrent(b);f&&await i.ready,S();let P=r.view,v=be(e,await p(t));if(t.operation==="review"&&!v.review)throw new m("INVALID_RESPONSE","Historical projection is missing");if(S(),v.runToken&&v.runToken!==e.runToken)throw new m("INVALID_RESPONSE","Run credential changed");let D=t.operation==="get"?t.settlementRequestId:"requestId"in t&&t.operation!=="start"?t.requestId:void 0;if(D&&v.settlement?.requestId!==D)throw new m("INVALID_RESPONSE","Exact command settlement is missing or belongs to another command");i.assertBinding(v),r.assertRun(v.run),r.bindScope(v.scope);let V=await i.observe(t,v,b,I);return!v.run.stopped&&["running","waiting"].includes(v.run.status)&&t.operation==="get"&&t.settlementRequestId||(S(),["running","waiting"].includes(v.run.status)||i.stop(),r.publish(t,v,P,I,V)),v}let c=i.submit,d=null,h=new WeakMap;function A(t){let I=h.get(t);if(I)return I;let b=T(t);return h.set(t,b),b}let F=!1;async function T(t){let I=await t;if(I.run.instruction?.type!=="evaluate_segment")return I;if(d)return d;F=!0;let b=r.generation,S=(async()=>{for(let P=0;P<32&&I.run.instruction?.type==="evaluate_segment";P++){if(i.pending||i.closeRequested)return I;let v=I.run;if(I.run.instruction?.type==="evaluate_segment"){let{advance:V}=await De(e.configuration,v,{predict:!1});if(b!==r.generation)throw new m("IDENTITY_CHANGED","Run identity changed during segment calculation");if(i.pending||i.closeRequested)return I;if(r.view&&(r.view.revision!==v.revision||r.view.visit!==v.visit||r.view.nodeId!==v.nodeId))return u({operation:"get"});let M=!0;De(e.configuration,v).then(({prediction:H})=>{M&&b===r.generation&&!i.closeRequested&&r.view?.id===v.id&&!r.view.stopped&&r.view.nodeId===v.nodeId&&r.view.visit===v.visit&&r.view.revision===v.revision&&(l=H)}).catch(()=>{});try{I=await c({operation:"commit_segment",requestId:Xe(v.id,v.visit,`segment:${v.revision}`),nodeId:v.nodeId,visit:v.visit,revision:v.revision,...V})}finally{M=!1,l=null}}}return I})();d=S;try{return await S}finally{d===S&&(d=null)}}let o={get configuration(){return F?e.configuration:void 0},get configurationReady(){return!0},get view(){return r.view?structuredClone(r.view):null},get pendingCommand(){let t=i.closing??i.pending;return t?structuredClone($(t)):null},get pendingCommands(){return[i.pending,i.closing].filter(t=>t!==null).map(t=>structuredClone($(t)))},get pendingPurchase(){return i.purchase?structuredClone(i.purchase):null},get prediction(){let t=r.view;return l&&t&&!t.stopped&&["running","waiting"].includes(t.status)&&t.id===l.runId&&t.nodeId===l.from.nodeId&&t.visit===l.from.visit&&t.revision===l.from.revision&&!i.closeRequested?structuredClone(l):null},settle:i.settle,get webViewUrl(){return"bundled"},resolvePaywall(t){return Pe(e,t)},async pageExperiments(t,I=[]){let b=r.generation;r.assertCurrent(b);let S=r.view?.id;if(!S)throw new m("INVALID_REQUEST","Read the Run before its page experiments");let P=tn.parse(await p(Te.parse({operation:"page_experiments",release:t,usedReceiptIds:I})));if(r.assertCurrent(b),P.runId!==S||P.scope.projectId!==r.scope?.projectId||P.scope.environment!==r.scope?.environment)throw new m("SCOPE_MISMATCH","Page experiment Run changed");return P},review(t){return u({operation:"review",...t?{receiptId:t}:{}},r.nextRead())},async get(t,I){f&&await i.ready,I??=i.purchase&&{receiptId:i.purchase.receiptId,operationId:i.purchase.operationId};let b=r.nextRead();return A(u({operation:"get",...t?{data:t}:{},...I?{purchase:I}:{}},b))},resume(t=r.view?.pendingRequest?.requestId){return t?i.closeRequested?o.settle(t):i.pending?.requestId===t?A(c(i.pending)):A(c({operation:"resume",requestId:t})):Promise.reject(new m("INVALID_REQUEST","No interrupted command is available"))},submit(t){return A(c(t))},retry(){return i.closeFlight?i.closeFlight:i.closing?c(i.closing):i.closeRequested&&i.pending?o.settle(i.pending.requestId):i.inFlight?A(i.inFlight):i.pending?A(c(i.pending)):Promise.reject(new m("INVALID_REQUEST","No command is pending"))},identify(t){r.identify(t),l=null,n.reset()},subscribe:r.subscribe,reset:a};return o}import{ZodError as Tn}from"zod";function Cn(e,n,r,s){try{return e.parse(n)}catch(l){throw s&&l instanceof Tn?new m(r,s):l}}async function Ee(e,n,r,s={},l){let y=typeof s=="function"?{}:s,f=Cn(n.request,r,"INVALID_REQUEST",y.request);try{let i=await e(n.path,f,n.method,l),p=typeof s=="function"?s:s.parseResponse;return p?p(n.response,i):Cn(n.response,i,"INVALID_RESPONSE",y.response)}catch(i){throw i instanceof m&&f!==null&&typeof f=="object"&&"requestId"in f&&typeof f.requestId=="string"&&(i.commandRequestId??=f.requestId),i}}async function jt(e,n){if(!ue.test(n.customerToken))throw new m("INVALID_TOKEN","A verified Customer credential is required");if(e.session&&e.session.peek()!==n.customerToken)throw new m("SCOPE_MISMATCH","Paywall credential does not match the shared session");let r=ne.resolvePaywall.request.parse({funnelId:n.funnelId,funnelVersionId:n.funnelVersionId,selector:n.paywallVersionId?{type:"version",versionId:n.paywallVersionId}:{type:"paywall",paywallId:n.paywallId},commerce:n.commerce,locale:n.locale,...n.requirement?{requirement:n.requirement}:{}}),s=Y(e);e.session||s.identify(n.customerToken);let l=null,y=!1,f=null,i=null,p=null,a=null;function u(){if(y)throw new m("IDENTITY_CHANGED","Paywall is closed")}async function c(){u();let F=ne.resolvePaywall,T=await Ee(s.request,F,{...r,selector:l?{type:"version",versionId:l.id}:r.selector}),o=await Pe(e,T.paywall);if(u(),n.paywallVersionId?o.id!==n.paywallVersionId:o.paywallId!==n.paywallId)throw new m("INVALID_RESPONSE","The requested Paywall changed");if(l&&(!dn(o,l)||o.paywallId!==l.paywallId))throw new m("INVALID_RESPONSE","The pinned Paywall or Offering Version changed");return l=o,structuredClone(l)}async function d(F){if(u(),a&&F!=="read")throw new m("COMMAND_PENDING","Wait for the original quote");if(!f)throw new m("INVALID_REQUEST","A quoted purchase is required");let T=f,o=F==="read"?ne.readSubscriptionOperation:ne.attach,t=await Ee(s.request,o,{operationId:T.operationId,...F==="read"?{}:{intent:F}});return fn(t.operation,{operationId:T.operationId,currency:r.commerce.currency},"The purchase operation changed"),u(),f?.operationId!==T.operationId?structuredClone(t.operation):(i=pn(i,t.operation),structuredClone(i))}let h={get view(){return l?structuredClone(l):null},get quote(){return f?structuredClone(f):null},get operation(){return i?structuredClone(i):null},get webViewUrl(){return"bundled"},refresh:c,async preview(F){if(u(),!l)throw new m("INVALID_REQUEST","Load the Paywall first");let T=l.document.buttons[F.actionId];if(T?.type!=="checkout")throw new m("INVALID_REQUEST","Choose an authored purchase action");let o=Ge(T.product,F.selection,l.capabilities);if(!o)throw new m("PRODUCT_UNAVAILABLE","Choose an available Product");let t=He(l.document.screen,o,F.selection,l.capabilities),I=ne.previewAttach.request.parse({funnelId:r.funnelId,funnelVersionId:r.funnelVersionId,requestId:F.requestId,plans:[{productVersionId:o,...Object.keys(t).length?{featureQuantities:t}:{}}],provider:r.commerce.provider,currency:r.commerce.currency,...F.offerId?{offerId:F.offerId}:{},...F.nativeOffer?{nativeOffer:F.nativeOffer}:{}}),b=JSON.stringify(I);if(p&&p!==b&&(a||!i||i.status==="pending"))throw new m("COMMAND_PENDING","Finish or cancel the original purchase before changing it");if(p===b){if(a)return a;if(f)return structuredClone(f)}p!==b&&(f=null,i=null),p=b;let S=(async()=>{let P=ne.previewAttach,v=await Ee(s.request,P,I);return u(),mn(v.quote,{productVersionId:o,featureQuantities:t,currency:r.commerce.currency,provider:r.commerce.provider},"The purchase quote changed its selected Product or presentment"),f=v.quote,i=null,structuredClone(f)})();a=S;try{return await S}finally{a===S&&(a=null)}},confirm:()=>d("confirm"),cancel:()=>d("cancel"),read:()=>d("read"),destroy(){y||(y=!0,A?.(),s.dispose(),l=null,f=null,i=null,p=null)}},A=e.session?.subscribeIdentity(h.destroy);try{return await c(),h}catch(F){throw h.destroy(),F}}import{z as Ln}from"zod";import{z as ge}from"zod";var _n=ge.record(ge.string().regex(/^[a-f0-9]{64}$/),ge.strictObject({at:ge.number(),text:ge.string()})),oe=2*1048576,Dn=100;function xn(){try{return typeof window>"u"?void 0:window.localStorage}catch{return}}function bn(e,n){let r=n===void 0?xn():n,s=new Map,l=0,y=!1,f=!1,i,p;async function a(c){if(!r)return null;let d;try{let h=await Promise.race([Promise.resolve().then(()=>r.getItem(c)),new Promise(A=>{d=setTimeout(()=>A(null),Dn)})]);return typeof h=="string"&&h.length<=oe&&new TextEncoder().encode(h).byteLength<=oe?h:null}catch{return null}finally{clearTimeout(d)}}function u(){if(p)return p;let c=(async()=>{try{let d=await a(`${e}:artifacts`);if(d)return _n.parse(JSON.parse(d))}catch{}return{}})();return p=c,c.finally(()=>{p===c&&(p=void 0)}),c}return{async readManifest(){return a(e)},writeManifest(c){!r||c.length>oe||new TextEncoder().encode(c).byteLength>oe||(i=c,!f&&(f=!0,Promise.resolve().then(async()=>{try{for(;i!==void 0;){let d=i;try{await r.setItem(e,d)}catch{}i===d&&(i=void 0)}}finally{f=!1}})))},async readArtifact(c){let d=(await u())[c],h=Date.now();return d&&h>=d.at&&h-d.at<=B.retentionMs?d.text:void 0},writeArtifact(c,d){if(!r||d.length>oe)return;let h=s.get(c);if(h?.text===d||!h&&s.size>=128)return;let A=new TextEncoder().encode(d).byteLength;l-(h?.byteLength??0)+A>oe||(s.set(c,{text:d,byteLength:A}),l+=A-(h?.byteLength??0),!y&&(y=!0,Promise.resolve().then(async()=>{try{for(;s.size;){let F=new Map(s);try{let T={...await u()},o=Date.now();for(let[S,P]of F)T[S]={at:o,text:P.text};let t={},I=2,b=0;for(let[S,P]of Object.entries(T).sort(([,v],[,D])=>D.at-v.at)){if(P.at>o||o-P.at>B.retentionMs)continue;let v=new TextEncoder().encode(JSON.stringify({[S]:P})).byteLength;I+v>oe||b>=128||(t[S]=P,I+=v,b++)}await r.setItem(`${e}:artifacts`,JSON.stringify(t))}catch{}finally{for(let[T,o]of F)s.get(T)===o&&(s.delete(T),l-=o.byteLength)}}}finally{y=!1}})))}}}var E=(e,n)=>new m(e,n),W=()=>performance.now(),Pn=e=>{typeof e=="object"&&"unref"in e&&e.unref()};function nr(e){let n=Ke.parse(e.scope),r=new te(e.origin??le);if(r.username||r.password||r.search||r.hash||r.pathname!=="/"||r.protocol!=="https:"&&!(r.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(r.hostname)))throw E("INVALID_URL","Configuration requires a trusted HTTPS origin");let s=new Set([r.origin,...(e.assetOrigins??[]).map(w=>{let g=new te(w);if(g.protocol!=="https:"||g.username||g.password||g.search||g.hash||g.pathname!=="/")throw E("INVALID_URL","Invalid configuration asset origin");return g.origin})]),l=e.fetch??globalThis.fetch.bind(globalThis),y=`/api/v1/configuration/${n.environmentId}`,f=`indiana:configuration:1:${r.origin}:${L(n)}`,i=bn(f,e.storage),p,a=0,u=0,c=!1,d=!1,h=0,A=0,F,T,o,t,I=0,b=new Set,S=new Set,P=new Map,v=new Map,D=0,V=!1;function M(){for(let w of b)try{w()}catch{}}function H(w){try{e.onError?.(w)}catch{}}let k=()=>!d&&!c&&!!p&&W()<a&&Date.now()<u;function J(){if(!k())throw E("CONFIGURATION_EXPIRED","Refresh configuration before using it")}function de(w,g,R){if(!P.has(w)){for(;P.size&&(P.size>=128||D+R>B.maxCacheBytes);){let C=P.entries().next().value;D-=C[1].byteLength,P.delete(C[0])}P.set(w,{text:g,byteLength:R}),D+=R}}function Z(w,g,R){return cn(w,g,{signal:R,error:C=>E("INVALID_RESPONSE",C==="missing"?"Configuration body is missing":"Configuration exceeds its byte limit")})}function fe(w){let g=new te(w,r);if(!s.has(g.origin)||g.username||g.password||g.hash||g.search)throw E("INVALID_URL","Configuration artifact origin is not trusted");return g.href}async function Fe(w,g,R=!1){let C=await l(fe(w),{method:"GET",credentials:"omit",redirect:"error",cache:R?"default":"no-cache",signal:g,headers:{}});if(C.status===429){let O=C.headers.get("retry-after")??"";I=/^\d+$/.test(O)?Number(O)*1e3:Math.max(0,Date.parse(O)-Date.now())||15e3}if(!C.ok&&C.status!==304)throw E(`CONFIGURATION_HTTP_${C.status}`,"Configuration synchronization failed");return C}function En(w,g,R){let C=Date.parse(w.headers.get("x-indiana-config-validated-at")??""),O=Date.parse(w.headers.get("x-indiana-config-valid-until")??""),_=Date.parse(w.headers.get("date")??""),N=w.headers.get("age"),G=N!==null&&/^\d+(\.\d+)?$/.test(N)?Number(N)*1e3:NaN;if(![C,O,_,G].every(Number.isFinite)||O<=C||O-C>B.maxControlAgeMs||C>_+1e3)throw E("INVALID_RESPONSE","Configuration freshness evidence is invalid");let x=Math.min(O-C,R.maxControlAgeSeconds*1e3,B.maxControlAgeMs)-Math.max(G,_-C,0)-(W()-g);if(x<=0)throw E("CONFIGURATION_EXPIRED","Configuration validation expired in transit");return W()+x}function Ae(){if(clearTimeout(o),clearTimeout(t),d||!b.size)return;k()&&(t=setTimeout(()=>{k()?Ae():M()},Math.max(1,a-W())),Pn(t));let w=A?Math.min(15e3,1e3*2**Math.min(A-1,4)):Math.min(15e3,(p?.policy.refreshIntervalSeconds??15)*1e3);o=setTimeout(()=>{ie().catch(H)},Math.max(I,w*(.8+Math.random()*.2))),Pn(o)}async function ie(){if(d)throw E("CONFIGURATION_DISPOSED","Configuration manager was destroyed");if(F)return F;let w=h,g=new AbortController;T=g;let R=(async()=>{if(!V){V=!0;try{let he=await i.readManifest();if(he&&!p){let K=Oe.parse(JSON.parse(he));L(K.scope)===L(n)&&(p=K)}}catch{}}g.signal.throwIfAborted();let N=p,G=W(),U=await Fe(y,g.signal);U.status===304&&(!N||!U.headers.has("x-indiana-config-validated-at")||!U.headers.has("x-indiana-config-valid-until")||!U.headers.has("age"))&&(U=await Fe(y,g.signal));let x=U.status===304?N:Oe.parse(JSON.parse(await Z(U,B.maxManifestBytes,g.signal))),{generation:ae,...se}=x,z=U.headers.get("etag");if(L(x.scope)!==L(n)||Qe(se)!==ae||z!==`"${ae}"`&&z!==`W/"${ae}"`)throw E("INVALID_RESPONSE","Configuration scope or content identity changed");if(N&&(x.revision<N.revision||x.revision===N.revision&&x.generation!==N.generation))throw E("INVALID_RESPONSE","Configuration revision moved backwards or changed identity");for(let[he,K]of Object.entries(N?.funnels??{})){let ee=x.funnels[he];if(ee&&(ee.controlRevision<K.controlRevision||ee.evaluationRevision<K.evaluationRevision||ee.controlRevision===K.controlRevision&&ee.state!==K.state||ee.evaluationRevision===K.evaluationRevision&&ee.evaluationMode!==K.evaluationMode))throw E("INVALID_RESPONSE","Funnel control revision changed identity")}let X=En(U,G,x.policy);if(g.signal.throwIfAborted(),w!==h)throw E("CONFIGURATION_DISPOSED","Configuration scope changed");return p=x,a=X,u=Date.now()+Math.max(0,X-W()),c=!1,A=0,I=0,i.writeManifest(L(x)),M(),structuredClone(x)})(),C=setTimeout(()=>g.abort(E("CONFIGURATION_UNAVAILABLE","Configuration initialization timed out")),B.initializationMs),O=new Promise((N,G)=>g.signal.addEventListener("abort",()=>G(g.signal.reason),{once:!0})),_=Promise.race([R,O]).catch(N=>{throw A++,(N instanceof Ln.ZodError||N instanceof SyntaxError||N instanceof m&&["CONFIGURATION_HTTP_404","CONFIGURATION_HTTP_410","INVALID_RESPONSE"].includes(N.code))&&(a=0,c=!0,M()),N}).finally(()=>{clearTimeout(C),F===_&&(F=void 0),Ae()});return F=_,_}async function ye(w){let g=w.sha256,R=se=>Ce(se,w);fe(w.url);let C=P.get(g);if(C){if(C.byteLength!==w.byteLength)throw E("INVALID_RESPONSE","Configuration artifact digest or size mismatch");return P.delete(g),P.set(g,C),C.text}let O=v.get(g);if(O){if(O.byteLength!==w.byteLength)throw E("INVALID_RESPONSE","Configuration artifact digest or size mismatch");return O.promise}let _=new AbortController;S.add(_);let N=h,G=(async()=>{try{let X=await i.readArtifact(g);if(X&&R(X)){if(_.signal.throwIfAborted(),d||N!==h)throw E("CONFIGURATION_DISPOSED","Configuration scope changed");return de(g,X,w.byteLength),X}}catch{}_.signal.throwIfAborted();let se=await Fe(w.url,_.signal,!0),z=await Z(se,w.byteLength,_.signal);if(!R(z))throw E("INVALID_RESPONSE","Configuration artifact digest or size mismatch");if(d||N!==h)throw E("CONFIGURATION_DISPOSED","Configuration scope changed");return de(g,z,w.byteLength),i.writeArtifact(g,z),z})(),U=setTimeout(()=>_.abort(E("CONFIGURATION_UNAVAILABLE","Configuration artifact timed out")),B.initializationMs),x=new Promise((se,z)=>_.signal.addEventListener("abort",()=>z(_.signal.reason),{once:!0})),ae=Promise.race([G,x]).finally(()=>{clearTimeout(U),S.delete(_),v.delete(g)});return v.set(g,{promise:ae,byteLength:w.byteLength}),ae}async function we(){return k()||await ie(),J(),p}async function me(w){let g,R=new Promise((C,O)=>{g=setTimeout(()=>O(E("CONFIGURATION_UNAVAILABLE","Configuration initialization timed out")),B.initializationMs)});try{return await Promise.race([w(),R])}finally{clearTimeout(g)}}function pe(w,g){if(J(),p?.generation!==w.generation)throw E("CONFIGURATION_CHANGED","Configuration changed while preparing a snapshot");if(g&&p.funnels[g]?.state!=="active")throw E("FUNNEL_STOPPED","Funnel is paused or unavailable")}async function xe(w){let g=w.gb.features;if(!g)throw E("CONFIGURATION_UNAVAILABLE","Public Feature delivery is disabled");let R=w.artifacts[g];if(R.formatVersion!==1)throw E("UNSUPPORTED_SCHEMA","Unsupported public GB configuration format");let C=je.parse(JSON.parse(await ye(R)));if(L(C.scope)!==L({projectId:n.projectId,environment:n.environment})||C.generation!==R.generation||C.remoteFeatures.some(O=>Object.hasOwn(C.features,O)))throw E("INVALID_RESPONSE","Public GB configuration scope or generation is invalid");return pe(w),{...C,evaluatedAt:new Date().toISOString(),expiresAt:new Date(Date.now()+Math.max(0,a-W())).toISOString()}}async function Le(w,g){let R=await we(),C=R.funnels[w];g&&(!C||C.evaluationMode==="local"&&!C.versions[g])&&(F&&await F,R=await ie()),pe(R,w);let O=R.funnels[w];if(O.evaluationMode!=="local")throw E("EVALUATION_MODE","This Funnel executes at Longplay; public graph loading is disabled");let _=g??O.currentVersionId,N=O.versions[_];if(!N)throw E("CONFIGURATION_UNAVAILABLE","Pinned Funnel Version is unavailable");if(R.artifacts[N.artifact].formatVersion!==3)throw E("UNSUPPORTED_SCHEMA","Unsupported public Funnel format");let[G,U]=await Promise.all([ye(R.artifacts[N.artifact]).then(x=>$e(JSON.parse(x))),O.evaluationMode==="local"?xe(R):void 0]);if(U&&L(Ye(G,U))!==L(N.dependencies))throw E("INVALID_RESPONSE","Funnel and GB dependency contract do not match");return pe(R,w),{document:G,growth:U,versionId:_,control:structuredClone(O),manifest:structuredClone(R)}}async function Ve(w,g){try{return await Le(w,g)}catch(R){if(!(R instanceof m)||!(R.code==="CONFIGURATION_CHANGED"||R.code==="CONFIGURATION_HTTP_404"&&k()))throw R;let C=p?.generation;if(F&&await F,await ie(),R.code!=="CONFIGURATION_CHANGED"&&p?.generation===C)throw R;return Le(w,g)}}function Ne(){c=!0,M(),ie().catch(H)}let Ie=()=>{(typeof document>"u"||document.visibilityState==="visible")&&Ne()};function Fn(w){if(d)throw E("CONFIGURATION_DISPOSED","Configuration manager was destroyed");return b.add(w),b.size===1&&(typeof window<"u"&&(window.addEventListener("online",Ne),window.addEventListener("focus",Ie),document.addEventListener("visibilitychange",Ie)),Ae()),()=>{b.delete(w),b.size||(clearTimeout(o),clearTimeout(t),Me())}}function Me(){typeof window<"u"&&(window.removeEventListener("online",Ne),window.removeEventListener("focus",Ie),document.removeEventListener("visibilitychange",Ie))}return{scope:Object.freeze({...n}),refresh:ie,subscribe:Fn,assertFresh:J,assertFeatures(w){J();let g=p.gb.features;if(!g)throw E("CONFIGURATION_UNAVAILABLE","Public Feature delivery is disabled");if(w!==void 0&&p.artifacts[g].generation!==w)throw E("CONFIGURATION_CHANGED","Refresh changed Feature configuration before evaluation")},get fresh(){return k()},get snapshot(){return p?structuredClone(p):null},get remainingMs(){return k()?Math.max(0,a-W()):0},async features(){return me(async()=>xe(await we()))},pageExperiments:()=>me(async()=>{let w=await we(),g=w.gb.pageExperiments;if(!g)throw E("CONFIGURATION_UNAVAILABLE","Public page experiments are disabled");let R=w.artifacts[g];if(R.formatVersion!==1)throw E("UNSUPPORTED_SCHEMA","Unsupported page experiment format");let C=an.parse(JSON.parse(await ye(R)));if(C.environmentId!==n.environmentId||C.generation!==R.generation)throw E("INVALID_RESPONSE","Page experiment scope or generation changed");return pe(w),C}),funnel:(w,g)=>me(()=>Ve(w,g)),paywall:(w,g)=>me(async()=>{let R=await we(),C=R.paywalls?.[w];if(!C||!g&&C.state!=="published")throw E("PAYWALL_UNAVAILABLE","Published Paywall is unavailable");let O=g??C.currentVersionId,_=C.versions[O],N=_&&R.artifacts[_.artifact];if(!N||N.kind!=="paywall"||N.formatVersion!==1)throw E("UNSUPPORTED_SCHEMA","Public Paywall format is unavailable");let G=ze.parse(JSON.parse(await ye(N)));return pe(R),{document:G,versionId:O,version:_.version,control:structuredClone(C),manifest:structuredClone(R)}}),async localFunnel(w,g){let R=await me(()=>Ve(w,g));if(!R.growth)throw E("EVALUATION_MODE","This Funnel requires remote execution");let{analyticsConfig:C,remoteFeatures:O,..._}=R.growth;return on({scope:{projectId:n.projectId,environment:n.environment},funnelId:w,versionId:R.versionId,evaluationMode:"local",evaluationRevision:R.control.evaluationRevision,document:R.document,payload:_})},assertFunnel(w,g,R){J();let C=p.funnels[w];if(!C||C.state!=="active")throw E("FUNNEL_STOPPED","Funnel is paused or unavailable");if(C.evaluationMode!=="local")throw E("EVALUATION_MODE","This Funnel now executes at Longplay");if(g!==void 0&&C.controlRevision!==g)throw E("RUN_RECONCILIATION_REQUIRED","Reconcile the original Run after a control change");if(R!==void 0&&!C.versions[R])throw E("CONFIGURATION_UNAVAILABLE","Pinned Funnel Version is unavailable")},destroy(){if(!d){d=!0,h++,a=0,T?.abort(E("CONFIGURATION_DISPOSED","Configuration manager was destroyed")),clearTimeout(o),clearTimeout(t),Me(),M(),b.clear();for(let w of S)w.abort(E("CONFIGURATION_DISPOSED","Configuration manager was destroyed"));P.clear(),D=0}}}}function Sn(e){let n=ue.test(e.apiKey);if(typeof window<"u"&&!n)throw new m("SERVER_ONLY","Funnel starts are issued by your backend");if(!n&&!re.test(e.apiKey))throw new m("INVALID_TOKEN","A customer credential or server API key is required");return{async start(r){let s=Q.safeParse({...r,operation:"start"});if(!s.success||s.data.operation!=="start"||(n?s.data.customer!==void 0:s.data.customer===void 0))throw new m("INVALID_REQUEST","Invalid current Funnel start");let l=s.data,y=Y({...e,timeoutMs:e.timeoutMs??35e3});try{e.session||y.identify(e.apiKey);let f=be(e,await y.request("funnels",l));if(!f.runToken)throw new m("INVALID_RESPONSE","Funnel start credentials are missing");if(f.run.source.id!==l.funnelId||f.run.locale!==(l.locale??"en")||!ce(f.run.parameters,l.parameters??{})||(l.customer?!f.customerId||l.customer.type==="id"&&f.customerId!==l.customer.value:f.customerId!==void 0))throw new m("INVALID_RESPONSE","Funnel start contract changed");return{...f,runToken:f.runToken}}finally{y.dispose()}}}}async function pr(e){e={...e};let n=e.configuration;if(!n)throw new m("CONFIGURATION_UNAVAILABLE","Local conditions require public configuration");let r={projectId:n.scope.projectId,environment:n.scope.environment};if(e.scope&&L(r)!==L(e.scope))throw new m("SCOPE_MISMATCH","Configuration and transport scopes differ");if((await n.funnel(e.funnelId)).control.evaluationMode!=="local")throw new m("EVALUATION_MODE","This Funnel uses Remote evaluation");let l=re.test(e.credential);if(l?!e.customerId:e.customerId!==void 0)throw new m("INVALID_REQUEST","Only Server-Key starts name their Customer");let y=Sn({...e,scope:r,apiKey:e.credential}),f=i=>{let p=Rn({...e,scope:r,runToken:i,...l?{serverKey:e.credential}:{}});return l||p.identify(e.credential),p};return{async start(i){let p=await y.start({...i,funnelId:e.funnelId,...l?{customer:{type:"id",value:e.customerId}}:{}}),a=f(p.runToken),u=await a.get();return{...p,...u,controller:a}},async restore(i){let p=f(i),a=await p.get();if(a.run.source.id!==e.funnelId)throw p.reset(),new m("SCOPE_MISMATCH","Run belongs to another Funnel");return{...a,runToken:i,controller:p}}}}export{Ee as a,Mn as b,be as c,_e as d,Xn as e,Nn as f,gn as g,lt as h,ce as i,yt as j,wt as k,Rn as l,jt as m,nr as n,Sn as o,pr as p};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import{z as Vr}from"zod";var zr=["USD","EUR","CNY","GBP","JPY","CAD","AUD","NZD","CHF","HKD","SGD","KRW","INR","BRL","MXN","TWD","THB","IDR","MYR","PHP","VND","ZAR","AED","SAR","SEK","NOK","DKK","PLN","CZK","HUF","ILS","TRY","RON"],j=Vr.enum(zr);function Ur(e){let t=j.parse(e.toUpperCase());return["JPY","KRW","VND"].includes(t)?0:2}function Pe(e,t,r="en",n={}){let i=j.parse(t.toUpperCase());return new Intl.NumberFormat(r,{style:"currency",currency:i,...n}).format(e/10**Ur(i))}import{z as l}from"zod";function $e(e){let t=2166136261,r=e.length;for(let n=0;n<r;n++)t^=e.charCodeAt(n),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return t>>>0}function pe(e,t,r){return r===2?$e($e(e+t)+"")%1e4/1e4:null}function gt(e){return e<=0?[]:new Array(e).fill(1/e)}function de(e,t){return e>=t[0]&&e<t[1]}function Fe(e,t){for(let[r,n]of t.entries())if(de(e,n))return r;return-1}function Be(e,t,r){t=t===void 0?1:t,t<0?t=0:t>1&&(t=1);let n=gt(e);r=r||n,r.length!==e&&(r=n);let i=r.reduce((c,u)=>u+c,0);(i<.99||i>1.01)&&(r=n);let a=0,o=t;return r.map(c=>{let u=a;return a+=c,[u,u+o*c]})}function Ve(e,t,r){if(!t)return null;let n=t.split("?")[1];if(!n)return null;let a=n.replace(/#.*/,"").split("&").map(o=>o.split("=",2)).filter(([o])=>o===e).map(([,o])=>o===void 0?NaN:parseInt(o))[0];return a!==void 0&&a>=0&&a<r?a:null}function ze(e){try{return e()}catch{return!1}}function ne(e){return typeof e=="string"?e:JSON.stringify(e)}function D(e){typeof e=="number"&&(e=e+""),(!e||typeof e!="string")&&(e="0");let t=e.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return t.length===3&&t.push("~"),t.map(r=>r.match(/^[0-9]+$/)?r.padStart(5," "):r).join("-")}function ht(e){try{let t=e.replace(/([^\\])\//g,"$1\\/");return new RegExp(t)}catch{return}}function Ue(e,t){if(!t.length)return!1;let r=!1,n=!1;for(let i of t){let a=Hr(e,i.type,i.pattern);if(i.include===!1){if(a)return!1}else r=!0,a&&(n=!0)}return n||!r}function Mr(e,t,r){try{let n=t.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return r&&(n="\\/?"+n.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+n+"$","i").test(e)}catch{return!1}}function qr(e,t){try{let r=new URL(t.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),n=[[e.host,r.host,!1],[e.pathname,r.pathname,!0]];return r.hash&&n.push([e.hash,r.hash,!1]),r.searchParams.forEach((i,a)=>{n.push([e.searchParams.get(a)||"",i,!1])}),!n.some(i=>!Mr(i[0],i[1],i[2]))}catch{return!1}}function Hr(e,t,r){try{let n=new URL(e,"https://_");if(t==="regex"){let i=ht(r);return i?i.test(n.href)||i.test(n.href.substring(n.origin.length)):!1}else if(t==="simple")return qr(n,r);return!1}catch{return!1}}function Me(e){for(let r of["namespace","status","url","groups"])if(Object.hasOwn(e,r))throw new TypeError(`Retired experiment field: ${r}`);let t=e;if(t.hashVersion!==void 0&&t.hashVersion!==2)throw new TypeError("Only hash version 2 is supported");if(t.filters?.some(r=>r.hashVersion!==2))throw new TypeError("Only hash version 2 is supported")}function Ae(e){for(let t of Object.values(e)){if(Array.isArray(t))throw new TypeError("Saved groups require typed list or condition entries");if(t&&Object.hasOwn(t,"useEmptyListGroup"))throw new TypeError("Retired saved group field: useEmptyListGroup")}}function bt(e){for(let t of["overrides","groups"])if(Object.hasOwn(e,t))throw new TypeError(`Retired evaluation context field: ${t}`);Ae(e.savedGroups??{})}var Gr=e=>e/2**32|0,Qr=e=>e>>>0;function yt(e,t,r,n){let i=Gr(r),a=Qr(r);e.setUint32(t,n?a:i,n),e.setUint32(t+4,n?i:a,n)}function xt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}var qe=e=>e?`"${e}" `:"";function Kr(e,t=""){if(typeof e!="number")throw new TypeError(qe(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(qe(t)+"expected integer >= 0, got "+e);return e}function ke(e,t,r=""){if(xt(e)&&(t===void 0||e.length===t))return e;t!==void 0&&Kr(t,"length");let n=xt(e),i=t!==void 0?` of length ${t}`:"",a=n?`length=${e.length}`:`type=${typeof e}`,o=qe(r)+"expected Uint8Array"+i+", got "+a;throw n?new RangeError(o):new TypeError(o)}var Zr=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError((t==="object"?"":`"${t}" `)+"expected object, got type="+typeof e)},St=(e,t)=>{Zr(e,t);let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)throw new TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,"__proto__"))throw new TypeError(`"${t}.__proto__" is not allowed`)};function He(e,t=!0){if(e.destroyed)throw new Error("hash was destroyed");if(t&&e.finished)throw new Error("digest() was already called")}function At(e,t){ke(e,void 0,"output");let r=t.outputLen;if(!(e.length>=r))throw new RangeError('"output" expected length >= '+r)}function Ge(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ee(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function F(e,t){return e<<32-t|e>>>t}var Wr=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Jr=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function kt(e){if(ke(e),Wr)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Jr[e[r]];return t}function Yr(e,t,r="opts"){return St(e,"defaults"),t!==void 0&&St(t,r),Object.assign(Object.create(null),e,t)}function Et(e,t={}){if(typeof e!="function")throw new TypeError('"hashCons" expected function, got type='+typeof e);t=Yr({},t,"info");let r=(i,a)=>e(a).update(i).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=i=>e(i),Object.assign(r,t),Object.freeze(r)}var _t=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function It(e,t,r){return e&t^~e&r}function wt(e,t,r){return e&t^e&r^t&r}var _e=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,i){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(t),this.view=Ee(this.buffer)}update(t){He(this),ke(t);let{view:r,buffer:n,blockLen:i}=this,a=t.length,o=!1;for(let c=0;c<a;){let u=Math.min(i-this.pos,a-c);if(u===i){let f=Ee(t);for(;i<=a-c;c+=i)this.process(f,c);o=!0;continue}n.set(c===0&&u===a?t:t.subarray(c,c+u),this.pos),this.pos+=u,c+=u,this.pos===i&&(this.process(r,0),this.pos=0,o=!0)}return this.length+=t.length,o&&this.roundClean(),this}digestInto(t){He(this),At(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:a}=this,{pos:o}=this;r[o++]=128,r.fill(0,o),this.padOffset>i-o&&(this.process(n,0),r.fill(0)),yt(n,i-8,this.length*8,a),this.process(n,0),this.roundClean();let c=t===r?n:Ee(t),u=this.outputLen,f=u/4,d=this.get();if(u%4||f>d.length)throw new Error("invalid outputLen");for(let m=0;m<f;m++)c.setUint32(4*m,d[m],a)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneIntoMeta(t){let{buffer:r,length:n,finished:i,destroyed:a,pos:o}=this;return t.destroyed=a,t.finished=i,t.length=n,t.pos=o,o&&t.buffer.set(r),t}clone(){return this._cloneInto()}},Rt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Xr=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),K=new Uint32Array(64),Qe=class extends _e{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(t,r){super(64,t,8,!1),this.A=r[0]|0,this.B=r[1]|0,this.C=r[2]|0,this.D=r[3]|0,this.E=r[4]|0,this.F=r[5]|0,this.G=r[6]|0,this.H=r[7]|0}get(){let{A:t,B:r,C:n,D:i,E:a,F:o,G:c,H:u}=this;return[t,r,n,i,a,o,c,u]}set(t,r,n,i,a,o,c,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=a|0,this.F=o|0,this.G=c|0,this.H=u|0}_cloneInto(t){return(t||=new this.constructor).set(...this.get()),this._cloneIntoMeta(t)}process(t,r){for(let m=0;m<16;m++,r+=4)K[m]=t.getUint32(r,!1);for(let m=16;m<64;m++){let y=K[m-15],S=K[m-2],_=F(y,7)^F(y,18)^y>>>3,A=F(S,17)^F(S,19)^S>>>10;K[m]=A+K[m-7]+_+K[m-16]|0}let{A:n,B:i,C:a,D:o,E:c,F:u,G:f,H:d}=this;for(let m=0;m<64;m++){let y=F(c,6)^F(c,11)^F(c,25),S=d+y+It(c,u,f)+Xr[m]+K[m]|0,A=(F(n,2)^F(n,13)^F(n,22))+wt(n,i,a)|0;d=f,f=u,u=c,c=o+S|0,o=a,a=i,i=n,n=S+A|0}n=n+this.A|0,i=i+this.B|0,a=a+this.C|0,o=o+this.D|0,c=c+this.E|0,u=u+this.F|0,f=f+this.G|0,d=d+this.H|0,this.set(n,i,a,o,c,u,f,d)}roundClean(){Ge(K)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Ge(this.buffer)}},Ke=class extends Qe{constructor(){super(32,Rt)}};var Nt=Et(()=>new Ke,_t(1));var Ot=new Map,Ze=32,Ct=new WeakMap,vt=new WeakMap;function en(e){return kt(Nt(new TextEncoder().encode(String(e))))}var we=e=>Array.isArray(e)?e.map(we):typeof e=="string"||typeof e=="number"?en(e):null,Ie=e=>typeof e=="string"?e.toLowerCase():e;function Pt(e){let t=Ct.get(e);return t||(t=new Set(e),Ct.set(e,t)),t}function tn(e){let t=vt.get(e);return t||(t=new Set(e.map(Ie)),vt.set(e,t)),t}function $t(e){Ae(e);for(let t of Object.values(e)){let r=t?.type==="list"||t?.type==="hashed"?t.values:null;r&&r.length>=Ze&&Pt(r)}return e}function B(e,t,r,n){r=r||{},n||Ae(r),n=n||new Set;for(let[i,a]of Object.entries(t))switch(i){case"$or":if(!Lt(e,a,r,n))return!1;break;case"$nor":if(Lt(e,a,r,n))return!1;break;case"$and":if(!sn(e,a,r,n))return!1;break;case"$not":if(B(e,a,r,n))return!1;break;case"$savedGroup":if(!rn(e,a,r,n))return!1;break;default:if(!fe(a,Ft(e,i),r,!1,n))return!1}return!0}function rn(e,t,r,n){if(!t||typeof t!="object"||Array.isArray(t))return!1;let{id:i,attributeKey:a}=t;if(typeof i!="string"||n.has(i)||a!==void 0&&typeof a!="string")return!1;let o=r[i];if(!o||Array.isArray(o)||typeof o!="object")return!1;let c=new Set(n).add(i);if(o.type==="list"||o.type==="hashed"){let u=a??o.attributeKey;if(typeof u!="string"||!Array.isArray(o.values))return!1;let f=Ft(e,u);return X(o.type==="hashed"?we(f):f,o.values)}return o.type==="condition"?!o.condition||typeof o.condition!="object"?!1:B(e,o.condition,r,c):!1}function Ft(e,t){let r=t.split("."),n=e;for(let i of r)if(n&&typeof n=="object"&&i in n)n=n[i];else return null;return n}function Tt(e,t=!1){let r=`${e}${t?"/i":""}`,n=Ot.get(r);return n||(n=new RegExp(e.replace(/([^\\])\//g,"$1\\/"),t?"i":void 0),Ot.set(r,n)),n}function fe(e,t,r,n=!1,i=new Set){if(typeof e=="string")return n?String(t).toLowerCase()===e.toLowerCase():t+""===e;if(typeof e=="number")return t*1===e;if(typeof e=="boolean")return t!==null&&!!t===e;if(e===null)return t===null;if(Array.isArray(e)||!Bt(e))return JSON.stringify(t)===JSON.stringify(e);let a=e;for(let o in a)if(!an(o,t,a[o],r,i))return!1;return!0}function Bt(e){let t=Object.keys(e);return t.length>0&&t.filter(r=>r[0]==="$").length===t.length}function nn(e){if(e===null)return"null";if(Array.isArray(e))return"array";let t=typeof e;return["string","number","boolean","object","undefined"].includes(t)?t:"unknown"}function on(e,t,r,n){if(!Array.isArray(e))return!1;let i=Bt(t)?a=>fe(t,a,r,!1,n):a=>B(a,t,r,n);for(let a=0;a<e.length;a++)if((e[a]??null)!==null&&i(e[a]))return!0;return!1}function X(e,t,r=!1){if(r){let i;if(t.length>=Ze){let a=tn(t);i=o=>{let c=Ie(o);return!(typeof c=="number"&&Number.isNaN(c))&&a.has(c)}}else i=a=>t.some(o=>Ie(a)===Ie(o));return Array.isArray(e)?e.some(a=>i(a)):i(e)}let n=t.length>=Ze?(i=>a=>i.has(a))(Pt(t)):i=>t.includes(i);return Array.isArray(e)?e.some(i=>n(i)):n(e)}function jt(e){return e===void 0?[]:e&&typeof e=="object"&&(e.type==="list"||e.type==="hashed")&&Array.isArray(e.values)?e.values:null}function Dt(e,t,r,n=!1,i=new Set){if(!Array.isArray(e))return!1;for(let a=0;a<t.length;a++){let o=!1;for(let c=0;c<e.length;c++)if(fe(t[a],e[c],r,n,i)){o=!0;break}if(!o)return!1}return!0}function an(e,t,r,n,i=new Set){let a=t,o=r;switch(e){case"$veq":return D(t)===D(r);case"$vne":return D(t)!==D(r);case"$vgt":return D(t)>D(r);case"$vgte":return D(t)>=D(r);case"$vlt":return D(t)<D(r);case"$vlte":return D(t)<=D(r);case"$eq":return t===r;case"$ne":return t!==r;case"$lt":return a<o;case"$lte":return a<=o;case"$gt":return a>o;case"$gte":return a>=o;case"$exists":return r?t!=null:t==null;case"$in":return Array.isArray(r)?X(t,r):!1;case"$ini":return Array.isArray(r)?X(t,r,!0):!1;case"$inGroup":{let c=n[r],u=jt(c);return u===null?!1:X(c?.type==="hashed"?we(t):t,u)}case"$notInGroup":{let c=n[r],u=jt(c);return u===null?!1:!X(c?.type==="hashed"?we(t):t,u)}case"$nin":return Array.isArray(r)?!X(t,r):!1;case"$nini":return Array.isArray(r)?!X(t,r,!0):!1;case"$not":return!fe(r,t,n,!1,i);case"$size":return Array.isArray(t)?fe(r,t.length,n,!1,i):!1;case"$elemMatch":return on(t,r,n,i);case"$all":return Array.isArray(r)?Dt(t,r,n,!1,i):!1;case"$alli":return Array.isArray(r)?Dt(t,r,n,!0,i):!1;case"$regex":try{return Tt(r).test(t)}catch{return!1}case"$regexi":try{return Tt(r,!0).test(t)}catch{return!1}case"$type":return nn(t)===r;default:return!1}}function Lt(e,t,r,n){if(!t.length)return!0;for(let i of t)if(B(e,i,r,n))return!0;return!1}function sn(e,t,r,n){for(let i of t)if(!B(e,i,r,n))return!1;return!0}function We(e){return bt(e),{context:e,stack:{evaluatedFeatures:new Set}}}function Je(e){return{...e.attributes,...e.attributeOverrides}}function Z(e,t,r){let n=t||"id",i="",a=Je(e);return a[n]&&(i=a[n]),!i&&r&&(a[r]&&(i=a[r]),i&&(n=r)),{hashAttribute:n,hashValue:i}}function k(e,t,r){e.context.log?.(t,r)}function Re(e,t){return t=t||0,`${e}__${t}`}function Ye(e,t){return`${e}||${t}`}function cn(e,t,r){let n=e.stickyBucketAssignmentDocs;if(!n)return{};let{hashAttribute:i,hashValue:a}=Z(e,t),o=Ye(i,ne(a)),{hashAttribute:c,hashValue:u}=Z(e,r),f=u?Ye(c,ne(u)):null,d={};return f&&n[f]&&Object.assign(d,n[f].assignments||{}),n[o]&&Object.assign(d,n[o].assignments||{}),d}function Vt({context:e,expKey:t,expBucketVersion:r,expHashAttribute:n,expFallbackAttribute:i,expMinBucketVersion:a,expMeta:o}){r=r||0,a=a||0,n=n||"id",o=o||[];let c=Re(t,r),u=cn(e,n,i);if(a>0)for(let m=0;m<a;m++){let y=Re(t,m);if(u[y]!==void 0)return{variation:-1,versionIsBlocked:!0}}let f=u[c];if(f===void 0)return{variation:-1};let d=o.findIndex(m=>m.key===f);return d<0?{variation:-1}:{variation:d}}function zt(e,t,r,n){let i=Ye(t,r),a=e.stickyBucketAssignmentDocs,o=a&&a[i]?a[i].assignments||{}:{},c={...o,...n},u=JSON.stringify(o)!==JSON.stringify(c);return{key:i,doc:{attributeName:t,attributeValue:r,assignments:c},changed:u}}function Ut(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function Mt(e,t){let r=We(t),n=Gt(e,null,r);return t.onExperimentEval?.(e,n),n}function qt(e,t){return et(e,We(t))}function un(e){return e.forcedVariations||{}}function Ht(e,t,r){let{context:n}=e;if(n.trackedExperiments){let i=Zt(t,r);if(n.trackedExperiments.has(i))return;n.trackedExperiments.add(i)}Xe(()=>n.onExperimentViewed?.(t,r))}function ln(e,t,r){let{context:n}=e;if(n.trackedFeatureUsage){let i=JSON.stringify(r.value);if(n.trackedFeatureUsage[t]===i)return;n.trackedFeatureUsage[t]=i}Xe(()=>n.onFeatureUsage?.(t,r))}function Xe(e){try{let t=e();t&&typeof t.catch=="function"&&t.catch(()=>{})}catch{}}function et(e,t){let{context:r}=t;if(t.stack.evaluatedFeatures.has(e))return k(t,`evalFeature: circular dependency detected: ${t.stack.id} -> ${e}`,{from:t.stack.id,to:e}),W(t,e,null,"cyclicPrerequisite");t.stack.evaluatedFeatures.add(e),t.stack.id=e;let n=r.features?.[e];for(let a of n?.rules??[])Me(a);let i=r.forcedFeatureValues;if(i&&i.has(e))return k(t,"Global override",{id:e,value:i.get(e)}),W(t,e,i.get(e),"override");if(!n)return k(t,"Unknown feature",{id:e}),W(t,e,null,"unknownFeature");if(n.rules){let a=new Set(t.stack.evaluatedFeatures);e:for(let o of n.rules){if(o.parentConditions)for(let f of o.parentConditions){t.stack.evaluatedFeatures=new Set(a);let d=et(f.id,t);if(d.source==="cyclicPrerequisite")return W(t,e,null,"cyclicPrerequisite");let m={value:d.value};if(!B(m,f.condition||{},r.savedGroups||{})){if(f.gate)return k(t,"Feature blocked by prerequisite",{id:e,rule:o}),W(t,e,null,"prerequisite");k(t,"Skip rule because prerequisite evaluation fails",{id:e,rule:o});continue e}}if(o.filters&&Kt(o.filters,t)){k(t,"Skip rule because of filters",{id:e,rule:o});continue}if("force"in o){if(o.condition&&!Qt(o.condition,t)){k(t,"Skip rule because of condition ff",{id:e,rule:o});continue}if(!pn(t,o.seed||e,o.hashAttribute,r.saveStickyBucketAssignmentDoc&&!o.disableStickyBucketing?o.fallbackAttribute:void 0,o.range,o.coverage,o.hashVersion)){k(t,"Skip rule because user not included in rollout",{id:e,rule:o});continue}return k(t,"Force value from rule",{id:e,rule:o}),o.tracks&&o.tracks.forEach(f=>{Ht(t,f.experiment,f.result)}),W(t,e,o.force,"force",o.id)}if(!o.variations){k(t,"Skip invalid rule",{id:e,rule:o});continue}let c={variations:o.variations,key:o.key||e};"coverage"in o&&(c.coverage=o.coverage),o.weights&&(c.weights=o.weights),o.hashAttribute&&(c.hashAttribute=o.hashAttribute),o.fallbackAttribute&&(c.fallbackAttribute=o.fallbackAttribute),o.disableStickyBucketing&&(c.disableStickyBucketing=o.disableStickyBucketing),o.bucketVersion!==void 0&&(c.bucketVersion=o.bucketVersion),o.minBucketVersion!==void 0&&(c.minBucketVersion=o.minBucketVersion),o.meta&&(c.meta=o.meta),o.ranges&&(c.ranges=o.ranges),o.name&&(c.name=o.name),o.phase&&(c.phase=o.phase),o.seed&&(c.seed=o.seed),o.hashVersion&&(c.hashVersion=o.hashVersion),o.filters&&(c.filters=o.filters),o.condition&&(c.condition=o.condition);let u=Gt(c,e,t);if(r.onExperimentEval?.(c,u),u.inExperiment&&!u.passthrough)return W(t,e,u.value,"experiment",o.id,c,u)}}return k(t,"Use default value",{id:e,value:n.defaultValue}),W(t,e,n.defaultValue===void 0?null:n.defaultValue,"defaultValue")}function Gt(e,t,r){let{context:n}=r;Me(e);let i=e.key,a=e.variations.length;if(a<2)return k(r,"Invalid experiment",{id:i}),v(r,e,-1,!1,t);if(n.enabled===!1)return k(r,"Context disabled",{id:i}),v(r,e,-1,!1,t);if(e.urlPatterns&&!Ue(n.url||"",e.urlPatterns))return k(r,"Skip because of url targeting",{id:i}),v(r,e,-1,!1,t);let o=Ve(i,n.url||"",a);if(o!==null)return k(r,"Force via querystring",{id:i,variation:o}),v(r,e,o,!1,t);let u=un(n)[i];if(u!==void 0)return k(r,"Force via dev tools",{id:i,variation:u}),v(r,e,u,!1,t);if(e.active===!1)return k(r,"Skip because inactive",{id:i}),v(r,e,-1,!1,t);let{hashAttribute:f,hashValue:d}=Z(n,e.hashAttribute,n.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0);if(!d)return k(r,"Skip because missing hashAttribute",{id:i}),v(r,e,-1,!1,t);let m=-1,y=!1,S=!1;if(n.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing){let{variation:T,versionIsBlocked:P}=Vt(Ut({context:n,expKey:e.key,expBucketVersion:e.bucketVersion,expHashAttribute:e.hashAttribute,expFallbackAttribute:e.fallbackAttribute,expMinBucketVersion:e.minBucketVersion,expMeta:e.meta}));y=T>=0,m=T,S=!!P}if(!y){if(e.filters&&Kt(e.filters,r))return k(r,"Skip because of filters",{id:i}),v(r,e,-1,!1,t);if(e.include&&!ze(e.include))return k(r,"Skip because of include function",{id:i}),v(r,e,-1,!1,t);if(e.condition&&!Qt(e.condition,r))return k(r,"Skip because of condition exp",{id:i}),v(r,e,-1,!1,t);if(e.parentConditions){let T=new Set(r.stack.evaluatedFeatures);for(let P of e.parentConditions){r.stack.evaluatedFeatures=new Set(T);let Y=et(P.id,r);if(Y.source==="cyclicPrerequisite")return v(r,e,-1,!1,t);let Le={value:Y.value};if(!B(Le,P.condition||{},n.savedGroups||{}))return k(r,"Skip because prerequisite evaluation fails",{id:i}),v(r,e,-1,!1,t)}}}let _=pe(e.seed||i,d,e.hashVersion??2);if(_===null)return k(r,"Skip because of invalid hash version",{id:i}),v(r,e,-1,!1,t);if(!y){let T=e.ranges||Be(a,e.coverage===void 0?1:e.coverage,e.weights);m=Fe(_,T)}if(S)return k(r,"Skip because sticky bucket version is blocked",{id:i}),v(r,e,-1,!1,t,void 0,!0);if(m<0)return k(r,"Skip because of coverage",{id:i}),v(r,e,-1,!1,t);if("force"in e)return k(r,"Force variation",{id:i,variation:e.force}),v(r,e,e.force===void 0?-1:e.force,!1,t);if(n.qaMode)return k(r,"Skip because QA mode",{id:i}),v(r,e,-1,!1,t);let A=v(r,e,m,!0,t,_,y);if(n.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing){let{changed:T,key:P,doc:Y}=zt(n,f,ne(d),{[Re(e.key,e.bucketVersion)]:A.key});if(T){n.stickyBucketAssignmentDocs=n.stickyBucketAssignmentDocs||{},n.stickyBucketAssignmentDocs[P]=Y;let Le=n.saveStickyBucketAssignmentDoc;Xe(()=>Le(Y))}}return Ht(r,e,A),k(r,"In experiment",{id:i,variation:A.variationId}),A}function W(e,t,r,n,i,a,o){let c={value:r,on:!!r,off:!r,source:n,ruleId:i||""};return a&&(c.experiment=a),o&&(c.experimentResult=o),n!=="override"&&ln(e,t,c),c}function Qt(e,t){return B(Je(t.context),e,t.context.savedGroups||{})}function Kt(e,t){return e.some(r=>{let{hashValue:n}=Z(t.context,r.attribute);if(!n)return!0;let i=pe(r.seed,n,r.hashVersion||2);return i===null?!0:!r.ranges.some(a=>de(i,a))})}function pn(e,t,r,n,i,a,o){if(!i&&a===void 0)return!0;if(!i&&a===0)return!1;let{hashValue:c}=Z(e.context,r,n);if(!c)return!1;let u=pe(t,c,o??2);return u===null?!1:i?de(u,i):a!==void 0?u<=a:!0}function v(e,t,r,n,i,a,o){let c=!0;(r<0||r>=t.variations.length)&&(r=0,c=!1);let{hashAttribute:u,hashValue:f}=Z(e.context,t.hashAttribute,e.context.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing?t.fallbackAttribute:void 0),d=t.meta?.[r]??{},m=t.variations[0];for(let[S,_]of t.variations.entries())if(S===r){m=_;break}let y={key:d.key||""+r,featureId:i,inExperiment:c,hashUsed:n,variationId:r,value:m,hashAttribute:u,hashValue:f,stickyBucketUsed:!!o};return d.name&&(y.name=d.name),a!==void 0&&(y.bucket=a),d.passthrough&&(y.passthrough=d.passthrough),y}function Zt(e,t){return t.hashAttribute+t.hashValue+e.key+t.variationId}/*!
|
|
2
|
+
Copyright (c) 2025 GrowthBook, Inc.
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
5
|
+
furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all
|
|
8
|
+
copies or substantial portions of the Software.
|
|
9
|
+
|
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
11
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
12
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
13
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
14
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
15
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
16
|
+
SOFTWARE.
|
|
17
|
+
*/var J=l.json().superRefine((e,t)=>{let r=0;function n(i,a){if(++r>1e4||a>20){t.addIssue({code:"custom",message:"JSON exceeds its depth or node budget"});return}if(typeof i=="string"&&(i.includes("\0")||/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(i))&&t.addIssue({code:"custom",message:"JSON text must contain valid Unicode without NUL"}),Array.isArray(i))i.forEach(o=>n(o,a+1));else if(i&&typeof i=="object")for(let[o,c]of Object.entries(i))(o.includes("\0")||/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(o)||["__proto__","prototype","constructor"].includes(o))&&t.addIssue({code:"custom",message:"Reserved JSON property"}),n(c,a+1)}n(e,0),new TextEncoder().encode(JSON.stringify(e)).byteLength>65536&&t.addIssue({code:"custom",message:"JSON exceeds 64 KiB"})}),rt=l.record(l.string().min(1).max(128),J).superRefine((e,t)=>{(!J.safeParse(e).success||Object.keys(e).length>128||new TextEncoder().encode(JSON.stringify(e)).byteLength>65536||["__proto__","constructor","prototype"].some(r=>Object.hasOwn(e,r)))&&t.addIssue({code:"custom",message:"Attribute document exceeds its budget or uses a reserved key"})}),dn=new Set(["$in","$ini","$inGroup","$nin","$nini","$notInGroup","$gt","$gte","$lt","$lte","$regex","$regexi","$ne","$eq","$size","$elemMatch","$all","$alli","$not","$type","$exists","$vgt","$vgte","$vlt","$vlte","$vne","$veq","$and","$or","$nor","$savedGroup"]),Ne=rt.superRefine((e,t)=>{function r(n){if(Array.isArray(n))n.forEach(r);else if(n&&typeof n=="object")for(let[i,a]of Object.entries(n)){if(i==="$savedGroup"&&!l.strictObject({id:l.uuid(),attributeKey:l.string().min(1).max(128).optional()}).safeParse(a).success&&t.addIssue({code:"custom",message:"Saved groups use v2 object references"}),!i.startsWith("$")&&i.split(".").some(o=>["__proto__","prototype","constructor"].includes(o))&&t.addIssue({code:"custom",message:"Reserved attribute path"}),i.startsWith("$")&&!dn.has(i)&&t.addIssue({code:"custom",message:`Unknown GrowthBook operator: ${i}`}),["$regex","$regexi"].includes(i)&&typeof a=="string"){(/\(\?[<!=]|\\[0-9]|\\k</.test(a)||[...a.matchAll(/\{(\d+)(?:,(\d*))?\}/g)].some(o=>Number(o[1])>255||Number(o[2]||0)>255)||i==="$regexi"&&/[^\x00-\x7f]/.test(a.replace(/\\u([0-9a-f]{4})/gi,(o,c)=>String.fromCharCode(Number.parseInt(c,16)))))&&t.addIssue({code:"custom",message:"Regex is outside the shared TS/SQL subset"});try{new RegExp(a)}catch{t.addIssue({code:"custom",message:"Invalid regular expression"})}}r(a)}}typeof e.source=="string"&&["all","any","group","parameter","answer","attribute","result"].includes(e.source)&&("operator"in e||"predicates"in e||"groupId"in e)&&t.addIssue({code:"custom",message:"Obsolete condition protocol"}),r(e)}),fn=l.discriminatedUnion("type",[l.strictObject({type:l.literal("condition"),condition:Ne}),l.strictObject({type:l.literal("list"),attributeKey:l.string().min(1).max(128),values:l.array(l.union([l.string(),l.number().finite()])).max(1e5)})]).refine(e=>e.type!=="list"||new TextEncoder().encode(JSON.stringify(e.values)).byteLength<=1048576,"Saved group list exceeds 1 MiB");function mn(e){let t=new Set;function r(n){if(Array.isArray(n))n.forEach(r);else if(n&&typeof n=="object")for(let[i,a]of Object.entries(n))i==="$savedGroup"&&a&&typeof a=="object"&&!Array.isArray(a)&&typeof a.id=="string"?t.add(a.id):["$inGroup","$notInGroup"].includes(i)&&typeof a=="string"?t.add(a):["$eq","$ne","$in","$nin","$ini","$nini"].includes(i)||r(a)}return r(e),[...t]}var gn=l.record(l.uuid(),fn).superRefine((e,t)=>{let r=new Set,n=new Set;function i(a){if(r.has(a)){t.addIssue({code:"custom",message:"Cyclic saved group dependency"});return}if(n.has(a))return;let o=e[a];if(!o){t.addIssue({code:"custom",message:"Missing saved group dependency"});return}r.add(a),o.type==="condition"&&mn(o.condition).forEach(i),r.delete(a),n.add(a)}Object.keys(e).forEach(i)}),nt=l.tuple([l.number().min(0).max(1),l.number().min(0).max(1)]).refine(([e,t])=>e<=t),Wt=l.strictObject({attribute:l.string().optional(),seed:l.string().min(1),hashVersion:l.literal(2),ranges:l.array(nt).min(1).max(100)}),hn=l.strictObject({id:l.string().min(1).max(128),condition:Ne,gate:l.boolean().optional()}),tt={id:l.string().max(128).optional(),condition:Ne.optional(),parentConditions:l.array(hn).max(50).optional(),filters:l.array(Wt).max(20).optional()},bn=l.union([l.strictObject({...tt}),l.strictObject({...tt,force:J,coverage:l.number().min(0).max(1).optional(),range:nt.optional(),seed:l.string().min(1).optional(),hashAttribute:l.string().optional(),hashVersion:l.literal(2).optional()}),l.strictObject({...tt,type:l.literal("experiment-ref"),experimentId:l.uuid(),values:l.record(l.string().min(1),J),meta:l.record(l.string().min(1),l.strictObject({passthrough:l.boolean()})).optional()})]),yn=l.strictObject({defaultValue:J,rules:l.array(bn).max(100)}),_o=l.record(l.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,127}$/),yn).superRefine((e,t)=>{Object.keys(e).length>100&&t.addIssue({code:"custom",message:"Too many Features"});let r=new Set,n=new Set;function i(a){if(r.has(a)){t.addIssue({code:"custom",message:`Cyclic Feature dependency: ${a}`});return}if(n.has(a))return;let o=e[a];if(!o){t.addIssue({code:"custom",message:`Unknown prerequisite Feature: ${a}`});return}r.add(a);for(let c of o.rules)for(let u of c.parentConditions??[])i(u.id);r.delete(a),n.add(a)}Object.keys(e).forEach(i)}),xn=l.strictObject({name:l.string().max(80),reason:l.string().max(500),dateStarted:l.iso.datetime({offset:!0}),dateEnded:l.iso.datetime({offset:!0}).nullable(),coverage:l.number().min(0).max(1),variationWeights:l.array(l.number().min(0).max(1)).min(2).max(20).refine(e=>Math.abs(e.reduce((t,r)=>t+r,0)-1)<=.01),condition:Ne,savedGroups:l.array(l.strictObject({match:l.enum(["any","all","none"]),ids:l.array(l.uuid()).min(1)})).max(50),namespace:l.strictObject({id:l.uuid(),ranges:l.array(nt).min(1)}).nullable(),seed:l.string().min(1).max(128)}),Sn=l.strictObject({key:l.string().min(1).max(128),name:l.string().min(1).max(80),hypothesis:l.string().max(2e3),status:l.enum(["draft","running","stopped"]),hashAttribute:l.string().min(1).max(128),fallbackAttribute:l.string().max(128).nullable(),hashVersion:l.literal(2),disableStickyBucketing:l.boolean(),bucketVersion:l.number().int().min(0).max(1e3),minBucketVersion:l.number().int().min(0).max(1e3),variations:l.array(l.strictObject({id:l.string().min(1),key:l.string().min(1),name:l.string().max(80),description:l.string().max(500)})).min(2).max(20),phases:l.array(xn).min(1).max(100),releasedVariationId:l.string().nullable(),excludeFromPayload:l.boolean(),statusSchedule:l.strictObject({startAt:l.iso.datetime({offset:!0}).nullable(),stopAt:l.iso.datetime({offset:!0}).nullable(),stopAfter:l.strictObject({value:l.number().int().positive().max(36500),unit:l.enum(["hours","days"])}).nullable().optional()}).nullable()}).superRefine((e,t)=>{(e.minBucketVersion>e.bucketVersion||e.statusSchedule?.stopAt&&e.statusSchedule?.stopAfter||e.phases.some((r,n)=>{if(n===0)return!1;let i=e.phases[n-1];return!i?.dateEnded||Date.parse(r.dateStarted)<Date.parse(i.dateStarted)||Date.parse(i.dateEnded)>Date.parse(r.dateStarted)})||new Set(e.variations.map(r=>r.key)).size!==e.variations.length||new Set(e.variations.map(r=>r.id)).size!==e.variations.length||e.releasedVariationId!==null&&!e.variations.some(r=>r.id===e.releasedVariationId)||e.statusSchedule?.startAt&&e.statusSchedule?.stopAt&&Date.parse(e.statusSchedule.startAt)>=Date.parse(e.statusSchedule.stopAt)||e.phases.some(r=>r.dateEnded&&Date.parse(r.dateStarted)>=Date.parse(r.dateEnded)||r.namespace?.ranges.some(([n,i],a,o)=>n>=i||o.some(([c,u],f)=>f!==a&&n<u&&c<i)))||e.phases.some(r=>r.variationWeights.length!==e.variations.length))&&t.addIssue({code:"custom",message:"Invalid experiment versions, variation keys or weights"})});var An=Sn.safeExtend({filters:l.array(Wt).optional()}),kn=l.strictObject({experiments:l.record(l.uuid(),An),savedGroups:gn}),En=l.strictObject({attributeName:l.string(),attributeValue:l.string(),assignments:l.record(l.string(),l.string())}),Io=l.strictObject({snapshot:kn,attributes:rt,results:rt,stickyBucketAssignmentDocs:l.record(l.string(),En)}),wo=l.strictObject({variantKey:l.string().nullable(),bucketVersion:l.number().int().min(0),source:l.enum(["unknownFeature","defaultValue","force","override","experiment","prerequisite","cyclicPrerequisite"]),bucket:l.number().min(0).max(1).optional(),stickyBucketUsed:l.boolean().optional(),hashUsed:l.boolean().optional()});import{z as I}from"zod";import{z as w}from"zod";var Oe=w.string().regex(/^(0|[1-9]\d{0,12})(\.\d{1,12})?$/),R=w.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e),_n=w.string().regex(/^-?(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>{let t=e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e;return t==="-0"?"0":t}),it=R.refine(e=>/[1-9]/.test(e),"\u6570\u91CF\u5FC5\u987B\u5927\u4E8E 0"),Jt=w.string().min(1).max(64),ee=w.string().min(1).regex(/^[a-zA-Z0-9_-]+$/),Yt=w.string().min(1).max(64).refine(e=>!e.includes("::"),"Dimension IDs cannot contain ::"),V=w.record(Jt,w.union([w.string().max(120),w.number().finite(),w.boolean()])).refine(e=>Object.keys(e).length<=16,"\u6700\u591A 16 \u4E2A\u8BA1\u4EF7\u5C5E\u6027").transform(e=>Object.fromEntries(Object.entries(e).map(([t,r])=>[t,String(r)]))),Xt=w.record(Jt,w.union([w.string().max(120),w.number().finite(),w.boolean()]).transform(String)).refine(e=>Object.keys(e).length<=8,"\u5339\u914D\u6761\u4EF6\u6700\u591A 8 \u4E2A\u5C5E\u6027"),ie=e=>{let t=e.startsWith("-");t&&(e=e.slice(1));let[r,n=""]=e.split(".");if(r===void 0||r==="")throw new Error("Invalid decimal value");let i=BigInt(r)*BigInt("1000000")+BigInt(n.padEnd(6,"0"));return t?-i:i},er=w.array(w.object({upTo:it.nullable(),cost:R}).strict()).min(1).max(12).refine(e=>e.at(-1)?.upTo===null&&e.slice(0,-1).every((t,r)=>{let n=e[r-1]?.upTo;return t.upTo!==null&&(r===0||n!=null&&ie(t.upTo)>ie(n))}),"\u9636\u68AF\u4E0A\u9650\u5FC5\u987B\u9012\u589E\uFF0C\u6700\u540E\u4E00\u6863\u4E3A\u65E0\u9650"),In=w.object({key:Yt,match:Xt,priority:w.number().int().default(0),cost:R.optional(),tiers:er.optional()}).strict().refine(e=>e.cost!==void 0||e.tiers!==void 0,"\u7EF4\u5EA6\u9700\u8981\u6307\u5B9A\u5355\u4EF7\u6216\u9636\u68AF"),wn=w.object({key:Yt,match:Xt,factor:it.optional(),add:_n.optional()}).strict().refine(e=>e.factor!==void 0||e.add!==void 0,"A multiplier needs a factor or an add").transform(e=>({...e,factor:e.factor??"1",add:e.add??"0"})),Rn=w.object({units:it.default("1"),cost:R,tiers:er.optional(),dimensions:w.array(In).max(12).optional(),multipliers:w.array(wn).max(4).optional()}).strict().superRefine((e,t)=>{let r=e.dimensions??[],n=e.multipliers??[];(new Set(r.map(o=>o.key)).size!==r.length||new Set(n.map(o=>o.key)).size!==n.length)&&t.addIssue({code:"custom",message:"\u7EF4\u5EA6\u548C\u500D\u7387\u7684 ID \u4E0D\u80FD\u91CD\u590D"});for(let[o,c]of r.entries())for(let u of r.slice(o+1))Object.keys(c.match).length===Object.keys(u.match).length&&c.priority===u.priority&&!Object.keys(c.match).some(f=>u.match[f]!==void 0&&u.match[f]!==c.match[f])&&t.addIssue({code:"custom",message:"\u7EF4\u5EA6\u53EF\u80FD\u540C\u65F6\u5339\u914D\uFF0C\u8BF7\u8C03\u6574\u4F18\u5148\u7EA7"});let i=[e.cost,...(e.tiers??[]).map(o=>o.cost),...r.flatMap(o=>[...o.cost===void 0?[]:[o.cost],...(o.tiers??[]).map(c=>c.cost)])],a=ie(e.units);for(let o of i)for(let c=0;c<1<<n.length;c++){let u=n.filter((_,A)=>c&1<<A);if(u.some((_,A)=>u.slice(A+1).some(T=>Object.keys(_.match).some(P=>T.match[P]!==void 0&&T.match[P]!==_.match[P]))))continue;let f=ie(o),d=BigInt("1"),m=BigInt("0");for(let[_,A]of n.entries())c&1<<_&&(f*=ie(A.factor??"1"),d*=BigInt("1000000"),m+=ie(A.add??"0"));let y=(f+m*d)*BigInt("1000000"),S=d*a;(y<BigInt("0")||y%S!==BigInt("0")||y/S>BigInt("999999999999999999"))&&t.addIssue({code:"custom",message:"\u6BCF\u4E2A\u4E1A\u52A1\u5355\u4F4D\u7684\u6700\u7EC8\u5355\u4EF7\u5FC5\u987B\u975E\u8D1F\u3001\u5728\u8303\u56F4\u5185\u4E14\u80FD\u7CBE\u786E\u8868\u793A\u4E3A\u6700\u591A 6 \u4F4D\u5C0F\u6570"})}}),Oo=Rn.safeExtend({featureKey:ee});import{z as Nn}from"zod";import{z as oe}from"zod";var tr=oe.enum(["stripe","apple","google","merchant"]),To=oe.enum(["membership","credit_pack","lifetime"]),jo=oe.enum(["active","grace","suspended","inactive","revoked"]),Do=oe.strictObject({currency:oe.string().regex(/^[A-Z]{3}$/),micros:oe.string().regex(/^(0|[1-9][0-9]{0,29})$/)});var rr=Nn.object({provider:tr,currency:j}).strict();var nr=I.strictObject({internal_feature_id:I.uuid(),quantity:R.refine(e=>/[1-9]/.test(e)),properties:V,entityId:I.uuid().optional()}),qo=I.strictObject({requirement:nr,commerce:rr.optional(),paywallId:I.uuid().optional()}),On=I.enum(["not_entitled","insufficient_balance","capacity_exceeded","limit_exceeded","awaiting_topup","authorization_required","payment_blocked","cash_budget_exceeded","unavailable","authentication_required"]),Cn=I.strictObject({productId:I.string().min(1),productVersionId:I.string().min(1),name:I.string().min(1).max(120),action:I.enum(["purchase","upgrade","addon","topup"]),membershipId:I.string().min(1).nullable(),currency:j,amountMinor:I.string().regex(/^(0|[1-9]\d{0,8})$/),interval:I.enum(["free","week","month","year","one_time"]),intervalCount:I.number().int().min(1).max(156)}),ir=I.strictObject({internal_feature_id:I.string().min(1),name:I.string().min(1).max(120),kind:I.enum(["access","metered","credit"]),quantity:R,allowed:I.boolean(),reason:On.nullable(),preview:I.strictObject({scenario:I.enum(["feature_flag","usage_limit"]),candidates:I.array(Cn).max(20)}).nullable()}).superRefine((e,t)=>{(e.allowed!==(e.reason===null)||e.allowed&&e.preview!==null||new Set(e.preview?.candidates.map(r=>r.productVersionId)).size!==(e.preview?.candidates.length??0)||e.preview?.candidates.some(r=>r.action==="upgrade"!=(r.membershipId!==null)))&&t.addIssue({code:"custom",message:"Invalid access recommendation"})}),Ho=I.strictObject({paywallId:I.uuid(),requirement:nr});import{z as h}from"zod";import{z as ce}from"zod";import{z as se}from"zod";import{z as ae}from"zod";var or=ae.number().int().min(0).max(1e8),ot=ae.strictObject({kind:ae.enum(["graduated","volume"]),tiers:ae.array(ae.strictObject({upTo:ae.number().int().min(1).max(1e4).nullable(),unitAmountMinor:or,flatAmountMinor:or.optional()})).min(1).max(12)}).refine(e=>e.tiers.at(-1)?.upTo===null&&e.tiers.slice(0,-1).every((t,r)=>{let n=e.tiers[r-1]?.upTo;return t.upTo!==null&&(r===0||n!=null&&t.upTo>n)}),"Tier ceilings must increase and end unbounded").refine(e=>!e.tiers.some(t=>(t.flatAmountMinor??0)>0)||e.kind==="volume"&&e.tiers.length>1,"Tier flat fees require volume pricing with multiple tiers");function at(e,t){if(!Number.isInteger(t)||t<0||t>1e4)throw new Error("Invalid purchased pack quantity");let r=e.pricing?ot.parse(e.pricing):void 0;if(t===0)return 0;let n=0n,i=0;if(!r)n=BigInt(e.amountMinor)*BigInt(t);else for(let a of r.tiers){let o=a.upTo??1e4;if(r.kind==="volume"){if(t<=o){n=BigInt(t)*BigInt(a.unitAmountMinor)+BigInt(a.flatAmountMinor??0);break}}else t>i&&(n+=BigInt(Math.min(t,o)-i)*BigInt(a.unitAmountMinor));i=o}if(n>200000000n)throw new Error("Purchased price exceeds the payment amount limit");return Number(n)}function ar(e){return at({amountMinor:e.unitAmountMinor,...e.pricing?{pricing:e.pricing}:{}},e.quantity)}var vn=R.refine(e=>/[1-9]/.test(e)),cr=se.strictObject({units:vn,prices:se.array(se.strictObject({currency:j,amountMinor:se.number().int().min(0).max(1e8),pricing:ot.optional()})).min(1).max(20).refine(e=>new Set(e.map(t=>t.currency)).size===e.length,"Currencies must be unique").refine(e=>e.every(t=>!t.pricing||t.amountMinor===0),"Tiered prices specify their rates in tiers"),minimumQuantity:se.number().int().min(0).max(1e4),maximumQuantity:se.number().int().min(0).max(1e4)}).refine(e=>e.maximumQuantity>=e.minimumQuantity,"Purchased quantity must fit its published bounds").refine(e=>{try{for(let t of e.prices)for(let r of[e.maximumQuantity,...t.pricing?.tiers.flatMap(n=>n.upTo===null?[]:[n.upTo,n.upTo+1])??[]])r<=e.maximumQuantity&&at({amountMinor:t.amountMinor,...t.pricing===void 0?{}:{pricing:t.pricing}},r);return!0}catch{return!1}},"Every purchasable quantity must fit the payment amount limit");function sr(e){if(!/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/.test(e))throw new Error("Invalid quantity");let[t,r=""]=e.split(".");if(t===void 0||t==="")throw new Error("Invalid decimal value");return BigInt(t)*1000000n+BigInt(r.padEnd(6,"0"))}function ur(e,t,r){if(!Number.isSafeInteger(r)||r<0||r>1e4)throw new Error("Invalid purchased quantity");let n=sr(e)+sr(t)*BigInt(r);if(n>999999999999999999n)throw new Error("Purchased allowance exceeds the ledger quantity limit");let i=(n%1000000n).toString().padStart(6,"0").replace(/0+$/,"");return(n/1000000n).toString()+(i?"."+i:"")}var st=ce.strictObject({internalFeatureId:ce.uuid(),name:ce.string().min(1).max(120),includedAmount:ce.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/),reset:ce.enum(["hour","day","week","month","year","lifetime"]),resetCount:ce.number().int().min(1).max(100),terms:cr});var Tn=["plan.name","plan.price","plan.period","plan.price_per_month","trial.headline","trial.terms","offer.headline","offer.name","offer.description","offer.eligibility","offer.validity","offer.terms","offer.discount","offer.price","offer.original_price","offer.months","offer.code","offer.ends_at","offer.expires_at","paywall.feature","paywall.message","paywall.action"],Ce=h.object({plan:h.string().min(1).max(200).optional(),coupon:h.uuid().optional(),promotionCode:h.uuid().optional(),picker:h.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/).optional()}).strict(),lr=h.object({text:h.string().optional(),label:h.string().optional(),alt:h.string().optional(),html:h.string().max(32768).optional(),price:h.object({current:h.string(),original:h.string().nullable(),period:h.string()}).optional(),code:h.string().optional(),countdownAt:h.iso.datetime().optional(),planId:h.string().min(1).max(200).optional(),planVersionId:h.string().min(1).max(200).optional(),currency:j.optional(),couponId:h.uuid().optional(),offerId:h.uuid().optional(),unavailable:h.boolean().optional(),unavailableReason:h.string().optional(),missing:h.array(h.string()).optional()}).strict(),sa=h.object({paywall:ir.optional(),nodes:h.record(h.string(),h.object({base:lr,picker:h.string().optional(),byPlan:h.record(h.string(),lr).optional()}).strict()),plans:h.record(h.string(),h.object({id:h.string().min(1).max(200),versionId:h.string().min(1).max(200),available:h.boolean(),name:h.string(),price:h.string(),period:h.string(),currency:j.optional(),amountMinor:h.number().int().nonnegative().optional(),interval:h.enum(["free","week","month","year","one_time"]).optional(),intervalCount:h.number().int().positive().optional(),prepaid:h.array(st).max(100).optional()}).strict()),pickers:h.record(h.string(),h.object({options:h.array(h.string().min(1).max(200)).max(20),selected:h.string().min(1).max(200).nullable()}).strict()),quantities:h.record(h.string(),h.strictObject({minimum:h.number().int().nonnegative(),maximum:h.number().int().nonnegative(),step:h.number().int().positive(),value:h.number().int().nonnegative(),label:h.string(),available:h.boolean()})).optional(),diagnostics:h.array(h.object({nodeId:h.string(),message:h.string()}).strict())}).strict();function pr(e){return[...e.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].flatMap(t=>t[1]===void 0?[]:[t[1].trim()])}function ct(e){let t=pr(e).filter(n=>!Tn.includes(n)&&!/^variables\.[A-Za-z0-9_][A-Za-z0-9_.:-]*$/.test(n)),r=e.replace(/\{\{\s*[^{}]+?\s*\}\}/g,"");return(r.includes("{{")||r.includes("}}"))&&t.push("\u65E0\u6548\u53D8\u91CF\u8BED\u6CD5"),[...new Set(t)]}function ca(e,t,r={}){let n=e?.nodes[t];if(!n)return;let i=n.picker?r[n.picker]??e?.pickers[n.picker]?.selected:void 0;return typeof i=="string"?n.byPlan?.[i]??n.base:n.base}import{z as b}from"zod";var jn=["credit_balance","credit_transactions","membership","billing","billing_controls","customer_plans","credit_packs","credit_pack_orders","offer_history"],dr=b.enum(jn),fr=b.object({source:dr,layout:b.enum(["full","compact"]),resourceKey:ee.optional(),pageSize:b.number().int().min(1).max(50),showSources:b.boolean(),allowPurchase:b.boolean(),outputs:b.object({billing_adjustment:b.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),billing_authorization:b.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),buy_pack:b.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),billing_portal:b.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),cancel_membership:b.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),resume_membership:b.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional()}).strict().optional()}).strict().superRefine((e,t)=>{(e.outputs?.billing_authorization||e.outputs?.billing_adjustment)&&e.source!=="billing_controls"&&t.addIssue({code:"custom",message:"Payment authorization routes belong to the billing controls component."}),e.resourceKey&&!["credit_balance","credit_transactions"].includes(e.source)&&t.addIssue({code:"custom",message:"\u8FD9\u4E2A\u6570\u636E\u6E90\u4E0D\u80FD\u7ED1\u5B9A\u79EF\u5206\u8D44\u6E90\u3002"}),e.showSources&&e.source!=="credit_balance"&&t.addIssue({code:"custom",message:"\u53EA\u6709\u79EF\u5206\u4F59\u989D\u53EF\u4EE5\u5C55\u5F00\u6765\u6E90\u3002"}),e.allowPurchase&&!["credit_packs","customer_plans","membership"].includes(e.source)&&t.addIssue({code:"custom",message:"\u53EA\u6709\u79EF\u5206\u5305\u3001\u5957\u9910\u4E0E\u4F1A\u5458\u7EC4\u4EF6\u53EF\u4EE5\u542F\u7528\u4EA4\u6613\u3002"})}),O=b.string().max(2e3),mr=b.object({id:b.string().max(100),label:O,detail:b.array(O).max(12),value:O.optional(),status:O.optional(),facts:b.array(b.object({label:O,value:O}).strict()).max(1e3),purchaseId:b.uuid().optional(),invoiceUrl:b.url().max(2048).refine(e=>{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}).optional(),billingActions:b.array(b.strictObject({action:b.literal("invoice_open"),label:O})).max(1).optional(),membershipActions:b.array(b.object({value:b.string().max(100),label:O}).strict()).max(3).optional()}).strict(),Dn=b.object({key:ee,name:O,spendable:O,reserved:O,available:O,expiry:O.nullable(),sources:b.array(mr).max(50),sourceCount:b.number().int().nonnegative(),sourcePage:b.number().int().positive(),hasNextSources:b.boolean(),hasPreviousSources:b.boolean()}).strict(),Ln=b.object({source:dr,status:b.enum(["idle","loading","ready","error"]),stale:b.boolean(),preview:b.boolean(),errorCode:b.string().max(80).optional(),errorMessage:O.optional(),resources:b.array(Dn).max(500),rows:b.array(mr).max(50),hasNext:b.boolean(),hasPrevious:b.boolean(),page:b.number().int().positive(),filter:b.string().max(40),updatedAt:b.iso.datetime().optional(),buyingId:b.uuid().optional(),membershipBusy:b.boolean().optional(),billingBusy:b.boolean().optional(),membershipReview:b.object({title:O,note:O,facts:b.array(b.object({label:O,value:O}).strict()).max(100)}).strict().optional(),membershipResult:O.optional()}).strict(),da=b.object({nodes:b.record(b.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Ln)}).strict(),fa=b.object({nodeId:b.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),action:b.enum(["refresh","next","previous","filter","buy_pack","billing_portal","billing_authorization","billing_adjustment","invoice_open","membership_preview","membership_confirm","membership_dismiss","sources_next","sources_previous"]),value:b.string().max(100).optional()}).strict();import{z as s}from"zod";function gr(e){return e.type==="stack"&&e.interaction?.type==="select"&&e.interaction.purpose==="product"&&!!e.interaction.pickerId}function hr(e){let t={};function r(n){if(gr(n)){let i=t[n.interaction.pickerId]??={ids:[],defaultId:null};for(let o of n.children){let c=o.type==="stack"?o.bind?.plan:void 0;c&&!i.ids.includes(c)&&i.ids.push(c)}let a=n.children[n.interaction.defaultIndex];!i.defaultId&&a?.type==="stack"&&(i.defaultId=a.bind?.plan??null)}n.type==="stack"&&n.children.forEach(r)}return e.pages.forEach(n=>r(n.root)),t}function br(e,t,r){let n={};function i(u){if(u.hidden)return;if(u.type==="plan_picker"){let m=r.pickers[u.id];n[u.id]={ids:m?.options??[],defaults:m?.selected?[m.selected]:[],remembered:[]};return}if(u.type!=="stack")return;let f=u.children.filter(m=>!m.hidden),d=u.interaction;if(gr(u)){let m=n[u.interaction.pickerId]??={ids:[],defaults:[],remembered:[]},y=r.pickers[u.interaction.pickerId]?.options??[];for(let _ of f){let A=_.type==="stack"?_.bind?.plan:void 0;A&&y.includes(A)&&!m.ids.includes(A)&&m.ids.push(A),A&&_.id===t[u.id]&&m.remembered.push(A)}let S=u.children[u.interaction.defaultIndex];S?.type==="stack"&&!S.hidden&&S.bind?.plan&&m.defaults.push(S.bind.plan)}if(d?.type==="tabs"){let m=f.find(y=>y.id===t[u.id])??u.children[d.defaultIndex];m&&i(m)}else if(d?.type==="toggle"){let m=typeof t[u.id]=="boolean"?t[u.id]:d.defaultEnabled,y=u.children[m?0:1];y&&i(y)}else f.forEach(i)}let a=typeof t.__page=="string"?t.__page:e.initialPageId??e.pages[0]?.id,o=e.pages.find(u=>u.id===a);o&&i(o.root);let c={};for(let[u,f]of Object.entries(n)){let d=t[u],m=f.remembered[0]??(f.ids.includes(r.pickers[u]?.selected??"")?r.pickers[u]?.selected:f.defaults[0]);c[u]=typeof d=="string"?f.ids.includes(d)?d:"":m&&f.ids.includes(m)?m:""}for(let u of Object.keys(hr(e)))c[u]??="";return c}import{z as Q}from"zod";var yr=Q.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),xr=Q.strictObject({tiers:Q.array(Q.strictObject({id:yr,name:Q.string().trim().min(1).max(80)})).min(1).max(8),assignments:Q.array(Q.strictObject({productVersionId:Q.string().min(1).max(200),tierId:yr,period:Q.enum(["month","year"])})).max(20)}).superRefine((e,t)=>{let r=e.tiers.map(n=>n.id);(new Set(r).size!==r.length||new Set(e.assignments.map(n=>n.productVersionId)).size!==e.assignments.length||new Set(e.assignments.map(n=>`${n.tierId}:${n.period}`)).size!==e.assignments.length||e.assignments.some(n=>!r.includes(n.tierId)))&&t.addIssue({code:"custom",message:"Each product and tier/period cell must have one unambiguous assignment"})});function Sr(e,t){return e.assignments.length===t.length&&e.assignments.every(r=>t.includes(r.productVersionId))}function xa(e){let t=ct(e).map(r=>`\u672A\u77E5\u53D8\u91CF\uFF1A${r}`);for(let r=0;r<e.length;r++){if(e[r]!=="<"||!/[A-Za-z!/?{]/.test(e[r+1]??""))continue;let n=r;if(e.startsWith("<!--",r)){let i=e.indexOf("-->",r+4);r=i<0?e.length:i+2}else{let i="";for(r++;r<e.length;r++){let a=e[r];if(i)a===i&&(i="");else if(a==='"'||a==="'")i=a;else if(a===">")break}}/\{\{|\}\}/.test(e.slice(n,r+1))&&t.push("\u53D8\u91CF\u53EA\u80FD\u653E\u5728 HTML \u6587\u5B57\u4E2D\uFF0C\u4E0D\u80FD\u653E\u5165\u6807\u7B7E\u3001\u5C5E\u6027\u6216\u6CE8\u91CA")}return[...new Set(t)]}import{z as Pn}from"zod";var kr=/^[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$/,ue=Pn.string().max(16).regex(kr,"\u8BED\u8A00\u4EE3\u7801\u683C\u5F0F\u4E0D\u6B63\u786E\uFF0C\u4F8B\u5982 zh-CN\u3001en").refine(e=>{try{return Intl.getCanonicalLocales(e)[0]===e}catch{return!1}},"\u6301\u4E45\u5316\u8BED\u8A00\u4EE3\u7801\u5FC5\u987B\u4F7F\u7528\u89C4\u8303\u5199\u6CD5");function ut(e){if(typeof e!="string")return null;try{let t=Intl.getCanonicalLocales(e.trim().replaceAll("_","-"))[0];if(!t)return null;let{language:r,script:n,region:i}=new Intl.Locale(t),a=[r,n,i].filter(Boolean).join("-");return kr.test(a)?a:null}catch{return null}}var $n=new Set(["TW","HK","MO"]);function Ar(e){let[t,r,n]=e.split("-");if(t!=="zh")return`${t}-${new Intl.Locale(e).maximize().script??""}`;let i=r?.length===4?r:void 0,a=r?.length===4?n:r;return i?`zh-${i}`:a&&$n.has(a)?"zh-Hant":"zh-Hans"}function Er(e,t,r){let n=t.map(i=>({code:ue.parse(i),normalized:i}));for(let i of e){let a=ut(i);if(!a)continue;let o=n.find(d=>d.normalized===a);if(o)return o.code;let c=Ar(a),u=n.filter(d=>Ar(d.normalized)===c),f=u.find(d=>!d.normalized.includes("-")||d.normalized===c)??u[0];if(f)return f.code}return r}var Fn=4,U={nodes:150,depth:8,children:50,locales:20,actions:40,pages:10,stringLength:2e3,customHtml:32768,customCss:16384,documentBytes:2e5},ge=s.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),E=s.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Bn=s.enum(["none","xs","sm","md","lg","xl"]),Vn=s.enum(["none","sm","md","lg","full"]),lt=s.string().regex(/^#[0-9a-fA-F]{6}$/),wr=s.string().max(2048).refine(e=>{try{let t=new URL(e);return t.protocol==="https:"&&t.hostname.length>0}catch{return!1}},"\u53EA\u652F\u6301 https \u94FE\u63A5"),pt=s.union([wr,s.string().max(32768).regex(/^data:image\/svg\+xml;base64,[A-Za-z0-9+/]+={0,2}$/),s.string().max(131072).regex(/^data:image\/jpeg;base64,\/9j\/[A-Za-z0-9+/]+={0,2}$/),s.string().max(131072).regex(/^data:image\/png;base64,iVBORw0KGgo[A-Za-z0-9+/]+={0,2}$/)]),_r=s.object({primary:lt,background:lt,text:lt,radius:Vn,font:s.enum(["system","serif","rounded","mono"])}).strict(),he=s.union([s.enum(["primary","text","muted","background","surface"]),s.string().regex(/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/)]),x=(e,t)=>s.number().int().min(e).max(t),Ir=s.union([s.enum(["fit","fill"]),x(1,1200)]),zn=s.object({top:x(0,200),right:x(0,200),bottom:x(0,200),left:x(0,200)}).strict(),Un=s.object({top:x(-100,200),right:x(-100,200),bottom:x(-100,200),left:x(-100,200)}).strict(),Rr=s.object({x:x(0,100),y:x(0,100)}).strict(),Mn=s.discriminatedUnion("type",[s.object({type:s.literal("color"),color:he}).strict(),s.object({type:s.literal("linear"),angle:x(0,360),stops:s.array(s.object({color:he,at:x(0,100)}).strict()).min(2).max(4)}).strict(),s.object({type:s.literal("image"),src:pt,fit:s.enum(["cover","contain"]),position:Rr.optional()}).strict()]),qn=s.discriminatedUnion("type",[s.object({type:s.literal("rect"),radius:s.union([x(0,200),s.object({topLeft:x(0,200),topRight:x(0,200),bottomRight:x(0,200),bottomLeft:x(0,200)}).strict()])}).strict(),s.object({type:s.literal("pill")}).strict()]),Hn=s.object({width:x(0,12),color:he,style:s.enum(["solid","dashed"])}).strict(),Gn=s.object({x:x(-40,40),y:x(-40,40),blur:x(0,80),spread:x(-20,40),color:he}).strict(),Qn=s.object({font:s.enum(["system","serif","rounded","mono"]),size:x(8,96),weight:s.number().int().min(100).max(900).multipleOf(100),lineHeight:s.number().min(.8).max(3),letterSpacing:s.number().min(-5).max(20),color:he,align:s.enum(["start","center","end"]),italic:s.boolean(),decoration:s.enum(["none","underline","line-through"]),transform:s.enum(["none","uppercase"])}).strict().partial(),te=s.object({width:Ir,height:Ir,padding:zn,margin:Un,gap:x(0,120),grow:s.union([s.boolean(),s.number().min(0).max(12)]),background:Mn,opacity:s.number().min(0).max(1),clipContent:s.boolean(),shape:qn,border:Hn,shadow:Gn,text:Qn}).strict().partial(),L={id:ge,name:s.string().trim().min(1).max(60).optional(),hidden:s.boolean().optional(),style:te.optional(),fallback:E.optional()},Kn=s.object({...L,type:s.literal("text"),productField:s.enum(["name","price","trial","period"]).optional(),feature:s.object({id:s.uuid(),field:s.enum(["name","allowance"])}).strict().optional(),text:E,variant:s.enum(["title","heading","body","caption"])}).strict(),Zn=s.object({...L,type:s.literal("image"),src:pt,localizedSrc:s.record(ue,pt).optional(),alt:E,aspect:s.enum(["auto","1:1","4:3","16:9","3:1"]),fit:s.enum(["cover","contain"]),position:Rr.optional()}).strict(),Wn=s.object({...L,type:s.literal("button"),label:E,variant:s.enum(["primary","secondary","link"]),action:E,purpose:s.enum(["purchase","navigation","close"]).optional(),bind:Ce.optional()}).strict(),Jn=s.object({...L,type:s.literal("divider")}).strict(),Yn=s.object({...L,type:s.literal("customer_data"),title:E,data:fr}).strict(),Xn=s.object({...L,type:s.literal("spacer"),size:Bn}).strict(),ei=s.object({...L,type:s.literal("custom_html"),html:s.record(ue,s.string().max(U.customHtml)),css:s.string().max(U.customCss)}).strict(),ti=s.object({...L,type:s.literal("price"),fallback:E,parts:s.object({current:te.optional(),original:te.optional(),period:te.optional()}).strict().optional()}).strict(),ri=s.object({...L,type:s.literal("coupon_code"),label:E,fallback:E}).strict(),ni=s.object({...L,type:s.literal("countdown"),source:s.enum(["offer.ends_at","offer.expires_at","fixed"]),at:s.iso.datetime().optional(),granularity:s.enum(["day","hour","minute","second"]),expired:E,fallback:E}).strict().refine(e=>e.source!=="fixed"||!!e.at,"\u56FA\u5B9A\u5012\u8BA1\u65F6\u9700\u8981\u7ED3\u675F\u65F6\u95F4"),ii=s.object({...L,type:s.literal("plan_picker"),label:E,fallback:E,planIds:s.array(s.string().min(1).max(200)).min(1).max(20).refine(e=>new Set(e).size===e.length,"\u5957\u9910\u4E0D\u80FD\u91CD\u590D").optional(),defaultPlan:s.string().min(1).max(200).optional(),grouping:xr.safeExtend({monthLabel:E,yearLabel:E,unavailableLabel:E}).optional(),states:s.object({selected:te.optional()}).strict().optional()}).strict().superRefine((e,t)=>{e.grouping&&(!e.planIds||!Sr(e.grouping,e.planIds))&&t.addIssue({code:"custom",message:"Grouped picker assignments must match its product allowlist"})}),oi=s.object({...L,type:s.literal("quantity_picker"),bind:Ce.optional(),label:E,fallback:E,internalFeatureId:s.uuid(),minimumQuantity:x(0,1e4),maximumQuantity:x(0,1e4),defaultQuantity:x(0,1e4),step:x(1,1e4)}).strict().refine(e=>e.minimumQuantity<=e.defaultQuantity&&e.defaultQuantity<=e.maximumQuantity&&(e.defaultQuantity-e.minimumQuantity)%e.step===0,"Quantity controls require a Product binding and valid bounds"),ai=s.discriminatedUnion("type",[s.object({type:s.literal("input"),label:E,keyboard:s.enum(["text","email","tel","url"]),maxLength:x(1,500)}).strict(),s.object({type:s.literal("multiselect"),label:E,min:x(0,50),max:x(1,50)}).strict(),s.object({type:s.literal("select"),label:E,defaultIndex:x(0,49),purpose:s.enum(["option","product","tier"]).optional(),pickerId:ge.optional(),selectedStyle:te.optional()}).strict(),s.object({type:s.literal("tabs"),label:E,defaultIndex:x(0,49),purpose:s.literal("tier").optional()}).strict(),s.object({type:s.literal("toggle"),label:E,defaultEnabled:s.boolean()}).strict(),s.object({type:s.literal("carousel"),label:E}).strict()]),z={...L,type:s.literal("stack"),direction:s.enum(["vertical","horizontal","overlay"]),align:s.enum(["start","center","end","stretch"]),justify:s.enum(["start","center","end","between"]),productSlot:s.object({index:x(0,19),period:s.enum(["month","year"]).optional(),requireBinding:s.boolean().optional()}).strict().optional(),interaction:ai.optional(),states:s.object({selected:te.optional()}).strict().optional(),purpose:s.literal("benefits").optional(),purchaseAction:E.optional(),buttonVariant:s.enum(["primary","secondary","link"]).optional(),bind:Ce.optional()},Nr=s.lazy(()=>s.object({...L,type:z.type,direction:z.direction,align:z.align,justify:z.justify,children:s.array(si).max(U.children),productSlot:z.productSlot,interaction:z.interaction,states:z.states,purpose:z.purpose,purchaseAction:z.purchaseAction,buttonVariant:z.buttonVariant,bind:z.bind}).strict()),si=s.lazy(()=>s.union([Nr,Kn,Zn,Wn,Jn,Xn,ei,ti,ri,ni,ii,oi,Yn])),ci=s.union([s.string().max(500),s.number().finite(),s.boolean(),s.null()]),me={id:E,event:E,properties:s.record(E,ci).refine(e=>Object.keys(e).length<=20,"\u6700\u591A 20 \u4E2A\u53C2\u6570")},ui=s.discriminatedUnion("type",[s.object({...me,type:s.literal("navigate"),close:s.literal(!1),pageId:ge}).strict(),s.object({...me,type:s.literal("event"),close:s.boolean()}).strict(),s.object({...me,type:s.literal("close"),close:s.literal(!0)}).strict(),s.object({...me,type:s.literal("open_url"),close:s.boolean(),url:wr}).strict(),s.object({...me,type:s.literal("claim_offer"),close:s.boolean(),couponId:s.uuid()}).strict()]),li=s.object({defaultLocale:ue,locales:s.record(ue,s.record(E,s.string().max(U.stringLength)))}).strict(),pi=s.enum(["popup","paywall","onboarding","page","banner"]);var di=s.discriminatedUnion("type",[s.object({type:s.literal("modal"),size:s.enum(["sm","md","lg"])}).strict(),s.object({type:s.literal("sheet"),size:s.enum(["sm","md","lg"])}).strict(),s.object({type:s.literal("fullscreen")}).strict(),s.object({type:s.literal("inline")}).strict()]),Oa={sm:360,md:420,lg:560},fi=s.object({kind:s.literal("screen"),schemaVersion:s.literal(Fn),name:s.string().trim().min(1).max(80),surface:pi,initialPageId:ge.optional(),presentation:di,theme:_r,pages:s.array(s.object({id:ge,name:s.string().trim().min(1).max(60),root:Nr,theme:_r.optional(),editorPosition:s.object({x:s.number().finite().min(-1e5).max(1e5),y:s.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict()).min(1).max(U.pages),strings:li,actions:s.array(ui).max(U.actions)}).strict();function H(e,t){for(let r of e.pages)dt(r.root,t)}var Ca=fi.superRefine((e,t)=>{let r=U;e.surface!=="paywall"&&e.pages.length!==1&&t.addIssue({code:"custom",message:"Only a Paywall can contain multiple screens"}),e.initialPageId&&!e.pages.some(d=>d.id===e.initialPageId)&&t.addIssue({code:"custom",message:"Initial screen does not exist"});for(let d of e.actions)d.type==="navigate"&&(e.surface!=="paywall"||!e.pages.some(m=>m.id===d.pageId))&&t.addIssue({code:"custom",message:"Navigation screen does not exist"});e.pages.length>r.pages&&t.addIssue({code:"custom",message:`\u9875\u9762\u6700\u591A ${r.pages} \u4E2A`}),e.actions.length>r.actions&&t.addIssue({code:"custom",message:`\u52A8\u4F5C\u6700\u591A ${r.actions} \u4E2A`});let n=d=>t.addIssue({code:"custom",message:d}),i=Object.keys(e.strings.locales);i.includes(e.strings.defaultLocale)||n("\u9ED8\u8BA4\u8BED\u8A00\u5FC5\u987B\u5728\u8BED\u8A00\u5217\u8868\u91CC"),i.length>U.locales&&n(`\u6700\u591A ${U.locales} \u79CD\u8BED\u8A00`);let a=new Set;for(let d of e.actions)a.has(d.id)&&n(`\u52A8\u4F5C\u6807\u8BC6\u91CD\u590D\uFF1A${d.id}`),a.add(d.id);let o=new Set;for(let d of e.pages)["next","back"].includes(d.id)&&n(`\u9875\u9762 id \u4E0D\u80FD\u4F7F\u7528\u4FDD\u7559\u540D\u79F0\uFF1A${d.id}`),o.has(d.id)&&n(`\u9875\u9762 id \u91CD\u590D\uFF1A${d.id}`),o.add(d.id);let c=new Set,u=0,f=!1;H(e,(d,m)=>{if(u++,m>U.depth&&(f=!0),c.has(d.id)&&n(`\u7EC4\u4EF6 id \u91CD\u590D\uFF1A${d.id}`),c.add(d.id),d.type==="button"&&!a.has(d.action)&&n(`\u6309\u94AE ${d.id} \u5F15\u7528\u7684\u52A8\u4F5C\u4E0D\u5B58\u5728\uFF1A${d.action}`),d.type==="custom_html")for(let y of Object.keys(d.html))i.includes(y)||n(`\u81EA\u5B9A\u4E49 HTML ${d.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${y}`);if(d.type==="image")for(let y of Object.keys(d.localizedSrc??{}))i.includes(y)||n(`\u56FE\u7247 ${d.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${y}`)}),u>r.nodes&&n(`\u7EC4\u4EF6\u6700\u591A ${r.nodes} \u4E2A`),f&&n(`\u5C42\u7EA7\u6700\u591A ${U.depth} \u5C42`)});function dt(e,t,r=1,n=null){if(t(e,r,n)!==!1&&e.type==="stack")for(let i of e.children)dt(i,t,r+1,e)}function Or(e){let t=[],r=new Set;return H(e,n=>{let i=(a,o,c)=>{r.has(a)||(r.add(a),t.push({key:a,nodeId:n.id,nodeType:n.type,field:o,required:c}))};n.type==="stack"&&n.interaction&&i(n.interaction.label,"label",!0),n.fallback&&i(n.fallback,"text",!0),n.type==="text"&&i(n.text,"text",!0),n.type==="customer_data"&&i(n.title,"title",!0),(n.type==="plan_picker"||n.type==="quantity_picker"||n.type==="coupon_code")&&i(n.label,"label",!0),n.type==="plan_picker"&&n.grouping&&(i(n.grouping.monthLabel,"label",!0),i(n.grouping.yearLabel,"label",!0),i(n.grouping.unavailableLabel,"text",!0)),n.type==="countdown"&&i(n.expired,"text",!0),n.type==="button"&&i(n.label,"label",!0),n.type==="image"&&(i(`image:${n.id}`,"src",!1),i(n.alt,"alt",!1)),n.type==="custom_html"&&i(`html:${n.id}`,"html",!0)}),t}function mi(e,t,r){if(t.field==="html"){let n;return H(e,i=>{i.id===t.nodeId&&i.type==="custom_html"&&(n=i.html[r])}),n}if(t.field==="src"){let n=ft(e,t.nodeId);return n?.type==="image"?n.localizedSrc?.[r]??(r===e.strings.defaultLocale?n.src:void 0):void 0}return e.strings.locales[r]?.[t.key]}function gi(e){let t=Or(e).filter(n=>n.required);return Object.keys(e.strings.locales).sort((n,i)=>n===e.strings.defaultLocale?-1:i===e.strings.defaultLocale?1:0).map(n=>{let i=t.filter(a=>!mi(e,a,n)?.trim()).map(a=>a.key);return{locale:n,total:t.length,filled:t.length-i.length,missing:i,complete:i.length===0}})}function hi(e){return gi(e).filter(t=>t.complete||t.locale===e.strings.defaultLocale).map(t=>t.locale)}function va(e,t){return Er(t,hi(e),e.strings.defaultLocale)}function Ta(e,t){let r=e.strings.locales[t]??{},n=e.strings.locales[e.strings.defaultLocale]??{},i={};for(let o of Or(e)){if(o.field==="html"||o.field==="src")continue;let c=r[o.key]?.trim()?r[o.key]:n[o.key];c!==void 0&&(i[o.key]=c)}let a=o=>{if(o.type==="stack")return{...o,children:o.children.map(a)};if(o.type==="custom_html"){let c=o.html[t]?.trim()?o.html[t]:o.html[e.strings.defaultLocale];return{...o,html:c===void 0?{}:{[t]:c}}}if(o.type==="image"){let{localizedSrc:c,...u}=o;return{...u,src:c?.[t]??c?.[e.strings.defaultLocale]??o.src}}return o};return{...e,pages:e.pages.map(o=>({...o,root:a(o.root)})),strings:{defaultLocale:t,locales:{[t]:i}}}}function bi(e,t){let r=null;return dt(e,n=>{if(r)return!1;n.id===t&&(r=n)}),r}function ft(e,t){for(let r of e.pages){let n=bi(r.root,t);if(n)return n}return null}function ja(e){let t=ut(e)?.split("-")[0];return t!==void 0&&["ar","he","fa","ur"].includes(t)}function Da(e,t,r){let n={};if(!t||typeof t!="object"||Array.isArray(t))return n;let i=t;if(H(e,a=>{if(a.type==="quantity_picker"){let c=i[a.id];typeof c=="number"&&Number.isSafeInteger(c)&&c>=a.minimumQuantity&&c<=a.maximumQuantity&&(c-a.minimumQuantity)%a.step===0&&(n[a.id]=c);return}if(a.type==="plan_picker"){let c=i[a.id];typeof c=="string"&&(n[a.id]=r?.pickers[a.id]?.options.includes(c)?c:"");return}if(a.type!=="stack"||!a.interaction)return;let o=Object.hasOwn(i,a.id)?i[a.id]:void 0;["select","tabs"].includes(a.interaction.type)&&typeof o=="string"&&a.children.some(c=>c.id===o)&&(n[a.id]=o),a.interaction.type==="toggle"&&typeof o=="boolean"&&(n[a.id]=o)}),e.surface==="paywall"&&typeof i.__page=="string"&&e.pages.some(a=>a.id===i.__page)&&(n.__page=i.__page),r){let a={...n};for(let[o,c]of Object.entries(i))(typeof c=="string"||typeof c=="boolean")&&(a[o]=c);Object.assign(n,br(e,a,r))}return n}import{z as N}from"zod";import{z as p}from"zod";import{z as g}from"zod";var re=R.refine(e=>/[1-9]/.test(e),"Quantity must be positive"),be=g.string().min(1).max(120),ve=g.enum(["cap","overflow"]),$=(e,t)=>{let[r,n=""]=e.split(".");if(r===void 0||r==="")throw new Error("Invalid decimal value");return BigInt(r)*10n**BigInt(t)+BigInt(n.padEnd(t,"0"))},ye=e=>{try{return e()}catch{return!1}},Fa=g.discriminatedUnion("operation",[g.object({operation:g.literal("quote"),overageBehavior:ve.optional(),internal_feature_id:g.uuid(),entityId:g.uuid().optional(),quantity:re,properties:V}).strict(),g.object({operation:g.literal("consume"),overageBehavior:ve.optional(),occurredAt:g.iso.datetime({offset:!0}).optional(),internal_feature_id:g.uuid(),entityId:g.uuid().optional(),quantity:R,properties:V,idempotencyKey:be}).strict(),g.object({operation:g.literal("reserve"),occurredAt:g.iso.datetime({offset:!0}).optional(),internal_feature_id:g.uuid(),entityId:g.uuid().optional(),quantity:re,properties:V,idempotencyKey:be,expiresInSeconds:g.number().int().min(1).max(86400)}).strict(),g.object({operation:g.literal("confirm"),operationId:g.uuid(),quantity:re,properties:V.optional(),idempotencyKey:be}).strict(),g.object({operation:g.literal("refund"),operationId:g.uuid(),quantity:re,idempotencyKey:be}).strict(),g.object({operation:g.literal("release"),operationId:g.uuid(),idempotencyKey:be}).strict()]),yi=g.object({internal_credit_feature_id:g.uuid().nullable(),internal_metered_feature_id:g.uuid(),dimension:g.string().min(1).max(64),counterKey:g.string().min(1).max(240),cycleStart:g.iso.datetime({offset:!0}),unitCost:R,units:re,amount:Oe,tier:g.number().int().min(1).max(12).nullable()}).strict(),xe=g.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,12})?$/);function Cr(e,t){let r=e.reduce((n,i)=>n+$(i.units,12),0n)-$(t,12);return e.some(n=>n.funding==="balance")?r>=-100n&&r<=100n:r===0n}var vr=g.discriminatedUnion("funding",[g.strictObject({funding:g.literal("balance"),sourceId:g.uuid(),rolloverId:g.uuid().nullable(),units:xe.refine(e=>/[1-9]/.test(e)),amount:Oe}),g.strictObject({funding:g.literal("unbilled"),units:xe.refine(e=>/[1-9]/.test(e))}),g.object({funding:g.literal("prepaid"),sourceId:g.uuid(),units:re,amount:Oe,pricing:g.array(yi).min(1).max(12)}).strict().refine(e=>ye(()=>e.pricing.reduce((t,r)=>t+$(r.units,6),0n)===$(e.units,6)&&e.pricing.reduce((t,r)=>t+$(r.amount,12),0n)===$(e.amount,12)&&e.pricing.every(t=>$(t.unitCost,6)*$(t.units,6)===$(t.amount,12))),"Frozen pricing must conserve allocated units and amounts"),g.object({funding:g.literal("postpaid"),invoiceLineId:g.uuid().nullable(),units:re,authorizationId:g.uuid()}).strict()]),Te=g.enum(["unavailable","insufficient_balance","limit_exceeded","awaiting_topup","authorization_required","payment_blocked","cash_budget_exceeded"]),Ba=g.object({allowed:g.boolean(),internal_feature_id:g.uuid(),quantity:R,requestedQuantity:R.optional(),overageBehavior:ve.optional(),reason:Te.nullable(),allocations:g.array(vr).max(500)}).strict().refine(e=>ye(()=>e.allowed?e.reason===null&&Cr(e.allocations,e.quantity):e.reason!==null&&e.allocations.length===0),"A quote must conserve its accepted units").refine(e=>ye(()=>e.overageBehavior===void 0?e.requestedQuantity===void 0&&/[1-9]/.test(e.quantity):e.requestedQuantity!==void 0&&$(e.requestedQuantity,6)>=$(e.quantity,6)&&(e.overageBehavior==="cap"||e.requestedQuantity===e.quantity)),"Explicit overage behavior must retain the requested quantity"),Va=g.object({id:g.uuid(),internal_feature_id:g.uuid(),kind:g.enum(["consume","reserve","confirm","refund","release","expire"]),originalId:g.uuid().nullable(),quantity:R,requestedQuantity:R.optional(),overageBehavior:ve.optional(),accepted:g.boolean(),reason:g.enum([...Te.options,"expired"]).nullable(),createdAt:g.iso.datetime({offset:!0}),reservationStatus:g.enum(["pending","confirmed","released","expired"]).nullable(),expiresAt:g.iso.datetime({offset:!0}).nullable(),allocations:g.array(vr).max(500)}).strict().refine(e=>ye(()=>e.accepted?e.reason===null&&Cr(e.allocations,e.quantity):e.reason!==null&&e.allocations.length===0),"An operation must conserve its requested units").refine(e=>ye(()=>e.overageBehavior===void 0?e.requestedQuantity===void 0:e.kind==="consume"&&e.requestedQuantity!==void 0&&$(e.requestedQuantity,6)>=$(e.quantity,6)&&(e.overageBehavior==="cap"||e.requestedQuantity===e.quantity)),"Overage metadata belongs to consumption and preserves requested units").refine(e=>/[1-9]/.test(e.quantity)||e.kind==="consume","Only consumption can record a zero cost event").refine(e=>e.allocations.every(t=>t.funding!=="postpaid"||t.invoiceLineId!==null),"Accepted operations must reference persisted invoice lines").refine(e=>e.originalId!==null===["confirm","refund","release","expire"].includes(e.kind)&&e.expiresAt!==null==(e.reservationStatus!==null)&&(e.kind!=="reserve"||!e.accepted||e.reservationStatus!==null),"Operation provenance and reservation state must be explicit");import{z as M}from"zod";var xi=M.string().max(40).regex(/^(0|[1-9]\d*)(\.\d{1,12})?$/),Si=M.string().max(41).regex(/^-?(0|[1-9]\d*)(\.\d{1,12})?$/),Tr=M.strictObject({internal_feature_id:M.uuid(),entityId:M.uuid().nullable()}),qa=Tr.extend({quantity:R,expectedRevision:M.number().int().min(0).max(Number.MAX_SAFE_INTEGER),idempotencyKey:M.string().min(1).max(120),properties:V.refine(e=>Object.keys(e).length<=13&&!Object.keys(e).some(t=>t.startsWith("usage_")),"Usage accounting reserves three properties")}).strict(),jr=Tr.extend({operationId:M.uuid().nullable(),usage:R,capacity:xi.nullable(),remaining:Si.nullable(),withinLimit:M.boolean(),revision:M.number().int().min(0).max(Number.MAX_SAFE_INTEGER),updatedAt:M.iso.datetime({offset:!0}).nullable()}).strict().superRefine((e,t)=>{let r=n=>{let i=n.startsWith("-"),[a,o=""]=(i?n.slice(1):n).split(".");if(a===void 0||a==="")throw new Error("Invalid decimal value");return(i?-1n:1n)*(BigInt(a)*10n**12n+BigInt(o.padEnd(12,"0")))};(e.capacity===null!=(e.remaining===null)||(e.capacity===null?!e.withinLimit:e.remaining===null||r(e.remaining)!==r(e.capacity)-r(e.usage)||e.withinLimit!==r(e.remaining)>=0n)||e.revision===0!=(e.operationId===null)||e.operationId===null!=(e.updatedAt===null))&&t.addIssue({code:"custom",message:"Absolute usage must conserve capacity and its immutable revision"})});var G=p.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,12})?$/),q=p.iso.datetime({offset:!0}),Ai=p.enum(["access","metered","credit"]),Se={internal_feature_id:p.uuid(),key:ee,name:p.string().min(1).max(120),kind:Ai},Ja=p.object({customerId:p.uuid(),snapshotAt:q,memberships:p.array(p.object({id:p.uuid(),productId:p.string().min(1).max(255),productVersionId:p.uuid(),billingProductVersionId:p.uuid(),version:p.number().int().positive(),key:p.string().min(1).max(64),name:p.string().min(1).max(120),groupId:p.string().max(255).nullable(),membershipType:p.enum(["main","addon"]),status:p.enum(["trial","active","past_due","ended","expired","trialing","paused","pending","scheduled","unknown"]),cancelAtPeriodEnd:p.boolean(),accessEnabled:p.boolean(),renewalChange:p.object({productVersionId:p.uuid(),name:p.string().min(1).max(120),version:p.number().int().positive(),effectiveAt:q,benefitsAppliedAt:q.nullable(),timing:p.enum(["immediate","renewal"]),changeKind:p.enum(["plan","seats","quantity"]),feature:p.strictObject({internal_feature_id:p.uuid(),name:p.string().min(1).max(80),fromQuantity:p.number().int().min(0).max(1e4),toQuantity:p.number().int().min(0).max(1e4)}).optional(),seat:p.object({key:p.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),fromQuantity:p.number().int().min(0).max(1e4),toQuantity:p.number().int().min(0).max(1e4)}).strict().nullable(),status:p.enum(["prepared","quoted","confirmed","pending","scheduled"])}).strict().refine(e=>e.changeKind==="seats"==(e.seat!==null)&&e.changeKind==="quantity"==(e.feature!==void 0),"Quantity changes require their fixed component identities and quantities").nullable(),period:p.object({phase:p.enum(["paid","trial"]),startsAt:q,endsAt:q.nullable()}).strict().nullable()}).strict()).max(100),membershipsLimited:p.boolean(),balances:p.array(p.object({...Se,usageType:p.enum(["consumable","non_consumable"]).nullable(),accessible:p.boolean(),unlimited:p.boolean(),available:G,held:G,debt:G,nextExpiresAt:q.nullable(),usage:jr.nullable()}).strict().refine(e=>e.kind==="metered"==(e.usageType!==null)&&(e.accessible||e.available==="0"&&e.held==="0")&&(e.usageType==="non_consumable"?e.usage!==null&&e.usage.internal_feature_id===e.internal_feature_id&&e.unlimited===(e.usage.capacity===null)&&e.available===(e.usage.remaining===null||e.usage.remaining.startsWith("-")?"0":e.usage.remaining)&&e.held==="0"&&e.debt==="0":e.usage===null),"Balances must expose their actual spendable or non-consumable state")).max(500),balancesLimited:p.boolean()}).strict(),Dr=p.enum(["source","usage","transaction","invoice","debt","settlement"]),je=p.object({at:q,id:p.uuid(),type:Dr}).strict(),Ya=p.object({type:Dr.nullable(),resourceKey:ee.optional(),kind:p.enum(["purchase","refund"]).optional(),topup:p.boolean().optional(),from:p.iso.date().nullable(),to:p.iso.date().nullable(),after:je.nullable(),limit:p.number().int().min(1).max(50)}).strict().refine(e=>!e.from||!e.to||e.from<=e.to,"Date range is reversed"),le={id:p.uuid(),occurredAt:q},ki=p.discriminatedUnion("type",[p.strictObject({...le,type:p.literal("invoice"),status:p.string().min(1).max(80),paid:G,refunded:G,currency:j,externalId:p.string().nullable()}),p.object({...le,...Se,type:p.literal("source"),reason:p.enum(["membership","trial","topup","manual","rollover","upgrade_carry","seat"]),quantity:G,unlimited:p.boolean(),status:p.enum(["scheduled","active","expired","revoked","unavailable"]),startsAt:q,expiresAt:q.nullable(),orderId:p.uuid().nullable(),parentSourceId:p.uuid().nullable()}).strict(),p.object({...le,type:p.literal("usage"),internal_feature_id:p.uuid(),name:p.string().min(1).max(120),kind:p.enum(["consume","set_usage","reserve","confirm","refund","release","expire"]),originalId:p.uuid().nullable(),quantity:R,accepted:p.boolean(),reason:p.enum([...Te.options,"expired"]).nullable(),properties:V,reservationStatus:p.enum(["pending","confirmed","released","expired"]).nullable(),expiresAt:q.nullable(),charges:p.array(p.discriminatedUnion("funding",[p.strictObject({funding:p.literal("balance"),sourceId:p.uuid(),rolloverId:p.uuid().nullable(),units:xe,amount:G}),p.strictObject({funding:p.literal("unbilled"),units:xe}),p.object({...Se,funding:p.literal("prepaid"),amount:G}).strict(),p.object({funding:p.literal("postpaid"),invoiceId:p.uuid(),invoiceLineId:p.uuid(),authorizationId:p.uuid(),units:R,currency:j}).strict()])).max(500)}).strict().refine(e=>(e.kind==="set_usage"||e.kind==="consume"&&e.quantity==="0"?e.accepted&&e.reason===null&&e.charges.length===0&&e.reservationStatus===null:e.accepted?e.reason===null&&e.charges.length>0:e.reason!==null&&e.charges.length===0)&&e.originalId!==null===["confirm","refund","release","expire"].includes(e.kind)&&e.expiresAt!==null==(e.reservationStatus!==null),"Usage facts must retain their original outcome and receipt"),p.object({...le,type:p.literal("transaction"),purpose:p.enum(["product","invoice"]),productVersionId:p.uuid().nullable(),productName:p.string().min(1).max(120).nullable(),productVersion:p.number().int().positive().nullable(),invoiceId:p.uuid().nullable(),orderId:p.uuid(),originalId:p.uuid().nullable(),kind:p.enum(["purchase","refund"]),amountMinor:p.number().int().nonnegative().max(2e8).nullable(),currency:j.nullable()}).strict().refine(e=>e.currency===null==(e.amountMinor===null)&&(e.purpose==="product"?e.productVersionId!==null&&e.productName!==null&&e.productVersion!==null&&e.invoiceId===null:e.productVersionId===null&&e.productName===null&&e.productVersion===null&&e.invoiceId!==null)&&e.kind==="refund"==(e.originalId!==null)&&(e.kind!=="refund"||e.amountMinor===null||e.amountMinor>0),"Payment fact provenance is incomplete"),p.object({...le,...Se,type:p.literal("debt"),sourceId:p.uuid(),transactionId:p.uuid(),amount:G}).strict(),p.object({...le,...Se,type:p.literal("settlement"),sourceId:p.uuid(),debtId:p.uuid(),kind:p.enum(["payment","usage_refund","payment_return"]),amount:G}).strict()]),Xa=p.object({customerId:p.uuid(),rows:p.array(ki).max(50),nextCursor:je.nullable()}).strict().refine(e=>new Set(e.rows.map(t=>t.type+t.id)).size===e.rows.length,"A page cannot repeat a fact").refine(e=>{let t=e.rows.at(-1);return!e.nextCursor||!!(t&&t.id===e.nextCursor.id&&t.type===e.nextCursor.type&&t.occurredAt===e.nextCursor.at)},"Cursor must name the final displayed fact");var is=N.discriminatedUnion("kind",[N.object({kind:N.literal("ledger"),cursor:je}).strict(),N.object({kind:N.literal("billing"),cursor:N.uuid()}).strict()]),Ei=N.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),_i=N.record(N.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),N.union([N.string().max(500),N.boolean(),N.array(N.string().max(500)).max(50)])).refine(e=>Object.keys(e).length<=40,"Too many answers"),Ii=/^(?:api_?key|authorization|password|(?:customer|run|visitor|access|purchase)_?token|client_?secret|signed_?transaction|raw_?proof)$/i;function mt(e,t=0){return t>20?!0:!!e&&typeof e=="object"&&(Array.isArray(e)?e.some(r=>mt(r,t+1)):Object.entries(e).some(([r,n])=>["__proto__","constructor","prototype"].includes(r)||Ii.test(r)||mt(n,t+1)))}var wi=/gg_(?:sk|ct|fr|fv|gc)_[A-Za-z0-9_-]{20,}/,os=N.record(Ei,J).refine(e=>Object.keys(e).length<=20,"Too many parameters").refine(e=>!mt(e)&&!wi.test(JSON.stringify(e)),"Credentials cannot be screen parameters");var Lr=N.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Ri=N.array(N.object({variable:Lr,componentId:Lr,required:N.boolean()}).strict()).max(40).refine(e=>new Set(e.map(t=>t.variable)).size===e.length&&new Set(e.map(t=>t.componentId)).size===e.length,"Input bindings must be unique"),as=N.object({bindings:Ri,answers:_i,values:N.record(N.string(),J).optional()}).strict();function Pr(e,t,r=1){if(e==="free")return"";if(e==="one_time")return t.startsWith("zh")?" \xB7 \u4E00\u6B21\u4ED8\u6B3E":" \xB7 one-time";let n=t.split("-")[0]??"en",i={zh:["/\u6708","/\u5E74"],en:["/month","/year"],ja:["/\u6708","/\u5E74"],ko:["/\uC6D4","/\uB144"],es:["/mes","/a\xF1o"],fr:["/mois","/an"],de:["/Monat","/Jahr"],pt:["/m\xEAs","/ano"],it:["/mese","/anno"],ar:["/\u0634\u0647\u0631","/\u0633\u0646\u0629"]},a={zh:"\u5468",en:"week",ja:"\u9031",ko:"\uC8FC",es:"semana",fr:"semaine",de:"Woche",pt:"semana",it:"settimana",ar:"\u0623\u0633\u0628\u0648\u0639"},o=e==="week"?`/${a[n]??a.en}`:(i[n]??i.en)[e==="month"?0:1];return r===1?o:`/${r} ${o.slice(1)}${n==="en"?"s":""}`}function ms(e,t){let r=[],n={};H(e,i=>{if(i.hidden)return!1;if(i.type!=="quantity_picker")return;let a=i.bind?.plan?[i.bind.plan]:[];i.bind?.picker&&H(e,o=>{if(o.type==="plan_picker"&&o.id===i.bind?.picker&&a.push(...o.planIds??[]),o.type==="stack"&&o.interaction?.type==="select"&&o.interaction.pickerId===i.bind?.picker)for(let c of o.children)c.type==="stack"&&c.bind?.plan&&a.push(c.bind.plan)}),a.length||r.push(`Quantity control ${i.id} needs a Product binding`);for(let o of new Set(a)){let c=t[o]?.prepaid?.find(f=>f.internalFeatureId===i.internalFeatureId)?.terms,u=n[o]??=new Set;(!c||u.has(i.internalFeatureId)||i.minimumQuantity<c.minimumQuantity||i.maximumQuantity>c.maximumQuantity)&&r.push(`Quantity control ${i.id} must match its Product's prepaid Feature and bounds`),u.add(i.internalFeatureId)}});for(let[i,a]of Object.entries(t))for(let o of a.prepaid??[])n[i]?.has(o.internalFeatureId)||r.push(`Product ${i} needs a quantity control for ${o.internalFeatureId}`);return r}function gs(e,t,r,n){let i=n.plans[t];if(!i?.available)throw new Error("Selected Product is unavailable");let a={};if(H(e,o=>{if(o.hidden)return!1;if(o.type!=="quantity_picker"||o.hidden||(o.bind?.plan??(o.bind?.picker?r[o.bind.picker]:void 0))!==t)return;let u=i.prepaid?.find(d=>d.internalFeatureId===o.internalFeatureId)?.terms,f=r[o.id];if(!u||typeof f!="number"||!Number.isSafeInteger(f)||f<Math.max(u.minimumQuantity,o.minimumQuantity)||f>Math.min(u.maximumQuantity,o.maximumQuantity)||(f-o.minimumQuantity)%o.step!==0||a[o.internalFeatureId]!==void 0)throw new Error("Choose a valid quantity for each prepaid Feature");a[o.internalFeatureId]=f}),(i.prepaid??[]).some(o=>a[o.internalFeatureId]===void 0))throw new Error("Choose a quantity for each prepaid Feature");return a}function Ni(e,t,r){let n=e.terms.prices.find(i=>i.currency===t);if(!n||r<e.terms.minimumQuantity||r>e.terms.maximumQuantity)throw new Error("Quantity or currency is unavailable");return{amountMinor:ar({quantity:r,unitAmountMinor:n.amountMinor,...n.pricing?{pricing:n.pricing}:{}}),allowance:ur(e.includedAmount,e.terms.units,r)}}function hs(e,t,r,n){let i=!1;if(H(e,c=>{c.type==="quantity_picker"&&(i=!0)}),!i)return t;let a=structuredClone(t);a.quantities={};let o=new Map;H(e,c=>{if(c.hidden)return!1;if(c.type!=="quantity_picker")return;let u=c.bind?.plan??(c.bind?.picker?r[c.bind.picker]??a.pickers[c.bind.picker]?.selected:void 0),f=typeof u=="string"?a.plans[u]:void 0,d=f?.prepaid?.find(Y=>Y.internalFeatureId===c.internalFeatureId),m=Math.max(c.minimumQuantity,d?.terms.minimumQuantity??0),y=Math.min(c.maximumQuantity,d?.terms.maximumQuantity??0),S=r[c.id]??c.defaultQuantity,_=typeof S=="number"&&Number.isSafeInteger(S)?S:c.defaultQuantity,A=!!d&&!!f?.available&&_>=m&&_<=y&&(_-c.minimumQuantity)%c.step===0,T=a.quantities[c.id]={minimum:m,maximum:Math.max(m,y),step:c.step,value:_,label:"",available:A};if(!A||!d||!f?.currency||f.amountMinor===void 0)return;let P=Ni(d,f.currency,_);T.label=`${new Intl.NumberFormat(n).format(Number(P.allowance))} ${d.name}${["week","month","year"].includes(d.reset)?Pr(d.reset,n,d.resetCount):d.reset==="lifetime"?"":` / ${d.resetCount} ${d.reset}`}`,o.set(String(u),(o.get(String(u))??f.amountMinor)+P.amountMinor)});for(let[c,u]of o){let f=a.plans[c];if(!f?.currency)continue;let d=Pe(u,f.currency,n);f.price=d;for(let[m,y]of Object.entries(a.nodes)){let S=ft(e,m),_=A=>{if(A.price&&(A.price={...A.price,current:d,original:null}),S?.type==="text"){let T=e.strings.locales[n]?.[S.text]??e.strings.locales[e.strings.defaultLocale]?.[S.text];T?.includes("{{plan.price")&&(A.text=T.replace(/\{\{\s*plan.price\s*\}\}/g,d).replace(/\{\{\s*plan.price_per_month\s*\}\}/g,Pe(Math.round(u/((f.interval==="year"?12:1)*(f.intervalCount??1))),f.currency,n)))}};y.byPlan?.[c]&&_(y.byPlan[c]),(y.base.planVersionId===c||S&&"bind"in S&&S.bind?.plan===c)&&_(y.base)}}return a}import{z as C}from"zod";var De=C.enum(["INVALID_PROTOCOL_VERSION","UNSUPPORTED_PROTOCOL_VERSION","PROTOCOL_RETIRED","UNAUTHENTICATED","FORBIDDEN","SCOPE_MISMATCH","INVALID_REQUEST","NOT_FOUND","CONFLICT","PAYLOAD_TOO_LARGE","RATE_LIMITED","SERVICE_UNAVAILABLE","NOT_CONFIGURED","CAPABILITY_UNAVAILABLE","INTERNAL_ERROR"]),Ss=C.enum([...De.options,"INVALID_SERVER_RESPONSE","RESPONSE_TOO_LARGE","AMBIGUOUS_AUTHENTICATION","BROWSER_REQUIRED","INVALID_REDIRECT_URI","AUTHORIZATION_UNAVAILABLE","UNREGISTERED_CLIENT","MANAGEMENT_OPERATION_FAILED"]),As=C.enum([...De.options,"stale_revision"]),Oi=C.enum(["fix_request","authenticate","check_permissions","check_scope","resolve_conflict","reload_state","retry_same_request","configure_integration","check_availability","upgrade_sdk","recover_operation","contact_support"]),Ci=C.enum(["CAPABILITY_NOT_ENABLED","INTEGRATION_MISSING","PROVIDER_CREDENTIAL_REJECTED","PRICE_BINDING_REQUIRED","IDEMPOTENCY_CONFLICT","RESULT_UNKNOWN","STATE_CHANGED","IDENTITY_CONTEXT_CHANGED","CUSTOMER_BINDING_CONFLICT","RUN_CONTRACT_MISMATCH","OPERATION_IN_PROGRESS","FUNNEL_VERSION_RETIRED"]),Fr={INVALID_PROTOCOL_VERSION:{status:400,recovery:"fix_request"},UNSUPPORTED_PROTOCOL_VERSION:{status:400,recovery:"upgrade_sdk"},PROTOCOL_RETIRED:{status:410,recovery:"upgrade_sdk"},UNAUTHENTICATED:{status:401,recovery:"authenticate"},FORBIDDEN:{status:403,recovery:"check_permissions"},SCOPE_MISMATCH:{status:403,recovery:"check_scope"},INVALID_REQUEST:{status:400,recovery:"fix_request"},NOT_FOUND:{status:404,recovery:"fix_request"},CONFLICT:{status:409,recovery:"resolve_conflict"},PAYLOAD_TOO_LARGE:{status:413,recovery:"fix_request"},RATE_LIMITED:{status:429,recovery:"retry_same_request"},SERVICE_UNAVAILABLE:{status:503,recovery:"retry_same_request"},NOT_CONFIGURED:{status:501,recovery:"configure_integration"},CAPABILITY_UNAVAILABLE:{status:501,recovery:"check_availability"},INTERNAL_ERROR:{status:500,recovery:"recover_operation"}};var $r={TIMEOUT:"recover_operation",NETWORK_ERROR:"recover_operation",HTTP_ERROR:"recover_operation",INVALID_RESPONSE:"recover_operation",NOT_IDENTIFIED:"authenticate",INVALID_TOKEN:"authenticate",INVALID_URL:"fix_request",INVALID_TIMEOUT:"fix_request",SERVER_ONLY:"fix_request",PROTOCOL_MISMATCH:"upgrade_sdk",IDENTITY_CHANGED:"reload_state",INVALID_STATE:"reload_state",EVENT_QUEUE_FULL:"retry_same_request",COMMAND_PENDING:"recover_operation",DECISION_PENDING:"recover_operation",DECISION_ACCEPTANCE_UNKNOWN:"recover_operation",RUN_RECONCILIATION_REQUIRED:"recover_operation",DECISION_FAILED:"contact_support",COMMAND_STORAGE_CONFLICT:"resolve_conflict",COMMAND_STORAGE_INVALID:"fix_request",CONFIGURATION_UNAVAILABLE:"check_availability",CONFIGURATION_EXPIRED:"reload_state",CONFIGURATION_CHANGED:"reload_state",CONFIGURATION_DISPOSED:"reload_state",UNSUPPORTED_SCHEMA:"upgrade_sdk",FUNNEL_STOPPED:"check_availability",PAYWALL_UNAVAILABLE:"check_availability",EVALUATION_MODE:"reload_state",SERVER_REQUIRED:"fix_request",STICKY_SAVE_FAILED:"retry_same_request",TRANSITION_LIMIT:"resolve_conflict",PRECONDITION_FAILED:"reload_state",PRODUCT_UNAVAILABLE:"fix_request",PURCHASE_HANDLER_REQUIRED:"fix_request",EVENT_HANDLER_REQUIRED:"fix_request",CLOSED:"fix_request",BRIDGE_UNAVAILABLE:"check_availability",INVALID_CONFIGURATION:"fix_request",NATIVE_OPERATION_FAILED:"contact_support",AI_PRICE_UNAVAILABLE:"fix_request",AI_USAGE_UNAVAILABLE:"recover_operation",AI_PROVIDER_ERROR:"check_availability",AI_BALANCE_REJECTED:"resolve_conflict"};function vi(e,t){if(e==="CONFLICT"&&t===425)return{retryable:!0,recovery:"retry_same_request"};if(e==="CONFLICT"&&t===412)return{retryable:!1,recovery:"reload_state"};if(e==="INVALID_SERVER_RESPONSE")return{retryable:!1,recovery:"recover_operation"};if(e==="AMBIGUOUS_AUTHENTICATION")return{retryable:!1,recovery:"fix_request"};if(Object.hasOwn($r,e)){let n=$r[e];return{retryable:n==="retry_same_request",recovery:n}}let r=De.safeParse(e);return r.success?{retryable:e==="RATE_LIMITED"||e==="SERVICE_UNAVAILABLE",recovery:Fr[r.data].recovery}:{retryable:!1,recovery:"contact_support"}}function ks(e,t){let r=De.safeParse(e);if(r.success)return e==="CONFLICT"?[409,412,425].includes(t):e==="SERVICE_UNAVAILABLE"?[408,502,503,504].includes(t):e==="INVALID_REQUEST"?[400,405,415,422].includes(t):e==="NOT_CONFIGURED"?[501,503].includes(t):Fr[r.data].status===t;let n={INVALID_SERVER_RESPONSE:[502],RESPONSE_TOO_LARGE:[502],AMBIGUOUS_AUTHENTICATION:[400],BROWSER_REQUIRED:[403],INVALID_REDIRECT_URI:[403],AUTHORIZATION_UNAVAILABLE:[400],UNREGISTERED_CLIENT:[403],MANAGEMENT_OPERATION_FAILED:[400,422,500]};return Object.hasOwn(n,e)&&(n[e]?.includes(t)??!1)}function Ti(e,t=Date.now()){if(e===null)return;let r=e.trim();if(/^\d+$/.test(r)){let i=Number(r);return Number.isSafeInteger(i)?i:void 0}if(!/^[A-Za-z]{3}, \d{2} [A-Za-z]{3} \d{4} \d{2}:\d{2}:\d{2} GMT$/.test(r))return;let n=Date.parse(r);return Number.isFinite(n)?Math.max(0,Math.ceil((n-t)/1e3)):void 0}var Br=C.object({retryable:C.boolean(),recovery:Oi,reason:Ci.optional(),retryAfterSeconds:C.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional()}),ji=C.object({requestId:C.uuid().optional(),error:C.object({code:C.string().regex(/^[A-Z][A-Z0-9_]{0,95}$/),message:C.string(),...Br.partial().shape})}),Es=C.object({error:ji.shape.error.extend({requestId:C.uuid().optional()})}),_s=C.object({error:C.string(),code:C.string().regex(/^[A-Za-z][A-Za-z0-9_]{0,95}$/),requestId:C.uuid(),...Br.shape});function Is(e,t,r={}){let n=vi(e,t),i=r.reason==="RESULT_UNKNOWN"?"recover_operation":r.recovery??n.recovery,a=n.retryable&&r.retryable!==!1&&i!=="recover_operation",o=a?Ti(r.retryAfter??null):void 0;return{...n,retryable:a,recovery:i,...o===void 0?{}:{retryAfterSeconds:o},...r.reason?{reason:r.reason}:{}}}export{De as a,Oi as b,Ci as c,ks as d,ji as e,Is as f,j as g,Ur as h,Pe as i,Oe as j,R as k,_n as l,V as m,ot as n,ar as o,cr as p,ur as q,ne as r,Ue as s,kt as t,Nt as u,$t as v,B as w,Mt as x,qt as y,Zt as z,J as A,rt as B,Ne as C,mn as D,En as E,ue as F,ut as G,Fa as H,yi as I,xe as J,Ba as K,Va as L,Tr as M,qa as N,jr as O,G as P,Ja as Q,Ya as R,Xa as S,st as T,To as U,rr as V,nr as W,qo as X,Cn as Y,ir as Z,lr as _,sa as $,pr as aa,ca as ba,hr as ca,xr as da,Sr as ea,da as fa,fa as ga,xa as ha,U as ia,E as ja,Oa as ka,H as la,Ca as ma,dt as na,Or as oa,gi as pa,va as qa,Ta as ra,ft as sa,ja as ta,Da as ua,is as va,_i as wa,os as xa,Ri as ya,as as za,Pr as Aa,ms as Ba,gs as Ca,hs as Da};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as o}from"./chunk-OZZMZH7X.js";function s(r,n){let i=structuredClone(r);for(let[a,e]of Object.entries(i.plans)){let t=n.plans[a];!t||t.versionId!==e.versionId||(t.amountMinor!==void 0&&(e.amountMinor=t.amountMinor),t.interval!==void 0&&(e.interval=t.interval),t.intervalCount!==void 0&&(e.intervalCount=t.intervalCount),t.prepaid!==void 0&&(e.prepaid=structuredClone(t.prepaid)))}return i}function c(r,n){let i=a=>"document"in a?a.offering.id:a.content.offeringVersionId;return r.id===n.id&&i(r)===i(n)&&r.content?.artifact.sha256===n.content?.artifact.sha256}function l(r,n,i){if(r.operationId!==n.operationId||n.currency!==void 0&&r.currency!==n.currency)throw new o("INVALID_RESPONSE",i)}function p(r,n,i){let a=Object.fromEntries((r.lines[0]?.prepaid??[]).map(e=>[e.internal_feature_id,e.quantity]));if(n.featureQuantities&&(Object.keys(a).length!==Object.keys(n.featureQuantities).length||Object.entries(n.featureQuantities).some(([e,t])=>a[e]!==t)))throw new o("INVALID_RESPONSE","The purchase quote changed its selected quantities");if(r.lines.length!==1||r.lines[0].productVersionId!==n.productVersionId||n.currency!==void 0&&r.currency!==n.currency||n.provider!==void 0&&r.provider!==n.provider&&!(n.provider==="stripe"&&r.provider==="merchant"&&r.execution?.provider==="merchant"))throw new o("INVALID_RESPONSE",i)}function f(r,n,i=!1){return!r||r.operationId!==n?.operationId?n:r.status==="complete"&&n.status!=="complete"||r.status!=="pending"&&(n.status==="pending"||i&&n.status!=="complete")?r:n}export{s as a,c as b,l as c,p as d,f as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as t}from"./chunk-VQBQAKJD.js";import{Za as n}from"./chunk-KQ4MS4LR.js";function r(e,o,a){return n(e,o,a,t)}export{r as a};
|
|
@@ -911,6 +911,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
911
911
|
runTimeoutSeconds: number;
|
|
912
912
|
maxTransitions: number;
|
|
913
913
|
};
|
|
914
|
+
executionContract?: "funnel-run/1" | "funnel-process/1" | undefined;
|
|
914
915
|
};
|
|
915
916
|
growth: {
|
|
916
917
|
evaluatedAt: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as F,j as Q}from"./chunk-33FQUT3Z.js";import{b as B}from"./chunk-SSLZKIIU.js";import{a as z,b as _}from"./chunk-MOWYD2TV.js";import"./chunk-OBZSDWLC.js";import{a as d}from"./chunk-OZZMZH7X.js";import{a as v}from"./chunk-DSPLGTQI.js";import{Q as M}from"./chunk-KQ4MS4LR.js";import{A as V,ka as P,qa as U,xa as N,ya as q}from"./chunk-VSJOHWDL.js";import{z as p}from"zod";var x=new WeakMap;function W(r){let t={string:p.string(),number:p.number().finite(),boolean:p.boolean(),strings:p.array(p.string()),json:V}[r.type];return r.nullable?t.nullable():t}async function ie(r,t){return $(r,t,!1)}async function se(r,t){return $(r,t,!0)}async function $(r,t,w){t.signal?.throwIfAborted();let L=M.parse(t.content),o=L.document;if(x.has(r))throw new d("CONFLICT","Content is already mounted in this container");let f=p.record(p.string(),V).parse(t.inputs??{});if(Object.keys(f).length>40)throw new d("INVALID_REQUEST","Too many content inputs");for(let[e,s]of Object.entries(f))N.parse({[e]:s});if(Object.keys(f).some(e=>!Object.hasOwn(o.contract.inputs,e)))throw new d("INVALID_REQUEST","Undeclared content input");for(let[e,s]of Object.entries(o.contract.inputs))if(Object.hasOwn(f,e))W(s).parse(f[e]);else if(s.required)throw new d("INVALID_REQUEST",`Missing content input ${e}`);for(let e of Object.keys(o.contract.outputs))if(typeof t.actions[e]!="function")throw new d("INVALID_REQUEST",`Missing host handler for ${e}`);let J=q.parse(t.bindings??[]),c=r.ownerDocument,T,k=o.kind==="popup",n=k?c.createElement("dialog"):null,i=c.createElement("div");if(i.dataset.indianaContent=o.kind,i.setAttribute("aria-label",o.name),i.style.cssText="width:100%;min-width:0",n){n.setAttribute("aria-label",o.name);let e=o.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=`${P[e.size]}px`,e.type==="sheet"&&(n.style.margin="auto auto 0")):n.style.width="100vw",n.append(i),r.append(n)}else r.append(i);let l=!1,C=!1,g=!1;w&&!n&&(i.style.width=`${r.getBoundingClientRect().width||c.defaultView?.innerWidth||800}px`);let G=w?F(n??i):()=>{},D,A,S=new Promise((e,s)=>{D=e,A=s});S.catch(()=>{});let u=null,E=structuredClone(o.screen);E.actions=E.actions.map(e=>e.type==="event"?{...e,close:!1}:e);let y;function m(){l||(l=!0,t.signal?.removeEventListener("abort",m),A(new Error("Content preparation cancelled")),y?.destroy(),n?.close(),n?.remove(),i.remove(),x.delete(r),n&&T?.())}let O=()=>{g&&(m(),v(t.onDismiss))};if(n){let e=c.createElement("button");e.type="button",e.textContent="\xD7",e.setAttribute("aria-label",t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),_(e,o.screen.theme),e.addEventListener("click",O),n.prepend(e)}n?.addEventListener("cancel",e=>{e.preventDefault(),O()});async function H(){if(l||!g||C||!u)return;let e=u;C=!0,i.setAttribute("aria-busy","true");try{await t.actions[e.actionId](structuredClone(e)),u=null}catch(s){v(t.onError,s)}finally{C=!1,l||i.removeAttribute("aria-busy")}}function R(){if(l)throw new d("CONFLICT","Content host has been destroyed");g||(T=B(c),G(),w&&!n&&(i.style.width="100%"),n&&(n.showModal(),z(n,o.screen.presentation.type)),g=!0)}try{w||R(),y=Q(i,{mode:"live",rendererUrl:t.rendererUrl,title:o.name,viewportHeight:o.kind==="page"?r.clientHeight||c.defaultView?.innerHeight||800:void 0,onRendered:a=>{a&&n?.setAttribute("aria-label",a),D()},onError:a=>{let I=new Error(a);A(I),v(t.onError,I)},onEscape:k?O:void 0,onAction:(a,I,K)=>{if(l||!g||C||u)return;let h=o.screen.actions.find(b=>b.id===a),j=o.contract.outputs[a];if(!(h?.type!=="event"||!j))try{let b=W(j).parse(Object.hasOwn(h.properties,"value")?h.properties.value:h.properties);u={requestId:crypto.randomUUID(),contentVersionId:L.id,actionId:a,event:h.event,value:b,selection:I??{},answers:K??{},requestedClose:h.close},H()}catch(b){v(t.onError,b)}}});let e={destroy:m,show:R,get pendingAction(){return u?structuredClone(u):null},retryAction:H,updateCapabilities:a=>y?.updateCapabilities(a)};x.set(r,e),t.signal?.addEventListener("abort",m,{once:!0}),t.signal?.aborted&&(m(),t.signal.throwIfAborted());let s=U(E,[t.locale,...c.defaultView?.navigator.languages??[]]);if(y.update(E,s,{capabilities:t.capabilities,serverInput:{bindings:J,answers:{},values:f}}),await Promise.race([y.ready,S]),w&&await S,l)throw new Error("Content preparation cancelled");return e}catch(e){throw m(),e}}export{ie as mountContent,se as prepareContent};
|