@tinkerlandai/longplay-sdk 0.0.0-stage → 0.10.4
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 +209 -0
- package/README.md +485 -2
- package/README.zh-CN.md +375 -0
- package/THIRD_PARTY_NOTICES.md +101 -0
- package/dist/ai-usage-Btwg1nD7.d.ts +247 -0
- package/dist/api-5gAz4-Sb.d.ts +16897 -0
- package/dist/chunk-2HFA34QO.js +6 -0
- package/dist/chunk-7DXL3LHT.js +1 -0
- package/dist/chunk-ACF2FBUB.js +1 -0
- package/dist/chunk-CLXORAOK.js +1 -0
- package/dist/chunk-DSPLGTQI.js +1 -0
- package/dist/chunk-EARSGITJ.js +1 -0
- package/dist/chunk-G56XGVMS.js +1 -0
- package/dist/chunk-HOW7NIIR.js +1 -0
- package/dist/chunk-JB46ZKGZ.js +1 -0
- package/dist/chunk-KBM7BYQY.js +1 -0
- package/dist/chunk-MRN4HP4W.js +1 -0
- package/dist/chunk-RE6BIFLN.js +2 -0
- package/dist/chunk-SBPTOOYB.js +1 -0
- package/dist/chunk-SSLZKIIU.js +1 -0
- package/dist/chunk-VMM3GA3L.js +4 -0
- package/dist/chunk-VOEFXEPP.js +1 -0
- package/dist/chunk-X6BCUINI.js +173 -0
- package/dist/chunk-XSVQHPQT.js +17 -0
- package/dist/chunk-YQHPEP4X.js +1 -0
- package/dist/chunk-ZPZVSC4J.js +1 -0
- package/dist/configuration-sync-CywDxRkX.d.ts +1698 -0
- package/dist/content-NYMIZRNR.js +1 -0
- package/dist/coupon-fA1QujHt.d.ts +184 -0
- package/dist/customer-page-km5f1PJZ.d.ts +480 -0
- package/dist/funnel-local-client-CVokI0rx.d.ts +46997 -0
- package/dist/funnel-node-evaluation-P5B4fPfJ.d.ts +2054 -0
- package/dist/funnel-resource-client-Cv5OjfAn.d.ts +14525 -0
- package/dist/funnel-runtime-host-UL4DEJDU.js +1 -0
- package/dist/growth-rules-B4YYy64R.d.ts +173 -0
- package/dist/index.d.ts +23545 -0
- package/dist/index.js +1 -0
- package/dist/native-shell.d.ts +4 -0
- package/dist/native-shell.js +1 -0
- package/dist/openrouter.d.ts +43 -0
- package/dist/openrouter.js +1 -0
- package/dist/page.d.ts +134 -0
- package/dist/page.js +1 -0
- package/dist/paywall-EJCNWDHK.js +1 -0
- package/dist/popup.d.ts +191 -0
- package/dist/popup.js +1 -0
- package/dist/react-native.d.ts +36701 -0
- package/dist/react-native.js +1 -0
- package/dist/screen-D81zCpfi.d.ts +3000 -0
- package/dist/screen-renderer-JMHV4GPP.js +1 -0
- package/dist/server.d.ts +7073 -0
- package/dist/server.js +1 -0
- package/dist/visual-dom-DQLPBZ2Z.js +1 -0
- package/dist/visual.d.ts +87 -0
- package/dist/visual.js +1 -0
- package/package.json +90 -3
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function P(e){let t=2166136261,n=e.length;for(let r=0;r<n;r++)t^=e.charCodeAt(r),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return t>>>0}function R(e,t,n){return n===2?P(P(e+t)+"")%1e4/1e4:null}function oe(e){return e<=0?[]:new Array(e).fill(1/e)}function C(e,t){return e>=t[0]&&e<t[1]}function K(e,t){for(let[n,r]of t.entries())if(C(e,r))return n;return-1}function G(e,t,n){t=t===void 0?1:t,t<0?t=0:t>1&&(t=1);let r=oe(e);n=n||r,n.length!==e&&(n=r);let o=n.reduce((a,u)=>u+a,0);(o<.99||o>1.01)&&(n=r);let i=0,s=t;return n.map(a=>{let u=i;return i+=a,[u,u+s*a]})}function N(e,t,n){if(!t)return null;let r=t.split("?")[1];if(!r)return null;let i=r.replace(/#.*/,"").split("&").map(s=>s.split("=",2)).filter(([s])=>s===e).map(([,s])=>s===void 0?NaN:parseInt(s))[0];return i!==void 0&&i>=0&&i<n?i:null}function M(e){try{return e()}catch{return!1}}function T(e){return typeof e=="string"?e:JSON.stringify(e)}function g(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(n=>n.match(/^[0-9]+$/)?n.padStart(5," "):n).join("-")}function se(e){try{let t=e.replace(/([^\\])\//g,"$1\\/");return new RegExp(t)}catch{return}}function I(e,t){if(!t.length)return!1;let n=!1,r=!1;for(let o of t){let i=De(e,o.type,o.pattern);if(o.include===!1){if(i)return!1}else n=!0,i&&(r=!0)}return r||!n}function Ue(e,t,n){try{let r=t.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return n&&(r="\\/?"+r.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+r+"$","i").test(e)}catch{return!1}}function _e(e,t){try{let n=new URL(t.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),r=[[e.host,n.host,!1],[e.pathname,n.pathname,!0]];return n.hash&&r.push([e.hash,n.hash,!1]),n.searchParams.forEach((o,i)=>{r.push([e.searchParams.get(i)||"",o,!1])}),!r.some(o=>!Ue(o[0],o[1],o[2]))}catch{return!1}}function De(e,t,n){try{let r=new URL(e,"https://_");if(t==="regex"){let o=se(n);return o?o.test(r.href)||o.test(r.href.substring(r.origin.length)):!1}else if(t==="simple")return _e(r,n);return!1}catch{return!1}}function q(e){for(let n of["namespace","status","url","groups"])if(Object.hasOwn(e,n))throw new TypeError(`Retired experiment field: ${n}`);let t=e;if(t.hashVersion!==void 0&&t.hashVersion!==2)throw new TypeError("Only hash version 2 is supported");if(t.filters?.some(n=>n.hashVersion!==2))throw new TypeError("Only hash version 2 is supported")}function O(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 ie(e){for(let t of["overrides","groups"])if(Object.hasOwn(e,t))throw new TypeError(`Retired evaluation context field: ${t}`);O(e.savedGroups??{})}var je=e=>e/2**32|0,Pe=e=>e>>>0;function ae(e,t,n,r){let o=je(n),i=Pe(n);e.setUint32(t,r?i:o,r),e.setUint32(t+4,r?o:i,r)}function ue(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}var W=e=>e?`"${e}" `:"";function Ke(e,t=""){if(typeof e!="number")throw new TypeError(W(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(W(t)+"expected integer >= 0, got "+e);return e}function $(e,t,n=""){if(ue(e)&&(t===void 0||e.length===t))return e;t!==void 0&&Ke(t,"length");let r=ue(e),o=t!==void 0?` of length ${t}`:"",i=r?`length=${e.length}`:`type=${typeof e}`,s=W(n)+"expected Uint8Array"+o+", got "+i;throw r?new RangeError(s):new TypeError(s)}var Ge=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError((t==="object"?"":`"${t}" `)+"expected object, got type="+typeof e)},ce=(e,t)=>{Ge(e,t);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,"__proto__"))throw new TypeError(`"${t}.__proto__" is not allowed`)};function J(e,t=!0){if(e.destroyed)throw new Error("hash was destroyed");if(t&&e.finished)throw new Error("digest() was already called")}function fe(e,t){$(e,void 0,"output");let n=t.outputLen;if(!(e.length>=n))throw new RangeError('"output" expected length >= '+n)}function Q(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function H(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function x(e,t){return e<<32-t|e>>>t}var Ne=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Me=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function le(e){if($(e),Ne)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=Me[e[n]];return t}function Ie(e,t,n="opts"){return ce(e,"defaults"),t!==void 0&&ce(t,n),Object.assign(Object.create(null),e,t)}function de(e,t={}){if(typeof e!="function")throw new TypeError('"hashCons" expected function, got type='+typeof e);t=Ie({},t,"info");let n=(o,i)=>e(i).update(o).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=o=>e(o),Object.assign(n,t),Object.freeze(n)}var he=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function be(e,t,n){return e&t^~e&n}function ge(e,t,n){return e&t^e&n^t&n}var L=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,n,r,o){this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(t),this.view=H(this.buffer)}update(t){J(this),$(t);let{view:n,buffer:r,blockLen:o}=this,i=t.length,s=!1;for(let a=0;a<i;){let u=Math.min(o-this.pos,i-a);if(u===o){let f=H(t);for(;o<=i-a;a+=o)this.process(f,a);s=!0;continue}r.set(a===0&&u===i?t:t.subarray(a,a+u),this.pos),this.pos+=u,a+=u,this.pos===o&&(this.process(n,0),this.pos=0,s=!0)}return this.length+=t.length,s&&this.roundClean(),this}digestInto(t){J(this),fe(t,this),this.finished=!0;let{buffer:n,view:r,blockLen:o,isLE:i}=this,{pos:s}=this;n[s++]=128,n.fill(0,s),this.padOffset>o-s&&(this.process(r,0),n.fill(0)),ae(r,o-8,this.length*8,i),this.process(r,0),this.roundClean();let a=t===n?r:H(t),u=this.outputLen,f=u/4,d=this.get();if(u%4||f>d.length)throw new Error("invalid outputLen");for(let c=0;c<f;c++)a.setUint32(4*c,d[c],i)}digest(){let{buffer:t,outputLen:n}=this;this.digestInto(t);let r=t.slice(0,n);return this.destroy(),r}_cloneIntoMeta(t){let{buffer:n,length:r,finished:o,destroyed:i,pos:s}=this;return t.destroyed=i,t.finished=o,t.length=r,t.pos=s,s&&t.buffer.set(n),t}clone(){return this._cloneInto()}},pe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var qe=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]),S=new Uint32Array(64),X=class extends L{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(t,n){super(64,t,8,!1),this.A=n[0]|0,this.B=n[1]|0,this.C=n[2]|0,this.D=n[3]|0,this.E=n[4]|0,this.F=n[5]|0,this.G=n[6]|0,this.H=n[7]|0}get(){let{A:t,B:n,C:r,D:o,E:i,F:s,G:a,H:u}=this;return[t,n,r,o,i,s,a,u]}set(t,n,r,o,i,s,a,u){this.A=t|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=u|0}_cloneInto(t){return(t||=new this.constructor).set(...this.get()),this._cloneIntoMeta(t)}process(t,n){for(let c=0;c<16;c++,n+=4)S[c]=t.getUint32(n,!1);for(let c=16;c<64;c++){let h=S[c-15],p=S[c-2],k=x(h,7)^x(h,18)^h>>>3,m=x(p,17)^x(p,19)^p>>>10;S[c]=m+S[c-7]+k+S[c-16]|0}let{A:r,B:o,C:i,D:s,E:a,F:u,G:f,H:d}=this;for(let c=0;c<64;c++){let h=x(a,6)^x(a,11)^x(a,25),p=d+h+be(a,u,f)+qe[c]+S[c]|0,m=(x(r,2)^x(r,13)^x(r,22))+ge(r,o,i)|0;d=f,f=u,u=a,a=s+p|0,s=i,i=o,o=r,r=p+m|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,u=u+this.F|0,f=f+this.G|0,d=d+this.H|0,this.set(r,o,i,s,a,u,f,d)}roundClean(){Q(S)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Q(this.buffer)}},z=class extends X{constructor(){super(32,pe)}};var xe=de(()=>new z,he(1));var ye=new Map,Y=32,ke=new WeakMap,me=new WeakMap;function We(e){return le(xe(new TextEncoder().encode(String(e))))}var _=e=>Array.isArray(e)?e.map(_):typeof e=="string"||typeof e=="number"?We(e):null,U=e=>typeof e=="string"?e.toLowerCase():e;function ve(e){let t=ke.get(e);return t||(t=new Set(e),ke.set(e,t)),t}function Je(e){let t=me.get(e);return t||(t=new Set(e.map(U)),me.set(e,t)),t}function Qe(e){O(e);for(let t of Object.values(e)){let n=t?.type==="list"||t?.type==="hashed"?t.values:null;n&&n.length>=Y&&ve(n)}return e}function y(e,t,n,r){n=n||{},r||O(n),r=r||new Set;for(let[o,i]of Object.entries(t))switch(o){case"$or":if(!Ee(e,i,n,r))return!1;break;case"$nor":if(Ee(e,i,n,r))return!1;break;case"$and":if(!et(e,i,n,r))return!1;break;case"$not":if(y(e,i,n,r))return!1;break;case"$savedGroup":if(!Xe(e,i,n,r))return!1;break;default:if(!V(i,Be(e,o),n,!1,r))return!1}return!0}function Xe(e,t,n,r){if(!t||typeof t!="object"||Array.isArray(t))return!1;let{id:o,attributeKey:i}=t;if(typeof o!="string"||r.has(o)||i!==void 0&&typeof i!="string")return!1;let s=n[o];if(!s||Array.isArray(s)||typeof s!="object")return!1;let a=new Set(r).add(o);if(s.type==="list"||s.type==="hashed"){let u=i??s.attributeKey;if(typeof u!="string"||!Array.isArray(s.values))return!1;let f=Be(e,u);return v(s.type==="hashed"?_(f):f,s.values)}return s.type==="condition"?!s.condition||typeof s.condition!="object"?!1:y(e,s.condition,n,a):!1}function Be(e,t){let n=t.split("."),r=e;for(let o of n)if(r&&typeof r=="object"&&o in r)r=r[o];else return null;return r}function we(e,t=!1){let n=`${e}${t?"/i":""}`,r=ye.get(n);return r||(r=new RegExp(e.replace(/([^\\])\//g,"$1\\/"),t?"i":void 0),ye.set(n,r)),r}function V(e,t,n,r=!1,o=new Set){if(typeof e=="string")return r?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)||!Te(e))return JSON.stringify(t)===JSON.stringify(e);let i=e;for(let s in i)if(!Ze(s,t,i[s],n,o))return!1;return!0}function Te(e){let t=Object.keys(e);return t.length>0&&t.filter(n=>n[0]==="$").length===t.length}function ze(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 Ye(e,t,n,r){if(!Array.isArray(e))return!1;let o=Te(t)?i=>V(t,i,n,!1,r):i=>y(i,t,n,r);for(let i=0;i<e.length;i++)if((e[i]??null)!==null&&o(e[i]))return!0;return!1}function v(e,t,n=!1){if(n){let o;if(t.length>=Y){let i=Je(t);o=s=>{let a=U(s);return!(typeof a=="number"&&Number.isNaN(a))&&i.has(a)}}else o=i=>t.some(s=>U(i)===U(s));return Array.isArray(e)?e.some(i=>o(i)):o(e)}let r=t.length>=Y?(o=>i=>o.has(i))(ve(t)):o=>t.includes(o);return Array.isArray(e)?e.some(o=>r(o)):r(e)}function Se(e){return e===void 0?[]:e&&typeof e=="object"&&(e.type==="list"||e.type==="hashed")&&Array.isArray(e.values)?e.values:null}function Ae(e,t,n,r=!1,o=new Set){if(!Array.isArray(e))return!1;for(let i=0;i<t.length;i++){let s=!1;for(let a=0;a<e.length;a++)if(V(t[i],e[a],n,r,o)){s=!0;break}if(!s)return!1}return!0}function Ze(e,t,n,r,o=new Set){let i=t,s=n;switch(e){case"$veq":return g(t)===g(n);case"$vne":return g(t)!==g(n);case"$vgt":return g(t)>g(n);case"$vgte":return g(t)>=g(n);case"$vlt":return g(t)<g(n);case"$vlte":return g(t)<=g(n);case"$eq":return t===n;case"$ne":return t!==n;case"$lt":return i<s;case"$lte":return i<=s;case"$gt":return i>s;case"$gte":return i>=s;case"$exists":return n?t!=null:t==null;case"$in":return Array.isArray(n)?v(t,n):!1;case"$ini":return Array.isArray(n)?v(t,n,!0):!1;case"$inGroup":{let a=r[n],u=Se(a);return u===null?!1:v(a?.type==="hashed"?_(t):t,u)}case"$notInGroup":{let a=r[n],u=Se(a);return u===null?!1:!v(a?.type==="hashed"?_(t):t,u)}case"$nin":return Array.isArray(n)?!v(t,n):!1;case"$nini":return Array.isArray(n)?!v(t,n,!0):!1;case"$not":return!V(n,t,r,!1,o);case"$size":return Array.isArray(t)?V(n,t.length,r,!1,o):!1;case"$elemMatch":return Ye(t,n,r,o);case"$all":return Array.isArray(n)?Ae(t,n,r,!1,o):!1;case"$alli":return Array.isArray(n)?Ae(t,n,r,!0,o):!1;case"$regex":try{return we(n).test(t)}catch{return!1}case"$regexi":try{return we(n,!0).test(t)}catch{return!1}case"$type":return ze(t)===n;default:return!1}}function Ee(e,t,n,r){if(!t.length)return!0;for(let o of t)if(y(e,o,n,r))return!0;return!1}function et(e,t,n,r){for(let o of t)if(!y(e,o,n,r))return!1;return!0}function Z(e){return ie(e),{context:e,stack:{evaluatedFeatures:new Set}}}function ee(e){return{...e.attributes,...e.attributeOverrides}}function A(e,t,n){let r=t||"id",o="",i=ee(e);return i[r]&&(o=i[r]),!o&&n&&(i[n]&&(o=i[n]),o&&(r=n)),{hashAttribute:r,hashValue:o}}function l(e,t,n){e.context.log?.(t,n)}function D(e,t){return t=t||0,`${e}__${t}`}function te(e,t){return`${e}||${t}`}function tt(e,t,n){let r=e.stickyBucketAssignmentDocs;if(!r)return{};let{hashAttribute:o,hashValue:i}=A(e,t),s=te(o,T(i)),{hashAttribute:a,hashValue:u}=A(e,n),f=u?te(a,T(u)):null,d={};return f&&r[f]&&Object.assign(d,r[f].assignments||{}),r[s]&&Object.assign(d,r[s].assignments||{}),d}function Fe({context:e,expKey:t,expBucketVersion:n,expHashAttribute:r,expFallbackAttribute:o,expMinBucketVersion:i,expMeta:s}){n=n||0,i=i||0,r=r||"id",s=s||[];let a=D(t,n),u=tt(e,r,o);if(i>0)for(let c=0;c<i;c++){let h=D(t,c);if(u[h]!==void 0)return{variation:-1,versionIsBlocked:!0}}let f=u[a];if(f===void 0)return{variation:-1};let d=s.findIndex(c=>c.key===f);return d<0?{variation:-1}:{variation:d}}function Re(e,t,n,r){let o=te(t,n),i=e.stickyBucketAssignmentDocs,s=i&&i[o]?i[o].assignments||{}:{},a={...s,...r},u=JSON.stringify(s)!==JSON.stringify(a);return{key:o,doc:{attributeName:t,attributeValue:n,assignments:a},changed:u}}function Ce(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function nt(e,t){let n=Z(t),r=Oe(e,null,n);return t.onExperimentEval?.(e,r),r}function rt(e,t){return re(e,Z(t))}function ot(e){return e.forcedVariations||{}}function Ve(e,t,n){let{context:r}=e;if(r.trackedExperiments){let o=Le(t,n);if(r.trackedExperiments.has(o))return;r.trackedExperiments.add(o)}ne(()=>r.onExperimentViewed?.(t,n))}function st(e,t,n){let{context:r}=e;if(r.trackedFeatureUsage){let o=JSON.stringify(n.value);if(r.trackedFeatureUsage[t]===o)return;r.trackedFeatureUsage[t]=o}ne(()=>r.onFeatureUsage?.(t,n))}function ne(e){try{let t=e();t&&typeof t.catch=="function"&&t.catch(()=>{})}catch{}}function re(e,t){let{context:n}=t;if(t.stack.evaluatedFeatures.has(e))return l(t,`evalFeature: circular dependency detected: ${t.stack.id} -> ${e}`,{from:t.stack.id,to:e}),E(t,e,null,"cyclicPrerequisite");t.stack.evaluatedFeatures.add(e),t.stack.id=e;let r=n.features?.[e];for(let i of r?.rules??[])q(i);let o=n.forcedFeatureValues;if(o&&o.has(e))return l(t,"Global override",{id:e,value:o.get(e)}),E(t,e,o.get(e),"override");if(!r)return l(t,"Unknown feature",{id:e}),E(t,e,null,"unknownFeature");if(r.rules){let i=new Set(t.stack.evaluatedFeatures);e:for(let s of r.rules){if(s.parentConditions)for(let f of s.parentConditions){t.stack.evaluatedFeatures=new Set(i);let d=re(f.id,t);if(d.source==="cyclicPrerequisite")return E(t,e,null,"cyclicPrerequisite");let c={value:d.value};if(!y(c,f.condition||{},n.savedGroups||{})){if(f.gate)return l(t,"Feature blocked by prerequisite",{id:e,rule:s}),E(t,e,null,"prerequisite");l(t,"Skip rule because prerequisite evaluation fails",{id:e,rule:s});continue e}}if(s.filters&&He(s.filters,t)){l(t,"Skip rule because of filters",{id:e,rule:s});continue}if("force"in s){if(s.condition&&!$e(s.condition,t)){l(t,"Skip rule because of condition ff",{id:e,rule:s});continue}if(!it(t,s.seed||e,s.hashAttribute,n.saveStickyBucketAssignmentDoc&&!s.disableStickyBucketing?s.fallbackAttribute:void 0,s.range,s.coverage,s.hashVersion)){l(t,"Skip rule because user not included in rollout",{id:e,rule:s});continue}return l(t,"Force value from rule",{id:e,rule:s}),s.tracks&&s.tracks.forEach(f=>{Ve(t,f.experiment,f.result)}),E(t,e,s.force,"force",s.id)}if(!s.variations){l(t,"Skip invalid rule",{id:e,rule:s});continue}let a={variations:s.variations,key:s.key||e};"coverage"in s&&(a.coverage=s.coverage),s.weights&&(a.weights=s.weights),s.hashAttribute&&(a.hashAttribute=s.hashAttribute),s.fallbackAttribute&&(a.fallbackAttribute=s.fallbackAttribute),s.disableStickyBucketing&&(a.disableStickyBucketing=s.disableStickyBucketing),s.bucketVersion!==void 0&&(a.bucketVersion=s.bucketVersion),s.minBucketVersion!==void 0&&(a.minBucketVersion=s.minBucketVersion),s.meta&&(a.meta=s.meta),s.ranges&&(a.ranges=s.ranges),s.name&&(a.name=s.name),s.phase&&(a.phase=s.phase),s.seed&&(a.seed=s.seed),s.hashVersion&&(a.hashVersion=s.hashVersion),s.filters&&(a.filters=s.filters),s.condition&&(a.condition=s.condition);let u=Oe(a,e,t);if(n.onExperimentEval?.(a,u),u.inExperiment&&!u.passthrough)return E(t,e,u.value,"experiment",s.id,a,u)}}return l(t,"Use default value",{id:e,value:r.defaultValue}),E(t,e,r.defaultValue===void 0?null:r.defaultValue,"defaultValue")}function Oe(e,t,n){let{context:r}=n;q(e);let o=e.key,i=e.variations.length;if(i<2)return l(n,"Invalid experiment",{id:o}),b(n,e,-1,!1,t);if(r.enabled===!1)return l(n,"Context disabled",{id:o}),b(n,e,-1,!1,t);if(e.urlPatterns&&!I(r.url||"",e.urlPatterns))return l(n,"Skip because of url targeting",{id:o}),b(n,e,-1,!1,t);let s=N(o,r.url||"",i);if(s!==null)return l(n,"Force via querystring",{id:o,variation:s}),b(n,e,s,!1,t);let u=ot(r)[o];if(u!==void 0)return l(n,"Force via dev tools",{id:o,variation:u}),b(n,e,u,!1,t);if(e.active===!1)return l(n,"Skip because inactive",{id:o}),b(n,e,-1,!1,t);let{hashAttribute:f,hashValue:d}=A(r,e.hashAttribute,r.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0);if(!d)return l(n,"Skip because missing hashAttribute",{id:o}),b(n,e,-1,!1,t);let c=-1,h=!1,p=!1;if(r.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing){let{variation:w,versionIsBlocked:B}=Fe(Ce({context:r,expKey:e.key,expBucketVersion:e.bucketVersion,expHashAttribute:e.hashAttribute,expFallbackAttribute:e.fallbackAttribute,expMinBucketVersion:e.minBucketVersion,expMeta:e.meta}));h=w>=0,c=w,p=!!B}if(!h){if(e.filters&&He(e.filters,n))return l(n,"Skip because of filters",{id:o}),b(n,e,-1,!1,t);if(e.include&&!M(e.include))return l(n,"Skip because of include function",{id:o}),b(n,e,-1,!1,t);if(e.condition&&!$e(e.condition,n))return l(n,"Skip because of condition exp",{id:o}),b(n,e,-1,!1,t);if(e.parentConditions){let w=new Set(n.stack.evaluatedFeatures);for(let B of e.parentConditions){n.stack.evaluatedFeatures=new Set(w);let F=re(B.id,n);if(F.source==="cyclicPrerequisite")return b(n,e,-1,!1,t);let j={value:F.value};if(!y(j,B.condition||{},r.savedGroups||{}))return l(n,"Skip because prerequisite evaluation fails",{id:o}),b(n,e,-1,!1,t)}}}let k=R(e.seed||o,d,e.hashVersion??2);if(k===null)return l(n,"Skip because of invalid hash version",{id:o}),b(n,e,-1,!1,t);if(!h){let w=e.ranges||G(i,e.coverage===void 0?1:e.coverage,e.weights);c=K(k,w)}if(p)return l(n,"Skip because sticky bucket version is blocked",{id:o}),b(n,e,-1,!1,t,void 0,!0);if(c<0)return l(n,"Skip because of coverage",{id:o}),b(n,e,-1,!1,t);if("force"in e)return l(n,"Force variation",{id:o,variation:e.force}),b(n,e,e.force===void 0?-1:e.force,!1,t);if(r.qaMode)return l(n,"Skip because QA mode",{id:o}),b(n,e,-1,!1,t);let m=b(n,e,c,!0,t,k,h);if(r.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing){let{changed:w,key:B,doc:F}=Re(r,f,T(d),{[D(e.key,e.bucketVersion)]:m.key});if(w){r.stickyBucketAssignmentDocs=r.stickyBucketAssignmentDocs||{},r.stickyBucketAssignmentDocs[B]=F;let j=r.saveStickyBucketAssignmentDoc;ne(()=>j(F))}}return Ve(n,e,m),l(n,"In experiment",{id:o,variation:m.variationId}),m}function E(e,t,n,r,o,i,s){let a={value:n,on:!!n,off:!n,source:r,ruleId:o||""};return i&&(a.experiment=i),s&&(a.experimentResult=s),r!=="override"&&st(e,t,a),a}function $e(e,t){return y(ee(t.context),e,t.context.savedGroups||{})}function He(e,t){return e.some(n=>{let{hashValue:r}=A(t.context,n.attribute);if(!r)return!0;let o=R(n.seed,r,n.hashVersion||2);return o===null?!0:!n.ranges.some(i=>C(o,i))})}function it(e,t,n,r,o,i,s){if(!o&&i===void 0)return!0;if(!o&&i===0)return!1;let{hashValue:a}=A(e.context,n,r);if(!a)return!1;let u=R(t,a,s??2);return u===null?!1:o?C(u,o):i!==void 0?u<=i:!0}function b(e,t,n,r,o,i,s){let a=!0;(n<0||n>=t.variations.length)&&(n=0,a=!1);let{hashAttribute:u,hashValue:f}=A(e.context,t.hashAttribute,e.context.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing?t.fallbackAttribute:void 0),d=t.meta?.[n]??{},c=t.variations[0];for(let[p,k]of t.variations.entries())if(p===n){c=k;break}let h={key:d.key||""+n,featureId:o,inExperiment:a,hashUsed:r,variationId:n,value:c,hashAttribute:u,hashValue:f,stickyBucketUsed:!!s};return d.name&&(h.name=d.name),i!==void 0&&(h.bucket=i),d.passthrough&&(h.passthrough=d.passthrough),h}function Le(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
|
+
*/export{T as a,I as b,le as c,xe as d,Qe as e,y as f,nt as g,rt as h,Le as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ia as E,ja as M,ka as j,la as O,ma as T}from"./chunk-2HFA34QO.js";import{k as w,qa as u}from"./chunk-ACF2FBUB.js";import{z as t}from"zod";var _=E,V=t.string().regex(/^(0|[1-9]\d{0,5})(\.\d{1,12})?$/),C=t.strictObject(Object.fromEntries(_.map(i=>[i,t.number().int().nonnegative().max(1e9)]))),L=M,D=j,q=t.strictObject({modelId:L,source:t.enum(["models.dev","custom"]),fetchedAt:t.iso.datetime(),rates:O,contextTier:t.number().int().nonnegative(),markupPercent:D}),U=t.strictObject({pricing:q,tokens:C,quantity:w,digest:t.string().regex(/^[a-f0-9]{64}$/)}),z=i=>{let[s,o=""]=i.split(".");return BigInt(s)*10n**12n+BigInt(o.padEnd(12,"0"))};function $(i){if(typeof i!="number"||!Number.isFinite(i)||i<0)throw new u("AI_PRICE_UNAVAILABLE","A published token price is missing");let s=String(i),o=s.includes("e")?i.toFixed(12).replace(/0+$/,"").replace(/\.$/,""):s;if(Number(o)!==i||!V.safeParse(o).success)throw new u("AI_PRICE_UNAVAILABLE","Published price exceeds the supported precision");return o}var R=t.strictObject({input:t.number().nonnegative(),output:t.number().nonnegative(),cache_read:t.number().nonnegative().optional(),cache_write:t.number().nonnegative().optional(),reasoning:t.number().nonnegative().optional(),input_audio:t.number().nonnegative().optional(),output_audio:t.number().nonnegative().optional()}),F=R.extend({context_over_200k:t.unknown().optional(),tiers:t.array(R.extend({tier:t.strictObject({type:t.literal("context"),size:t.number().int().nonnegative()})})).max(20).refine(i=>new Set(i.map(s=>s.tier.size)).size===i.length).optional()});async function N(i,s,o){let d=new TextEncoder().encode(JSON.stringify({pricing:i,tokens:s,quantity:o}));return[...new Uint8Array(await crypto.subtle.digest("SHA-256",d))].map(m=>m.toString(16).padStart(2,"0")).join("")}function B(i,s){let o=0n;for(let c of _){if(!s[c])continue;let f=i.rates[c];if(f===void 0)throw new u("AI_PRICE_UNAVAILABLE",`No published price for ${c}; report exclusive token pools`);o+=z(f)*BigInt(s[c])}let[d,m="0"]=String(i.markupPercent).split("e"),r=(d.split(".")[1]?.length??0)-Number(m),e=10n**BigInt(Math.max(r,0)),n=BigInt(d.replace(".",""))*10n**BigInt(Math.max(-r,0)),g=100n*e+n,l=100n*e*1000000n,a=(o*g+l-1n)/l;return w.parse(`${a/1000000n}.${(a%1000000n).toString().padStart(6,"0")}`)}function K(i={}){if(typeof window<"u")throw new u("SERVER_ONLY","AI token pricing belongs on your backend");let s=T.parse({defaultMarkup:i.defaultMarkup??0,providerMarkups:i.providerMarkups??{},modelMarkups:i.modelMarkups??{},customModels:i.customModels??{}}),o=null,d=0;async function m(){if(!o||Date.now()>=d){d=Date.now()+15*6e4;let r=(async()=>{let e=await(i.fetch??fetch)("https://models.dev/api.json",{signal:AbortSignal.timeout(3e4)});if(!e.ok)throw new u("AI_PRICE_UNAVAILABLE","Models.dev pricing is unavailable");return{data:t.record(t.string(),t.object({models:t.record(t.string(),t.unknown())})).parse(await e.json()),fetchedAt:new Date().toISOString()}})().catch(e=>{throw o===r&&(o=null),e});o=r}return o}return{refreshPrices(){o=null,d=0},async quoteTokens(r){let e=L.parse(r.modelId),n=C.parse(r.tokens),[g,...l]=e.split("/"),a=s.customModels[e],c,f,p,y=0;if(a?.input!==void 0&&a.output!==void 0&&_.every(A=>n[A]===0||a[A]!==void 0))c={...a,input:a.input,output:a.output},f="custom",p=new Date().toISOString();else{let A=await m(),x=A.data[g]?.models[l.join("/")];if(!x)throw new u("AI_PRICE_UNAVAILABLE","Unknown model; configure a complete custom price");let{cost:I}=t.object({cost:F}).parse(x),P=n.input+n.cache_read+n.cache_write+n.input_audio;if(I.tiers===void 0&&I.context_over_200k!==void 0&&P>2e5)throw new u("AI_PRICE_UNAVAILABLE","A current context tier is required for this model");let b=I.tiers?.filter(k=>P>k.tier.size).sort((k,Q)=>Q.tier.size-k.tier.size)[0],v=b??I;b&&(y=b.tier.size),c=Object.fromEntries(_.filter(k=>v[k]!==void 0).map(k=>[k,$(v[k])])),c={...c,...a},f=a?"custom":"models.dev",p=A.fetchedAt}let h=q.parse({modelId:e,source:f,fetchedAt:p,rates:c,contextTier:y,markupPercent:s.modelMarkups[e]??s.providerMarkups[g]??s.defaultMarkup}),S=B(h,n);return U.parse({pricing:h,tokens:n,quantity:S,digest:await N(h,n,S)})},async trackTokens(r,e){let n=U.parse(e.quote);if(n.quantity!==B(n.pricing,n.tokens)||n.digest!==await N(n.pricing,n.tokens,n.quantity))throw new u("INVALID_REQUEST","AI quote changed after pricing");let g=e.properties??{},l=e.providerCostUsd===void 0?void 0:t.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,18})?$/).parse(e.providerCostUsd),a=e.generationId===void 0?void 0:t.string().min(1).max(120).parse(e.generationId),c=8+ +(l!==void 0)+ +(a!==void 0);if(Object.keys(g).some(p=>p.startsWith("ai_")))throw new u("INVALID_REQUEST","AI tracking reserves ai_ event properties");if(Object.keys(g).length>16-c)throw new u("INVALID_REQUEST","AI tracking properties exceed the available event budget");let f={operation:"consume",internal_feature_id:e.internal_feature_id,quantity:n.quantity,idempotencyKey:e.idempotencyKey,properties:{...g,...l!==void 0?{ai_provider_cost_usd:l}:{},...a!==void 0?{ai_generation_id:a}:{},ai_model:n.pricing.modelId,ai_source:n.pricing.source,ai_price_at:n.pricing.fetchedAt,ai_quote_hash:n.digest,ai_markup:String(n.pricing.markupPercent),ai_tier:String(n.pricing.contextTier),ai_tokens:_.map(p=>n.tokens[p]).join(","),ai_rates:"v1:"+_.map(p=>n.pricing.rates[p]===void 0?"-":z(n.pricing.rates[p]).toString(36)).join(",")},...e.entityId?{entityId:e.entityId}:{}};return r.mutateBalance({customerId:e.customerId,command:f})}}}async function Y(i,s,o={}){let{config:d,model_markups:m}=await i.readAiPricing(s);return K({defaultMarkup:d.default_markup??0,providerMarkups:Object.fromEntries(Object.entries(d.provider_markups??{}).map(([r,e])=>[r,e.markup])),modelMarkups:Object.fromEntries(Object.entries(m??{}).filter(([,r])=>r.markup!==void 0).map(([r,e])=>[r,e.markup])),customModels:Object.fromEntries(Object.entries(m??{}).filter(([,r])=>r.input_cost!==void 0||r.output_cost!==void 0).map(([r,e])=>[r,{...e.input_cost!==void 0?{input:String(e.input_cost)}:{},...e.output_cost!==void 0?{output:String(e.output_cost)}:{}}])),...o})}export{q as a,U as b,K as c,Y as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as ue,b as me,c as ye,d as ge,e as ve}from"./chunk-SBPTOOYB.js";import{M as fe,Y as le}from"./chunk-2HFA34QO.js";import{ea as pe,oa as we,qa as m}from"./chunk-ACF2FBUB.js";import{b as he,e as be}from"./chunk-EARSGITJ.js";import{d as Ie}from"./chunk-HOW7NIIR.js";import{a as z}from"./chunk-DSPLGTQI.js";import{b as de}from"./chunk-XSVQHPQT.js";function Ce(e){let b=e.view;if(!b?.paywall)throw new m("INVALID_REQUEST","The current node is not a Paywall");let n=b.paywall.receiptId,P=b.nodeId,y=b.visit,p=b.paywall.resolution,u=p,f="document"in p?p:null;function s(i){if(!me(i,p))throw new m("INVALID_RESPONSE","The pinned Paywall binding changed")}let o=b.paywall.quote,D=b.paywall.operation,C=!1,$=new AbortController,d=b.paywall.purchaseRequestId,r=0,c=b.paywall.selectionGeneration??0,T=b.paywall.canReselect===!0,A=null,O=new Map,g=new Map,V=new Map;function L(i){if(i.purchase&&i.purchase.receiptId!==n)throw new m("INVALID_RESPONSE","Purchase receipt changed");let a=i.run.paywall;return i.purchase??(a?.receiptId===n?a:null)}function S(){if(C)throw new m("IDENTITY_CHANGED","Paywall presentation has closed")}function _(i,a,l){if(S(),a!==r||l!==void 0&&o?.operationId!==l)return!1;let I=c,w=i.run.paywall;if(w?.receiptId===n){if((w.selectionGeneration??0)<c)return!1;c=w.selectionGeneration??0,T=w.canReselect===!0,s(w.resolution)}let v=L(i),h=c>I,k=h?v?.quote??null:v?.quote??o,E=v?.operation??(k?.operationId===o?.operationId?D:null);return k&&E&&ye(E,{operationId:k.operationId},"Purchase operation changed"),w?.receiptId===n&&(u=w.resolution,f="document"in u?u:f?{...u,document:f.document,offering:f.offering,capabilities:ue(u.capabilities,f.capabilities)}:null),(h||k?.operationId!==o?.operationId)&&(r++,w?.receiptId===n&&(d=w.purchaseRequestId)),o=k,D=ve(D,E,!0),!0}function x(i,a,l){return new Promise((I,w)=>{let v=!1,h=()=>{clearTimeout(B),$.signal.removeEventListener("abort",H)},k=F=>{v||(v=!0,h(),I(F))},E=F=>{v||(v=!0,h(),w(F))},H=()=>E(new m("IDENTITY_CHANGED","Paywall presentation has closed")),B=setTimeout(()=>E(new m("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,l)),Math.max(0,a-Date.now()));$.signal.addEventListener("abort",H,{once:!0}),$.signal.aborted&&H(),i.then(k,E)})}function J(i){return new Promise(a=>{let l=()=>{clearTimeout(I),$.signal.removeEventListener("abort",l),a()},I=setTimeout(l,i);$.signal.addEventListener("abort",l,{once:!0}),$.signal.aborted&&l()})}async function j(i,a,l){S();let I=O.get(i);if(!I){let h=e.pendingCommands?.find(k=>k.requestId===i)??e.pendingCommand;if(h?.operation==="submit"&&h.requestId===i&&h.nodeId===P&&h.visit===y){a.type==="paywall_quote"&&h.input.type==="paywall_quote"&&h.input.predecessor&&!a.predecessor&&(a={...a,predecessor:h.input.predecessor});let k=le.parse(h),E=le.parse({...h,input:a});if(E.operation!=="submit"||k.operation!=="submit"||JSON.stringify(E.input)!==JSON.stringify(k.input))throw new m("CONFLICT","A restored purchase request cannot change its input");a=E.input,I=k,O.set(i,I)}}if(I){if(JSON.stringify(I.input)!==JSON.stringify(a))throw new m("CONFLICT","A purchase request cannot change its input")}else{let h=e.view;if(!h||h.nodeId!==P||h.visit!==y||h.paywall?.receiptId!==n)throw new m("PRECONDITION_FAILED","The Paywall visit has changed");I={operation:"submit",requestId:i,nodeId:P,visit:y,revision:h.revision,input:a},O.set(i,I)}let w=Date.now()+3e4,v=await x(e.submit(I),w,i);for(;v.run.pendingRequest?.requestId===i&&Date.now()<w&&!C&&(await J(Math.min(1e3,w-Date.now())),!(C||Date.now()>=w));)v=await x(e.resume(i),w,i);if(C)throw new m("IDENTITY_CHANGED","Paywall presentation has closed");if(v.run.pendingRequest?.requestId===i)throw new m("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,i);if(!_(v,l,a.type==="paywall_confirm"||a.type==="paywall_cancel"?a.operationId:void 0))throw new m("PRECONDITION_FAILED","The purchase selection has changed")}async function q(i){if(!o)throw new m("INVALID_REQUEST","A quoted purchase is required");let a=`${i}:${o.operationId}`,l=g.get(a);if(!l){let I=i==="confirm"?"paywall_confirm":"paywall_cancel",w=e.pendingCommands?.find(v=>v.operation==="submit"&&v.input.type===I&&"operationId"in v.input&&v.input.operationId===o.operationId)??e.pendingCommand;l=w?.operation==="submit"&&w.input.type===I&&"operationId"in w.input&&w.input.operationId===o.operationId?w.requestId:crypto.randomUUID(),g.set(a,l)}if(await j(l,{type:i==="confirm"?"paywall_confirm":"paywall_cancel",operationId:o.operationId},r),!D)throw new m("INVALID_RESPONSE","The accepted purchase result is missing");return structuredClone(D)}return{get view(){return structuredClone(f)},get quote(){return o?structuredClone(o):null},get operation(){return D?structuredClone(D):null},get webViewUrl(){return e.webViewUrl},get canReselect(){return T},async refresh(){S();let i=r,a=await e.get();if(_(a,i),a.run.paywall?.receiptId!==n)throw new m("PRECONDITION_FAILED","Paywall presentation has changed");if(!f){if("document"in u||!e.resolvePaywall)throw new m("INVALID_RESPONSE","Public Paywall reader is unavailable");let l=await e.resolvePaywall(u);S(),s(l),f={...u,document:l.document,offering:l.offering,capabilities:ue(u.capabilities,l.capabilities)}}return structuredClone(f)},preview(i){if(!f)return Promise.reject(new m("PRECONDITION_FAILED","Load the Paywall presentation first"));if(d&&d!==i.requestId&&(A||!T))return Promise.reject(new m("COMMAND_PENDING","Retry the original purchase before starting another"));let a=f.document.buttons[i.actionId],l=a?.type==="checkout"?fe(a.product,i.selection,f.capabilities):null;if(!l)return Promise.reject(new m("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));let I=we(f.document.screen,l,i.selection,f.capabilities),w=JSON.stringify({actionId:i.actionId,product:l,featureQuantities:I,offerId:i.offerId,nativeOffer:i.nativeOffer});if(V.has(i.requestId)&&V.get(i.requestId)!==w)return Promise.reject(new m("CONFLICT","A purchase request cannot change its quantities or Product"));if(V.set(i.requestId,w),d===i.requestId&&A)return A;let v=d!==i.requestId&&c>0?{operationId:o?.operationId??null,generation:c}:void 0;if(v&&(!T||c<=0))return Promise.reject(new m("COMMAND_PENDING","Original purchase requires authoritative termination"));d!==i.requestId&&r++;let h=r;d=i.requestId;let k=(async()=>{if(await j(i.requestId,{type:"paywall_quote",actionId:i.actionId,productVersionId:l,...Object.keys(I).length?{featureQuantities:I}:{},...v?{predecessor:v}:{},...i.offerId?{offerId:i.offerId}:{},...i.nativeOffer?{nativeOffer:i.nativeOffer}:{}},h),!o)throw new m("INVALID_RESPONSE","The accepted quote is missing");return ge(o,{productVersionId:l,featureQuantities:I},"The selected purchase changed"),structuredClone(o)})();return A=k,k.then(()=>{A===k&&(A=null)},E=>{A===k&&(A=null),d===i.requestId&&e.pendingCommand?.requestId!==i.requestId&&E instanceof m&&E.status!==void 0&&E.status<500&&![401,425].includes(E.status)&&(d=null)}),k},confirm:()=>q("confirm"),cancel:()=>q("cancel"),async read(){if(S(),!o)throw new m("INVALID_REQUEST","A quoted purchase is required");let i=o.operationId,a=r,l=e.pendingCommands?.find(h=>h.operation==="submit"&&(h.input.type==="paywall_confirm"||h.input.type==="paywall_cancel")&&h.input.operationId===i)??e.pendingCommand;l?.operation==="submit"&&(l.input.type==="paywall_confirm"||l.input.type==="paywall_cancel")&&l.input.operationId===i&&await e.settle?.(l.requestId);let I=await e.get(void 0,{receiptId:n,operationId:i});S();let w=L(I);if(w?.quote&&w.quote.operationId!==i||w?.operation&&w.operation.operationId!==i)throw new m("INVALID_RESPONSE","Purchase operation changed");let v=_(I,a,i)?D:w?.operation;if(!v)throw new m("INVALID_RESPONSE","The current purchase result is missing");return structuredClone(v)},destroy(){C=!0,$.abort(),O.clear(),g.clear(),V.clear()}}}function Ee(e){let b=new Set,n=new Set,P=null;function y(p){if(e.reviewing||b.has(p)||n.has(p)||e.stopped)return;n.add(p);let u=async()=>{if(e.reviewing||e.stopped||e.key!==p){n.delete(p);return}if(e.busy||e.client.pendingCommand){setTimeout(()=>{u()},250);return}let f=(async()=>{let o=e.client.view,D=e.expected(),C=D.requestId,$=!1;try{await e.client.submit({operation:"shown",...D})}catch(d){if(!(d instanceof m)||d.code!=="CONFLICT"||d.status!==409||e.client.pendingCommand)throw d;await e.client.get();let r=e.client.view;if(e.stopped||e.reviewing||e.key!==p||!r||!o||r.id!==o.id||r.source.versionId!==o.source.versionId||r.nodeId!==D.nodeId||r.visit!==D.visit||r.revision<=D.revision||r.stopped||!r.screen||!["running","waiting"].includes(r.status)||e.client.pendingCommand)throw d;let c=e.expected();C=c.requestId,await e.client.submit({operation:"shown",...c})}for(;!e.stopped&&e.key===p&&e.client.pendingCommand?.requestId===C;){if(!e.client.settle)throw new m("COMMAND_PENDING","The original display acknowledgement is still pending");await e.client.settle(C),$=!0,e.client.pendingCommand?.requestId===C&&await new Promise(d=>setTimeout(d,1500))}e.stopped||e.key!==p||($&&await e.client.get(),!(e.stopped||e.key!==p)&&b.add(p))})();P=f;let s=()=>{P===f&&(P=null),n.delete(p)};f.then(s,o=>{s(),e.busy||e.fail(o)})};u()}return{report:y,get inFlight(){return P}}}function Pe(e){let b={},n=new Map;async function P(y){let p=e.client.view,u=p?.screen,f=u?.customerData.nodes[y.nodeId];if(e.stopped||e.busy||!p||!u||!f)return;if(!["refresh","next","previous","filter","sources_next","sources_previous"].includes(y.action)){let r=e.document,c=r?pe(r,y.nodeId):null,T=c?.type==="customer_data"?c.data.outputs?.[y.action]:void 0;T&&u.outputs.includes(T)?await e.perform(()=>e.client.submit({operation:"submit",...e.expected(),input:{type:"screen",output:T,answers:e.answers,selection:y.value?{[y.nodeId]:y.value}:{}}})):await e.onIntent?.(y,p);return}let o=y.action.startsWith("sources_")?f.resources.find(r=>r.key===y.value):null;if(y.action.startsWith("sources_")&&!o)throw new m("INVALID_REQUEST","Choose a current resource");let D=`${p.visit}:${y.nodeId}:${o?.key??""}`,C=n.get(D)??[null],d=b[y.nodeId]??{page:1,after:null,filter:"all",...o?{resourceKey:o.key}:{}};if(y.action==="filter"){let r=y.value;if(!r||!(f.source==="offer_history"?["all","issued","reserved","redeemed","expired","revoked"]:["all","purchase","refund","source","usage","debt","settlement"]).includes(r))throw new m("INVALID_REQUEST","Unknown data filter");d={page:1,after:null,filter:r},C.splice(0,C.length,null)}else if(y.action==="next"||y.action==="sources_next"){let r=o?.sources.at(-1),c=o?r?{kind:"ledger",cursor:{at:r.detail[0],id:r.id,type:"source"}}:null:u.dataCursors[y.nodeId];if(!c||!o&&!f.hasNext)return;C[d.page]=c,d={...d,page:d.page+1,after:c}}else if(y.action==="previous"||y.action==="sources_previous"){if(d.page<=1)return;d={...d,page:d.page-1,after:C[d.page-2]??null}}n.set(D,C),b={...b,[y.nodeId]:d},await e.perform(()=>e.client.get({nodeId:p.nodeId,visit:p.visit,revision:p.revision,components:b}))}return{get queries(){return b},intent:P,reset(){b={},n.clear()}}}function Re(e){let{doc:b,holder:n,reviewHolder:P,mountScreenPreview:y}=e,p=!1,u,f=0,s=null,o="",D=new Map,C=r=>r?`${r.id}:${r.nodeId}:${r.visit}:${r.revision}:${r.paywall?.quote?.operationId??""}`:"";async function $(r){if(e.stopped||!e.client.review)return;p||(o=C(e.client.view),D.set(o,structuredClone(e.answers))),p=!0,u=r,n.hidden=!0,e.suspend(!0),P.hidden=!1;let c=++f;try{let T=await e.client.review(r);if(e.stopped||c!==f||!p)return;if(!T.review)throw new m("INVALID_RESPONSE","Historical projection is missing");s?.destroy(),s=null,P.replaceChildren();let A=T.run.locale.startsWith("zh"),O=b.createElement("p");O.textContent=A?"\u53EA\u8BFB\u56DE\u770B":"Read-only history",P.append(O);for(let[L,S]of T.review.pages.entries()){let _=b.createElement("button");_.type="button",_.textContent=A?`\u7B2C ${L+1} \u9875`:`Page ${L+1}`,_.onclick=()=>{$(S.receiptId)},P.append(_)}if(T.review.page){let L=T.review.page,S=b.createElement("div");if(S.inert=!0,P.append(S),s=y(S,{mode:"live",rendererUrl:e.client.webViewUrl,title:L.document.name,onAction:()=>{},onAnswers:()=>{},onCustomerDataIntent:()=>{},onRendered:()=>{},onEscape:()=>{d()}}),s.update(L.document,T.run.locale,{serverInput:{bindings:L.inputs,answers:L.answers,values:L.values}}),await s.ready,e.stopped||c!==f||!p)return}let g=A?{issued:"\u5DF2\u9886\u53D6",reserved:"\u5DF2\u9884\u7559",redeemed:"\u5DF2\u4F7F\u7528",expired:"\u5DF2\u8FC7\u671F",revoked:"\u5DF2\u64A4\u9500",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4"}:{issued:"Issued",reserved:"Reserved",redeemed:"Used",expired:"Expired",revoked:"Revoked",unknown:"Status unconfirmed"},V=A?{pending:"\u5904\u7406\u4E2D",complete:"\u5DF2\u5B8C\u6210",cancelled:"\u5DF2\u53D6\u6D88",failed:"\u5931\u8D25",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4"}:{pending:"Processing",complete:"Completed",cancelled:"Cancelled",failed:"Failed",unknown:"Status unconfirmed"};for(let L of[...T.review.coupons.map((S,_)=>`${A?"\u4F18\u60E0\u5238":"Coupon"} ${_+1}: ${g[S.status]}`),...T.review.purchases.map((S,_)=>`${A?"\u8D2D\u4E70":"Purchase"} ${_+1}: ${V[S.status]}`)]){let S=b.createElement("p");S.textContent=L,P.append(S)}e.client.view&&await e.enqueue(e.client.view)}catch(T){if(c!==f||e.stopped)return;s?.destroy(),s=null,P.replaceChildren(),e.fail(T)}}async function d(){if(!p||e.stopped||!e.client.review)return;let r=++f;try{if(await e.client.review(),e.stopped||r!==f)return;p=!1,f++,s?.destroy(),s=null,P.replaceChildren(),P.hidden=!0,n.hidden=!1;let c=e.client.view;C(c)!==o?(D.set(o,structuredClone(e.answers)),e.resetScreen()):(D.delete(o),e.suspend(!1)),c&&await e.enqueue(c)}catch(c){if(r!==f||e.stopped)return;s?.destroy(),s=null,P.replaceChildren(),e.fail(c)}}return{get active(){return p},get receipt(){return u},open:$,exit:d,get drafts(){return new Map([...D].map(([r,c])=>[r,structuredClone(c)]))},stop(){p=!1,f++,s?.destroy(),s=null,P.replaceChildren(),P.hidden=!0,n.hidden=!1}}}function De(e){if(!e.client.pageExperiments)throw new Error("The Run controller does not support page experiments");let b=e.client.pageExperiments.bind(e.client),n=!1,P=!1,y=0,p=!1,u=!1,f,s=new Map,o=new Set,D={},C=new Map,$=he(e.appManifestRelease),d=()=>{for(let g of s.values())g.effect.revert();s.clear();for(let g of C.values())g();C.clear()};function r(g){n||o.has(g)||(o.add(g),b(e.appManifestRelease,[g]).catch(V=>{o.delete(g),z(e.onError,V)}))}async function c(){if(n)return;let g=e.client.view;if(!g||g.stopped||!["running","waiting"].includes(g.status)){y++,d();return}if(p){u=!0;return}p=!0;let V=++y,L=`${g.id}:${g.visit}:${g.revision}`,S=location.href;try{let[_,{applyVisualVariation:x}]=await Promise.all([b(e.appManifestRelease),import("./visual-dom-DQLPBZ2Z.js")]),J=e.client.view;if(n||V!==y||!J||J.stopped||!["running","waiting"].includes(J.status)||`${J.id}:${J.visit}:${J.revision}`!==L||location.href!==S)return;let j=new Set,q=new Set;for(let i of _.assignments){let a=`${_.payload.environmentId}:${i.experimentKey}`;if(q.add(a),C.has(a)||C.set(a,be(a,D)),!!i.inExperiment)for(let l of _.payload.experiments){if(l.key!==i.experimentKey||!de(location.href,l.urlPatterns??[]))continue;let I=l.meta?.findIndex(H=>H.key===i.variationKey)??-1,w=l.variations[I];if(!w?.renderGuard)continue;let v=i.receiptId+":"+l.changeId,h=JSON.stringify([i.variationKey,w]);j.add(v);let k=s.get(v);if(k?.signature===h){k.effect.applied&&r(i.receiptId);continue}s.get(v)?.effect.revert(),s.delete(v);let E=x(w,{requireUniqueTargets:!0,boundVariations:l.variations,allowJs:!1,onApplied:()=>r(i.receiptId),onError:H=>z(e.onError,H)});s.set(v,{signature:h,effect:E}),E.applied&&r(i.receiptId)}}for(let[i,a]of s)j.has(i)||(a.effect.revert(),s.delete(i));for(let[i,a]of C)q.has(i)||(a(),C.delete(i))}catch(_){V===y&&d(),z(e.onError,_)}finally{p=!1,u&&!n&&(u=!1,c())}}let T=e.client.subscribe(()=>{y++,c()}),A=Ie(()=>{y++,d(),c()}),O=async()=>{await c(),n||(f=setTimeout(()=>{O()},15e3))};return{async start(){P||n||(P=!0,await O())},refresh:c,destroy(){n=!0,y++,clearTimeout(f),T(),A(),d(),$.destroy()}}}async function rn(e,b){let n=b,{mountScreenPreview:P}=await import("./screen-renderer-JMHV4GPP.js"),{showPaywall:y}=await import("./paywall-EJCNWDHK.js"),p=n.appManifestRelease?De({client:n.client,appManifestRelease:n.appManifestRelease,onError:n.onError}):void 0;p?.start();let u=e.ownerDocument,f=u.activeElement,s=u.createElement("section"),o=u.createElement("div"),D=u.createElement("div"),C=u.createElement("div"),$=u.createElement("button");C.hidden=!0,$.type="button";let d=u.createElement("p"),r=u.createElement("p"),c=u.createElement("button"),T=u.createElement("button"),A=u.createElement("button"),O=u.createElement("dialog");s.dataset.indianaFunnel="",s.setAttribute("aria-busy","false"),s.style.cssText="box-sizing:border-box;width:100%;min-width:0;font:14px/1.5 system-ui,sans-serif;color:#172033;background:#fff",D.style.cssText="display:flex;gap:12px;align-items:center;flex-wrap:wrap;padding:12px 20px",d.setAttribute("role","status"),r.setAttribute("role","alert"),r.hidden=!0,c.type=T.type=A.type="button",D.append(c,d,r,A,$,T),s.append(o,C,D),e.append(s);let g=null,V=null,L=null,S="",_="",x="",J="",j="",q=!1,i=0,a=!1,l="",I=null,w=Promise.resolve(),v=null,h=null,k=new Set,E={},H=(t,R=null)=>{q||(h=R,r.textContent=t instanceof Error?t.message:"Request failed",r.hidden=!1,A.hidden=n.client.pendingCommand===null,z(n.onError,t))};function B(){let t=n.client.view;if(!t)throw new m("INVALID_REQUEST","No current Run is available");return{requestId:crypto.randomUUID(),nodeId:t.nodeId,visit:t.visit,revision:t.revision}}let F=Re({client:n.client,doc:u,holder:o,reviewHolder:C,mountScreenPreview:P,get stopped(){return q},get answers(){return E},suspend(t){V?.setSuspended(t)},resetScreen(){S="",_="",x=""},enqueue:Y,fail:H}),ee=Ee({client:n.client,expected:B,fail:H,get stopped(){return q},get reviewing(){return F.active},get key(){return S},get busy(){return i}}),ne=Pe({client:n.client,expected:B,perform:W,onIntent:n.onCustomerDataIntent,get stopped(){return q},get busy(){return i},get document(){return g?.document},get answers(){return E}}),oe=t=>t&&(t.screen||t.paywall)?`${t.id}:${t.nodeId}:${t.visit}`:"";function X(){let t=n.client.view;c.disabled=!F.active&&(i>0||!!n.client.pendingCommand||!t?.canBack||t.stopped||!["running","waiting"].includes(t.status)||!oe(t)||_!==oe(t))}async function W(t,R=!1){if(!(i&&!R||q||F.active&&!R)){i++,s.setAttribute("aria-busy","true"),X(),r.hidden=!0,h=null;try{if(!R&&ee.inFlight){let N=n.client.view;await ee.inFlight;let U=n.client.view;if(!N||!U||U.id!==N.id||U.nodeId!==N.nodeId||U.visit!==N.visit||U.stopped||!["running","waiting"].includes(U.status))throw new m("PRECONDITION_FAILED","The screen changed while its display was acknowledged")}if(q)return;let Q=await t();q||await Y(n.client.view??Q.run)}catch(Q){H(Q,n.client.pendingCommand?.requestId??null)}finally{i=Math.max(0,i-1),s.setAttribute("aria-busy",String(i>0)),q||(A.hidden=n.client.pendingCommand===null,X())}}}function te(){I&&clearTimeout(I),!(q||!L||!["running","waiting"].includes(L.status)&&!n.client.pendingCommand)&&(I=setTimeout(()=>{I=null,ce().finally(te)},L.pendingRequest||n.client.pendingCommand?1500:5e3))}async function ce(){if(!(q||a||i)){if(F.active){await F.open(F.receipt);return}a=!0;try{let t=n.client.pendingCommand;t&&n.client.settle&&await n.client.settle(t.requestId);let R=n.client.view,Q=ne.queries,N=await n.client.get(R?.screen&&Object.keys(Q).length?{nodeId:R.nodeId,visit:R.visit,revision:R.revision,components:Q}:void 0);!q&&Q===ne.queries&&await Y(n.client.view??N.run)}catch(t){H(t)}finally{a=!1}}}function Se(t){let R=t.screen?.presentation;if(!R||R.type==="inline"){O.open&&O.close(),s.parentElement!==e&&e.append(s);return}s.parentElement!==O&&(O.append(s),e.append(O));let Q={sm:420,md:640,lg:900};O.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in R?Q[R.size]+"px":"100vw"}`,O.setAttribute("aria-label",g?.document?.name??t.screen?.content.document.name??"Funnel"),O.open||O.showModal()}async function Fe(t){if(q)return;L=t,h&&n.client.pendingCommand?.requestId!==h&&(r.hidden=!0,h=null);let R=t.locale.startsWith("zh");if($.textContent=R?"\u56DE\u770B":"History",$.hidden=!n.client.review,c.textContent=F.active?R?"\u8FD4\u56DE\u5F53\u524D":"Return to current":R?"\u8FD4\u56DE":"Back",T.textContent=R?"\u5173\u95ED":"Close",A.textContent=R?"\u91CD\u8BD5":"Retry",X(),A.hidden=n.client.pendingCommand===null,d.textContent=t.pendingRequest?R?"\u6B63\u5728\u5904\u7406":"Processing":t.instruction?.type==="wait"?R?"\u7B49\u5F85\u4E2D":"Waiting":"",l!==`${t.revision}:${t.visit}:${t.status}:${t.stopped}`&&(l=`${t.revision}:${t.visit}:${t.status}:${t.stopped}`,z(n.onState,structuredClone(t))),!t.pendingRequest&&["closed","ineligible","failed"].includes(t.status)){Z();return}if(t.stopped||n.client.configurationReady===!1){F.stop(),g?.destroy(),g=null,V?.destroy(),V=null,o.replaceChildren(),S="",_="",x="",j="",O.open&&O.close(),s.hidden=!0,te();return}if(s.hidden=!1,F.active){te();return}let Q=oe(t);if(Q!==S&&(_="",g?.destroy(),g=null,V?.destroy(),V=null,o.replaceChildren(),S=Q,x="",j="",E={...t.answers},ne.reset()),Se(t),t.screen){let U=t.screen.content;g||(g=P(o,{mode:"live",rendererUrl:n.client.webViewUrl,title:U.document.name,onAction(G,se={},ae={}){if(F.active)return;E={...E,...ae};let Te=Object.fromEntries((t.screen?.inputs??[]).filter(({variable:re})=>Object.hasOwn(E,re)).map(({variable:re})=>[re,E[re]]));W(()=>n.client.submit({operation:"submit",...B(),input:{type:"screen",output:G,answers:Te,selection:se}}))},onAnswers:G=>{F.active||(E={...E,...G})},onCustomerDataIntent:G=>{F.active||ne.intent(G).catch(H)},onEscape:()=>{F.active||ie()},onError:G=>H(new Error(G)),onRendered:()=>ee.report(Q)}));let M={capabilities:t.screen.capabilities,customerData:t.screen.customerData,parameters:t.parameters,serverInput:{bindings:t.screen.inputs,answers:E,values:t.screen.values}},K=JSON.stringify([U,t.locale,M.parameters,t.screen.inputs,t.screen.values]);if(K!==x)g.update(U.document,t.locale,M),x=K,J=JSON.stringify(M.capabilities),j=JSON.stringify(M.customerData);else{let G=JSON.stringify(M.capabilities);G!==J&&(g.updateCapabilities(M.capabilities),J=G),JSON.stringify(M.customerData)!==j&&(g.updateCustomerData(M.customerData),j=JSON.stringify(M.customerData))}await g.ready}else if(t.paywall&&!V){let U=await y(o,{canInteract:()=>!F.active&&!q,start:async()=>Ce(n.client),onPurchase:n.onPurchase,onCheckoutUrl:n.onCheckoutUrl,resolveOfferId:n.resolveOfferId,onEvent:n.onEvent,onOpenUrl:M=>n.onOpenUrl?n.onOpenUrl({receiptId:t.paywall.receiptId,url:M,openIn:"same_window"}):u.defaultView?.location.assign(M),onAction:async M=>{if(F.active)return;let K=await n.client.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:t.nodeId,visit:t.visit,revision:t.revision,input:{type:"screen",output:M,answers:{}}});await Y(n.client.view??K.run)},onError:H,onDismiss:()=>{!F.active&&!q&&n.client.view?.visit===t.visit&&ie()}});q?U.host?.destroy():(V=U.host,V?.setSuspended(F.active)),ee.report(Q)}if(q)return;_=Q,X();let N=t.instruction;if(N&&(N.type==="open_url"||N.type==="event")&&!k.has(N.receiptId)){let U=u.createElement("button");U.type="button",U.textContent=N.type==="open_url"?`${R?"\u524D\u5F80":"Continue to"} ${new URL(N.url).host}`:R?"\u7EE7\u7EED":"Continue",U.onclick=()=>{let M=B(),K=N.type==="open_url"&&!n.onOpenUrl&&N.openIn==="new_window"?Ne(N.url):null;W(async()=>{let G="success";if(N.type==="open_url")if(n.onOpenUrl)try{G=await n.onOpenUrl({receiptId:N.receiptId,url:N.url,openIn:N.openIn})===!1?"failed":"opened"}catch(ae){z(n.onError,ae),G="failed"}else G=N.openIn==="new_window"&&!K?"failed":"opened";if(N.type==="event"){if(!n.onEvent)throw new m("EVENT_HANDLER_REQUIRED","Provide the event handler");await n.onEvent(N.event)}if(q||n.client.view?.nodeId!==M.nodeId||n.client.view.visit!==M.visit)throw new m("PRECONDITION_FAILED","The client action visit changed");let se=await n.client.submit({operation:"submit",...M,input:{type:"client_action",receiptId:N.receiptId,outcome:G}});return k.add(N.receiptId),N.type==="open_url"&&!n.onOpenUrl&&N.openIn==="same_window"&&u.defaultView?.location.assign(N.url),se})},o.replaceChildren(U)}!t.pendingRequest&&t.status==="completed"&&!k.has(`complete:${t.id}`)&&(k.add(`complete:${t.id}`),z(n.onComplete,structuredClone(t))),te()}function Ne(t){let R=u.defaultView?.open(t,"_blank")??null;return R&&(R.opener=null),R}function Y(t){return X(),w=w.catch(()=>{}).then(()=>Fe(t)),w}let Oe=n.client.subscribe(t=>{n.client.configurationReady===!1&&(s.hidden=!0,g?.destroy(),g=null,V?.destroy(),V=null,o.replaceChildren(),S="",_="",x="",j="",O.open&&O.close()),Y(t).catch(H)}),ke=n.client.subscribeError?.(H);function ie(){return v||(q?Promise.resolve():n.client.view&&!["running","waiting"].includes(n.client.view.status)?(Z(),Promise.resolve()):(v=W(()=>n.client.submit({operation:"close",...B()}),!0).then(()=>{n.client.view?.status==="closed"&&Z()}).finally(()=>{v=null}),v))}function Z(){p?.destroy(),!q&&(q=!0,I&&clearTimeout(I),Oe(),ke?.(),g?.destroy(),F.stop(),V?.destroy(),O.close(),O.remove(),s.remove(),f instanceof HTMLElement&&f.isConnected&&f.focus(),z(n.onDismiss,L?structuredClone(L):null))}c.onclick=()=>{if(!c.disabled){if(F.active){F.exit();return}W(()=>n.client.submit({operation:"back",...B()}))}},$.onclick=()=>{F.open()},T.onclick=()=>{ie()},A.onclick=()=>{W(()=>n.client.retry())},O.addEventListener("cancel",t=>{t.preventDefault(),ie()});try{let t=await n.client.get();await Y(n.client.view??t.run)}catch(t){throw Z(),t}return{destroy:Z,refresh:ce,review:F.open,exitReview:F.exit,get unappliedDrafts(){return F.drafts}}}export{De as a,rn as b};
|