@tinkerlandai/indiana-sdk 0.8.3 → 0.8.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +44 -3
  3. package/README.zh-CN.md +8 -0
  4. package/dist/{ai-usage-BV-FlgWr.d.ts → ai-usage-DUlre7JC.d.ts} +1 -1
  5. package/dist/{api-B3FIE41b.d.ts → api-XDc4pRlN.d.ts} +63 -10
  6. package/dist/chunk-3F2NQOR2.js +1 -0
  7. package/dist/{chunk-BNU6IG3F.js → chunk-663UOBHL.js} +1 -1
  8. package/dist/chunk-BUDTHBFF.js +173 -0
  9. package/dist/chunk-EJTBSGLV.js +10 -0
  10. package/dist/{chunk-SHSNIJJM.js → chunk-F2GOIBDQ.js} +1 -1
  11. package/dist/chunk-RZBZ6LCT.js +4 -0
  12. package/dist/{chunk-2QPETWDX.js → chunk-SSHUBTT3.js} +1 -1
  13. package/dist/chunk-SSLZKIIU.js +1 -0
  14. package/dist/{configuration-sync-DNvKXHk-.d.ts → configuration-sync-Ce3dShy7.d.ts} +6 -1
  15. package/dist/content-2FCUY6XX.js +1 -0
  16. package/dist/{customer-page-WUQVK_tp.d.ts → customer-page-9B97Qdt_.d.ts} +21 -1
  17. package/dist/{funnel-local-client-wbz-4gFx.d.ts → funnel-local-client-CUGavICI.d.ts} +43 -23
  18. package/dist/{funnel-runtime-host-C5P5JTV3.js → funnel-runtime-host-ENRTSXPJ.js} +1 -1
  19. package/dist/index.d.ts +76 -26
  20. package/dist/index.js +1 -1
  21. package/dist/native-shell.js +1 -1
  22. package/dist/openrouter.d.ts +2 -2
  23. package/dist/openrouter.js +1 -1
  24. package/dist/page.d.ts +1 -1
  25. package/dist/page.js +1 -1
  26. package/dist/paywall-734GWAS4.js +1 -0
  27. package/dist/popup.d.ts +14 -4
  28. package/dist/popup.js +1 -1
  29. package/dist/react-native.d.ts +1 -1
  30. package/dist/react-native.js +1 -1
  31. package/dist/screen-renderer-DLXDQQKK.js +1 -0
  32. package/dist/server.d.ts +13 -13
  33. package/dist/server.js +1 -1
  34. package/dist/src-CLEFCTAU.js +1 -0
  35. package/dist/visual.js +2 -2
  36. package/package.json +1 -1
  37. package/dist/chunk-ANOOBDW5.js +0 -350
  38. package/dist/chunk-X747SY26.js +0 -4
  39. package/dist/chunk-Y32NPIYY.js +0 -1
  40. package/dist/chunk-ZT66RIFU.js +0 -10
  41. package/dist/content-J3FKZTGT.js +0 -1
  42. package/dist/paywall-3GIRKSHN.js +0 -1
  43. package/dist/screen-renderer-5FPYVSPW.js +0 -1
  44. package/dist/src-BMJCIMIF.js +0 -1
@@ -1,7 +1,7 @@
1
1
  import { OpenRouter } from '@openrouter/sdk';
2
2
  import { ChatUsage } from '@openrouter/sdk/models';
3
- import { F as FoundationApi } from './api-B3FIE41b.js';
4
- import { c as createAiPricing, A as AiUsageContext, a as AiTokenUsage, b as AiTokenQuote } from './ai-usage-BV-FlgWr.js';
3
+ import { F as FoundationApi } from './api-XDc4pRlN.js';
4
+ import { c as createAiPricing, A as AiUsageContext, a as AiTokenUsage, b as AiTokenQuote } from './ai-usage-DUlre7JC.js';
5
5
  import './screen-BpAejkn0.js';
6
6
  import 'zod';
7
7
  import 'zod/v4';
@@ -1 +1 @@
1
- import"./chunk-SHSNIJJM.js";import"./chunk-2QPETWDX.js";import"./chunk-ZT66RIFU.js";import{a as i}from"./chunk-SOQO2RDZ.js";import"./chunk-LMR2TM3X.js";import"./chunk-OBYJWIRB.js";import"./chunk-EXCPE2XH.js";import"./chunk-RRII2DMC.js";import"./chunk-KQCTDXVD.js";import{z as k}from"zod";var c=k.number().int().min(0).max(1e9);function R(e,o){let a=c.parse(e.promptTokens),p=c.parse(e.completionTokens),s=c.parse(e.promptTokensDetails?.cachedTokens??0),t=c.parse(e.promptTokensDetails?.cacheWriteTokens??0),r=c.parse(e.promptTokensDetails?.audioTokens??0),l=c.parse(e.completionTokensDetails?.audioTokens??0),n=c.parse(e.completionTokensDetails?.reasoningTokens??0);if(c.parse(e.totalTokens)!==a+p||s+t+r>a||n+l>p||(e.promptTokensDetails?.videoTokens??0)>0)throw new i("AI_USAGE_UNAVAILABLE","Token pools must conserve usage; video needs an explicit token mapper");return{input:a-s-t-r,output:p-l-(o==="separate"?n:0),cache_read:s,cache_write:t,input_audio:r,output_audio:l,reasoning:o==="separate"?n:0}}function I(e){if(!Number.isFinite(e)||e<0)throw new i("AI_USAGE_UNAVAILABLE","Provider cost must be a nonnegative USD amount");let o=String(e),a=o.includes("e")?e.toFixed(18).replace(/0+$/,"").replace(/\.$/,""):o;if(!/^(0|[1-9]\d{0,11})(\.\d{1,18})?$/.test(a)||Number(a)!==e)throw new i("AI_USAGE_UNAVAILABLE","Provider cost exceeds the supported precision");return a}async function f(e){if(typeof window<"u")throw new i("SERVER_ONLY","OpenRouter accounting requires your backend");if(!["output","separate"].includes(e.reasoning)||!e.modelId||!e.generationId)throw new i("INVALID_REQUEST","Actual model, generation ID and reasoning pricing are required");let o={context:e.context,generationId:e.generationId,modelId:`openrouter/${e.modelId}`,usage:e.usage,tokens:null,quote:null,receipt:null,phase:"captured"};await e.persist(o);let a=e.mapTokens?e.mapTokens(e.usage):R(e.usage,e.reasoning),p=e.usage.cost==null?void 0:I(e.usage.cost),s=e.quote??await e.pricing.quoteTokens({modelId:o.modelId,tokens:a});if(s.pricing.modelId!==o.modelId||Object.keys(a).some(l=>a[l]!==s.tokens[l]))throw new i("INVALID_REQUEST","Saved quote must match the provider model and token pools");await e.persist({...o,tokens:a,quote:s,phase:"quoted"});let t=await e.pricing.trackTokens(e.client,{...e.context,quote:s,providerCostUsd:p,generationId:e.generationId});if(!t.receipt.accepted)throw new i("AI_BALANCE_REJECTED","OpenRouter usage was saved but the balance request was rejected");let r={...o,tokens:a,quote:s,receipt:t,phase:"settled"};return await e.persist(r),r}function T(e){if(typeof window<"u")throw new i("SERVER_ONLY","OpenRouter accounting requires your backend");if(!["output","separate"].includes(e.reasoning))throw new i("INVALID_REQUEST","Reasoning pricing is required");let o=e.openRouter.chat;async function a(t){if(!t.usage||!t.modelId||!t.generationId)throw new i("AI_USAGE_UNAVAILABLE","OpenRouter did not return final usage and the actual model");await f({...e,context:t.context,generationId:t.generationId,modelId:t.modelId.slice(11),usage:t.usage})}let p=async(t,r)=>{let n={context:await e.context(),generationId:null,modelId:null,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"},d;try{d=await o.send(t,r)}catch(g){throw await e.persist(n),g}if(!(d instanceof ReadableStream)){if(n={...n,generationId:d.id,modelId:d.model?`openrouter/${d.model}`:null,usage:d.usage??null},!n.usage||!n.modelId)throw await e.persist(n),new i("AI_USAGE_UNAVAILABLE","OpenRouter omitted final accounting");return await a(n),d}let w=d.getReader(),m=!1;return new ReadableStream({async pull(g){try{let{value:u,done:A}=await w.read();if(A){if(m=!0,!n.usage||!n.modelId)throw await e.persist(n),new i("AI_USAGE_UNAVAILABLE","OpenRouter stream ended without final accounting");await a(n),g.close();return}if(u.error)throw new i("AI_PROVIDER_ERROR",u.error.message);u.usage&&(n={...n,generationId:u.id,modelId:u.model?`openrouter/${u.model}`:null,usage:u.usage}),g.enqueue(u)}catch(u){m||(m=!0,await e.persist(n)),await w.cancel(u),g.error(u)}},async cancel(g){m||(m=!0,await e.persist(n)),await w.cancel(g)}})},s=new Proxy(o,{get(t,r){return r==="send"?p:Reflect.get(t,r,t)}});return new Proxy(e.openRouter,{get(t,r){return r==="chat"?s:Reflect.get(t,r,t)}})}export{T as createOpenRouterUsageClient,f as trackOpenRouterUsage};
1
+ import"./chunk-F2GOIBDQ.js";import"./chunk-SSHUBTT3.js";import"./chunk-EJTBSGLV.js";import{a as i}from"./chunk-SOQO2RDZ.js";import"./chunk-LMR2TM3X.js";import"./chunk-OBYJWIRB.js";import"./chunk-EXCPE2XH.js";import"./chunk-RRII2DMC.js";import"./chunk-KQCTDXVD.js";import{z as k}from"zod";var c=k.number().int().min(0).max(1e9);function R(e,o){let a=c.parse(e.promptTokens),p=c.parse(e.completionTokens),s=c.parse(e.promptTokensDetails?.cachedTokens??0),t=c.parse(e.promptTokensDetails?.cacheWriteTokens??0),r=c.parse(e.promptTokensDetails?.audioTokens??0),l=c.parse(e.completionTokensDetails?.audioTokens??0),n=c.parse(e.completionTokensDetails?.reasoningTokens??0);if(c.parse(e.totalTokens)!==a+p||s+t+r>a||n+l>p||(e.promptTokensDetails?.videoTokens??0)>0)throw new i("AI_USAGE_UNAVAILABLE","Token pools must conserve usage; video needs an explicit token mapper");return{input:a-s-t-r,output:p-l-(o==="separate"?n:0),cache_read:s,cache_write:t,input_audio:r,output_audio:l,reasoning:o==="separate"?n:0}}function I(e){if(!Number.isFinite(e)||e<0)throw new i("AI_USAGE_UNAVAILABLE","Provider cost must be a nonnegative USD amount");let o=String(e),a=o.includes("e")?e.toFixed(18).replace(/0+$/,"").replace(/\.$/,""):o;if(!/^(0|[1-9]\d{0,11})(\.\d{1,18})?$/.test(a)||Number(a)!==e)throw new i("AI_USAGE_UNAVAILABLE","Provider cost exceeds the supported precision");return a}async function f(e){if(typeof window<"u")throw new i("SERVER_ONLY","OpenRouter accounting requires your backend");if(!["output","separate"].includes(e.reasoning)||!e.modelId||!e.generationId)throw new i("INVALID_REQUEST","Actual model, generation ID and reasoning pricing are required");let o={context:e.context,generationId:e.generationId,modelId:`openrouter/${e.modelId}`,usage:e.usage,tokens:null,quote:null,receipt:null,phase:"captured"};await e.persist(o);let a=e.mapTokens?e.mapTokens(e.usage):R(e.usage,e.reasoning),p=e.usage.cost==null?void 0:I(e.usage.cost),s=e.quote??await e.pricing.quoteTokens({modelId:o.modelId,tokens:a});if(s.pricing.modelId!==o.modelId||Object.keys(a).some(l=>a[l]!==s.tokens[l]))throw new i("INVALID_REQUEST","Saved quote must match the provider model and token pools");await e.persist({...o,tokens:a,quote:s,phase:"quoted"});let t=await e.pricing.trackTokens(e.client,{...e.context,quote:s,providerCostUsd:p,generationId:e.generationId});if(!t.receipt.accepted)throw new i("AI_BALANCE_REJECTED","OpenRouter usage was saved but the balance request was rejected");let r={...o,tokens:a,quote:s,receipt:t,phase:"settled"};return await e.persist(r),r}function T(e){if(typeof window<"u")throw new i("SERVER_ONLY","OpenRouter accounting requires your backend");if(!["output","separate"].includes(e.reasoning))throw new i("INVALID_REQUEST","Reasoning pricing is required");let o=e.openRouter.chat;async function a(t){if(!t.usage||!t.modelId||!t.generationId)throw new i("AI_USAGE_UNAVAILABLE","OpenRouter did not return final usage and the actual model");await f({...e,context:t.context,generationId:t.generationId,modelId:t.modelId.slice(11),usage:t.usage})}let p=async(t,r)=>{let n={context:await e.context(),generationId:null,modelId:null,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"},d;try{d=await o.send(t,r)}catch(g){throw await e.persist(n),g}if(!(d instanceof ReadableStream)){if(n={...n,generationId:d.id,modelId:d.model?`openrouter/${d.model}`:null,usage:d.usage??null},!n.usage||!n.modelId)throw await e.persist(n),new i("AI_USAGE_UNAVAILABLE","OpenRouter omitted final accounting");return await a(n),d}let w=d.getReader(),m=!1;return new ReadableStream({async pull(g){try{let{value:u,done:A}=await w.read();if(A){if(m=!0,!n.usage||!n.modelId)throw await e.persist(n),new i("AI_USAGE_UNAVAILABLE","OpenRouter stream ended without final accounting");await a(n),g.close();return}if(u.error)throw new i("AI_PROVIDER_ERROR",u.error.message);u.usage&&(n={...n,generationId:u.id,modelId:u.model?`openrouter/${u.model}`:null,usage:u.usage}),g.enqueue(u)}catch(u){m||(m=!0,await e.persist(n)),await w.cancel(u),g.error(u)}},async cancel(g){m||(m=!0,await e.persist(n)),await w.cancel(g)}})},s=new Proxy(o,{get(t,r){return r==="send"?p:Reflect.get(t,r,t)}});return new Proxy(e.openRouter,{get(t,r){return r==="chat"?s:Reflect.get(t,r,t)}})}export{T as createOpenRouterUsageClient,f as trackOpenRouterUsage};
package/dist/page.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as ConfigurationSync } from './configuration-sync-DNvKXHk-.js';
1
+ import { C as ConfigurationSync } from './configuration-sync-Ce3dShy7.js';
2
2
  import { J as JsonValue, R as Result } from './growth-rules-B4YYy64R.js';
3
3
  import { z } from 'zod';
4
4
  import './screen-BpAejkn0.js';
package/dist/page.js CHANGED
@@ -1 +1 @@
1
- import{e as o,f as r,g as e,h as f}from"./chunk-X747SY26.js";import"./chunk-EXCPE2XH.js";import"./chunk-KQCTDXVD.js";export{f as createPageExperiments,o as mergeQueryStrings,r as pageAttributes,e as readPayload};
1
+ import{h as o,i as r,j as e,k as f}from"./chunk-RZBZ6LCT.js";import"./chunk-DSPLGTQI.js";import"./chunk-EXCPE2XH.js";import"./chunk-KQCTDXVD.js";export{f as createPageExperiments,o as mergeQueryStrings,r as pageAttributes,e as readPayload};
@@ -0,0 +1 @@
1
+ import{b as W}from"./chunk-SSLZKIIU.js";import"./chunk-SSHUBTT3.js";import{Je as q,ek as j}from"./chunk-EJTBSGLV.js";import{a as w}from"./chunk-SOQO2RDZ.js";import{ka as L,v as $}from"./chunk-LMR2TM3X.js";import{a as z}from"./chunk-DSPLGTQI.js";import"./chunk-OBYJWIRB.js";import"./chunk-EXCPE2XH.js";import"./chunk-RRII2DMC.js";import"./chunk-KQCTDXVD.js";async function J(v,t,h){if(t.status!=="complete")throw new w("INVALID_RESPONSE","A verified completed purchase is required");if(await h.onComplete?.(t),!v||!h.check)return;let P=L.parse(await h.check());if(P.internal_feature_id!==v.internal_feature_id||P.quantity!==v.quantity)throw new w("INVALID_RESPONSE","The access requirement changed");P.allowed&&await h.onAccessGranted?.(P)}async function se(v,t){let h=t.check?L.parse(await t.check()):null;if(h?.allowed)return await t.onAccessGranted?.(h),{check:h,host:null};let P=W(v.ownerDocument),n=await t.start(),y=n.view??await n.refresh();if(!y)throw new w("INVALID_RESPONSE","Paywall presentation is missing");let{mountScreenPreview:K}=await import("./screen-renderer-DLXDQQKK.js"),i=v.ownerDocument,O=new AbortController,b=i.createElement("section"),Q=i.createElement("div"),D=i.createElement("div"),g=i.createElement("p"),c=i.createElement("button"),_=i.createElement("button"),u=i.createElement("dialog"),p=y.document.screen.strings.defaultLocale.startsWith("zh");b.dataset.indianaPaywall="",b.setAttribute("aria-label",y.document.name),b.style.cssText="width:100%;box-sizing:border-box;background:#fff;color:#172033;font:14px/1.5 system-ui,sans-serif",D.style.cssText="display:flex;gap:12px;padding:12px 20px;align-items:center;flex-wrap:wrap",g.setAttribute("role","status"),_.textContent=p?"\u5173\u95ED":"Close",c.textContent=p?"\u91CD\u8BD5":"Retry",c.hidden=!0,D.append(g,c,_),b.append(Q,D);let U=y.document.presentation,R,d=!1,T=!1,f=null,G=!1,m=()=>!G&&t.canInteract?.()!==!1,M=!1,r=null,I=null,N=e=>{g.textContent=e instanceof Error?e.message:p?"\u8BF7\u6C42\u5931\u8D25":"Request failed",z(t.onError,e),c.hidden=r===null};async function C(e){if(!(T||d||!m())){T=!0,c.hidden=!0,g.textContent="";try{await e()}catch(s){d||N(s)}finally{T=!1}}}async function X(e){await J(h,e,t)}async function E(e){if(d)return;if(!m()){r=async()=>E(await n.read()),c.hidden=!1;return}if(g.textContent=e.status,e.status==="complete"){r=null,await X(e);return}if(e.status!=="pending"){if(n.canReselect===!1){g.textContent=p?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",c.textContent=p?"\u67E5\u8BE2\u7ED3\u679C":"Check result",r=async()=>E(await n.read()),c.hidden=!1;return}c.textContent=p?"\u91CD\u8BD5":"Retry",r=null,f=null;return}let s=Date.now()+6e5,l=2e3;for(;!d&&Date.now()<s;){if(await new Promise(k=>{let S=()=>{clearTimeout(A),k()},A=setTimeout(()=>{O.signal.removeEventListener("abort",S),k()},l);O.signal.addEventListener("abort",S,{once:!0})}),d)return;if(!m()){r=async()=>E(await n.read()),c.hidden=!1;return}let a=await n.read();if(a.status!=="pending"){await E(a);return}l=Math.min(l*1.5,3e4)}r=async()=>E(await n.read()),c.hidden=!1}async function V(){I?.remove(),I=null,r=V;let e=await n.confirm();if(!m()){r=V,c.hidden=!1;return}if(e.status==="pending"){if(e.checkoutUrl)t.onCheckoutUrl?await t.onCheckoutUrl(e.checkoutUrl):i.defaultView?.location.assign(e.checkoutUrl);else if(e.execution||e.nativePurchase){if(!t.onPurchase)throw new w("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await t.onPurchase({operation:e,signal:O.signal})}}r=async()=>E(await n.read()),await E(e)}function Y(e){I?.remove();let s=i.createElement("div"),l=i.createElement("button"),a=i.createElement("button"),k=i.createElement("p");k.textContent=e.lines.map(o=>o.productName).join(", ")+" \xB7 "+$(e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),e.currency),l.textContent=p?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",a.textContent=p?"\u53D6\u6D88":"Cancel",l.onclick=()=>{C(V)};let S=async()=>{let o=await n.cancel();d||(s.remove(),I=null,await E(o))};a.onclick=()=>{r=S,C(S)};let A=i.createElement("div");for(let o of e.lines){let F=i.createElement("p");if(F.textContent=`${o.productName} \xB7 ${$(o.catalogAmountMinor,e.currency)}${j(o.interval,p?"zh-CN":"en",o.intervalCount??1)}`,A.append(F),o.trial){let B=i.createElement("p");B.textContent=p?`\u8BD5\u7528 ${o.trial.days} \u5929\uFF1B${o.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${o.trial.days}; ${o.trial.cardRequired?"a payment method is required":"no payment method is required"}`,A.append(B)}}if(!e.charge){let o=i.createElement("p");o.textContent=p?"\u76EE\u5F55\u4EF7\u683C\uFF1B\u6700\u7EC8\u91D1\u989D\u4EE5\u7ED3\u8D26\u65F6\u7A0E\u8D39\u548C\u8BD5\u7528\u89C4\u5219\u4E3A\u51C6\u3002":"Catalog price; the final charge depends on checkout taxes and trial terms.",A.append(o)}s.append(k,A,l,a),D.prepend(s),I=s,r=null}async function H(){if(!f)return;if(r=H,!M){let s=n.view,l=s?.document.buttons[f.actionId],a=s&&l?.type==="checkout"?q(l.product,f.selection,s.capabilities):null;if(!a)throw new w("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let k=await t.resolveOfferId?.({actionId:f.actionId,productVersionId:a});if(d)return;k!==void 0&&(f.offerId=k),M=!0}if(!m()){c.hidden=!1;return}let e=await n.preview(f);d||Y(e)}function x(e="destroy"){d||(d=!0,O.abort(),R?.destroy(),n.destroy(),u.open&&u.close(),u.remove(),b.remove(),P(),e==="dismiss"&&z(t.onDismiss))}_.onclick=()=>{m()&&x("dismiss")},u.addEventListener("cancel",e=>{e.preventDefault(),m()&&x("dismiss")}),c.onclick=()=>{r&&C(r)};try{if(U.type==="inline")v.append(b);else{let e={sm:420,md:640,lg:900};u.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in U?e[U.size]+"px":"100vw"}`,u.setAttribute("aria-label",y.document.name),u.append(b),v.append(u),m()&&u.showModal()}R=K(Q,{mode:"live",rendererUrl:n.webViewUrl,title:y.document.name,onAction(e,s={}){if(!m())return;let l=n.view,a=l?.document.buttons[e];if(a){if(a.type==="close"){C(async()=>{await t.onAction?.(e),x(t.onAction?"action":"dismiss")});return}if(a.type==="action"){r=async()=>{if(a.action.type==="event"){if(!t.onEvent)throw new w("EVENT_HANDLER_REQUIRED","Provide the event handler");await t.onEvent(a.action.event)}else t.onOpenUrl?await t.onOpenUrl(a.action.url):i.defaultView?.location.assign(a.action.url);await t.onAction?.(e),r=null},C(r);return}if((n.quote||f)&&n.canReselect===!1){r=n.quote?async()=>E(await n.read()):H,C(r);return}if(!l||!q(a.product,s,l.capabilities)){N(new w("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(f&&f.actionId!==e){N(new w("COMMAND_PENDING","Finish the current purchase"));return}f||(f={requestId:crypto.randomUUID(),actionId:e,selection:s},M=!1),C(H)}},onEscape:()=>{m()&&x("dismiss")},onError:e=>N(new Error(e))}),R.update(y.document.screen,y.document.screen.strings.defaultLocale,{capabilities:y.capabilities,serverInput:{bindings:[],answers:{}}}),await R.ready}catch(e){throw x(),e}return{check:h,host:{setSuspended(e){G=e,b.hidden=e,e&&u.open?u.close():!e&&!d&&U.type!=="inline"&&!u.open&&u.showModal()},destroy:x,refresh:async()=>{if(!m()){if(n.view)return n.view;throw new w("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await n.refresh();return d||R?.updateCapabilities(e.capabilities),e}}}}export{se as showPaywall};
package/dist/popup.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as ScreenAction, b as ScreenNode, c as ScreenDocument } from './screen-BpAejkn0.js';
2
- import { O as Offer, c as OfferUnavailableReason, d as CustomerPageData, a as SurfaceData, e as ScreenParameters, f as ScreenRendererInput, S as ScreenAnswers, b as CustomerDataIntent } from './customer-page-WUQVK_tp.js';
2
+ import { O as Offer, c as OfferUnavailableReason, d as CustomerPageData, a as SurfaceData, e as ScreenParameters, f as ScreenRendererInput, S as ScreenAnswers, b as CustomerDataIntent } from './customer-page-9B97Qdt_.js';
3
3
  import { WindowLike } from 'dompurify';
4
4
  import 'zod';
5
5
 
@@ -104,14 +104,24 @@ type PopupHandle = {
104
104
  * Passive import. Call explicitly after obtaining an approved configuration.
105
105
  * 接受完整文档(离线使用导出的发布版本)或下发的单语言文档;多语言时按 options.locale 与浏览器语言挑选。
106
106
  */
107
- declare function showPopup(input: ScreenDocument, options?: {
107
+ type PopupOptions = {
108
108
  /** Hosted public shell, supplied by the current SDK gateway after authorization. */
109
109
  rendererUrl?: string;
110
110
  onError?: (error: unknown) => void;
111
111
  locale?: string;
112
112
  capabilities?: SurfaceData;
113
113
  onEvent?: (event: PopupEvent) => void | Promise<void>;
114
- }): PopupHandle;
114
+ };
115
+ type PreparedPopupHandle = PopupHandle & {
116
+ /** Resolves after the first rendered response, rather than the bridge handshake. */
117
+ ready: Promise<void>;
118
+ /** Display the prepared iframe in place. A handle is used for one presentation. */
119
+ show(): PopupHandle;
120
+ };
121
+ declare function showPopup(input: ScreenDocument, options?: PopupOptions): PopupHandle;
122
+ /** Explicitly prepare an already-authorized screen before the opening click.
123
+ * Destroy on unmount or identity change. Preparation emits no display or action events. */
124
+ declare function preparePopup(input: ScreenDocument, options?: PopupOptions): PreparedPopupHandle;
115
125
  type ScreenPreviewHandle = {
116
126
  /** Rejects if the renderer cannot start; this does not grant customer authorization. */
117
127
  ready: Promise<void>;
@@ -176,4 +186,4 @@ type CustomerPageHandle = {
176
186
  destroy(): void;
177
187
  };
178
188
 
179
- export { type CustomerPageHandle, type HtmlCodeDiagnostic, type PopupEvent, type PopupHandle, type RendererEditorKey, type RendererEditorMessages, ScreenDocument, type ScreenNodeRect, type ScreenPreviewHandle, formatCustomerDecimal, hostedRendererScript, hostedRendererShell, inspectCustomHtml, mountScreenPreview, prepareScreen, sanitizeCustomHtml, showPopup };
189
+ export { type CustomerPageHandle, type HtmlCodeDiagnostic, type PopupEvent, type PopupHandle, type PopupOptions, type PreparedPopupHandle, type RendererEditorKey, type RendererEditorMessages, ScreenDocument, type ScreenNodeRect, type ScreenPreviewHandle, formatCustomerDecimal, hostedRendererScript, hostedRendererShell, inspectCustomHtml, mountScreenPreview, preparePopup, prepareScreen, sanitizeCustomHtml, showPopup };
package/dist/popup.js CHANGED
@@ -1 +1 @@
1
- import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x}from"./chunk-ANOOBDW5.js";import"./chunk-DSPLGTQI.js";import"./chunk-SOQO2RDZ.js";import"./chunk-LMR2TM3X.js";import"./chunk-RRII2DMC.js";import"./chunk-KQCTDXVD.js";export{p as formatCustomerDecimal,r as hostedRendererScript,o as hostedRendererShell,f as inspectCustomHtml,x as mountScreenPreview,m as prepareScreen,e as sanitizeCustomHtml,t as showPopup};
1
+ import{a as o,b as r,c as e,d as f,e as m,g as p,h as t,i as x,j as a}from"./chunk-BUDTHBFF.js";import"./chunk-SSLZKIIU.js";import"./chunk-SOQO2RDZ.js";import"./chunk-LMR2TM3X.js";import"./chunk-DSPLGTQI.js";import"./chunk-RRII2DMC.js";import"./chunk-KQCTDXVD.js";export{p as formatCustomerDecimal,r as hostedRendererScript,o as hostedRendererShell,f as inspectCustomHtml,a as mountScreenPreview,x as preparePopup,m as prepareScreen,e as sanitizeCustomHtml,t as showPopup};
@@ -1,7 +1,7 @@
1
1
  import { S as Scope, a as PushHost, P as PushAddressObservation } from './errors-C8lRYZ0n.js';
2
2
  export { I as IndianaError, b as PushJournal } from './errors-C8lRYZ0n.js';
3
3
  import { z } from 'zod';
4
- import { a as apiOperations } from './api-B3FIE41b.js';
4
+ import { a as apiOperations } from './api-XDc4pRlN.js';
5
5
  import './screen-BpAejkn0.js';
6
6
  import 'zod/v4';
7
7
 
@@ -1 +1 @@
1
- import{a as wA}from"./chunk-BNU6IG3F.js";import{a as X}from"./chunk-VVV3JNS3.js";import{a as PA}from"./chunk-2QPETWDX.js";import{Ki as B}from"./chunk-ZT66RIFU.js";import{a as H}from"./chunk-SOQO2RDZ.js";import"./chunk-LMR2TM3X.js";import{b as mA}from"./chunk-OBYJWIRB.js";import"./chunk-EXCPE2XH.js";import"./chunk-RRII2DMC.js";import"./chunk-KQCTDXVD.js";function P(A){return typeof A=="string"?A:String(A)}var jA=/[\ud800-\udbff](?![\udc00-\udfff])|(^|[^\ud800-\udbff])[\udc00-\udfff]/g;function QA(A){return A.replace(jA,"$1\uFFFD")}function eA(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 IA(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 yA(A){let e;if(Array.isArray(A)){let t=A.map(P);if(t.length===2)return t}else if((e=IA(A))!=null){let t=eA(e.next()),r=eA(e.next());if(!t.done&&!r.done)return[P(t.value),P(r.value)]}throw new TypeError("Each query pair must be an iterable [name, value] tuple")}var DA="0123456789ABCDEF",FA=/(?:%[0-9A-Fa-f]{2})+/g;function k(A){return`%${DA[A>>4&15]}${DA[15&A]}`}function BA(A,e,t=!1){return A>=55296&&A<=57343&&(A=65533),A<=127?t&&A===32?"+":e(A)?k(A):String.fromCharCode(A):A<=2047?k(192|A>>6)+k(128|63&A):A<=65535?k(224|A>>12)+k(128|A>>6&63)+k(128|63&A):k(240|A>>18)+k(128|A>>12&63)+k(128|A>>6&63)+k(128|63&A)}function tA(A){return A>=48&&A<=57?A-48:A>=65&&A<=70?A-65+10:A>=97&&A<=102?A-97+10:-1}function rA(A,e=!1){let t=0;for(;t<A.length;t++){let r=A.charCodeAt(t);if(r===37||e&&r===43)break}return t===A.length?A:(e?A.replace(/\+/g," "):A).replace(FA,r=>{try{return decodeURIComponent(r)}catch{return"\uFFFD".repeat(r.length/3)}})}function T(A){return A<=31||A>126}function _A(A){switch(A){case 32:case 34:case 60:case 62:case 96:return!0;default:return T(A)}}function cA(A){switch(A){case 32:case 34:case 35:case 60:case 62:return!0;default:return T(A)}}function YA(A){return cA(A)||A===39}function nA(A){switch(A){case 63:case 94:case 96:case 123:case 125:return!0;default:return cA(A)}}function G(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 nA(A)}}function CA(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 G(t)}})(A)}}function kA(A,e){return BA(A=A||0,e)}function U(A,e,t=!1){let r=0;for(;r<A.length;r++){let c=A.charCodeAt(r);if(c>=128||t&&c===32||e(c))break}if(r===A.length)return A;let n=A.slice(0,r);for(;r<A.length;r++){let c=A.charCodeAt(r),i=c;if(c>=55296&&c<=56319&&r+1<A.length){let u=A.charCodeAt(r+1);u>=56320&&u<=57343&&(i=(c-55296<<10)+u-56320+65536,r++)}n+=BA(i,e,t)}return n}function aA(A){let e=[],t=0,r=0;for(;r<=A.length;){if(r=A.indexOf("&",t),r<0&&(r=A.length),r!==t){let n=A.slice(t,r),c=n.indexOf("=");c<0&&(c=n.length),e.push([rA(n.slice(0,c),!0),rA(n.slice(c+1),!0)])}if(t=r+1,r===A.length)break}return e}function sA(A){let e="";for(let t=0;t<A.length;t++){let r=U(A[t][0],CA,!0),n=U(A[t][1],CA,!0);e+=t!==0?`&${r}=${n}`:`${r}=${n}`}return e}var GA=[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],JA=[7296,7297,7298,7299,7300,7301,7302,7303,7304,42958,42962,42964,42993],WA=["\u0432","\u0434","\u043E","\u0441","\u0442","\u0442","\u044A","\u0463","\uA64B","\uA7CF","\uA7D3","\uA7D5","s"],VA=[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 XA(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[KA,ZA,Ae,bA]=[[[],"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,r]){return[e,t.split(",").map(n=>parseInt(n,36)),Uint8Array.from(atob(r),n=>n.charCodeAt(0))]});function ee(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 UA(A,e){for(let t=0;t<A.length;t+=2)if(e>=A[t]&&e<=A[t+1])return!0;return!1}function M(A,e){let[t,r,n]=A,c=e>>8;for(let h=0;h<t.length;h+=2)if(c>=t[h]&&c<=t[h+1])return!0;let i=r.indexOf(c);if(i<0)return!1;let u=255&e;return!!(n[32*i+(u>>3)]&1<<(7&u))}function te(A){let e=Array.from(A,t=>t.codePointAt(0));for(let t=0;t<e.length;t++){let r=e[t];if(r!==8204&&r!==8205||t>0&&UA(VA,e[t-1]))continue;if(r===8205)return!1;let n=t-1;for(;n>=0&&M(bA,e[n]);)n--;let c=t+1;for(;c<e.length&&M(bA,e[c]);)c++;if(!(n>=0&&c<e.length&&M(ZA,e[n])&&M(Ae,e[c])))return!1}return!0}var re=/(?![\p{Mark}\p{Decimal_Number}])[\p{Script=Arabic}\p{Script=Hebrew}]/u,ne=/\p{Script=Latin}/u;function se(A){return!re.test(A)||!ne.test(A)}var R=36,F=1,iA=26,ie=38,le=700,oe=72,ue=128,ce=2147483647;function SA(A){return String.fromCharCode(A+22+75*+(A<26))}function ae(A,e,t){let r=0;for(A=t?Math.floor(A/le):A>>1,A+=Math.floor(A/e);A>(R-F)*iA>>1;r+=R)A=Math.floor(A/(R-F));return Math.floor(r+(R-F+1)*A/(A+ie))}function fe(A){let e=Array.from(A,h=>h.codePointAt(0)),t="",r=0;for(let h=0;h<e.length;h++){let p=e[h];p<128&&(t+=String.fromCharCode(p),r++)}let n=r;n&&(t+="-");let c=ue,i=0,u=oe;for(;r<e.length;){let h=ce;for(let p=0;p<e.length;p++){let d=e[p];d>=c&&d<h&&(h=d)}i+=(h-c)*(r+1),c=h;for(let p=0;p<e.length;p++){let d=e[p];if(d<c&&i++,d===c){let y=i;for(let S=R;;S+=R){let q=S<=u?F:S>=u+iA?iA:S-u;if(y<q)break;t+=SA(q+(y-q)%(R-q)),y=Math.floor((y-q)/(R-q))}t+=SA(y),u=ae(i,r+1,r===n),i=0,r++}}i++,c++}return t}function K(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 r=0;r<A.length;r++){let n=tA(A.charCodeAt(r));if(n>=e||n<0)return-1;t=t*e+n}return t}function qA(A){switch(A){case".":case"%2e":case"%2E":return!0;default:return!1}}function zA(A,e){return(A>=65&&A<=90||A>=97&&A<=122)&&(e===58||e===124)}function HA(A){return A.length===2&&zA(A.codePointAt(0),A.codePointAt(1))}function vA(A){return A.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|<|>|\?|@|\[|\\|\]|\^|\|/u)!==-1}function C(A){switch(A){case"ftp":case"http":case"https":case"ws":case"wss":case"file":return!0;default:return!1}}function RA(A){switch(A){case"ftp":return 21;case"http":case"ws":return 80;case"https":case"wss":return 443;default:return null}}function lA(A,e){if(A[0]==="[")return A[A.length-1]==="]"?(function(r){let n=[0,0,0,0,0,0,0,0],c=null,i=0,u=0,h=Array.from(r,p=>p.codePointAt(0));if(h[u]===58){if(h[u+1]!==58)return null;u+=2,i++,c=i}for(;u<h.length;){if(i===8)return null;if(h[u]===58){if(c!==null)return null;u++,i++,c=i;continue}let p=0,d=0,y=0;for(;y<4&&(p=tA(h[u]))>=0;)d=(d<<4)+p,u++,y++;if(h[u]===46){if(y===0||i>6)return null;u-=y;let S=0;for(;h[u]!==void 0;){let q=0;if(S>0)if(h[u]===46&&S<4)u++;else return null;if(h[u]==null||h[u]<48||h[u]>57)return null;for(;h[u]>=48&&h[u]<=57;){if(q=10*q+tA(h[u]),q>255)return null;u++}n[i]=256*n[i]+q,S++,S%2==0&&i++}if(S!==4)return null;break}else if(h[u]===58){if(h[++u]===void 0)return null}else if(h[u]!==void 0)return null;n[i]=d,i++}if(c!==null){let p=i-c;for(i=7;i!==0&&p>0;){let d=n[c+p-1];n[c+p-1]=n[i],n[i]=d,i--,p--}}else if(c===null&&i!==8)return null;return n})(A.substring(1,A.length-1)):null;if(e)return(function(r){return vA(r)?null:U(r,T)})(A);{let t=(function(n){let c=!1,i=!1;for(let h=0;h<n.length;h++){let p=n.charCodeAt(h);if(p<=32||p===37||p===127)return null;if(p>=128){c=!0;break}p>=65&&p<=90&&(i=!0)}if(!c)return n!==""?i?n.toLowerCase():n:null;if((function(p){for(let d of p){let y=d.codePointAt(0);if(/[\p{Cn}\p{Co}\p{Cs}\p{Noncharacter_Code_Point}]/u.test(d)&&!UA(GA,y)||M(KA,y))return!0}return!1})(n))return null;let u=(n=(function(p){let d="";for(let y of p){let S=y.codePointAt(0);if(S!==8204&&S!==8205&&/\p{Default_Ignorable_Code_Point}/u.test(y))continue;let q=ee(y,S);if(q){d+=q;continue}let dA=JA.indexOf(S);d+=dA<0?y:WA[dA]}return d})(n).normalize("NFKC").replace(/[\u3002\uff0e\uff61]/g,".").toLowerCase()).split(".");for(let h=0;h<u.length;h++){let p=u[h];if(p==="")continue;let d=/[^\0-\x7f]/.test(p);if(XA(p)||d&&(/^\p{Mark}/u.test(p)||!te(p)||!se(p)||p.startsWith("xn--")))return null;d&&(u[h]=`xn--${fe(p)}`)}return(n=u.join("."))!==""?n:null})(A.indexOf("%")===-1?A:rA(A));return t===null||vA(t)?null:(function(n){let c=n.length,i=n.lastIndexOf(".",c-2)+1;if(n.charCodeAt(c-1)===46&&c--,c<=i)return!1;if(K(n.slice(i,c))>=0)return!0;for(;i<c;i++){let u=n.charCodeAt(i);if(u<48||u>57)return!1}return!0})(t)?(function(n){let c=n.split("."),i=c.length;if(c[i-1]||i--,i>4)return null;let u=0;for(let p=0;p<i-1;p++){let d=K(c[p]);if(d<0||d>255)return null;u+=d*(1<<8*(3-p))}let h=K(c[i-1]);return h<0||h>=256**(5-i)?null:(u+=h,u)})(t):t}}function oA(A){return typeof A=="number"?(function(t){let n="";return n+=`${(t>>>24&255).toString(10)}.`,n+=`${(t>>>16&255).toString(10)}.`,n+=`${(t>>>8&255).toString(10)}.`,n+=(t&255).toString(10),n})(A):Array.isArray(A)?`[${(function(t){let r=(function(u){let h=-1,p=-1,d=1,y=0;for(let S=0;S<u.length;++S)u[S]!==0?(y>d&&(h=p,d=y),p=-1,y=0):(p===-1&&(p=S),++y);return y>d?p:h})(t),n="",c=!1;for(let i=0;i<=7;++i)if(!(c&&t[i]===0)){if(c&&(c=!1),r===i){n+=i===0?"::":":",c=!0;continue}n+=t[i].toString(16),i!==7&&(n+=":")}return n})(A)}]`:A}function LA(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 OA(A){return A.username!==""||A.password!==""}function Z(A){return A.host===null||A.host===""||A.scheme==="file"}var s=0,l="",g="",m=null,o,_=!1,Y=!1,O=!1,b;function v(A,e,t,r){e||(A=(function(i){let u=0,h=i.length;for(;u<h&&!(i.charCodeAt(u)>32);++u);for(;h>u&&!(i.charCodeAt(h-1)>32);--h);return i.substring(u,h)})(A)),A=(function(i){let u=0;for(;u<i.length;u++){let p=i.charCodeAt(u);if(p===9||p===10||p===13)break}if(u===i.length)return i;let h=i.slice(0,u);for(;u<i.length;u++){let p=i.charCodeAt(u);p!==9&&p!==10&&p!==13&&(h+=i[u])}return h})(A),s=0,l=A,g="",m=t||null,o=e||{scheme:"",username:"",password:"",host:null,port:null,path:[],query:null,fragment:null,opaquePath:!1},_=!1,Y=!1,O=!1,b=r||0;let n=he;switch(r){case 3:case 4:n=J;break;case 5:n=hA;break;case 6:n=N;break;case 7:n=L;break;case 8:n=z}return n(a(A,s))!==1?o:null}function f(A,e){return s+=s===A?E(e):1,s<=l.length}function a(A,e){return e<A.length?A.codePointAt(e):void 0}function E(A){return A!=null&&A>65535?2:1}function NA(A){return A==null?"":A<=65535?String.fromCharCode(A):String.fromCodePoint(A)}var he=A=>{let e=s;if(A!=null&&(A>=65&&A<=90||A>=97&&A<=122)){let t=s+1;for(A=l.charCodeAt(t);A===43||A===45||A===46||A>=65&&A<=90||A>=97&&A<=122||A>=48&&A<=57;)t++,A=l.charCodeAt(t);return g=l.slice(s,t).toLowerCase(),s=t,pe(t<l.length?A:void 0)}else return b?1:(--s,f(e,A)?$A(a(l,s)):0)},pe=A=>{let e=s;if(A===58){if(b){if(C(o.scheme)!==C(g))return 0;if((OA(o)||o.port!==null)&&g==="file")return 0;if(o.scheme==="file"&&o.host==="")return 0}return o.scheme=g,b?(o.port===RA(o.scheme)&&(o.port=null),0):(g="",o.scheme==="file"?f(e,A)?pA(a(l,s)):0:C(o.scheme)&&m!==null&&m.scheme===o.scheme?f(e,A)?ge(a(l,s)):0:C(o.scheme)?f(e,A)?me(a(l,s)):0:a(l,s+1)===47?(s++,f(e,A)?de(a(l,s)):0):(o.path=[""],o.opaquePath=!0,f(e,A)?xA(a(l,s)):0))}else return b?1:(g="",s=-1,f(e,A)?$A(a(l,s)):0)},$A=A=>{let e=s;return m===null||m.opaquePath&&A!==35?1:m.opaquePath&&A===35?(o.scheme=m.scheme,o.path=m.path.slice(),o.opaquePath=m.opaquePath,o.query=m.query,o.fragment="",f(e,A)?z(a(l,s)):0):m.scheme==="file"?(s--,f(e,A)?pA(a(l,s)):0):(s--,f(e,A)?fA(a(l,s)):0)},ge=A=>{let e=s;return A===47&&a(l,s+1)===47?(++s,f(e,A)?V(a(l,s)):0):(s--,f(e,A)?fA(a(l,s)):0)},de=A=>{let e=s;return A===47?f(e,A)?$(a(l,s)):0:(s--,f(e,A)?I(a(l,s)):0)},fA=A=>{let e=s;return o.scheme=m.scheme,A===47||C(o.scheme)&&A===92?f(e,A)?EA(a(l,s)):0:(o.username=m.username,o.password=m.password,o.host=m.host,o.port=m.port,o.path=m.path.slice(),o.query=m.query,A===63?(o.query="",f(e,A)?L(a(l,s)):0):A===35?(o.fragment="",f(e,A)?z(a(l,s)):0):A!=null?(o.query=null,o.path.pop(),s--,f(e,A)?I(a(l,s)):0):f(e,A)?fA(a(l,s)):0)},EA=A=>{let e=s;return C(o.scheme)&&(A===47||A===92)?f(e,A)?V(a(l,s)):0:A===47?f(e,A)?$(a(l,s)):0:(o.username=m.username,o.password=m.password,o.host=m.host,o.port=m.port,s--,f(e,A)?I(a(l,s)):0)},me=A=>{let e=s;return A===47&&a(l,s+1)===47?s++:s--,f(e,A)?V(a(l,s)):0},V=A=>{let e=s;return A!==47&&A!==92?(s--,f(e,A)?$(a(l,s)):0):f(e,A)?V(a(l,s)):0},$=A=>{let e=s;if(A!=null&&A!==64&&A!==35&&A!==47&&A!==63&&(A!==92||!C(o.scheme))){let t=s+E(A);for(;t<l.length;){let r=a(l,t);if(r==null||r===64||r===35||r===47||r===63||r===92&&C(o.scheme))break;t+=E(r)}return g+=l.slice(s,t),s=t-1,f(e,A)?$(a(l,s)):0}if(A===64){_&&(g=`%40${g}`),_=!0;for(let t=0;t<g.length;t++){let r=g.codePointAt(t);if(r===58&&!Y){Y=!0;continue}let n=kA(r,G);Y?o.password+=n:o.username+=n,r!=null&&r>65535&&t++}return g="",f(e,A)?$(a(l,s)):0}else return A==null||A===35||A===47||A===63||A===92&&C(o.scheme)?_&&g===""?1:(s-=g.length+1,g="",f(e,A)?J(a(l,s)):0):(g+=NA(A),f(e,A)?$(a(l,s)):0)},J=A=>{let e=s;if(b&&o.scheme==="file")return s--,f(e,A)?gA(a(l,s)):0;if(A!=null&&A!==58&&A!==35&&A!==47&&A!==63&&(A!==92||!C(o.scheme))){let t=s+E(A);for(A===91?O=!0:A===93&&(O=!1);t<l.length;){let r=a(l,t);if(r==null||!O&&r===58||r===35||r===47||r===63||r===92&&C(o.scheme))break;r===91?O=!0:r===93&&(O=!1),t+=E(r)}return g+=l.slice(s,t),s=t-1,f(e,A)?J(a(l,s)):0}else if(A===58&&!O){if(g===""||b===4)return 1;let t=lA(g,!C(o.scheme));return t===null?1:(o.host=oA(t),g="",f(e,A)?hA(a(l,s)):0)}else if(A==null||A===35||A===47||A===63||A===92&&C(o.scheme)){if(s--,C(o.scheme)&&g==="")return 1;if(b&&g===""&&(OA(o)||o.port!==null))return 1;let t=lA(g,!C(o.scheme));return t===null?1:(o.host=oA(t),g="",b?0:f(e,A)?N(a(l,s)):0)}else return g+=NA(A),f(e,A)?J(a(l,s)):0},hA=A=>{let e=s;if(A!=null&&A>=48&&A<=57){let t=s+1;for(;t<l.length;){let r=l.charCodeAt(t);if(r<48||r>57)break;t++}return g+=l.slice(s,t),s=t-1,f(e,A)?hA(a(l,s)):0}else if(b||A==null||A===35||A===47||A===63||A===92&&C(o.scheme)){if(g!==""){let t=parseInt(g,10);if(t>65535)return 1;if(o.port=t===RA(o.scheme)?null:t,g="",b)return 0}return b?1:(s--,f(e,A)?N(a(l,s)):0)}else return 1};function MA(A,e){let t=A.length-e;if(t<2)return!1;if(zA(a(A,e),a(A,e+1))){if(t===2)return!0;{let r=a(A,e+2);return r===47||r===92||r===63||r===35}}else return!1}var pA=A=>{let e=s;return o.scheme="file",o.host="",A===47||A===92?f(e,A)?we(a(l,s)):0:m?.scheme==="file"?(o.host=m.host,o.path=m.path.slice(),o.opaquePath=m.opaquePath,o.query=m.query,A===63?(o.query="",f(e,A)?L(a(l,s)):0):A===35?(o.fragment="",f(e,A)?z(a(l,s)):0):A!=null?(o.query=null,MA(l,s)?o.path=[]:LA(o),s--,f(e,A)?I(a(l,s)):0):f(e,A)?pA(a(l,s)):0):(s--,f(e,A)?I(a(l,s)):0)},we=A=>{let e=s;return A===47||A===92?f(e,A)?gA(a(l,s)):0:(m!==null&&m.scheme==="file"&&(!MA(l,s)&&(function(r){if(r.length===2){let n=r.codePointAt(0),c=r.codePointAt(1);return(n>=65&&n<=90||n>=97&&n<=122)&&c===58}else return!1})(m.path[0])&&o.path.push(m.path[0]),o.host=m.host),s--,f(e,A)?I(a(l,s)):0)},gA=A=>{let e=s;if(A!=null&&A!==47&&A!==92&&A!==63&&A!==35){let t=s+E(A);for(;t<l.length;){let r=a(l,t);if(r==null||r===47||r===92||r===63||r===35)break;t+=E(r)}return g+=l.slice(s,t),s=t-1,f(e,A)?gA(a(l,s)):0}else if(A==null||A===47||A===92||A===63||A===35){if(s--,!b&&HA(g))return f(e,A)?I(a(l,s)):0;if(g==="")return o.host="",b?0:f(e,A)?N(a(l,s)):0;{let t=lA(g,!C(o.scheme));return t===null?1:(t==="localhost"&&(t=""),o.host=oA(t),g="",b?0:f(e,A)?N(a(l,s)):0)}}return 1},N=A=>{let e=s;return C(o.scheme)?(A!==92&&A!==47&&s--,f(e,A)?I(a(l,s)):0):!b&&A===63?(o.query="",f(e,A)?L(a(l,s)):0):!b&&A===35?(o.fragment="",f(e,A)?z(a(l,s)):0):A!=null?(A!==47&&s--,f(e,A)?I(a(l,s)):0):(b&&o.host===null&&o.path.push(""),f(e,A)?N(a(l,s)):0)},I=A=>{let e=s;if(A!=null&&A!==47&&(!C(o.scheme)||A!==92)&&(b||A!==63&&A!==35)){let t=s+E(A);for(;t<l.length;){let r=a(l,t);if(r==null||r===47||C(o.scheme)&&r===92||!b&&(r===63||r===35))break;t+=E(r)}g+=U(l.slice(s,t),nA),s=t,A=a(l,t)}if(A==null||A===47||C(o.scheme)&&A===92||!b&&(A===63||A===35)){let t=C(o.scheme)&&A===92;return(function(n){switch(n){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)?(LA(o),A!==47&&!t&&o.path.push("")):qA(g)&&A!==47&&!t?o.path.push(""):qA(g)||(o.scheme==="file"&&o.path.length===0&&HA(g)&&(g=`${g[0]}:`),o.path.push(g)),g="",A===63?(o.query="",f(e,A)?L(a(l,s)):0):A===35?(o.fragment="",f(e,A)?z(a(l,s)):0):f(e,A)?I(a(l,s)):0}else return g+=kA(A,nA),f(e,A)?I(a(l,s)):0},xA=A=>{let e=s;if(A===63)return o.query="",f(e,A)?L(a(l,s)):0;if(A===35)return o.fragment="",f(e,A)?z(a(l,s)):0;if(A!=null){let t=s+E(A);for(;t<l.length;){let n=a(l,t);if(n===63||n===35)break;t+=E(n)}let r=l.slice(s,t);if(t<l.length&&r.charCodeAt(r.length-1)===32?o.path[0]+=U(r.slice(0,-1),T)+"%20":o.path[0]+=U(r,T),s=t,(A=a(l,t))===63)return o.query="",f(e,A)?L(a(l,s)):0;if(A===35)return o.fragment="",f(e,A)?z(a(l,s)):0}return f(e,A)?xA(a(l,s)):0},L=A=>{let e=s,t=s;if(A!=null){if(b)t=l.length;else{let n=l.indexOf("#",s);t=n===-1?l.length:n}let r=C(o.scheme)?YA:cA;o.query+=U(l.slice(s,t),r)}return s=t,a(l,t)===35&&!b?(o.fragment="",f(e,A)?z(a(l,s)):0):f(e,A)?L(a(l,s)):0},z=A=>{let e=s;return A!=null&&(o.fragment+=U(l.slice(s),_A),s=l.length),f(e,A)?z(a(l,s)):0};function uA(A){if(A.opaquePath)return A.path[0];{let e="";for(let t of A.path)e+=`/${t}`;return e}}function TA(A){switch(A.scheme){case"blob":{let e=v(uA(A),null,null,0);return e===null||e.scheme!=="http"&&e.scheme!=="https"?"null":TA(e)}case"ftp":case"http":case"https":case"ws":case"wss":return(function(t){let r=`${t.scheme}://`;return r+=t.host,t.port!==null&&(r+=`:${t.port}`),r})(A);default:return"null"}}var w=Symbol("URLImpl"),j=class A{constructor(e,t){if(e===void 0&&t===void 0)throw new TypeError('The "url" argument must be specified.');e=P(e),t!=null&&(t=P(t));let r=null;if(t!=null&&(r=v(t,null,null,0),r==null))throw new TypeError(`Invalid base URL: ${t}`);let n=v(e,null,r,0);if(n==null)throw new TypeError(`Invalid URL: ${e}`);this[w]={url:n,query:null}}static createObjectURL(e){throw new TypeError("URL.createObjetURL is unsupported")}static revokeObjectURL(e){}static parse(e,t){e=P(e),t!==void 0&&(t=P(t));try{return new A(e,t)}catch{return null}}static canParse(e,t){e=P(e),t!==void 0&&(t=P(t));let r=null;return t!=null&&(r=v(t,null,null,0),r==null)?!1:v(e,null,r,0)!=null}get href(){return(function(t){let r=`${t.scheme}:`;return t.host!==null&&(r+="//",(t.username!==""||t.password!=="")&&(r+=t.username,t.password!==""&&(r+=`:${t.password}`),r+="@"),r+=t.host,t.port!==null&&(r+=`:${t.port}`)),t.host===null&&!t.opaquePath&&t.path.length>1&&t.path[0]===""&&(r+="/."),r+=uA(t),t.query!==null&&(r+=`?${t.query}`),t.fragment!==null&&(r+=`#${t.fragment}`),r})(this[w].url)}set href(e){let t=v(e=P(e),null,null,0);if(t==null)throw new TypeError(`Invalid URL: ${e}`);this[w].url=t,this[w].query&&AA(this[w].query,t.query)}get origin(){return TA(this[w].url)}get protocol(){return`${this[w].url.scheme}:`}set protocol(e){v(`${e=P(e)}:`,this[w].url,null,2)}get username(){return this[w].url.username}set username(e){e=P(e),Z(this[w].url)||(function(r,n){r.username=U(n,G)})(this[w].url,e)}get password(){return this[w].url.password}set password(e){e=P(e),Z(this[w].url)||(function(r,n){r.password=U(n,G)})(this[w].url,e)}get host(){let{url:e}=this[w];return e.host==null?"":e.port==null?e.host:`${e.host}:${e.port}`}set host(e){e=P(e),this[w].url.opaquePath||v(e,this[w].url,null,3)}get hostname(){let{url:e}=this[w];return e.host!=null?e.host:""}set hostname(e){e=P(e),this[w].url.opaquePath||v(e,this[w].url,null,4)}get port(){let{url:e}=this[w];return e.port!=null?`${e.port}`:""}set port(e){e=P(e);let{url:t}=this[w];Z(t)||(e?v(e,t,null,5):t.port=null)}get pathname(){return uA(this[w].url)}set pathname(e){e=P(e);let{url:t}=this[w];t.opaquePath||(t.path=[],v(e,t,null,6))}get search(){let{url:e}=this[w];return e.query?`?${e.query}`:""}set search(e){e=P(e);let{url:t,query:r}=this[w];if(!e)t.query=null,r&&AA(r,null);else{let n=e[0]==="?"?e.substring(1):e;t.query="",v(n,t,null,7),r&&AA(r,t.query)}}get searchParams(){let e=this[w],t=e.query;return t==null&&(t=e.query=(function(n,c){let i=new W;return i[D].url=n,i[D].serialized=c==null,c&&(i[D].list=aA(c)),i})(this,e.url.query)),t}get hash(){let{url:e}=this[w];return e.fragment?`#${e.fragment}`:""}set hash(e){e=P(e);let{url:t}=this[w];if(!e)t.fragment=null;else{let r=e[0]==="#"?e.substring(1):e;t.fragment="",v(r,t,null,8)}}toJSON(){return this.href}toString(){return this.href}};Object.defineProperty(j.prototype,Symbol.toStringTag,{value:"URL",configurable:!0});var D=Symbol("URLSearchParamsImpl"),Pe=Symbol.dispose||Symbol.for("dispose");function AA(A,e){e?A[D].list=aA(e):A[D].list.length=0,A[D].serialized=e==null}function Q(A){if(A.url){let e=sA(A.list);(function(r,n){r[w].url.query=n})(A.url,e||null),A.serialized=!0}}var ye=typeof Iterator<"u"?Iterator:Object,x=class extends ye{constructor(e,t){super(),this[D]={ptr:e,map:t,index:0}}next(){let e=this[D];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}[Pe](){}},W=class{constructor(e){let t=this[D]={list:[],url:null,serialized:!0},r;if(Array.isArray(e))for(let n=0;n<e.length;n++)t.list.push(yA(e[n]));else if((r=IA(e))!=null){let n;for(;!(n=eA(r.next())).done;)t.list.push(yA(n.value))}else if((typeof e=="object"||typeof e=="function")&&e!=null){let n=Object.keys(e);for(let c=0;c<n.length;c++){let i=n[c],u=QA(i),h=P(e[i]),p=t.list.find(d=>d[0]===u);p?p[1]=h:t.list.push([u,h])}}else if(e!==void 0){let n=P(e);n=n[0]==="?"?n.substring(1):n,t.list=aA(n)}}get size(){return this[D].list.length}append(e,t){e=P(e),t=P(t),this[D].list.push([e,t]);let r=this[D];r.url&&r.serialized?(function(c,i){let u=c[w].url;u.query=u.query?`${u.query}&${i}`:i})(r.url,sA([[e,t]])):Q(r)}delete(e,t){e=P(e),t=t!=null?P(t):void 0;let{list:r}=this[D],n=0;for(;n<r.length;)r[n][0]===e&&(t==null||r[n][1]===t)?r.splice(n,1):n++;Q(this[D])}get(e){e=P(e);let{list:t}=this[D];for(let r=0;r<t.length;r++)if(t[r][0]===e)return t[r][1];return null}getAll(e){e=P(e);let t=[],{list:r}=this[D];for(let n=0;n<r.length;n++)r[n][0]===e&&t.push(r[n][1]);return t}has(e,t){e=P(e),t=t!=null?P(t):void 0;let{list:r}=this[D];for(let n=0;n<r.length;n++)if(r[n][0]===e&&(t==null||r[n][1]===t))return!0;return!1}set(e,t){e=P(e),t=P(t);let{list:r}=this[D],n=!1,c=!1,i=0;for(;i<r.length;)r[i][0]===e?n?(r.splice(i,1),c=!0):(n=!0,r[i][1]!==t&&(r[i][1]=t,c=!0),i++):i++;n||(r.push([e,t]),c=!0),c&&Q(this[D])}sort(){this[D].list.sort((e,t)=>e[0]<t[0]?-1:e[0]>t[0]?1:0),Q(this[D])}forEach(e,t){if(typeof e!="function")throw new TypeError('The "callback" argument must be of type function');let{list:r}=this[D];for(let n=0;n<r.length;n++)e.call(t,r[n][1],r[n][0],this)}entries(){return new x(this[D],e=>e)}keys(){return new x(this[D],e=>e[0])}values(){return new x(this[D],e=>e[1])}toString(){return sA(this[D].list)}[Symbol.iterator](){return this.entries()}};Object.defineProperty(W.prototype,Symbol.toStringTag,{value:"URLSearchParams",configurable:!0});var De=B.trackUsage.request.shape.command,Ce=B.trackUsage.response,be=B.checkEntitlement.request.omit({customerId:!0}).strict();function ke(A){let e=mA.parse(A.scope),t=PA({...A,scope:e},void 0,j),r=wA(A.push,t,e),n=0,c=!1;return{messaging:{async preference(i){let u=B.readMessagingPreference;return u.response.parse(await t.request(u.path,u.request.parse({channel:i}))).preference},async setPreference(i){let u=B.setMessagingPreference;return u.response.parse(await t.request(u.path,u.request.parse(i))).preference}},push:{sync:r.sync,read:r.read,recover:r.recover,tokenObserver:r.tokenObserver,recoveryObserver:r.recoveryObserver,async preference(){let i=B.readMessagingPreference;return i.response.parse(await t.request(i.path,{channel:"push"})).preference},async setPreference(i){let u=B.setMessagingPreference;return u.response.parse(await t.request(u.path,u.request.parse({...i,channel:"push"}))).preference}},identify(i){if(!/^gg_ct_[A-Za-z0-9_-]{32,128}$/.test(i))throw new H("INVALID_TOKEN","A Customer Token is required");r.identify(i),n++,t.identify(i),c=!0,r.start()},reset(){try{r.reset()}finally{n++,c=!1,t.reset(),r.start()}},async readHoldings(){let i=B.readHoldings;return X(t.request,i,{})},async checkEntitlement(i){let u=B.checkEntitlement;return X(t.request,{...u,request:be},i)},async trackUsage(i){if(!c)throw new H("UNAUTHENTICATED","Identify the Customer first");if(!A.usageReporter)throw new H("INVALID_REQUEST","Configure your authenticated backend usageReporter");let u=De.parse(i),h=n,p;try{p=await A.usageReporter(u)}catch(y){throw h!==n?new H("IDENTITY_CHANGED","Customer identity changed during usage reporting"):y}if(h!==n)throw new H("IDENTITY_CHANGED","Customer identity changed during usage reporting");let d=Ce.parse(p);if(d.scope.projectId!==e.projectId||d.scope.environment!==e.environment)throw new H("INVALID_RESPONSE","Usage response scope differs");return d}}}export{H as IndianaError,ke as createIndianaReactNative};
1
+ import{a as wA}from"./chunk-663UOBHL.js";import{a as X}from"./chunk-VVV3JNS3.js";import{a as PA}from"./chunk-SSHUBTT3.js";import{Yi as B}from"./chunk-EJTBSGLV.js";import{a as H}from"./chunk-SOQO2RDZ.js";import"./chunk-LMR2TM3X.js";import{b as mA}from"./chunk-OBYJWIRB.js";import"./chunk-EXCPE2XH.js";import"./chunk-RRII2DMC.js";import"./chunk-KQCTDXVD.js";function P(A){return typeof A=="string"?A:String(A)}var jA=/[\ud800-\udbff](?![\udc00-\udfff])|(^|[^\ud800-\udbff])[\udc00-\udfff]/g;function QA(A){return A.replace(jA,"$1\uFFFD")}function eA(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 IA(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 yA(A){let e;if(Array.isArray(A)){let t=A.map(P);if(t.length===2)return t}else if((e=IA(A))!=null){let t=eA(e.next()),r=eA(e.next());if(!t.done&&!r.done)return[P(t.value),P(r.value)]}throw new TypeError("Each query pair must be an iterable [name, value] tuple")}var DA="0123456789ABCDEF",FA=/(?:%[0-9A-Fa-f]{2})+/g;function k(A){return`%${DA[A>>4&15]}${DA[15&A]}`}function BA(A,e,t=!1){return A>=55296&&A<=57343&&(A=65533),A<=127?t&&A===32?"+":e(A)?k(A):String.fromCharCode(A):A<=2047?k(192|A>>6)+k(128|63&A):A<=65535?k(224|A>>12)+k(128|A>>6&63)+k(128|63&A):k(240|A>>18)+k(128|A>>12&63)+k(128|A>>6&63)+k(128|63&A)}function tA(A){return A>=48&&A<=57?A-48:A>=65&&A<=70?A-65+10:A>=97&&A<=102?A-97+10:-1}function rA(A,e=!1){let t=0;for(;t<A.length;t++){let r=A.charCodeAt(t);if(r===37||e&&r===43)break}return t===A.length?A:(e?A.replace(/\+/g," "):A).replace(FA,r=>{try{return decodeURIComponent(r)}catch{return"\uFFFD".repeat(r.length/3)}})}function T(A){return A<=31||A>126}function _A(A){switch(A){case 32:case 34:case 60:case 62:case 96:return!0;default:return T(A)}}function cA(A){switch(A){case 32:case 34:case 35:case 60:case 62:return!0;default:return T(A)}}function YA(A){return cA(A)||A===39}function nA(A){switch(A){case 63:case 94:case 96:case 123:case 125:return!0;default:return cA(A)}}function G(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 nA(A)}}function CA(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 G(t)}})(A)}}function kA(A,e){return BA(A=A||0,e)}function U(A,e,t=!1){let r=0;for(;r<A.length;r++){let c=A.charCodeAt(r);if(c>=128||t&&c===32||e(c))break}if(r===A.length)return A;let n=A.slice(0,r);for(;r<A.length;r++){let c=A.charCodeAt(r),i=c;if(c>=55296&&c<=56319&&r+1<A.length){let u=A.charCodeAt(r+1);u>=56320&&u<=57343&&(i=(c-55296<<10)+u-56320+65536,r++)}n+=BA(i,e,t)}return n}function aA(A){let e=[],t=0,r=0;for(;r<=A.length;){if(r=A.indexOf("&",t),r<0&&(r=A.length),r!==t){let n=A.slice(t,r),c=n.indexOf("=");c<0&&(c=n.length),e.push([rA(n.slice(0,c),!0),rA(n.slice(c+1),!0)])}if(t=r+1,r===A.length)break}return e}function sA(A){let e="";for(let t=0;t<A.length;t++){let r=U(A[t][0],CA,!0),n=U(A[t][1],CA,!0);e+=t!==0?`&${r}=${n}`:`${r}=${n}`}return e}var GA=[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],JA=[7296,7297,7298,7299,7300,7301,7302,7303,7304,42958,42962,42964,42993],WA=["\u0432","\u0434","\u043E","\u0441","\u0442","\u0442","\u044A","\u0463","\uA64B","\uA7CF","\uA7D3","\uA7D5","s"],VA=[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 XA(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[KA,ZA,Ae,bA]=[[[],"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,r]){return[e,t.split(",").map(n=>parseInt(n,36)),Uint8Array.from(atob(r),n=>n.charCodeAt(0))]});function ee(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 UA(A,e){for(let t=0;t<A.length;t+=2)if(e>=A[t]&&e<=A[t+1])return!0;return!1}function M(A,e){let[t,r,n]=A,c=e>>8;for(let h=0;h<t.length;h+=2)if(c>=t[h]&&c<=t[h+1])return!0;let i=r.indexOf(c);if(i<0)return!1;let u=255&e;return!!(n[32*i+(u>>3)]&1<<(7&u))}function te(A){let e=Array.from(A,t=>t.codePointAt(0));for(let t=0;t<e.length;t++){let r=e[t];if(r!==8204&&r!==8205||t>0&&UA(VA,e[t-1]))continue;if(r===8205)return!1;let n=t-1;for(;n>=0&&M(bA,e[n]);)n--;let c=t+1;for(;c<e.length&&M(bA,e[c]);)c++;if(!(n>=0&&c<e.length&&M(ZA,e[n])&&M(Ae,e[c])))return!1}return!0}var re=/(?![\p{Mark}\p{Decimal_Number}])[\p{Script=Arabic}\p{Script=Hebrew}]/u,ne=/\p{Script=Latin}/u;function se(A){return!re.test(A)||!ne.test(A)}var R=36,F=1,iA=26,ie=38,le=700,oe=72,ue=128,ce=2147483647;function SA(A){return String.fromCharCode(A+22+75*+(A<26))}function ae(A,e,t){let r=0;for(A=t?Math.floor(A/le):A>>1,A+=Math.floor(A/e);A>(R-F)*iA>>1;r+=R)A=Math.floor(A/(R-F));return Math.floor(r+(R-F+1)*A/(A+ie))}function fe(A){let e=Array.from(A,h=>h.codePointAt(0)),t="",r=0;for(let h=0;h<e.length;h++){let p=e[h];p<128&&(t+=String.fromCharCode(p),r++)}let n=r;n&&(t+="-");let c=ue,i=0,u=oe;for(;r<e.length;){let h=ce;for(let p=0;p<e.length;p++){let d=e[p];d>=c&&d<h&&(h=d)}i+=(h-c)*(r+1),c=h;for(let p=0;p<e.length;p++){let d=e[p];if(d<c&&i++,d===c){let y=i;for(let S=R;;S+=R){let q=S<=u?F:S>=u+iA?iA:S-u;if(y<q)break;t+=SA(q+(y-q)%(R-q)),y=Math.floor((y-q)/(R-q))}t+=SA(y),u=ae(i,r+1,r===n),i=0,r++}}i++,c++}return t}function K(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 r=0;r<A.length;r++){let n=tA(A.charCodeAt(r));if(n>=e||n<0)return-1;t=t*e+n}return t}function qA(A){switch(A){case".":case"%2e":case"%2E":return!0;default:return!1}}function zA(A,e){return(A>=65&&A<=90||A>=97&&A<=122)&&(e===58||e===124)}function HA(A){return A.length===2&&zA(A.codePointAt(0),A.codePointAt(1))}function vA(A){return A.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|<|>|\?|@|\[|\\|\]|\^|\|/u)!==-1}function C(A){switch(A){case"ftp":case"http":case"https":case"ws":case"wss":case"file":return!0;default:return!1}}function RA(A){switch(A){case"ftp":return 21;case"http":case"ws":return 80;case"https":case"wss":return 443;default:return null}}function lA(A,e){if(A[0]==="[")return A[A.length-1]==="]"?(function(r){let n=[0,0,0,0,0,0,0,0],c=null,i=0,u=0,h=Array.from(r,p=>p.codePointAt(0));if(h[u]===58){if(h[u+1]!==58)return null;u+=2,i++,c=i}for(;u<h.length;){if(i===8)return null;if(h[u]===58){if(c!==null)return null;u++,i++,c=i;continue}let p=0,d=0,y=0;for(;y<4&&(p=tA(h[u]))>=0;)d=(d<<4)+p,u++,y++;if(h[u]===46){if(y===0||i>6)return null;u-=y;let S=0;for(;h[u]!==void 0;){let q=0;if(S>0)if(h[u]===46&&S<4)u++;else return null;if(h[u]==null||h[u]<48||h[u]>57)return null;for(;h[u]>=48&&h[u]<=57;){if(q=10*q+tA(h[u]),q>255)return null;u++}n[i]=256*n[i]+q,S++,S%2==0&&i++}if(S!==4)return null;break}else if(h[u]===58){if(h[++u]===void 0)return null}else if(h[u]!==void 0)return null;n[i]=d,i++}if(c!==null){let p=i-c;for(i=7;i!==0&&p>0;){let d=n[c+p-1];n[c+p-1]=n[i],n[i]=d,i--,p--}}else if(c===null&&i!==8)return null;return n})(A.substring(1,A.length-1)):null;if(e)return(function(r){return vA(r)?null:U(r,T)})(A);{let t=(function(n){let c=!1,i=!1;for(let h=0;h<n.length;h++){let p=n.charCodeAt(h);if(p<=32||p===37||p===127)return null;if(p>=128){c=!0;break}p>=65&&p<=90&&(i=!0)}if(!c)return n!==""?i?n.toLowerCase():n:null;if((function(p){for(let d of p){let y=d.codePointAt(0);if(/[\p{Cn}\p{Co}\p{Cs}\p{Noncharacter_Code_Point}]/u.test(d)&&!UA(GA,y)||M(KA,y))return!0}return!1})(n))return null;let u=(n=(function(p){let d="";for(let y of p){let S=y.codePointAt(0);if(S!==8204&&S!==8205&&/\p{Default_Ignorable_Code_Point}/u.test(y))continue;let q=ee(y,S);if(q){d+=q;continue}let dA=JA.indexOf(S);d+=dA<0?y:WA[dA]}return d})(n).normalize("NFKC").replace(/[\u3002\uff0e\uff61]/g,".").toLowerCase()).split(".");for(let h=0;h<u.length;h++){let p=u[h];if(p==="")continue;let d=/[^\0-\x7f]/.test(p);if(XA(p)||d&&(/^\p{Mark}/u.test(p)||!te(p)||!se(p)||p.startsWith("xn--")))return null;d&&(u[h]=`xn--${fe(p)}`)}return(n=u.join("."))!==""?n:null})(A.indexOf("%")===-1?A:rA(A));return t===null||vA(t)?null:(function(n){let c=n.length,i=n.lastIndexOf(".",c-2)+1;if(n.charCodeAt(c-1)===46&&c--,c<=i)return!1;if(K(n.slice(i,c))>=0)return!0;for(;i<c;i++){let u=n.charCodeAt(i);if(u<48||u>57)return!1}return!0})(t)?(function(n){let c=n.split("."),i=c.length;if(c[i-1]||i--,i>4)return null;let u=0;for(let p=0;p<i-1;p++){let d=K(c[p]);if(d<0||d>255)return null;u+=d*(1<<8*(3-p))}let h=K(c[i-1]);return h<0||h>=256**(5-i)?null:(u+=h,u)})(t):t}}function oA(A){return typeof A=="number"?(function(t){let n="";return n+=`${(t>>>24&255).toString(10)}.`,n+=`${(t>>>16&255).toString(10)}.`,n+=`${(t>>>8&255).toString(10)}.`,n+=(t&255).toString(10),n})(A):Array.isArray(A)?`[${(function(t){let r=(function(u){let h=-1,p=-1,d=1,y=0;for(let S=0;S<u.length;++S)u[S]!==0?(y>d&&(h=p,d=y),p=-1,y=0):(p===-1&&(p=S),++y);return y>d?p:h})(t),n="",c=!1;for(let i=0;i<=7;++i)if(!(c&&t[i]===0)){if(c&&(c=!1),r===i){n+=i===0?"::":":",c=!0;continue}n+=t[i].toString(16),i!==7&&(n+=":")}return n})(A)}]`:A}function LA(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 OA(A){return A.username!==""||A.password!==""}function Z(A){return A.host===null||A.host===""||A.scheme==="file"}var s=0,l="",g="",m=null,o,_=!1,Y=!1,O=!1,b;function v(A,e,t,r){e||(A=(function(i){let u=0,h=i.length;for(;u<h&&!(i.charCodeAt(u)>32);++u);for(;h>u&&!(i.charCodeAt(h-1)>32);--h);return i.substring(u,h)})(A)),A=(function(i){let u=0;for(;u<i.length;u++){let p=i.charCodeAt(u);if(p===9||p===10||p===13)break}if(u===i.length)return i;let h=i.slice(0,u);for(;u<i.length;u++){let p=i.charCodeAt(u);p!==9&&p!==10&&p!==13&&(h+=i[u])}return h})(A),s=0,l=A,g="",m=t||null,o=e||{scheme:"",username:"",password:"",host:null,port:null,path:[],query:null,fragment:null,opaquePath:!1},_=!1,Y=!1,O=!1,b=r||0;let n=he;switch(r){case 3:case 4:n=J;break;case 5:n=hA;break;case 6:n=N;break;case 7:n=L;break;case 8:n=z}return n(a(A,s))!==1?o:null}function f(A,e){return s+=s===A?E(e):1,s<=l.length}function a(A,e){return e<A.length?A.codePointAt(e):void 0}function E(A){return A!=null&&A>65535?2:1}function NA(A){return A==null?"":A<=65535?String.fromCharCode(A):String.fromCodePoint(A)}var he=A=>{let e=s;if(A!=null&&(A>=65&&A<=90||A>=97&&A<=122)){let t=s+1;for(A=l.charCodeAt(t);A===43||A===45||A===46||A>=65&&A<=90||A>=97&&A<=122||A>=48&&A<=57;)t++,A=l.charCodeAt(t);return g=l.slice(s,t).toLowerCase(),s=t,pe(t<l.length?A:void 0)}else return b?1:(--s,f(e,A)?$A(a(l,s)):0)},pe=A=>{let e=s;if(A===58){if(b){if(C(o.scheme)!==C(g))return 0;if((OA(o)||o.port!==null)&&g==="file")return 0;if(o.scheme==="file"&&o.host==="")return 0}return o.scheme=g,b?(o.port===RA(o.scheme)&&(o.port=null),0):(g="",o.scheme==="file"?f(e,A)?pA(a(l,s)):0:C(o.scheme)&&m!==null&&m.scheme===o.scheme?f(e,A)?ge(a(l,s)):0:C(o.scheme)?f(e,A)?me(a(l,s)):0:a(l,s+1)===47?(s++,f(e,A)?de(a(l,s)):0):(o.path=[""],o.opaquePath=!0,f(e,A)?xA(a(l,s)):0))}else return b?1:(g="",s=-1,f(e,A)?$A(a(l,s)):0)},$A=A=>{let e=s;return m===null||m.opaquePath&&A!==35?1:m.opaquePath&&A===35?(o.scheme=m.scheme,o.path=m.path.slice(),o.opaquePath=m.opaquePath,o.query=m.query,o.fragment="",f(e,A)?z(a(l,s)):0):m.scheme==="file"?(s--,f(e,A)?pA(a(l,s)):0):(s--,f(e,A)?fA(a(l,s)):0)},ge=A=>{let e=s;return A===47&&a(l,s+1)===47?(++s,f(e,A)?V(a(l,s)):0):(s--,f(e,A)?fA(a(l,s)):0)},de=A=>{let e=s;return A===47?f(e,A)?$(a(l,s)):0:(s--,f(e,A)?I(a(l,s)):0)},fA=A=>{let e=s;return o.scheme=m.scheme,A===47||C(o.scheme)&&A===92?f(e,A)?EA(a(l,s)):0:(o.username=m.username,o.password=m.password,o.host=m.host,o.port=m.port,o.path=m.path.slice(),o.query=m.query,A===63?(o.query="",f(e,A)?L(a(l,s)):0):A===35?(o.fragment="",f(e,A)?z(a(l,s)):0):A!=null?(o.query=null,o.path.pop(),s--,f(e,A)?I(a(l,s)):0):f(e,A)?fA(a(l,s)):0)},EA=A=>{let e=s;return C(o.scheme)&&(A===47||A===92)?f(e,A)?V(a(l,s)):0:A===47?f(e,A)?$(a(l,s)):0:(o.username=m.username,o.password=m.password,o.host=m.host,o.port=m.port,s--,f(e,A)?I(a(l,s)):0)},me=A=>{let e=s;return A===47&&a(l,s+1)===47?s++:s--,f(e,A)?V(a(l,s)):0},V=A=>{let e=s;return A!==47&&A!==92?(s--,f(e,A)?$(a(l,s)):0):f(e,A)?V(a(l,s)):0},$=A=>{let e=s;if(A!=null&&A!==64&&A!==35&&A!==47&&A!==63&&(A!==92||!C(o.scheme))){let t=s+E(A);for(;t<l.length;){let r=a(l,t);if(r==null||r===64||r===35||r===47||r===63||r===92&&C(o.scheme))break;t+=E(r)}return g+=l.slice(s,t),s=t-1,f(e,A)?$(a(l,s)):0}if(A===64){_&&(g=`%40${g}`),_=!0;for(let t=0;t<g.length;t++){let r=g.codePointAt(t);if(r===58&&!Y){Y=!0;continue}let n=kA(r,G);Y?o.password+=n:o.username+=n,r!=null&&r>65535&&t++}return g="",f(e,A)?$(a(l,s)):0}else return A==null||A===35||A===47||A===63||A===92&&C(o.scheme)?_&&g===""?1:(s-=g.length+1,g="",f(e,A)?J(a(l,s)):0):(g+=NA(A),f(e,A)?$(a(l,s)):0)},J=A=>{let e=s;if(b&&o.scheme==="file")return s--,f(e,A)?gA(a(l,s)):0;if(A!=null&&A!==58&&A!==35&&A!==47&&A!==63&&(A!==92||!C(o.scheme))){let t=s+E(A);for(A===91?O=!0:A===93&&(O=!1);t<l.length;){let r=a(l,t);if(r==null||!O&&r===58||r===35||r===47||r===63||r===92&&C(o.scheme))break;r===91?O=!0:r===93&&(O=!1),t+=E(r)}return g+=l.slice(s,t),s=t-1,f(e,A)?J(a(l,s)):0}else if(A===58&&!O){if(g===""||b===4)return 1;let t=lA(g,!C(o.scheme));return t===null?1:(o.host=oA(t),g="",f(e,A)?hA(a(l,s)):0)}else if(A==null||A===35||A===47||A===63||A===92&&C(o.scheme)){if(s--,C(o.scheme)&&g==="")return 1;if(b&&g===""&&(OA(o)||o.port!==null))return 1;let t=lA(g,!C(o.scheme));return t===null?1:(o.host=oA(t),g="",b?0:f(e,A)?N(a(l,s)):0)}else return g+=NA(A),f(e,A)?J(a(l,s)):0},hA=A=>{let e=s;if(A!=null&&A>=48&&A<=57){let t=s+1;for(;t<l.length;){let r=l.charCodeAt(t);if(r<48||r>57)break;t++}return g+=l.slice(s,t),s=t-1,f(e,A)?hA(a(l,s)):0}else if(b||A==null||A===35||A===47||A===63||A===92&&C(o.scheme)){if(g!==""){let t=parseInt(g,10);if(t>65535)return 1;if(o.port=t===RA(o.scheme)?null:t,g="",b)return 0}return b?1:(s--,f(e,A)?N(a(l,s)):0)}else return 1};function MA(A,e){let t=A.length-e;if(t<2)return!1;if(zA(a(A,e),a(A,e+1))){if(t===2)return!0;{let r=a(A,e+2);return r===47||r===92||r===63||r===35}}else return!1}var pA=A=>{let e=s;return o.scheme="file",o.host="",A===47||A===92?f(e,A)?we(a(l,s)):0:m?.scheme==="file"?(o.host=m.host,o.path=m.path.slice(),o.opaquePath=m.opaquePath,o.query=m.query,A===63?(o.query="",f(e,A)?L(a(l,s)):0):A===35?(o.fragment="",f(e,A)?z(a(l,s)):0):A!=null?(o.query=null,MA(l,s)?o.path=[]:LA(o),s--,f(e,A)?I(a(l,s)):0):f(e,A)?pA(a(l,s)):0):(s--,f(e,A)?I(a(l,s)):0)},we=A=>{let e=s;return A===47||A===92?f(e,A)?gA(a(l,s)):0:(m!==null&&m.scheme==="file"&&(!MA(l,s)&&(function(r){if(r.length===2){let n=r.codePointAt(0),c=r.codePointAt(1);return(n>=65&&n<=90||n>=97&&n<=122)&&c===58}else return!1})(m.path[0])&&o.path.push(m.path[0]),o.host=m.host),s--,f(e,A)?I(a(l,s)):0)},gA=A=>{let e=s;if(A!=null&&A!==47&&A!==92&&A!==63&&A!==35){let t=s+E(A);for(;t<l.length;){let r=a(l,t);if(r==null||r===47||r===92||r===63||r===35)break;t+=E(r)}return g+=l.slice(s,t),s=t-1,f(e,A)?gA(a(l,s)):0}else if(A==null||A===47||A===92||A===63||A===35){if(s--,!b&&HA(g))return f(e,A)?I(a(l,s)):0;if(g==="")return o.host="",b?0:f(e,A)?N(a(l,s)):0;{let t=lA(g,!C(o.scheme));return t===null?1:(t==="localhost"&&(t=""),o.host=oA(t),g="",b?0:f(e,A)?N(a(l,s)):0)}}return 1},N=A=>{let e=s;return C(o.scheme)?(A!==92&&A!==47&&s--,f(e,A)?I(a(l,s)):0):!b&&A===63?(o.query="",f(e,A)?L(a(l,s)):0):!b&&A===35?(o.fragment="",f(e,A)?z(a(l,s)):0):A!=null?(A!==47&&s--,f(e,A)?I(a(l,s)):0):(b&&o.host===null&&o.path.push(""),f(e,A)?N(a(l,s)):0)},I=A=>{let e=s;if(A!=null&&A!==47&&(!C(o.scheme)||A!==92)&&(b||A!==63&&A!==35)){let t=s+E(A);for(;t<l.length;){let r=a(l,t);if(r==null||r===47||C(o.scheme)&&r===92||!b&&(r===63||r===35))break;t+=E(r)}g+=U(l.slice(s,t),nA),s=t,A=a(l,t)}if(A==null||A===47||C(o.scheme)&&A===92||!b&&(A===63||A===35)){let t=C(o.scheme)&&A===92;return(function(n){switch(n){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)?(LA(o),A!==47&&!t&&o.path.push("")):qA(g)&&A!==47&&!t?o.path.push(""):qA(g)||(o.scheme==="file"&&o.path.length===0&&HA(g)&&(g=`${g[0]}:`),o.path.push(g)),g="",A===63?(o.query="",f(e,A)?L(a(l,s)):0):A===35?(o.fragment="",f(e,A)?z(a(l,s)):0):f(e,A)?I(a(l,s)):0}else return g+=kA(A,nA),f(e,A)?I(a(l,s)):0},xA=A=>{let e=s;if(A===63)return o.query="",f(e,A)?L(a(l,s)):0;if(A===35)return o.fragment="",f(e,A)?z(a(l,s)):0;if(A!=null){let t=s+E(A);for(;t<l.length;){let n=a(l,t);if(n===63||n===35)break;t+=E(n)}let r=l.slice(s,t);if(t<l.length&&r.charCodeAt(r.length-1)===32?o.path[0]+=U(r.slice(0,-1),T)+"%20":o.path[0]+=U(r,T),s=t,(A=a(l,t))===63)return o.query="",f(e,A)?L(a(l,s)):0;if(A===35)return o.fragment="",f(e,A)?z(a(l,s)):0}return f(e,A)?xA(a(l,s)):0},L=A=>{let e=s,t=s;if(A!=null){if(b)t=l.length;else{let n=l.indexOf("#",s);t=n===-1?l.length:n}let r=C(o.scheme)?YA:cA;o.query+=U(l.slice(s,t),r)}return s=t,a(l,t)===35&&!b?(o.fragment="",f(e,A)?z(a(l,s)):0):f(e,A)?L(a(l,s)):0},z=A=>{let e=s;return A!=null&&(o.fragment+=U(l.slice(s),_A),s=l.length),f(e,A)?z(a(l,s)):0};function uA(A){if(A.opaquePath)return A.path[0];{let e="";for(let t of A.path)e+=`/${t}`;return e}}function TA(A){switch(A.scheme){case"blob":{let e=v(uA(A),null,null,0);return e===null||e.scheme!=="http"&&e.scheme!=="https"?"null":TA(e)}case"ftp":case"http":case"https":case"ws":case"wss":return(function(t){let r=`${t.scheme}://`;return r+=t.host,t.port!==null&&(r+=`:${t.port}`),r})(A);default:return"null"}}var w=Symbol("URLImpl"),j=class A{constructor(e,t){if(e===void 0&&t===void 0)throw new TypeError('The "url" argument must be specified.');e=P(e),t!=null&&(t=P(t));let r=null;if(t!=null&&(r=v(t,null,null,0),r==null))throw new TypeError(`Invalid base URL: ${t}`);let n=v(e,null,r,0);if(n==null)throw new TypeError(`Invalid URL: ${e}`);this[w]={url:n,query:null}}static createObjectURL(e){throw new TypeError("URL.createObjetURL is unsupported")}static revokeObjectURL(e){}static parse(e,t){e=P(e),t!==void 0&&(t=P(t));try{return new A(e,t)}catch{return null}}static canParse(e,t){e=P(e),t!==void 0&&(t=P(t));let r=null;return t!=null&&(r=v(t,null,null,0),r==null)?!1:v(e,null,r,0)!=null}get href(){return(function(t){let r=`${t.scheme}:`;return t.host!==null&&(r+="//",(t.username!==""||t.password!=="")&&(r+=t.username,t.password!==""&&(r+=`:${t.password}`),r+="@"),r+=t.host,t.port!==null&&(r+=`:${t.port}`)),t.host===null&&!t.opaquePath&&t.path.length>1&&t.path[0]===""&&(r+="/."),r+=uA(t),t.query!==null&&(r+=`?${t.query}`),t.fragment!==null&&(r+=`#${t.fragment}`),r})(this[w].url)}set href(e){let t=v(e=P(e),null,null,0);if(t==null)throw new TypeError(`Invalid URL: ${e}`);this[w].url=t,this[w].query&&AA(this[w].query,t.query)}get origin(){return TA(this[w].url)}get protocol(){return`${this[w].url.scheme}:`}set protocol(e){v(`${e=P(e)}:`,this[w].url,null,2)}get username(){return this[w].url.username}set username(e){e=P(e),Z(this[w].url)||(function(r,n){r.username=U(n,G)})(this[w].url,e)}get password(){return this[w].url.password}set password(e){e=P(e),Z(this[w].url)||(function(r,n){r.password=U(n,G)})(this[w].url,e)}get host(){let{url:e}=this[w];return e.host==null?"":e.port==null?e.host:`${e.host}:${e.port}`}set host(e){e=P(e),this[w].url.opaquePath||v(e,this[w].url,null,3)}get hostname(){let{url:e}=this[w];return e.host!=null?e.host:""}set hostname(e){e=P(e),this[w].url.opaquePath||v(e,this[w].url,null,4)}get port(){let{url:e}=this[w];return e.port!=null?`${e.port}`:""}set port(e){e=P(e);let{url:t}=this[w];Z(t)||(e?v(e,t,null,5):t.port=null)}get pathname(){return uA(this[w].url)}set pathname(e){e=P(e);let{url:t}=this[w];t.opaquePath||(t.path=[],v(e,t,null,6))}get search(){let{url:e}=this[w];return e.query?`?${e.query}`:""}set search(e){e=P(e);let{url:t,query:r}=this[w];if(!e)t.query=null,r&&AA(r,null);else{let n=e[0]==="?"?e.substring(1):e;t.query="",v(n,t,null,7),r&&AA(r,t.query)}}get searchParams(){let e=this[w],t=e.query;return t==null&&(t=e.query=(function(n,c){let i=new W;return i[D].url=n,i[D].serialized=c==null,c&&(i[D].list=aA(c)),i})(this,e.url.query)),t}get hash(){let{url:e}=this[w];return e.fragment?`#${e.fragment}`:""}set hash(e){e=P(e);let{url:t}=this[w];if(!e)t.fragment=null;else{let r=e[0]==="#"?e.substring(1):e;t.fragment="",v(r,t,null,8)}}toJSON(){return this.href}toString(){return this.href}};Object.defineProperty(j.prototype,Symbol.toStringTag,{value:"URL",configurable:!0});var D=Symbol("URLSearchParamsImpl"),Pe=Symbol.dispose||Symbol.for("dispose");function AA(A,e){e?A[D].list=aA(e):A[D].list.length=0,A[D].serialized=e==null}function Q(A){if(A.url){let e=sA(A.list);(function(r,n){r[w].url.query=n})(A.url,e||null),A.serialized=!0}}var ye=typeof Iterator<"u"?Iterator:Object,x=class extends ye{constructor(e,t){super(),this[D]={ptr:e,map:t,index:0}}next(){let e=this[D];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}[Pe](){}},W=class{constructor(e){let t=this[D]={list:[],url:null,serialized:!0},r;if(Array.isArray(e))for(let n=0;n<e.length;n++)t.list.push(yA(e[n]));else if((r=IA(e))!=null){let n;for(;!(n=eA(r.next())).done;)t.list.push(yA(n.value))}else if((typeof e=="object"||typeof e=="function")&&e!=null){let n=Object.keys(e);for(let c=0;c<n.length;c++){let i=n[c],u=QA(i),h=P(e[i]),p=t.list.find(d=>d[0]===u);p?p[1]=h:t.list.push([u,h])}}else if(e!==void 0){let n=P(e);n=n[0]==="?"?n.substring(1):n,t.list=aA(n)}}get size(){return this[D].list.length}append(e,t){e=P(e),t=P(t),this[D].list.push([e,t]);let r=this[D];r.url&&r.serialized?(function(c,i){let u=c[w].url;u.query=u.query?`${u.query}&${i}`:i})(r.url,sA([[e,t]])):Q(r)}delete(e,t){e=P(e),t=t!=null?P(t):void 0;let{list:r}=this[D],n=0;for(;n<r.length;)r[n][0]===e&&(t==null||r[n][1]===t)?r.splice(n,1):n++;Q(this[D])}get(e){e=P(e);let{list:t}=this[D];for(let r=0;r<t.length;r++)if(t[r][0]===e)return t[r][1];return null}getAll(e){e=P(e);let t=[],{list:r}=this[D];for(let n=0;n<r.length;n++)r[n][0]===e&&t.push(r[n][1]);return t}has(e,t){e=P(e),t=t!=null?P(t):void 0;let{list:r}=this[D];for(let n=0;n<r.length;n++)if(r[n][0]===e&&(t==null||r[n][1]===t))return!0;return!1}set(e,t){e=P(e),t=P(t);let{list:r}=this[D],n=!1,c=!1,i=0;for(;i<r.length;)r[i][0]===e?n?(r.splice(i,1),c=!0):(n=!0,r[i][1]!==t&&(r[i][1]=t,c=!0),i++):i++;n||(r.push([e,t]),c=!0),c&&Q(this[D])}sort(){this[D].list.sort((e,t)=>e[0]<t[0]?-1:e[0]>t[0]?1:0),Q(this[D])}forEach(e,t){if(typeof e!="function")throw new TypeError('The "callback" argument must be of type function');let{list:r}=this[D];for(let n=0;n<r.length;n++)e.call(t,r[n][1],r[n][0],this)}entries(){return new x(this[D],e=>e)}keys(){return new x(this[D],e=>e[0])}values(){return new x(this[D],e=>e[1])}toString(){return sA(this[D].list)}[Symbol.iterator](){return this.entries()}};Object.defineProperty(W.prototype,Symbol.toStringTag,{value:"URLSearchParams",configurable:!0});var De=B.trackUsage.request.shape.command,Ce=B.trackUsage.response,be=B.checkEntitlement.request.omit({customerId:!0}).strict();function ke(A){let e=mA.parse(A.scope),t=PA({...A,scope:e},void 0,j),r=wA(A.push,t,e),n=0,c=!1;return{messaging:{async preference(i){let u=B.readMessagingPreference;return u.response.parse(await t.request(u.path,u.request.parse({channel:i}))).preference},async setPreference(i){let u=B.setMessagingPreference;return u.response.parse(await t.request(u.path,u.request.parse(i))).preference}},push:{sync:r.sync,read:r.read,recover:r.recover,tokenObserver:r.tokenObserver,recoveryObserver:r.recoveryObserver,async preference(){let i=B.readMessagingPreference;return i.response.parse(await t.request(i.path,{channel:"push"})).preference},async setPreference(i){let u=B.setMessagingPreference;return u.response.parse(await t.request(u.path,u.request.parse({...i,channel:"push"}))).preference}},identify(i){if(!/^gg_ct_[A-Za-z0-9_-]{32,128}$/.test(i))throw new H("INVALID_TOKEN","A Customer Token is required");r.identify(i),n++,t.identify(i),c=!0,r.start()},reset(){try{r.reset()}finally{n++,c=!1,t.reset(),r.start()}},async readHoldings(){let i=B.readHoldings;return X(t.request,i,{})},async checkEntitlement(i){let u=B.checkEntitlement;return X(t.request,{...u,request:be},i)},async trackUsage(i){if(!c)throw new H("UNAUTHENTICATED","Identify the Customer first");if(!A.usageReporter)throw new H("INVALID_REQUEST","Configure your authenticated backend usageReporter");let u=De.parse(i),h=n,p;try{p=await A.usageReporter(u)}catch(y){throw h!==n?new H("IDENTITY_CHANGED","Customer identity changed during usage reporting"):y}if(h!==n)throw new H("IDENTITY_CHANGED","Customer identity changed during usage reporting");let d=Ce.parse(p);if(d.scope.projectId!==e.projectId||d.scope.environment!==e.environment)throw new H("INVALID_RESPONSE","Usage response scope differs");return d}}}export{H as IndianaError,ke as createIndianaReactNative};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,g as f,h as g,i as h,j as i}from"./chunk-BUDTHBFF.js";import"./chunk-SSLZKIIU.js";import"./chunk-SOQO2RDZ.js";import"./chunk-LMR2TM3X.js";import"./chunk-DSPLGTQI.js";import"./chunk-RRII2DMC.js";import"./chunk-KQCTDXVD.js";export{f as formatCustomerDecimal,b as hostedRendererScript,a as hostedRendererShell,d as inspectCustomHtml,i as mountScreenPreview,h as preparePopup,e as prepareScreen,c as sanitizeCustomHtml,g as showPopup};
package/dist/server.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- import { F as FoundationApi, I as InvoiceModeParams } from './api-B3FIE41b.js';
2
- import { u as IndianaServerOptions, v as FunnelLocalConfiguration, p as PaywallStartInput, g as PaywallSession, h as FeatureClientOptions, R as RemoteFeatureResult } from './funnel-local-client-wbz-4gFx.js';
3
- export { k as FeatureClient, l as FunnelNodeEvaluationContext, j as FunnelStartInput, L as LocalFunnelClient, n as LocalFunnelClientOptions, q as createFeatureClient, w as createFunnelStartClient, r as createLocalFunnelClient, t as evaluateFunnelNode } from './funnel-local-client-wbz-4gFx.js';
1
+ import { F as FoundationApi, I as InvoiceModeParams } from './api-XDc4pRlN.js';
2
+ import { u as IndianaServerOptions, v as FunnelLocalConfiguration, p as PaywallStartInput, g as PaywallSession, h as FeatureClientOptions, R as RemoteFeatureResult } from './funnel-local-client-CUGavICI.js';
3
+ export { k as FeatureClient, l as FunnelNodeEvaluationContext, j as FunnelStartInput, L as LocalFunnelClient, n as LocalFunnelClientOptions, q as createFeatureClient, w as createFunnelStartClient, r as createLocalFunnelClient, t as evaluateFunnelNode } from './funnel-local-client-CUGavICI.js';
4
4
  import * as zod from 'zod';
5
5
  import { z } from 'zod';
6
6
  import { S as StackNode } from './screen-BpAejkn0.js';
7
- import { C as ConfigurationSync } from './configuration-sync-DNvKXHk-.js';
8
- export { c as createConfigurationSync } from './configuration-sync-DNvKXHk-.js';
7
+ import { C as ConfigurationSync } from './configuration-sync-Ce3dShy7.js';
8
+ export { c as createConfigurationSync } from './configuration-sync-Ce3dShy7.js';
9
9
  import { J as JsonValue, E as EvaluationContext, s as stickyAssignmentDocumentSchema, F as FeatureResult } from './growth-rules-B4YYy64R.js';
10
10
  import { I as IndianaError } from './errors-C8lRYZ0n.js';
11
- export { d as AiPricingOptions, b as AiTokenQuote, a as AiTokenUsage, A as AiUsageContext, e as AiUsageMiddlewareOptions, f as AiUsageRecord, g as aiPriceSnapshotSchema, h as aiTokenQuoteSchema, c as createAiPricing, i as createAiUsageMiddleware, j as createConfiguredAiPricing } from './ai-usage-BV-FlgWr.js';
11
+ export { d as AiPricingOptions, b as AiTokenQuote, a as AiTokenUsage, A as AiUsageContext, e as AiUsageMiddlewareOptions, f as AiUsageRecord, g as aiPriceSnapshotSchema, h as aiTokenQuoteSchema, c as createAiPricing, i as createAiUsageMiddleware, j as createConfiguredAiPricing } from './ai-usage-DUlre7JC.js';
12
12
  import 'zod/v4';
13
13
  import '@ai-sdk/provider';
14
14
 
@@ -238,7 +238,7 @@ declare function renewFunnelRun(options: IndianaServerOptions, input: {
238
238
  revision: number;
239
239
  visit: number;
240
240
  nodeId: string;
241
- nodeType: "output" | "action" | "feature" | "split" | "condition" | "coupon" | "end" | "screen" | "offering" | "coupons" | "entry" | "external_page" | "wait";
241
+ nodeType: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
242
242
  status: "failed" | "completed" | "running" | "closed" | "ineligible" | "waiting";
243
243
  stopped: boolean;
244
244
  canBack: boolean;
@@ -1887,7 +1887,7 @@ declare function createFunnelLocalEvaluator(options: FunnelLocalEvaluatorOptions
1887
1887
  entry: string;
1888
1888
  nodes: {
1889
1889
  id: string;
1890
- type: "output" | "action" | "feature" | "split" | "condition" | "coupon" | "end" | "screen" | "offering" | "coupons" | "entry" | "external_page" | "wait";
1890
+ type: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
1891
1891
  outputs: Record<string, string>;
1892
1892
  writes: Record<string, string>;
1893
1893
  resources: {
@@ -2139,7 +2139,7 @@ declare function createSynchronizedFunnelLocalEvaluator(configuration: Configura
2139
2139
  entry: string;
2140
2140
  nodes: {
2141
2141
  id: string;
2142
- type: "output" | "action" | "feature" | "split" | "condition" | "coupon" | "end" | "screen" | "offering" | "coupons" | "entry" | "external_page" | "wait";
2142
+ type: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
2143
2143
  outputs: Record<string, string>;
2144
2144
  writes: Record<string, string>;
2145
2145
  resources: {
@@ -2429,7 +2429,7 @@ declare function createFunnelDecisionClient(options: IndianaServerOptions & {
2429
2429
  entry: string;
2430
2430
  nodes: {
2431
2431
  id: string;
2432
- type: "output" | "action" | "feature" | "split" | "condition" | "coupon" | "end" | "screen" | "offering" | "coupons" | "entry" | "external_page" | "wait";
2432
+ type: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
2433
2433
  outputs: Record<string, string>;
2434
2434
  writes: Record<string, string>;
2435
2435
  resources: {
@@ -2667,7 +2667,7 @@ declare function createFunnelDecisionClient(options: IndianaServerOptions & {
2667
2667
  entry: string;
2668
2668
  nodes: {
2669
2669
  id: string;
2670
- type: "output" | "action" | "feature" | "split" | "condition" | "coupon" | "end" | "screen" | "offering" | "coupons" | "entry" | "external_page" | "wait";
2670
+ type: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
2671
2671
  outputs: Record<string, string>;
2672
2672
  writes: Record<string, string>;
2673
2673
  resources: {
@@ -2695,7 +2695,7 @@ declare function createFunnelDecisionClient(options: IndianaServerOptions & {
2695
2695
  entry: string;
2696
2696
  nodes: {
2697
2697
  id: string;
2698
- type: "output" | "action" | "feature" | "split" | "condition" | "coupon" | "end" | "screen" | "offering" | "coupons" | "entry" | "external_page" | "wait";
2698
+ type: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
2699
2699
  outputs: Record<string, string>;
2700
2700
  writes: Record<string, string>;
2701
2701
  resources: {
@@ -3235,7 +3235,7 @@ declare function createFunnelCampaignClient(options: IndianaServerOptions & {
3235
3235
  revision: number;
3236
3236
  visit: number;
3237
3237
  nodeId: string;
3238
- nodeType: "output" | "action" | "feature" | "split" | "condition" | "coupon" | "end" | "screen" | "offering" | "coupons" | "entry" | "external_page" | "wait";
3238
+ nodeType: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
3239
3239
  status: "failed" | "completed" | "running" | "closed" | "ineligible" | "waiting";
3240
3240
  stopped: boolean;
3241
3241
  canBack: boolean;
package/dist/server.js CHANGED
@@ -1 +1 @@
1
- import{a as K,b as N,c as fe,d as ye,e as ve,g as T,h as Ie,j as ge,k as Pe,l as Ue,m as Me,n as Ve}from"./chunk-Y32NPIYY.js";import"./chunk-GRLMT5PR.js";import{a as Be,b as Ge,c as je,d as qe}from"./chunk-SHSNIJJM.js";import{a}from"./chunk-VVV3JNS3.js";import{a as A}from"./chunk-2QPETWDX.js";import{Ki as r,Mj as pe,Nf as _,Nj as le,Of as O,Pf as ie,Si as j,Xe as te,ej as q,fj as se,gj as ce,hf as G,if as oe,ij as D,jj as ue,kf as ae,mk as de,ok as me,qc as B,tc as X,xc as ee}from"./chunk-ZT66RIFU.js";import{a as o}from"./chunk-SOQO2RDZ.js";import{Mb as re}from"./chunk-LMR2TM3X.js";import{b as $,h as ne}from"./chunk-OBYJWIRB.js";import"./chunk-EXCPE2XH.js";import{b as Z,q as W}from"./chunk-RRII2DMC.js";import{d as J}from"./chunk-KQCTDXVD.js";function we(e){return{async getCustomer(t){let n=r.getCustomer;return a(e,n,t,{request:"Invalid customer lookup",response:"Invalid customer response"})},async listCustomers(t={}){let n=r.listCustomers;return a(e,n,t,{request:"Invalid customer filters",response:"Invalid customer response"})},async updateCustomer(t){let n=r.updateCustomer;return a(e,n,t,{request:"Invalid customer patch",response:"Invalid customer response"})},async createGuestCustomer(t){let n=r.createGuestCustomer;return a(e,n,t)},async resumeGuestSession(t){let n=r.resumeGuestSession;return a(e,n,t)},async claimGuestCustomer(t){let n=r.claimGuestCustomer;return a(e,n,t)},async renewCustomerSession(t){let n=r.renewSession;return a(e,n,t)},async revokeCustomerSessions(t){let n=r.revokeSessions;return a(e,n,t)},async createCustomerSession(t){return a(e,r.createSession,{customerId:t},{request:"A customer ID is required",response:"Invalid customer session response"})},async getOrCreateCustomer(t){return a(e,r.createCustomer,t,{request:"Invalid customer input",response:"Invalid customer response"})}}}function u(e,t){try{return e.parse(t)}catch{throw new o("INVALID_RESPONSE","Invalid gateway response")}}function he(e){return{async checkEntitlement(t){let n=r.checkEntitlement;return a(e,n,t,u)},async readHoldings(t){let n=r.readHoldings;return a(e,n,t,u)},async readSeats(t){let n=r.readSeats;return a(e,n,t,u)},async manageSeat(t){let n=r.manageSeat;return a(e,n,t,u)}}}function Se(e){return{async readAiPricing(t){let n=r.readAiPricing;return a(e,n,t,u)},async readUsage(t){let n=r.readUsage;return a(e,n,t,u)},async setUsage(t){let n=r.setUsage;return a(e,n,t,u)},async manageBalanceGrant(t){let n=r.manageBalanceGrant;return a(e,n,t,u)},async readBalanceSource(t){let n=r.readBalanceSource;return a(e,n,t,u)},async adjustBalance(t){let n=r.adjustBalance;return a(e,n,t,u)},async listBalanceGrants(t){let n=r.listBalanceGrants;return a(e,n,t,u)},async manageBillingLimits(t){let n=r.manageBillingLimits;return a(e,n,t,u)},async manageUsageEntity(t){let n=r.manageUsageEntity;return a(e,n,t,u)},async readUsageAnalytics(t){let n=r.readUsageAnalytics;return a(e,n,t,u)},async readCreditAnalytics(t){let n=r.readCreditAnalytics;return a(e,n,t,u)},async submitUsageBatch(t){let n=r.submitUsageBatch;return a(e,n,t,u)},async readUsageBatch(t){let n=r.readUsageBatch;return a(e,n,t,u)},async readLedger(t){let n=r.readLedger;return a(e,n,t,u)},async readCreditStatement(t){let n=r.readCreditStatement;return a(e,n,t,u)},async quoteBalance(t){let n=r.quoteBalance;return a(e,n,t,u)},async trackUsage(t){let n=r.trackUsage;return a(e,n,t,u)},async mutateBalance(t){let n=r.mutateBalance;return a(e,n,t,u)}}}function Ee(e){return{async listInvoiceTemplates(t={}){let n=r.listInvoiceTemplates;return a(e,n,t,u)},async previewInvoice(t){let n=r.previewInvoice;return a(e,n,t,u)},async createInvoice(t){let n=r.createInvoice;return a(e,n,t,u)},async manageInvoice(t){let n=r.manageInvoice;return a(e,n,t,u)},async readInvoiceOperation(t){let n=r.readInvoiceOperation;return a(e,n,t,u)},async listInvoices(t){let n=r.listInvoices;return a(e,n,t,u)},async getInvoice(t){let n=r.getInvoice;return a(e,n,t,u)},async setupPayment(t){let n=r.setupPayment;return a(e,n,t,u)},async readPaymentSetup(t){let n=r.readPaymentSetup;return a(e,n,t,u)},async readBillingInvoice(t){let n=r.readBillingInvoice;return a(e,n,t,u)},async previewRefund(t){let n=r.previewRefund;return a(e,n,t,u)},async refund(t){let n=r.refund;return a(e,n,t,u)},async readRefund(t){let n=r.readRefund;return a(e,n,t,u)}}}function Ae(e){return{async previewSubscriptionBatch(t){let n=r.previewSubscriptionBatch;return a(e,n,t,u)},async confirmSubscriptionBatch(t){let n=r.confirmSubscriptionBatch;return a(e,n,t,u)},async readSubscriptionBatch(t){let n=r.readSubscriptionBatch;return a(e,n,t,u)},async abandonSubscriptionBatch(t){let n=r.abandonSubscriptionBatch;return a(e,n,t,u)},async manageSubscriptionTrial(t){let n=r.manageSubscriptionTrial;return a(e,n,t,u)},async readSubscriptionTrial(t){let n=r.readSubscriptionTrial;return a(e,n,t,u)},async listSubscriptions(t){let n=r.listSubscriptions;return a(e,n,t,u)},async listPurchases(t){let n=r.listPurchases;return a(e,n,t,u)},async listSubscriptionConflicts(t){let n=r.listSubscriptionConflicts;return a(e,n,t,u)},async retrySubscriptionConflict(t){let n=r.retrySubscriptionConflict;return a(e,n,t,u)},async previewUpdate(t){let n=r.previewUpdate;return a(e,n,t,u)},async update(t){let n=r.update;return a(e,n,t,u)},async readSubscriptionUpdate(t){let n=r.readSubscriptionUpdate;return a(e,n,t,u)},async restoreNativePurchase(t){let n=r.restoreNativePurchase;return a(e,n,t,u)},async verifySubscriptions(t){let n=r.verifySubscriptions;return a(e,n,t,u)},async previewAttach(t){let n=r.previewAttach;return a(e,n,t,u)},async attach(t){let n=r.attach;return a(e,n,t,u)},async readSubscriptionOperation(t){let n=r.readSubscriptionOperation;return a(e,n,t,u)}}}function Fe(e){return{async recordCouponRedemption(t){return a(e,r.recordCouponRedemption,t,{request:"Invalid Coupon redemption facts",parseResponse:u})},async grantOffer(t){let n=r.grantOffer;return a(e,{...n,request:n.request.refine(c=>!!c.customerId)},{...t,requestId:t.requestId??crypto.randomUUID()},{request:"Invalid offer grant",response:"Invalid offer response"})}}}function Ce(e){return{...he(e),...Se(e),...Ee(e),...Ae(e),...Fe(e)}}function Re(e){return{async getFeatures(t={}){let n=r.getFeatures;return a(e,n,t,u)},async evaluateFeatures(t){let n=r.evaluateFeatures;return a(e,n,t,u)}}}function Oe(e){return{async trackEvents(t){let n=r.trackEvents;return a(e,n,t,u)}}}function be(e){return{async resolveContent(t){let n=r.resolveContent;return a(e,n,t,u)},async resolvePaywall(t){let n=r.resolvePaywall;return a(e,n,t,u)},async resolveOffering(t){let n=r.resolveOffering;return a(e,n,t,u)}}}function Ke(e){if(typeof window<"u")throw new o("SERVER_ONLY","Secret API keys must stay on your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(e.apiKey))throw new o("INVALID_TOKEN","A server API key is required");let t=A(e);t.identify(e.apiKey);let n=t.request;return{async sendMessage(c){let i=r.sendMessage;return i.response.parse(await n(i.path,i.request.parse(c)))},async readMessage(c){let i=r.readMessage;return i.response.parse(await n(i.path,i.request.parse(c)))},...we(n),...Ce(n),...Re(n),...Oe(n),...be(n)}}function ze(){if(typeof window<"u")throw new o("SERVER_ONLY","Guest identity is issued by your backend");let e=crypto.getRandomValues(new Uint8Array(32));return"gg_gc_"+btoa(String.fromCharCode(...e)).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}async function Ye(e,t){if(typeof window<"u")throw new o("SERVER_ONLY","Renewal requires your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(e.apiKey))throw new o("INVALID_TOKEN","A server API key is required");let{funnelCredentialCommandSchema:n,funnelCredentialResponseSchema:c}=await import("./src-BMJCIMIF.js"),i=A(e);i.identify(e.apiKey);let l=c.parse(await N(e,await i.request("funnels",n.parse({...t,operation:"renew_run"}))));if(l.run.id!==t.runId)throw new o("INVALID_RESPONSE","Run renewal identity changed");return l}function ke(e){let t=ye(e),n=s=>{throw new o("INVALID_RESPONSE",s)};t.nodes.size!==e.topology.nodes.length&&n("Duplicate local node identity"),t.nodes.get(e.topology.entry)?.type!=="entry"&&n("A local Funnel must start at Entry");let c=new Set(["entry","condition","feature","split","end","output"]);for(let s of t.nodes.values()){if(!c.has(s.type))throw new o("SERVER_REQUIRED","This Funnel requires authoritative server execution");if(s.type==="entry"&&s.id!==e.topology.entry&&n("Unexpected Entry node"),["entry","feature"].includes(s.type)&&!s.outputs.next&&n("Local next exit is unavailable"),s.type==="feature"){let p=s.resources.featureKey;(!p||!Object.hasOwn(e.evaluation.variables,s.writes.value)||!Object.hasOwn(t.features,p))&&n("Local Feature definition or declaration is unavailable")}if(s.type==="condition"){let p=e.conditions[s.id];(!p||!s.outputs.default||p.some((f,y)=>f.port!==`case:${y}`||!s.outputs[f.port]))&&n("Local Condition exits are unavailable")}if(s.type==="split"&&(!s.resources.experimentId||!Object.hasOwn(e.growth.experiments,s.resources.experimentId)||!s.outputs.notParticipating)&&n("Local Experiment definition or exit is unavailable"),s.type==="end"||s.type==="output"){let p=e.evaluation.terminals[s.id];if(!p)throw new o("SERVER_REQUIRED","Terminal resource delivery requires the server");Object.keys(s.outputs).length&&n("A terminal cannot have outgoing edges"),p.output?.type==="feature"&&!Object.hasOwn(t.features,p.output.featureKey)&&n("Terminal Feature definition is unavailable")}for(let p of Object.values(s.outputs))t.nodes.has(p)||n("Local target is unavailable")}let i=new Set,l=new Set;function d(s){if(l.has(s)&&n("Local graph contains a cycle"),!i.has(s)){l.add(s);for(let p of Object.values(t.nodes.get(s).outputs))d(p);l.delete(s),i.add(s)}}return d(e.topology.entry),i.size!==t.nodes.size&&n("Local graph contains unreachable nodes"),{evaluate(s){let p={},f=s.context;f.features=t.features,f.savedGroups=t.savedGroups;let y=()=>{f.attributes=te({declarations:e.evaluation.variables,attributes:s.attributes,parameters:s.parameters,answers:{},results:p,savedGroups:t.savedGroups})};y();let g=e.topology.entry,m=0;for(;;){let v=t.nodes.get(g);if(v.type==="end"||v.type==="output"){let I=e.evaluation.terminals[g],w=I.output,S=w?.type==="feature"?t.feature(w.featureKey,f):w?.type==="variable"?ee({source:"variable",key:w.key,...w.path?{path:w.path}:{}},{declarations:e.evaluation.variables,answers:{},results:p,parameters:s.parameters,attributes:s.attributes,savedGroups:t.savedGroups}):w?.value??null;return B(e.evaluation.outputSchema,S)||n("Local output does not match its declaration"),{outcome:I.outcome,value:S}}if(m++>=e.evaluation.maxTransitions)throw new o("TRANSITION_LIMIT","Local Funnel transition budget exceeded");if(v.type==="entry")g=v.outputs.next;else{let I=t.evaluate(g,f);if(v.type==="feature"){let w=v.writes.value,S=I.value??null;B(e.evaluation.variables[w],S)||n("Local Feature value does not match its declaration"),X(e.evaluation.variables,{writes:v.writes},{[w]:S}),p[w]=S,y()}g=I.target}}}}}import{z as Le}from"zod";function xe(e,t,n){let c=Z.parse(e.attributes);if(["parameters","answers","results"].some(E=>Object.hasOwn(c,E)))throw new o("INVALID_REQUEST","Flow namespaces cannot be caller attributes");let i=re.parse(e.parameters??{}),l=Le.record(Le.string(),W).parse(e.stickyBucketAssignmentDocs??{});for(let[E,h]of Object.entries(l))if(E!==`${h.attributeName}||${h.attributeValue}`||!Object.hasOwn(c,h.attributeName)||J(c[h.attributeName])!==h.attributeValue)throw new o("INVALID_REQUEST","Sticky document identity does not match this session");let d=e.saveStickyBucketAssignmentDoc,s=e.onFeatureUsage,p=e.onExperimentViewed,f=e.onError,y=new Map,g=new Set,m={},v=Promise.resolve();function I(E){let h=v.then(()=>(n(),E()));return v=h.catch(()=>{}),h}function w(E){try{f?.(E)}catch{}}function S(E){try{let h=E();h&&typeof h.catch=="function"&&h.catch(w)}catch(h){w(h)}}async function k(){for(let[E,h]of y){if(n(),d)try{await d(structuredClone(h))}catch{throw new o("STICKY_SAVE_FAILED","Persist the pending Sticky assignment before using this evaluation")}n(),y.delete(E)}}return{evaluate(E={}){let h=E.track===!0;return I(async()=>{let L=await t();n(L);let Y=new Set(g),H={...m},Q=new Map,M=[],_e={stickyBucketAssignmentDocs:structuredClone(l),saveStickyBucketAssignmentDoc(F){Q.set(`${F.attributeName}||${F.attributeValue}`,structuredClone(F))},...h?{trackedExperiments:Y,trackedFeatureUsage:H,onExperimentViewed(F,R){let V=structuredClone(F),Te=structuredClone(R);p&&M.push(()=>p(structuredClone(V),structuredClone(Te)))},onFeatureUsage(F,R){let V=structuredClone(R);s&&M.push(()=>s(F,structuredClone(V)))}}:{}},Ne=L.program.evaluate({attributes:c,parameters:i,context:_e});n(L);for(let[F,R]of Q)l[F]=R,y.set(F,R);await k(),n(L),h&&(g=Y,m=H);for(let F of M)S(F);let x=L.configuration;return structuredClone({evaluationMode:"local",scope:x.scope,funnelId:x.funnelId,versionId:x.versionId,evaluationRevision:x.evaluationRevision,generation:x.growth.generation,...Ne})})},flush:()=>I(k),get stickyBucketAssignmentDocs(){return n(),structuredClone(l)}}}var He=6e4;function P(e){if(typeof window<"u")throw new o("SERVER_ONLY","Local Funnel sessions run on your backend");let t=$.parse(e.scope),n=e.funnelId,c=e.load,i,l,d,s=0,p=g=>Date.now()>=g.expiresAt;async function f(){if(l)return l;let g=s;i=void 0;let m=(async()=>{let v=await c();if(g!==s)throw new o("IDENTITY_CHANGED","Local evaluator was reset");if(v&&typeof v=="object"&&"evaluationMode"in v&&v.evaluationMode==="remote")throw u(D,v),new o("EVALUATION_MODE","This Funnel requires remote decide");let I=u(ue,v);if(g!==s)throw new o("IDENTITY_CHANGED","Local evaluator was reset");if(I.scope.projectId!==t.projectId||I.scope.environment!==t.environment||I.funnelId!==n)throw new o("SCOPE_MISMATCH","Local configuration scope changed");if(I.growth.scope.projectId!==t.projectId||I.growth.scope.environment!==t.environment||I.growth.expiresAt!==I.expiresAt)throw new o("INVALID_RESPONSE","GB configuration scope or expiry changed");let w=Math.min(Date.now()+He,I.expiresAt?Date.parse(I.expiresAt):1/0);if(Date.now()>=w)throw new o("CONFIGURATION_EXPIRED","Refresh expired local rules");let S=JSON.stringify([t.projectId,t.environment,n,I.versionId,I.evaluationRevision,I.growth.generation]),k=[I.topology,I.conditions,I.evaluation,I.growth.features,I.growth.experiments,I.growth.savedGroups];if(d?.key===S&&!Ie(d.body,k))throw new o("INVALID_RESPONSE","Immutable local configuration identity changed");return d?.key!==S&&(d={key:S,body:k,program:ke(I)}),i={key:S,configuration:I,expiresAt:w,program:d.program},i})();l=m;try{return await m}finally{l===m&&(l=void 0)}}function y(){return l??(i&&!p(i)?Promise.resolve(i):f())}return{session(g){let m=s;return xe(g,y,v=>{if(e.assertUsable?.(),m!==s)throw new o("IDENTITY_CHANGED","Local evaluator was reset");if(v&&(p(v)||i?.key!==v.key))throw new o("CONFIGURATION_EXPIRED","Refresh local rules before using this result")})},async refresh(){return structuredClone((await f()).configuration)},reset(){s++,i=void 0,l=void 0,d=void 0}}}function Qe(e,t){let n=e.snapshot?.generation,c=P({scope:{projectId:e.scope.projectId,environment:e.scope.environment},funnelId:t,load:()=>e.localFunnel(t),assertUsable:()=>e.assertFunnel(t)}),i=e.subscribe(()=>{let d=e.snapshot?.generation;e.fresh&&d!==n&&(n=d,c.refresh().catch(()=>{}))}),l=c.session;return Object.assign(c,{session(d){let s=l(d),p=s.evaluate;return Object.assign(s,{async evaluate(...f){return e.fresh||await e.refresh(),p(...f)}})},destroy(){i(),c.reset()}})}function $e(e){if(typeof window<"u")throw new o("SERVER_ONLY","Secret API keys must stay on the backend");return{start:t=>ge(e,t)}}function De(e,t,n){return de(e,t,n,fe)}var b=class extends o{constructor(n,c){super("DECISION_PENDING","Decision is still pending; read this decision ID or retry the original request ID",202,c);this.decisionId=n;this.decisionRequestId=c}decisionId;decisionRequestId};async function U(e,t,n,c){let{decisionId:i,requestId:l}=e,d=e,s=250,p=0;for(;;){if(d.decisionId!==i||d.requestId!==l||d.decision&&!T(d.decision,t))throw new o("INVALID_RESPONSE","Decision request or customer changed");if(d.decision)return d.decision;if(d.status==="failed")throw new o("DECISION_FAILED","Decision execution failed",503,l);if(Date.now()>=n)throw new b(i,l);if(await new Promise(f=>setTimeout(f,Math.min(Math.max(s,p-Date.now()),n-Date.now()))),Date.now()>=n)throw new b(i,l);s=Math.min(1e3,s*2);try{d=await c(i,n)}catch(f){if(f instanceof o&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE","RATE_LIMITED"].includes(f.code)){p=Date.now()+(f.retryAfterSeconds??0)*1e3;continue}throw f}}}function z(e){if("remoteEval"in e)throw new o("INVALID_REQUEST","Configure evaluation mode on the Funnel; remoteEval is not supported");if(typeof window<"u")throw new o("SERVER_ONLY","Funnel decisions are requested by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(e.apiKey))throw new o("INVALID_TOKEN","A server API key is required");let t,n,c=new Map;async function i(p,f){let y=p;y.status!=="pending"&&c.delete(y.decisionId);for(let g=0;g<32&&y.evaluation;g++){let m=y.evaluation;if(m.runId!==y.decisionId)throw new o("INVALID_RESPONSE","Local evaluation Run changed");let v=c.get(y.decisionId);if(!v&&m.type==="evaluate_segment"){let w=me.parse(await l({operation:"segment_configuration",funnelId:e.funnelId,versionId:m.versionId},f));if(w.configuration.scope.projectId!==e.scope.projectId||w.configuration.scope.environment!==e.scope.environment||w.configuration.funnelId!==e.funnelId||w.configuration.versionId!==m.versionId||w.configuration.evaluationRevision!==m.policyRevision)throw new o("SCOPE_MISMATCH","Original decision segment configuration changed");if(c.size>=128)throw new o("COMMAND_PENDING","Reconcile outstanding decisions first");v={operation:"commit_decision_segment",decisionId:y.decisionId,requestId:j(y.decisionId,m.visit,`segment:${m.revision}`),nodeId:m.nodeId,visit:m.visit,revision:m.revision,policyRevision:m.policyRevision,generation:w.configuration.growth.generation,...ve(w.configuration,w.document,m)},c.set(y.decisionId,v)}if(!v){if(m.type!=="evaluate")throw new o("INVALID_RESPONSE","Unknown decision instruction");if((!n||n.versionId!==m.versionId||n.evaluationRevision!==m.policyRevision||n.expiresAt&&Date.parse(n.expiresAt)<=Date.now())&&(n=D.parse(await l({operation:"configuration",funnelId:e.funnelId,versionId:m.versionId},f))),n.scope.projectId!==e.scope.projectId||n.scope.environment!==e.scope.environment||n.funnelId!==e.funnelId)throw new o("SCOPE_MISMATCH","Local evaluation configuration scope changed");if(n.evaluationMode!=="local"||n.versionId!==m.versionId||n.evaluationRevision!==m.policyRevision)throw new o("EVALUATION_MODE","Original Local evaluation policy is unavailable");if(c.size>=128)throw new o("COMMAND_PENDING","Reconcile outstanding Local decisions first");v={operation:"evaluate_decision",decisionId:y.decisionId,requestId:j(y.decisionId,m.visit,"evaluation"),nodeId:m.nodeId,visit:m.visit,revision:m.revision,receiptId:m.receiptId,policyRevision:m.policyRevision,generation:n.growth.generation,result:De(n,m.nodeId,m)},c.set(y.decisionId,v)}let I=O.parse(await l(v,f));if(I.decisionId!==p.decisionId||I.requestId!==p.requestId)throw new o("INVALID_RESPONSE","Decision identity changed during local evaluation");c.delete(y.decisionId),y=I}return y}async function l(p,f,y=!1){let g=A({...e,fetch:(m,v)=>{let I=new Headers(v?.headers);return I.set("Accept-Encoding","identity"),y&&I.set("Prefer","respond-async"),(e.fetch??globalThis.fetch)(m,{...v,headers:I})},timeoutMs:Math.min(e.timeoutMs??1e4,f?Math.max(1,f-Date.now()):12e4)});return g.identify(e.apiKey),g.request("funnels",p)}async function d(p,f){let y=O.parse(await l(_.parse({operation:"read_decision",decisionId:p}),f));if(y.decisionId!==p)throw new o("INVALID_RESPONSE","Decision identity changed");return i(y,f)}async function s(p,f,y=!1){let g=_.options[0].parse({...p,operation:"decide",funnelId:e.funnelId}),m;try{m=O.parse(await l(g,f,y))}catch(v){throw v instanceof o&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE"].includes(v.code)?new o("DECISION_ACCEPTANCE_UNKNOWN","Decision acceptance is unknown; retry the original request ID and input",v.status,p.requestId):v}if(m.requestId!==p.requestId||m.decision&&!T(m.decision,g.customer))throw new o("INVALID_RESPONSE","Decision request or customer changed");return{response:await i(m,f),customer:g.customer}}return{local(){return t??=P({scope:e.scope,funnelId:e.funnelId,load:()=>l({operation:"local_configuration",funnelId:e.funnelId})})},async configuration(){let p=D.parse(await l({operation:"configuration",funnelId:e.funnelId}));if(p.scope.projectId!==e.scope.projectId||p.scope.environment!==e.scope.environment||p.funnelId!==e.funnelId)throw new o("SCOPE_MISMATCH","Configuration scope changed");return p},features(p={}){return K({...p,scope:e.scope,load:async()=>ne.parse(await l({operation:"feature_config",funnelId:e.funnelId}))})},read:p=>d(p),async submit(p){return(await s(p,void 0,!0)).response},async decide(p){let f=Date.now()+3e4,y=await s(p,f);return U(y.response,y.customer,f,d)},async reportUsed(p){let f=ie.parse(await l(_.parse({...p,operation:"report_used"})));if(f.decisionId!==p.decisionId||f.eventId!==p.eventId)throw new o("INVALID_RESPONSE","Usage receipt identity changed");return f}}}function Je(e){if(typeof window<"u")throw new o("SERVER_ONLY","Native receipts are verified by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(e.apiKey))throw new o("INVALID_TOKEN","Server API key required");let t=A({...e,timeoutMs:e.timeoutMs??35e3});return t.identify(e.apiKey),{async recover(n){let c=pe.parse(n);if(c.orderId!==c.receiptId)throw new o("INVALID_REQUEST","Native recovery requires the accepted commercial intent");let i=c.nativeEvidence,l={requestId:c.requestId,customerToken:c.customerToken,purchaseIntentId:c.orderId,...i===null?{intent:"read"}:i.provider==="apple"?{provider:"apple",signedTransaction:i.signedTransaction}:{provider:"google",purchaseToken:i.purchaseToken}},d=r.restoreNativePurchase.response.parse(await t.request(r.restoreNativePurchase.path,l));if(d.operation.requestId!==c.requestId||d.operation.purchaseIntentId!==c.orderId)throw new o("INVALID_RESPONSE","Native receipt request identity changed");let s=le.parse({scope:d.scope,requestId:c.requestId,orderId:d.operation.orderId,receiptId:d.operation.orderId,orderStatus:d.operation.status,refunded:d.operation.refunded,...d.operation.completion===null?{}:{nativeCompletion:{orderId:d.operation.orderId,receiptId:d.operation.orderId,...d.operation.completion}}});if(s.requestId!==c.requestId||s.orderId!==c.orderId||s.receiptId!==c.receiptId||s.scope.projectId!==e.scope.projectId||s.scope.environment!==e.scope.environment)throw new o("INVALID_RESPONSE","Current order receipt scope changed");return s}}}import{z as Ze}from"zod";var C=Ze.number().int().min(0).max(Number.MAX_SAFE_INTEGER);function We(e,t){let n=C.parse(e.inputTokens.total),c=C.parse(e.outputTokens.total),i=C.parse(e.inputTokens.cacheRead??0),l=C.parse(e.inputTokens.cacheWrite??0),d=C.parse(e.outputTokens.reasoning??0);if(i+l>n||d>c||e.inputTokens.noCache!==void 0&&C.parse(e.inputTokens.noCache)!==n-i-l||e.outputTokens.text!==void 0&&C.parse(e.outputTokens.text)!==c-d)throw new o("AI_USAGE_UNAVAILABLE","Provider token counts do not conserve total usage");return{input:n-i-l,cache_read:i,cache_write:l,output:t==="output"?c:c-d,reasoning:t==="separate"?d:0,input_audio:0,output_audio:0}}function Xe(e){if(typeof window<"u")throw new o("SERVER_ONLY","AI usage belongs on the trusted backend");if(!e.modelId||!["output","separate"].includes(e.reasoning))throw new o("INVALID_REQUEST","Model ID and reasoning pricing are required");async function t(c){await e.persist({context:c,modelId:e.modelId,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"})}async function n(c,i){let l={context:c,modelId:e.modelId,usage:i,tokens:null,quote:null,receipt:null,phase:"captured"};await e.persist(l);let d=e.mapTokens?e.mapTokens(i):We(i,e.reasoning),s=await e.pricing.quoteTokens({modelId:e.modelId,tokens:d});await e.persist({...l,tokens:d,quote:s,phase:"quoted"});let p=await e.pricing.trackTokens(e.client,{...c,quote:s});if(!p.receipt.accepted)throw new o("AI_BALANCE_REJECTED","AI usage was captured but the balance operation was rejected");await e.persist({...l,tokens:d,quote:s,receipt:p,phase:"settled"})}return{specificationVersion:"v4",async wrapGenerate({doGenerate:c}){let i=await e.context(),l;try{l=await c()}catch(d){throw await t(i),d}return await n(i,l.usage),l},async wrapStream({doStream:c}){let i=await e.context(),l;try{l=await c()}catch(y){throw await t(i),y}let d=!1,s=!1,p=l.stream.getReader();async function f(){d||s||(s=!0,await t(i))}return{...l,stream:new ReadableStream({async pull(y){try{let{value:g,done:m}=await p.read();if(m){if(!d)throw await f(),new o("AI_USAGE_UNAVAILABLE","Stream ended without final usage; no amount was invented");y.close();return}if(g.type==="finish"){if(d)throw new o("AI_USAGE_UNAVAILABLE","Provider sent more than one final usage record");d=!0,await n(i,g.usage)}y.enqueue(g)}catch(g){try{await f()}finally{y.error(g),await p.cancel(g)}}},async cancel(y){try{await f()}finally{await p.cancel(y)}}})}}}}function en(e){if(typeof window<"u")throw new o("SERVER_ONLY","Funnel receipts are sent by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(e.apiKey))throw new o("INVALID_TOKEN","A server API key is required");let t=A(e);return t.identify(e.apiKey),{async signal(n){let c=G.parse({...n,operation:"signal"}),i=oe.parse(await t.request("funnels",c));if(i.runId!==n.runId||i.eventId!==n.eventId||i.scope.projectId!==e.scope.projectId||i.scope.environment!==e.scope.environment)throw new o("INVALID_RESPONSE","Receipt identity changed");return i},async readResults(n){let c=G.parse({operation:"read_results",runId:n}),i=ae.parse(await t.request("funnels",c));if(i.runId!==n||i.scope.projectId!==e.scope.projectId||i.scope.environment!==e.scope.environment)throw new o("INVALID_RESPONSE","Result identity changed");return i}}}function nn(e){if("remoteEval"in e)throw new o("INVALID_REQUEST","Configure evaluation mode on the Funnel; remoteEval is not supported");if(typeof window<"u")throw new o("SERVER_ONLY","Campaign entry requires your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(e.apiKey))throw new o("INVALID_TOKEN","A server API key is required");let t=A({...e,timeoutMs:e.timeoutMs??35e3});return t.identify(e.apiKey),{async decide(n){let c=Date.now()+(e.timeoutMs??3e4),i=q.parse({...n,funnelId:e.funnelId,operation:"campaign_decide"}),l=A({...e,timeoutMs:Math.min(e.timeoutMs??35e3,Math.max(1,c-Date.now()))});l.identify(e.apiKey);let d=O.parse(await l.request("funnels",i));if(d.scope.projectId!==e.scope.projectId||d.scope.environment!==e.scope.environment)throw new o("SCOPE_MISMATCH","Campaign scope changed");return U(d,i.customer,c,(s,p)=>z({...e,timeoutMs:Math.min(e.timeoutMs??1e4,Math.max(1,p-Date.now()))}).read(s))},async start(n){let c=q.parse({...n,funnelId:e.funnelId,operation:"campaign_start"}),i=ce.parse(await t.request("funnels",c)),l=se.parse("suppressed"in i?i:await N(e,i));if(l.scope.projectId!==e.scope.projectId||l.scope.environment!==e.scope.environment)throw new o("SCOPE_MISMATCH","Campaign scope changed");if(!("suppressed"in l)&&(l.run.source.id!==e.funnelId||!l.customerId||c.customer.type==="id"&&l.customerId!==c.customer.value))throw new o("INVALID_RESPONSE","Campaign Funnel or Customer changed");return l}}}export{b as FunnelDecisionTimeoutError,o as IndianaError,Be as aiPriceSnapshotSchema,Ge as aiTokenQuoteSchema,je as createAiPricing,Xe as createAiUsageMiddleware,Pe as createConfigurationSync,qe as createConfiguredAiPricing,K as createFeatureClient,nn as createFunnelCampaignClient,z as createFunnelDecisionClient,P as createFunnelLocalEvaluator,en as createFunnelOrchestrationClient,Me as createFunnelStartClient,ze as createGuestToken,Ke as createIndianaServer,Ve as createLocalFunnelClient,Je as createNativeReceiptClient,$e as createPaywallStartClient,Qe as createSynchronizedFunnelLocalEvaluator,Ue as evaluateFunnelNode,Ye as renewFunnelRun};
1
+ import{a as K,b as N,c as fe,d as ye,e as ve,g as T,h as Ie,j as ge,k as Pe,l as Ue,m as Me,n as Ve}from"./chunk-3F2NQOR2.js";import"./chunk-GRLMT5PR.js";import{a as Be,b as Ge,c as je,d as qe}from"./chunk-F2GOIBDQ.js";import{a}from"./chunk-VVV3JNS3.js";import{a as A}from"./chunk-SSHUBTT3.js";import{$f as _,$j as le,Ak as de,Ck as me,Fc as B,Ic as X,Mc as ee,Yi as r,_j as pe,ag as O,bg as ie,ej as j,kf as te,sj as q,tj as se,uj as ce,vf as G,wf as oe,wj as D,xj as ue,yf as ae}from"./chunk-EJTBSGLV.js";import{a as o}from"./chunk-SOQO2RDZ.js";import{Mb as re}from"./chunk-LMR2TM3X.js";import{b as $,h as ne}from"./chunk-OBYJWIRB.js";import"./chunk-EXCPE2XH.js";import{b as Z,q as W}from"./chunk-RRII2DMC.js";import{d as J}from"./chunk-KQCTDXVD.js";function we(e){return{async getCustomer(t){let n=r.getCustomer;return a(e,n,t,{request:"Invalid customer lookup",response:"Invalid customer response"})},async listCustomers(t={}){let n=r.listCustomers;return a(e,n,t,{request:"Invalid customer filters",response:"Invalid customer response"})},async updateCustomer(t){let n=r.updateCustomer;return a(e,n,t,{request:"Invalid customer patch",response:"Invalid customer response"})},async createGuestCustomer(t){let n=r.createGuestCustomer;return a(e,n,t)},async resumeGuestSession(t){let n=r.resumeGuestSession;return a(e,n,t)},async claimGuestCustomer(t){let n=r.claimGuestCustomer;return a(e,n,t)},async renewCustomerSession(t){let n=r.renewSession;return a(e,n,t)},async revokeCustomerSessions(t){let n=r.revokeSessions;return a(e,n,t)},async createCustomerSession(t){return a(e,r.createSession,{customerId:t},{request:"A customer ID is required",response:"Invalid customer session response"})},async getOrCreateCustomer(t){return a(e,r.createCustomer,t,{request:"Invalid customer input",response:"Invalid customer response"})}}}function u(e,t){try{return e.parse(t)}catch{throw new o("INVALID_RESPONSE","Invalid gateway response")}}function he(e){return{async checkEntitlement(t){let n=r.checkEntitlement;return a(e,n,t,u)},async readHoldings(t){let n=r.readHoldings;return a(e,n,t,u)},async readSeats(t){let n=r.readSeats;return a(e,n,t,u)},async manageSeat(t){let n=r.manageSeat;return a(e,n,t,u)}}}function Se(e){return{async readAiPricing(t){let n=r.readAiPricing;return a(e,n,t,u)},async readUsage(t){let n=r.readUsage;return a(e,n,t,u)},async setUsage(t){let n=r.setUsage;return a(e,n,t,u)},async manageBalanceGrant(t){let n=r.manageBalanceGrant;return a(e,n,t,u)},async readBalanceSource(t){let n=r.readBalanceSource;return a(e,n,t,u)},async adjustBalance(t){let n=r.adjustBalance;return a(e,n,t,u)},async listBalanceGrants(t){let n=r.listBalanceGrants;return a(e,n,t,u)},async manageBillingLimits(t){let n=r.manageBillingLimits;return a(e,n,t,u)},async manageUsageEntity(t){let n=r.manageUsageEntity;return a(e,n,t,u)},async readUsageAnalytics(t){let n=r.readUsageAnalytics;return a(e,n,t,u)},async readCreditAnalytics(t){let n=r.readCreditAnalytics;return a(e,n,t,u)},async submitUsageBatch(t){let n=r.submitUsageBatch;return a(e,n,t,u)},async readUsageBatch(t){let n=r.readUsageBatch;return a(e,n,t,u)},async readLedger(t){let n=r.readLedger;return a(e,n,t,u)},async readCreditStatement(t){let n=r.readCreditStatement;return a(e,n,t,u)},async quoteBalance(t){let n=r.quoteBalance;return a(e,n,t,u)},async trackUsage(t){let n=r.trackUsage;return a(e,n,t,u)},async mutateBalance(t){let n=r.mutateBalance;return a(e,n,t,u)}}}function Ee(e){return{async listInvoiceTemplates(t={}){let n=r.listInvoiceTemplates;return a(e,n,t,u)},async previewInvoice(t){let n=r.previewInvoice;return a(e,n,t,u)},async createInvoice(t){let n=r.createInvoice;return a(e,n,t,u)},async manageInvoice(t){let n=r.manageInvoice;return a(e,n,t,u)},async readInvoiceOperation(t){let n=r.readInvoiceOperation;return a(e,n,t,u)},async listInvoices(t){let n=r.listInvoices;return a(e,n,t,u)},async getInvoice(t){let n=r.getInvoice;return a(e,n,t,u)},async setupPayment(t){let n=r.setupPayment;return a(e,n,t,u)},async readPaymentSetup(t){let n=r.readPaymentSetup;return a(e,n,t,u)},async readBillingInvoice(t){let n=r.readBillingInvoice;return a(e,n,t,u)},async previewRefund(t){let n=r.previewRefund;return a(e,n,t,u)},async refund(t){let n=r.refund;return a(e,n,t,u)},async readRefund(t){let n=r.readRefund;return a(e,n,t,u)}}}function Ae(e){return{async previewSubscriptionBatch(t){let n=r.previewSubscriptionBatch;return a(e,n,t,u)},async confirmSubscriptionBatch(t){let n=r.confirmSubscriptionBatch;return a(e,n,t,u)},async readSubscriptionBatch(t){let n=r.readSubscriptionBatch;return a(e,n,t,u)},async abandonSubscriptionBatch(t){let n=r.abandonSubscriptionBatch;return a(e,n,t,u)},async manageSubscriptionTrial(t){let n=r.manageSubscriptionTrial;return a(e,n,t,u)},async readSubscriptionTrial(t){let n=r.readSubscriptionTrial;return a(e,n,t,u)},async listSubscriptions(t){let n=r.listSubscriptions;return a(e,n,t,u)},async listPurchases(t){let n=r.listPurchases;return a(e,n,t,u)},async listSubscriptionConflicts(t){let n=r.listSubscriptionConflicts;return a(e,n,t,u)},async retrySubscriptionConflict(t){let n=r.retrySubscriptionConflict;return a(e,n,t,u)},async previewUpdate(t){let n=r.previewUpdate;return a(e,n,t,u)},async update(t){let n=r.update;return a(e,n,t,u)},async readSubscriptionUpdate(t){let n=r.readSubscriptionUpdate;return a(e,n,t,u)},async restoreNativePurchase(t){let n=r.restoreNativePurchase;return a(e,n,t,u)},async verifySubscriptions(t){let n=r.verifySubscriptions;return a(e,n,t,u)},async previewAttach(t){let n=r.previewAttach;return a(e,n,t,u)},async attach(t){let n=r.attach;return a(e,n,t,u)},async readSubscriptionOperation(t){let n=r.readSubscriptionOperation;return a(e,n,t,u)}}}function Fe(e){return{async recordCouponRedemption(t){return a(e,r.recordCouponRedemption,t,{request:"Invalid Coupon redemption facts",parseResponse:u})},async grantOffer(t){let n=r.grantOffer;return a(e,{...n,request:n.request.refine(c=>!!c.customerId)},{...t,requestId:t.requestId??crypto.randomUUID()},{request:"Invalid offer grant",response:"Invalid offer response"})}}}function Ce(e){return{...he(e),...Se(e),...Ee(e),...Ae(e),...Fe(e)}}function Re(e){return{async getFeatures(t={}){let n=r.getFeatures;return a(e,n,t,u)},async evaluateFeatures(t){let n=r.evaluateFeatures;return a(e,n,t,u)}}}function Oe(e){return{async trackEvents(t){let n=r.trackEvents;return a(e,n,t,u)}}}function be(e){return{async resolveContent(t){let n=r.resolveContent;return a(e,n,t,u)},async resolvePaywall(t){let n=r.resolvePaywall;return a(e,n,t,u)},async resolveOffering(t){let n=r.resolveOffering;return a(e,n,t,u)}}}function Ke(e){if(typeof window<"u")throw new o("SERVER_ONLY","Secret API keys must stay on your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(e.apiKey))throw new o("INVALID_TOKEN","A server API key is required");let t=A(e);t.identify(e.apiKey);let n=t.request;return{async sendMessage(c){let i=r.sendMessage;return i.response.parse(await n(i.path,i.request.parse(c)))},async readMessage(c){let i=r.readMessage;return i.response.parse(await n(i.path,i.request.parse(c)))},...we(n),...Ce(n),...Re(n),...Oe(n),...be(n)}}function ze(){if(typeof window<"u")throw new o("SERVER_ONLY","Guest identity is issued by your backend");let e=crypto.getRandomValues(new Uint8Array(32));return"gg_gc_"+btoa(String.fromCharCode(...e)).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}async function Ye(e,t){if(typeof window<"u")throw new o("SERVER_ONLY","Renewal requires your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(e.apiKey))throw new o("INVALID_TOKEN","A server API key is required");let{funnelCredentialCommandSchema:n,funnelCredentialResponseSchema:c}=await import("./src-CLEFCTAU.js"),i=A(e);i.identify(e.apiKey);let l=c.parse(await N(e,await i.request("funnels",n.parse({...t,operation:"renew_run"}))));if(l.run.id!==t.runId)throw new o("INVALID_RESPONSE","Run renewal identity changed");return l}function ke(e){let t=ye(e),n=s=>{throw new o("INVALID_RESPONSE",s)};t.nodes.size!==e.topology.nodes.length&&n("Duplicate local node identity"),t.nodes.get(e.topology.entry)?.type!=="entry"&&n("A local Funnel must start at Entry");let c=new Set(["entry","condition","feature","split","end","output"]);for(let s of t.nodes.values()){if(!c.has(s.type))throw new o("SERVER_REQUIRED","This Funnel requires authoritative server execution");if(s.type==="entry"&&s.id!==e.topology.entry&&n("Unexpected Entry node"),["entry","feature"].includes(s.type)&&!s.outputs.next&&n("Local next exit is unavailable"),s.type==="feature"){let p=s.resources.featureKey;(!p||!Object.hasOwn(e.evaluation.variables,s.writes.value)||!Object.hasOwn(t.features,p))&&n("Local Feature definition or declaration is unavailable")}if(s.type==="condition"){let p=e.conditions[s.id];(!p||!s.outputs.default||p.some((f,y)=>f.port!==`case:${y}`||!s.outputs[f.port]))&&n("Local Condition exits are unavailable")}if(s.type==="split"&&(!s.resources.experimentId||!Object.hasOwn(e.growth.experiments,s.resources.experimentId)||!s.outputs.notParticipating)&&n("Local Experiment definition or exit is unavailable"),s.type==="end"||s.type==="output"){let p=e.evaluation.terminals[s.id];if(!p)throw new o("SERVER_REQUIRED","Terminal resource delivery requires the server");Object.keys(s.outputs).length&&n("A terminal cannot have outgoing edges"),p.output?.type==="feature"&&!Object.hasOwn(t.features,p.output.featureKey)&&n("Terminal Feature definition is unavailable")}for(let p of Object.values(s.outputs))t.nodes.has(p)||n("Local target is unavailable")}let i=new Set,l=new Set;function d(s){if(l.has(s)&&n("Local graph contains a cycle"),!i.has(s)){l.add(s);for(let p of Object.values(t.nodes.get(s).outputs))d(p);l.delete(s),i.add(s)}}return d(e.topology.entry),i.size!==t.nodes.size&&n("Local graph contains unreachable nodes"),{evaluate(s){let p={},f=s.context;f.features=t.features,f.savedGroups=t.savedGroups;let y=()=>{f.attributes=te({declarations:e.evaluation.variables,attributes:s.attributes,parameters:s.parameters,answers:{},results:p,savedGroups:t.savedGroups})};y();let g=e.topology.entry,m=0;for(;;){let v=t.nodes.get(g);if(v.type==="end"||v.type==="output"){let I=e.evaluation.terminals[g],w=I.output,S=w?.type==="feature"?t.feature(w.featureKey,f):w?.type==="variable"?ee({source:"variable",key:w.key,...w.path?{path:w.path}:{}},{declarations:e.evaluation.variables,answers:{},results:p,parameters:s.parameters,attributes:s.attributes,savedGroups:t.savedGroups}):w?.value??null;return B(e.evaluation.outputSchema,S)||n("Local output does not match its declaration"),{outcome:I.outcome,value:S}}if(m++>=e.evaluation.maxTransitions)throw new o("TRANSITION_LIMIT","Local Funnel transition budget exceeded");if(v.type==="entry")g=v.outputs.next;else{let I=t.evaluate(g,f);if(v.type==="feature"){let w=v.writes.value,S=I.value??null;B(e.evaluation.variables[w],S)||n("Local Feature value does not match its declaration"),X(e.evaluation.variables,{writes:v.writes},{[w]:S}),p[w]=S,y()}g=I.target}}}}}import{z as Le}from"zod";function xe(e,t,n){let c=Z.parse(e.attributes);if(["parameters","answers","results"].some(E=>Object.hasOwn(c,E)))throw new o("INVALID_REQUEST","Flow namespaces cannot be caller attributes");let i=re.parse(e.parameters??{}),l=Le.record(Le.string(),W).parse(e.stickyBucketAssignmentDocs??{});for(let[E,h]of Object.entries(l))if(E!==`${h.attributeName}||${h.attributeValue}`||!Object.hasOwn(c,h.attributeName)||J(c[h.attributeName])!==h.attributeValue)throw new o("INVALID_REQUEST","Sticky document identity does not match this session");let d=e.saveStickyBucketAssignmentDoc,s=e.onFeatureUsage,p=e.onExperimentViewed,f=e.onError,y=new Map,g=new Set,m={},v=Promise.resolve();function I(E){let h=v.then(()=>(n(),E()));return v=h.catch(()=>{}),h}function w(E){try{f?.(E)}catch{}}function S(E){try{let h=E();h&&typeof h.catch=="function"&&h.catch(w)}catch(h){w(h)}}async function k(){for(let[E,h]of y){if(n(),d)try{await d(structuredClone(h))}catch{throw new o("STICKY_SAVE_FAILED","Persist the pending Sticky assignment before using this evaluation")}n(),y.delete(E)}}return{evaluate(E={}){let h=E.track===!0;return I(async()=>{let L=await t();n(L);let Y=new Set(g),H={...m},Q=new Map,M=[],_e={stickyBucketAssignmentDocs:structuredClone(l),saveStickyBucketAssignmentDoc(F){Q.set(`${F.attributeName}||${F.attributeValue}`,structuredClone(F))},...h?{trackedExperiments:Y,trackedFeatureUsage:H,onExperimentViewed(F,R){let V=structuredClone(F),Te=structuredClone(R);p&&M.push(()=>p(structuredClone(V),structuredClone(Te)))},onFeatureUsage(F,R){let V=structuredClone(R);s&&M.push(()=>s(F,structuredClone(V)))}}:{}},Ne=L.program.evaluate({attributes:c,parameters:i,context:_e});n(L);for(let[F,R]of Q)l[F]=R,y.set(F,R);await k(),n(L),h&&(g=Y,m=H);for(let F of M)S(F);let x=L.configuration;return structuredClone({evaluationMode:"local",scope:x.scope,funnelId:x.funnelId,versionId:x.versionId,evaluationRevision:x.evaluationRevision,generation:x.growth.generation,...Ne})})},flush:()=>I(k),get stickyBucketAssignmentDocs(){return n(),structuredClone(l)}}}var He=6e4;function P(e){if(typeof window<"u")throw new o("SERVER_ONLY","Local Funnel sessions run on your backend");let t=$.parse(e.scope),n=e.funnelId,c=e.load,i,l,d,s=0,p=g=>Date.now()>=g.expiresAt;async function f(){if(l)return l;let g=s;i=void 0;let m=(async()=>{let v=await c();if(g!==s)throw new o("IDENTITY_CHANGED","Local evaluator was reset");if(v&&typeof v=="object"&&"evaluationMode"in v&&v.evaluationMode==="remote")throw u(D,v),new o("EVALUATION_MODE","This Funnel requires remote decide");let I=u(ue,v);if(g!==s)throw new o("IDENTITY_CHANGED","Local evaluator was reset");if(I.scope.projectId!==t.projectId||I.scope.environment!==t.environment||I.funnelId!==n)throw new o("SCOPE_MISMATCH","Local configuration scope changed");if(I.growth.scope.projectId!==t.projectId||I.growth.scope.environment!==t.environment||I.growth.expiresAt!==I.expiresAt)throw new o("INVALID_RESPONSE","GB configuration scope or expiry changed");let w=Math.min(Date.now()+He,I.expiresAt?Date.parse(I.expiresAt):1/0);if(Date.now()>=w)throw new o("CONFIGURATION_EXPIRED","Refresh expired local rules");let S=JSON.stringify([t.projectId,t.environment,n,I.versionId,I.evaluationRevision,I.growth.generation]),k=[I.topology,I.conditions,I.evaluation,I.growth.features,I.growth.experiments,I.growth.savedGroups];if(d?.key===S&&!Ie(d.body,k))throw new o("INVALID_RESPONSE","Immutable local configuration identity changed");return d?.key!==S&&(d={key:S,body:k,program:ke(I)}),i={key:S,configuration:I,expiresAt:w,program:d.program},i})();l=m;try{return await m}finally{l===m&&(l=void 0)}}function y(){return l??(i&&!p(i)?Promise.resolve(i):f())}return{session(g){let m=s;return xe(g,y,v=>{if(e.assertUsable?.(),m!==s)throw new o("IDENTITY_CHANGED","Local evaluator was reset");if(v&&(p(v)||i?.key!==v.key))throw new o("CONFIGURATION_EXPIRED","Refresh local rules before using this result")})},async refresh(){return structuredClone((await f()).configuration)},reset(){s++,i=void 0,l=void 0,d=void 0}}}function Qe(e,t){let n=e.snapshot?.generation,c=P({scope:{projectId:e.scope.projectId,environment:e.scope.environment},funnelId:t,load:()=>e.localFunnel(t),assertUsable:()=>e.assertFunnel(t)}),i=e.subscribe(()=>{let d=e.snapshot?.generation;e.fresh&&d!==n&&(n=d,c.refresh().catch(()=>{}))}),l=c.session;return Object.assign(c,{session(d){let s=l(d),p=s.evaluate;return Object.assign(s,{async evaluate(...f){return e.fresh||await e.refresh(),p(...f)}})},destroy(){i(),c.reset()}})}function $e(e){if(typeof window<"u")throw new o("SERVER_ONLY","Secret API keys must stay on the backend");return{start:t=>ge(e,t)}}function De(e,t,n){return de(e,t,n,fe)}var b=class extends o{constructor(n,c){super("DECISION_PENDING","Decision is still pending; read this decision ID or retry the original request ID",202,c);this.decisionId=n;this.decisionRequestId=c}decisionId;decisionRequestId};async function U(e,t,n,c){let{decisionId:i,requestId:l}=e,d=e,s=250,p=0;for(;;){if(d.decisionId!==i||d.requestId!==l||d.decision&&!T(d.decision,t))throw new o("INVALID_RESPONSE","Decision request or customer changed");if(d.decision)return d.decision;if(d.status==="failed")throw new o("DECISION_FAILED","Decision execution failed",503,l);if(Date.now()>=n)throw new b(i,l);if(await new Promise(f=>setTimeout(f,Math.min(Math.max(s,p-Date.now()),n-Date.now()))),Date.now()>=n)throw new b(i,l);s=Math.min(1e3,s*2);try{d=await c(i,n)}catch(f){if(f instanceof o&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE","RATE_LIMITED"].includes(f.code)){p=Date.now()+(f.retryAfterSeconds??0)*1e3;continue}throw f}}}function z(e){if("remoteEval"in e)throw new o("INVALID_REQUEST","Configure evaluation mode on the Funnel; remoteEval is not supported");if(typeof window<"u")throw new o("SERVER_ONLY","Funnel decisions are requested by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(e.apiKey))throw new o("INVALID_TOKEN","A server API key is required");let t,n,c=new Map;async function i(p,f){let y=p;y.status!=="pending"&&c.delete(y.decisionId);for(let g=0;g<32&&y.evaluation;g++){let m=y.evaluation;if(m.runId!==y.decisionId)throw new o("INVALID_RESPONSE","Local evaluation Run changed");let v=c.get(y.decisionId);if(!v&&m.type==="evaluate_segment"){let w=me.parse(await l({operation:"segment_configuration",funnelId:e.funnelId,versionId:m.versionId},f));if(w.configuration.scope.projectId!==e.scope.projectId||w.configuration.scope.environment!==e.scope.environment||w.configuration.funnelId!==e.funnelId||w.configuration.versionId!==m.versionId||w.configuration.evaluationRevision!==m.policyRevision)throw new o("SCOPE_MISMATCH","Original decision segment configuration changed");if(c.size>=128)throw new o("COMMAND_PENDING","Reconcile outstanding decisions first");v={operation:"commit_decision_segment",decisionId:y.decisionId,requestId:j(y.decisionId,m.visit,`segment:${m.revision}`),nodeId:m.nodeId,visit:m.visit,revision:m.revision,policyRevision:m.policyRevision,generation:w.configuration.growth.generation,...ve(w.configuration,w.document,m)},c.set(y.decisionId,v)}if(!v){if(m.type!=="evaluate")throw new o("INVALID_RESPONSE","Unknown decision instruction");if((!n||n.versionId!==m.versionId||n.evaluationRevision!==m.policyRevision||n.expiresAt&&Date.parse(n.expiresAt)<=Date.now())&&(n=D.parse(await l({operation:"configuration",funnelId:e.funnelId,versionId:m.versionId},f))),n.scope.projectId!==e.scope.projectId||n.scope.environment!==e.scope.environment||n.funnelId!==e.funnelId)throw new o("SCOPE_MISMATCH","Local evaluation configuration scope changed");if(n.evaluationMode!=="local"||n.versionId!==m.versionId||n.evaluationRevision!==m.policyRevision)throw new o("EVALUATION_MODE","Original Local evaluation policy is unavailable");if(c.size>=128)throw new o("COMMAND_PENDING","Reconcile outstanding Local decisions first");v={operation:"evaluate_decision",decisionId:y.decisionId,requestId:j(y.decisionId,m.visit,"evaluation"),nodeId:m.nodeId,visit:m.visit,revision:m.revision,receiptId:m.receiptId,policyRevision:m.policyRevision,generation:n.growth.generation,result:De(n,m.nodeId,m)},c.set(y.decisionId,v)}let I=O.parse(await l(v,f));if(I.decisionId!==p.decisionId||I.requestId!==p.requestId)throw new o("INVALID_RESPONSE","Decision identity changed during local evaluation");c.delete(y.decisionId),y=I}return y}async function l(p,f,y=!1){let g=A({...e,fetch:(m,v)=>{let I=new Headers(v?.headers);return I.set("Accept-Encoding","identity"),y&&I.set("Prefer","respond-async"),(e.fetch??globalThis.fetch)(m,{...v,headers:I})},timeoutMs:Math.min(e.timeoutMs??1e4,f?Math.max(1,f-Date.now()):12e4)});return g.identify(e.apiKey),g.request("funnels",p)}async function d(p,f){let y=O.parse(await l(_.parse({operation:"read_decision",decisionId:p}),f));if(y.decisionId!==p)throw new o("INVALID_RESPONSE","Decision identity changed");return i(y,f)}async function s(p,f,y=!1){let g=_.options[0].parse({...p,operation:"decide",funnelId:e.funnelId}),m;try{m=O.parse(await l(g,f,y))}catch(v){throw v instanceof o&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE"].includes(v.code)?new o("DECISION_ACCEPTANCE_UNKNOWN","Decision acceptance is unknown; retry the original request ID and input",v.status,p.requestId):v}if(m.requestId!==p.requestId||m.decision&&!T(m.decision,g.customer))throw new o("INVALID_RESPONSE","Decision request or customer changed");return{response:await i(m,f),customer:g.customer}}return{local(){return t??=P({scope:e.scope,funnelId:e.funnelId,load:()=>l({operation:"local_configuration",funnelId:e.funnelId})})},async configuration(){let p=D.parse(await l({operation:"configuration",funnelId:e.funnelId}));if(p.scope.projectId!==e.scope.projectId||p.scope.environment!==e.scope.environment||p.funnelId!==e.funnelId)throw new o("SCOPE_MISMATCH","Configuration scope changed");return p},features(p={}){return K({...p,scope:e.scope,load:async()=>ne.parse(await l({operation:"feature_config",funnelId:e.funnelId}))})},read:p=>d(p),async submit(p){return(await s(p,void 0,!0)).response},async decide(p){let f=Date.now()+3e4,y=await s(p,f);return U(y.response,y.customer,f,d)},async reportUsed(p){let f=ie.parse(await l(_.parse({...p,operation:"report_used"})));if(f.decisionId!==p.decisionId||f.eventId!==p.eventId)throw new o("INVALID_RESPONSE","Usage receipt identity changed");return f}}}function Je(e){if(typeof window<"u")throw new o("SERVER_ONLY","Native receipts are verified by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(e.apiKey))throw new o("INVALID_TOKEN","Server API key required");let t=A({...e,timeoutMs:e.timeoutMs??35e3});return t.identify(e.apiKey),{async recover(n){let c=pe.parse(n);if(c.orderId!==c.receiptId)throw new o("INVALID_REQUEST","Native recovery requires the accepted commercial intent");let i=c.nativeEvidence,l={requestId:c.requestId,customerToken:c.customerToken,purchaseIntentId:c.orderId,...i===null?{intent:"read"}:i.provider==="apple"?{provider:"apple",signedTransaction:i.signedTransaction}:{provider:"google",purchaseToken:i.purchaseToken}},d=r.restoreNativePurchase.response.parse(await t.request(r.restoreNativePurchase.path,l));if(d.operation.requestId!==c.requestId||d.operation.purchaseIntentId!==c.orderId)throw new o("INVALID_RESPONSE","Native receipt request identity changed");let s=le.parse({scope:d.scope,requestId:c.requestId,orderId:d.operation.orderId,receiptId:d.operation.orderId,orderStatus:d.operation.status,refunded:d.operation.refunded,...d.operation.completion===null?{}:{nativeCompletion:{orderId:d.operation.orderId,receiptId:d.operation.orderId,...d.operation.completion}}});if(s.requestId!==c.requestId||s.orderId!==c.orderId||s.receiptId!==c.receiptId||s.scope.projectId!==e.scope.projectId||s.scope.environment!==e.scope.environment)throw new o("INVALID_RESPONSE","Current order receipt scope changed");return s}}}import{z as Ze}from"zod";var C=Ze.number().int().min(0).max(Number.MAX_SAFE_INTEGER);function We(e,t){let n=C.parse(e.inputTokens.total),c=C.parse(e.outputTokens.total),i=C.parse(e.inputTokens.cacheRead??0),l=C.parse(e.inputTokens.cacheWrite??0),d=C.parse(e.outputTokens.reasoning??0);if(i+l>n||d>c||e.inputTokens.noCache!==void 0&&C.parse(e.inputTokens.noCache)!==n-i-l||e.outputTokens.text!==void 0&&C.parse(e.outputTokens.text)!==c-d)throw new o("AI_USAGE_UNAVAILABLE","Provider token counts do not conserve total usage");return{input:n-i-l,cache_read:i,cache_write:l,output:t==="output"?c:c-d,reasoning:t==="separate"?d:0,input_audio:0,output_audio:0}}function Xe(e){if(typeof window<"u")throw new o("SERVER_ONLY","AI usage belongs on the trusted backend");if(!e.modelId||!["output","separate"].includes(e.reasoning))throw new o("INVALID_REQUEST","Model ID and reasoning pricing are required");async function t(c){await e.persist({context:c,modelId:e.modelId,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"})}async function n(c,i){let l={context:c,modelId:e.modelId,usage:i,tokens:null,quote:null,receipt:null,phase:"captured"};await e.persist(l);let d=e.mapTokens?e.mapTokens(i):We(i,e.reasoning),s=await e.pricing.quoteTokens({modelId:e.modelId,tokens:d});await e.persist({...l,tokens:d,quote:s,phase:"quoted"});let p=await e.pricing.trackTokens(e.client,{...c,quote:s});if(!p.receipt.accepted)throw new o("AI_BALANCE_REJECTED","AI usage was captured but the balance operation was rejected");await e.persist({...l,tokens:d,quote:s,receipt:p,phase:"settled"})}return{specificationVersion:"v4",async wrapGenerate({doGenerate:c}){let i=await e.context(),l;try{l=await c()}catch(d){throw await t(i),d}return await n(i,l.usage),l},async wrapStream({doStream:c}){let i=await e.context(),l;try{l=await c()}catch(y){throw await t(i),y}let d=!1,s=!1,p=l.stream.getReader();async function f(){d||s||(s=!0,await t(i))}return{...l,stream:new ReadableStream({async pull(y){try{let{value:g,done:m}=await p.read();if(m){if(!d)throw await f(),new o("AI_USAGE_UNAVAILABLE","Stream ended without final usage; no amount was invented");y.close();return}if(g.type==="finish"){if(d)throw new o("AI_USAGE_UNAVAILABLE","Provider sent more than one final usage record");d=!0,await n(i,g.usage)}y.enqueue(g)}catch(g){try{await f()}finally{y.error(g),await p.cancel(g)}}},async cancel(y){try{await f()}finally{await p.cancel(y)}}})}}}}function en(e){if(typeof window<"u")throw new o("SERVER_ONLY","Funnel receipts are sent by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(e.apiKey))throw new o("INVALID_TOKEN","A server API key is required");let t=A(e);return t.identify(e.apiKey),{async signal(n){let c=G.parse({...n,operation:"signal"}),i=oe.parse(await t.request("funnels",c));if(i.runId!==n.runId||i.eventId!==n.eventId||i.scope.projectId!==e.scope.projectId||i.scope.environment!==e.scope.environment)throw new o("INVALID_RESPONSE","Receipt identity changed");return i},async readResults(n){let c=G.parse({operation:"read_results",runId:n}),i=ae.parse(await t.request("funnels",c));if(i.runId!==n||i.scope.projectId!==e.scope.projectId||i.scope.environment!==e.scope.environment)throw new o("INVALID_RESPONSE","Result identity changed");return i}}}function nn(e){if("remoteEval"in e)throw new o("INVALID_REQUEST","Configure evaluation mode on the Funnel; remoteEval is not supported");if(typeof window<"u")throw new o("SERVER_ONLY","Campaign entry requires your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(e.apiKey))throw new o("INVALID_TOKEN","A server API key is required");let t=A({...e,timeoutMs:e.timeoutMs??35e3});return t.identify(e.apiKey),{async decide(n){let c=Date.now()+(e.timeoutMs??3e4),i=q.parse({...n,funnelId:e.funnelId,operation:"campaign_decide"}),l=A({...e,timeoutMs:Math.min(e.timeoutMs??35e3,Math.max(1,c-Date.now()))});l.identify(e.apiKey);let d=O.parse(await l.request("funnels",i));if(d.scope.projectId!==e.scope.projectId||d.scope.environment!==e.scope.environment)throw new o("SCOPE_MISMATCH","Campaign scope changed");return U(d,i.customer,c,(s,p)=>z({...e,timeoutMs:Math.min(e.timeoutMs??1e4,Math.max(1,p-Date.now()))}).read(s))},async start(n){let c=q.parse({...n,funnelId:e.funnelId,operation:"campaign_start"}),i=ce.parse(await t.request("funnels",c)),l=se.parse("suppressed"in i?i:await N(e,i));if(l.scope.projectId!==e.scope.projectId||l.scope.environment!==e.scope.environment)throw new o("SCOPE_MISMATCH","Campaign scope changed");if(!("suppressed"in l)&&(l.run.source.id!==e.funnelId||!l.customerId||c.customer.type==="id"&&l.customerId!==c.customer.value))throw new o("INVALID_RESPONSE","Campaign Funnel or Customer changed");return l}}}export{b as FunnelDecisionTimeoutError,o as IndianaError,Be as aiPriceSnapshotSchema,Ge as aiTokenQuoteSchema,je as createAiPricing,Xe as createAiUsageMiddleware,Pe as createConfigurationSync,qe as createConfiguredAiPricing,K as createFeatureClient,nn as createFunnelCampaignClient,z as createFunnelDecisionClient,P as createFunnelLocalEvaluator,en as createFunnelOrchestrationClient,Me as createFunnelStartClient,ze as createGuestToken,Ke as createIndianaServer,Ve as createLocalFunnelClient,Je as createNativeReceiptClient,$e as createPaywallStartClient,Qe as createSynchronizedFunnelLocalEvaluator,Ue as evaluateFunnelNode,Ye as renewFunnelRun};