@tinkerlandai/indiana-sdk 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -1 +1 @@
1
- import{a as T,b as v,d as te,e as pe,f as de}from"./chunk-G5ZGWOLJ.js";import{a as o,b as I}from"./chunk-CRJJ4EA2.js";import{Aj as Y,Cj as H,Ck as b,Dk as Z,Fk as J,G as O,Gj as C,Hj as _,Ij as W,Ll as X,Ml as ee,Wg as j,Xg as Q,Yg as K,Zg as G,_g as z,ci as $,qi as c,zj as P}from"./chunk-D37O6FAW.js";import"./chunk-MJG7X7LM.js";function p(r,n){try{return r.parse(n)}catch{throw new o("INVALID_RESPONSE","Invalid gateway response")}}function le(r){if(typeof window<"u")throw new o("SERVER_ONLY","Secret API keys must stay on the backend");return{start:n=>te(r,n)}}var S=class extends o{constructor(t,e){super("DECISION_PENDING","Decision is still pending; read this decision ID or retry the original request ID",202,e);this.decisionId=t;this.decisionRequestId=e}decisionId;decisionRequestId};function U(r){if("remoteEval"in r)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(r.apiKey))throw new o("INVALID_TOKEN","A server API key is required");async function n(a,s,i=!1){let u=I({...r,fetch:(m,f)=>{let d=new Headers(f?.headers);return d.set("Accept-Encoding","identity"),i&&d.set("Prefer","respond-async"),(r.fetch??globalThis.fetch)(m,{...f,headers:d})},timeoutMs:Math.min(r.timeoutMs??1e4,s?Math.max(1,s-Date.now()):12e4)});return u.identify(r.apiKey),u.request("funnels",a)}async function t(a,s){let i=_.parse(await n(C.parse({operation:"read_decision",decisionId:a}),s));if(i.decisionId!==a)throw new o("INVALID_RESPONSE","Decision identity changed");return i}async function e(a,s,i=!1){let u=C.options[0].parse({...a,operation:"decide",funnelId:r.funnelId}),m;try{m=_.parse(await n(u,s,i))}catch(f){throw f instanceof o&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE"].includes(f.code)?new o("DECISION_ACCEPTANCE_UNKNOWN","Decision acceptance is unknown; retry the original request ID and input",f.status,a.requestId):f}if(m.requestId!==a.requestId||m.decision&&!v(m.decision,u.customer))throw new o("INVALID_RESPONSE","Decision request or customer changed");return{response:m,customer:u.customer}}return{async configuration(){let a=J.parse(await n({operation:"configuration",funnelId:r.funnelId}));if(a.scope.projectId!==r.scope.projectId||a.scope.environment!==r.scope.environment||a.funnelId!==r.funnelId)throw new o("SCOPE_MISMATCH","Configuration scope changed");return a},features(a={}){return T({...a,scope:r.scope,load:async()=>$.parse(await n({operation:"feature_config",funnelId:r.funnelId}))})},read:a=>t(a),async submit(a){return(await e(a,void 0,!0)).response},async decide(a){let s=Date.now()+3e4,i=await e(a,s),u=i.response,m=u.decisionId,f=250;for(;;){if(u.requestId!==a.requestId||u.decision&&!v(u.decision,i.customer))throw new o("INVALID_RESPONSE","Decision request or customer changed");if(u.decision)return u.decision;if(u.status==="failed")throw new o("DECISION_FAILED","Decision execution failed",503,a.requestId);if(Date.now()>=s)throw new S(m,a.requestId);if(await new Promise(d=>setTimeout(d,Math.min(f,s-Date.now()))),Date.now()>=s)throw new S(m,a.requestId);try{f=Math.min(1e3,f*2),u=await t(m,s)}catch(d){if(d instanceof o&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE","RATE_LIMITED"].includes(d.code))continue;throw d}}},async reportUsed(a){let s=W.parse(await n(C.parse({...a,operation:"report_used"})));if(s.decisionId!==a.decisionId||s.eventId!==a.eventId)throw new o("INVALID_RESPONSE","Usage receipt identity changed");return s}}}function me(r){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(r.apiKey))throw new o("INVALID_TOKEN","Server API key required");let n=I({...r,timeoutMs:r.timeoutMs??35e3});return n.identify(r.apiKey),{async recover(t){let e=X.parse(t);if(e.orderId!==e.receiptId)throw new o("INVALID_REQUEST","Native recovery requires the accepted commercial intent");let a=e.nativeEvidence,s={requestId:e.requestId,customerToken:e.customerToken,purchaseIntentId:e.orderId,...a===null?{intent:"read"}:a.provider==="apple"?{provider:"apple",signedTransaction:a.signedTransaction}:{provider:"google",purchaseToken:a.purchaseToken}},i=c.restoreNativePurchase.response.parse(await n.request(c.restoreNativePurchase.path,s));if(i.operation.requestId!==e.requestId)throw new o("INVALID_RESPONSE","Native receipt request identity changed");let u=ee.parse({scope:i.scope,requestId:e.requestId,orderId:i.operation.orderId,receiptId:i.operation.orderId,orderStatus:i.operation.status,refunded:i.operation.refunded,...i.operation.completion===null?{}:{nativeCompletion:{orderId:i.operation.orderId,receiptId:i.operation.orderId,...i.operation.completion}}});if(u.requestId!==e.requestId||u.orderId!==e.orderId||u.receiptId!==e.receiptId||u.scope.projectId!==r.scope.projectId||u.scope.environment!==r.scope.environment)throw new o("INVALID_RESPONSE","Current order receipt scope changed");return u}}}import{z as l}from"zod";var q=j,fe=l.string().regex(/^(0|[1-9]\d{0,5})(\.\d{1,12})?$/),se=l.strictObject(Object.fromEntries(q.map(r=>[r,l.number().int().nonnegative().max(1e9)]))),ie=Q,we=K,D=l.strictObject({modelId:ie,source:l.enum(["models.dev","custom"]),fetchedAt:l.iso.datetime(),rates:G,contextTier:l.number().int().nonnegative(),markupPercent:we}),x=l.strictObject({pricing:D,tokens:se,quantity:O,digest:l.string().regex(/^[a-f0-9]{64}$/)}),oe=r=>{let[n,t=""]=r.split(".");return BigInt(n)*10n**12n+BigInt(t.padEnd(12,"0"))};function Ie(r){if(typeof r!="number"||!Number.isFinite(r)||r<0)throw new o("AI_PRICE_UNAVAILABLE","A published token price is missing");let n=String(r),t=n.includes("e")?r.toFixed(12).replace(/0+$/,"").replace(/\.$/,""):n;if(Number(t)!==r||!fe.safeParse(t).success)throw new o("AI_PRICE_UNAVAILABLE","Published price exceeds the supported precision");return t}var ne=l.strictObject({input:l.number().nonnegative(),output:l.number().nonnegative(),cache_read:l.number().nonnegative().optional(),cache_write:l.number().nonnegative().optional(),reasoning:l.number().nonnegative().optional(),input_audio:l.number().nonnegative().optional(),output_audio:l.number().nonnegative().optional()}),ge=ne.extend({context_over_200k:l.unknown().optional(),tiers:l.array(ne.extend({tier:l.strictObject({type:l.literal("context"),size:l.number().int().nonnegative()})})).max(20).refine(r=>new Set(r.map(n=>n.tier.size)).size===r.length).optional()});async function re(r,n,t){let e=new TextEncoder().encode(JSON.stringify({pricing:r,tokens:n,quantity:t}));return[...new Uint8Array(await crypto.subtle.digest("SHA-256",e))].map(a=>a.toString(16).padStart(2,"0")).join("")}function ae(r,n){let t=0n;for(let w of q){if(!n[w])continue;let g=r.rates[w];if(g===void 0)throw new o("AI_PRICE_UNAVAILABLE",`No published price for ${w}; report exclusive token pools`);t+=oe(g)*BigInt(n[w])}let[e,a="0"]=String(r.markupPercent).split("e"),s=(e.split(".")[1]?.length??0)-Number(a),i=10n**BigInt(Math.max(s,0)),u=BigInt(e.replace(".",""))*10n**BigInt(Math.max(-s,0)),m=100n*i+u,f=100n*i*1000000n,d=(t*m+f-1n)/f;return O.parse(`${d/1000000n}.${(d%1000000n).toString().padStart(6,"0")}`)}function ce(r={}){if(typeof window<"u")throw new o("SERVER_ONLY","AI token pricing belongs on your backend");let n=z.parse({defaultMarkup:r.defaultMarkup??0,providerMarkups:r.providerMarkups??{},modelMarkups:r.modelMarkups??{},customModels:r.customModels??{}}),t=null,e=0;async function a(){if(!t||Date.now()>=e){e=Date.now()+15*6e4;let s=(async()=>{let i=await(r.fetch??fetch)("https://models.dev/api.json",{signal:AbortSignal.timeout(3e4)});if(!i.ok)throw new o("AI_PRICE_UNAVAILABLE","Models.dev pricing is unavailable");return{data:l.record(l.string(),l.object({models:l.record(l.string(),l.unknown())})).parse(await i.json()),fetchedAt:new Date().toISOString()}})().catch(i=>{throw t===s&&(t=null),i});t=s}return t}return{refreshPrices(){t=null,e=0},async quoteTokens(s){let i=ie.parse(s.modelId),u=se.parse(s.tokens),[m,...f]=i.split("/"),d=n.customModels[i],w,g,h,L=0;if(d?.input!==void 0&&d.output!==void 0&&q.every(E=>u[E]===0||d[E]!==void 0))w={...d,input:d.input,output:d.output},g="custom",h=new Date().toISOString();else{let E=await a(),V=E.data[m]?.models[f.join("/")];if(!V)throw new o("AI_PRICE_UNAVAILABLE","Unknown model; configure a complete custom price");let{cost:k}=l.object({cost:ge}).parse(V),M=u.input+u.cache_read+u.cache_write+u.input_audio;if(k.tiers===void 0&&k.context_over_200k!==void 0&&M>2e5)throw new o("AI_PRICE_UNAVAILABLE","A current context tier is required for this model");let N=k.tiers?.filter(y=>M>y.tier.size).sort((y,ue)=>ue.tier.size-y.tier.size)[0],B=N??k;N&&(L=N.tier.size),w=Object.fromEntries(q.filter(y=>B[y]!==void 0).map(y=>[y,Ie(B[y])])),w={...w,...d},g=d?"custom":"models.dev",h=E.fetchedAt}let R=D.parse({modelId:i,source:g,fetchedAt:h,rates:w,contextTier:L,markupPercent:n.modelMarkups[i]??n.providerMarkups[m]??n.defaultMarkup}),F=ae(R,u);return x.parse({pricing:R,tokens:u,quantity:F,digest:await re(R,u,F)})},async trackTokens(s,i){let u=x.parse(i.quote);if(u.quantity!==ae(u.pricing,u.tokens)||u.digest!==await re(u.pricing,u.tokens,u.quantity))throw new o("INVALID_REQUEST","AI quote changed after pricing");let m=i.properties??{},f=i.providerCostUsd===void 0?void 0:l.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,18})?$/).parse(i.providerCostUsd),d=i.generationId===void 0?void 0:l.string().min(1).max(120).parse(i.generationId),w=8+ +(f!==void 0)+ +(d!==void 0);if(Object.keys(m).some(h=>h.startsWith("ai_")))throw new o("INVALID_REQUEST","AI tracking reserves ai_ event properties");if(Object.keys(m).length>16-w)throw new o("INVALID_REQUEST","AI tracking properties exceed the available event budget");let g={operation:"consume",internal_feature_id:i.internal_feature_id,quantity:u.quantity,idempotencyKey:i.idempotencyKey,properties:{...m,...f!==void 0?{ai_provider_cost_usd:f}:{},...d!==void 0?{ai_generation_id:d}:{},ai_model:u.pricing.modelId,ai_source:u.pricing.source,ai_price_at:u.pricing.fetchedAt,ai_quote_hash:u.digest,ai_markup:String(u.pricing.markupPercent),ai_tier:String(u.pricing.contextTier),ai_tokens:q.map(h=>u.tokens[h]).join(","),ai_rates:"v1:"+q.map(h=>u.pricing.rates[h]===void 0?"-":oe(u.pricing.rates[h]).toString(36)).join(",")},...i.entityId?{entityId:i.entityId}:{}};return s.mutateBalance({customerId:i.customerId,command:g})}}}async function he(r,n,t={}){let{config:e,model_markups:a}=await r.readAiPricing(n);return ce({defaultMarkup:e.default_markup??0,providerMarkups:Object.fromEntries(Object.entries(e.provider_markups??{}).map(([s,i])=>[s,i.markup])),modelMarkups:Object.fromEntries(Object.entries(a??{}).filter(([,s])=>s.markup!==void 0).map(([s,i])=>[s,i.markup])),customModels:Object.fromEntries(Object.entries(a??{}).filter(([,s])=>s.input_cost!==void 0||s.output_cost!==void 0).map(([s,i])=>[s,{...i.input_cost!==void 0?{input:String(i.input_cost)}:{},...i.output_cost!==void 0?{output:String(i.output_cost)}:{}}])),...t})}import{z as ye}from"zod";var A=ye.number().int().min(0).max(Number.MAX_SAFE_INTEGER);function Se(r,n){let t=A.parse(r.inputTokens.total),e=A.parse(r.outputTokens.total),a=A.parse(r.inputTokens.cacheRead??0),s=A.parse(r.inputTokens.cacheWrite??0),i=A.parse(r.outputTokens.reasoning??0);if(a+s>t||i>e||r.inputTokens.noCache!==void 0&&A.parse(r.inputTokens.noCache)!==t-a-s||r.outputTokens.text!==void 0&&A.parse(r.outputTokens.text)!==e-i)throw new o("AI_USAGE_UNAVAILABLE","Provider token counts do not conserve total usage");return{input:t-a-s,cache_read:a,cache_write:s,output:n==="output"?e:e-i,reasoning:n==="separate"?i:0,input_audio:0,output_audio:0}}function Ae(r){if(typeof window<"u")throw new o("SERVER_ONLY","AI usage belongs on the trusted backend");if(!r.modelId||!["output","separate"].includes(r.reasoning))throw new o("INVALID_REQUEST","Model ID and reasoning pricing are required");async function n(e){await r.persist({context:e,modelId:r.modelId,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"})}async function t(e,a){let s={context:e,modelId:r.modelId,usage:a,tokens:null,quote:null,receipt:null,phase:"captured"};await r.persist(s);let i=r.mapTokens?r.mapTokens(a):Se(a,r.reasoning),u=await r.pricing.quoteTokens({modelId:r.modelId,tokens:i});await r.persist({...s,tokens:i,quote:u,phase:"quoted"});let m=await r.pricing.trackTokens(r.client,{...e,quote:u});if(!m.receipt.accepted)throw new o("AI_BALANCE_REJECTED","AI usage was captured but the balance operation was rejected");await r.persist({...s,tokens:i,quote:u,receipt:m,phase:"settled"})}return{specificationVersion:"v4",async wrapGenerate({doGenerate:e}){let a=await r.context(),s;try{s=await e()}catch(i){throw await n(a),i}return await t(a,s.usage),s},async wrapStream({doStream:e}){let a=await r.context(),s;try{s=await e()}catch(d){throw await n(a),d}let i=!1,u=!1,m=s.stream.getReader();async function f(){i||u||(u=!0,await n(a))}return{...s,stream:new ReadableStream({async pull(d){try{let{value:w,done:g}=await m.read();if(g){if(!i)throw await f(),new o("AI_USAGE_UNAVAILABLE","Stream ended without final usage; no amount was invented");d.close();return}if(w.type==="finish"){if(i)throw new o("AI_USAGE_UNAVAILABLE","Provider sent more than one final usage record");i=!0,await t(a,w.usage)}d.enqueue(w)}catch(w){try{await f()}finally{d.error(w),await m.cancel(w)}}},async cancel(d){try{await f()}finally{await m.cancel(d)}}})}}}}function qe(r){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(r.apiKey))throw new o("INVALID_TOKEN","A server API key is required");let n=I(r);return n.identify(r.apiKey),{async signal(t){let e=P.parse({...t,operation:"signal"}),a=Y.parse(await n.request("funnels",e));if(a.runId!==t.runId||a.eventId!==t.eventId||a.scope.projectId!==r.scope.projectId||a.scope.environment!==r.scope.environment)throw new o("INVALID_RESPONSE","Receipt identity changed");return a},async readResults(t){let e=P.parse({operation:"read_results",runId:t}),a=H.parse(await n.request("funnels",e));if(a.runId!==t||a.scope.projectId!==r.scope.projectId||a.scope.environment!==r.scope.environment)throw new o("INVALID_RESPONSE","Result identity changed");return a}}}function Ee(r){if(typeof window<"u")throw new o("SERVER_ONLY","Campaign entry requires your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(r.apiKey))throw new o("INVALID_TOKEN","A server API key is required");let n=I({...r,timeoutMs:r.timeoutMs??35e3});n.identify(r.apiKey);let t=U(r);return{async decide(e){let a=b.parse({...e,funnelId:r.funnelId,operation:"campaign_decide"}),s=_.parse(await n.request("funnels",a));if(s.scope.projectId!==r.scope.projectId||s.scope.environment!==r.scope.environment)throw new o("SCOPE_MISMATCH","Campaign scope changed");let i=s.decisionId,u=s.requestId,m=Date.now()+(r.timeoutMs??3e4);for(;s.status==="pending";){if(Date.now()>=m)throw new S(i,u);if(await new Promise(f=>setTimeout(f,250)),s=await t.read(i),s.requestId!==u)throw new o("INVALID_RESPONSE","Campaign decision identity changed")}if(s.status==="failed")throw new o("DECISION_FAILED","Campaign decision execution failed");if(!s.decision||!v(s.decision,a.customer))throw new o("INVALID_RESPONSE","Campaign Customer changed");return s.decision},async start(e){let a=b.parse({...e,funnelId:r.funnelId,operation:"campaign_start"}),s=Z.parse(await n.request("funnels",a));if(s.scope.projectId!==r.scope.projectId||s.scope.environment!==r.scope.environment)throw new o("SCOPE_MISMATCH","Campaign scope changed");if(!("suppressed"in s)&&(s.run.source.id!==r.funnelId||!s.customerId||a.customer.type==="id"&&s.customerId!==a.customer.value))throw new o("INVALID_RESPONSE","Campaign Funnel or Customer changed");return s}}}function tt(){if(typeof window<"u")throw new o("SERVER_ONLY","Guest identity is issued by your backend");let r=crypto.getRandomValues(new Uint8Array(32));return"gg_gc_"+btoa(String.fromCharCode(...r)).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function nt(r){if(typeof window<"u")throw new o("SERVER_ONLY","Secret API keys must stay on your backend");let n=I(r);return n.identify(r.apiKey),{async getFeatures(t={}){let e=c.getFeatures;return p(e.response,await n.request(e.path,e.request.parse(t),e.method))},async evaluateFeatures(t){let e=c.evaluateFeatures;return p(e.response,await n.request(e.path,e.request.parse(t),e.method))},async trackEvents(t){let e=c.trackEvents;return p(e.response,await n.request(e.path,e.request.parse(t),e.method))},async resolvePaywall(t){let e=c.resolvePaywall;return p(e.response,await n.request(e.path,e.request.parse(t)))},async resolveOffering(t){let e=c.resolveOffering;return p(e.response,await n.request(e.path,e.request.parse(t)))},async checkEntitlement(t){let e=c.checkEntitlement;return p(e.response,await n.request(e.path,e.request.parse(t)))},async setupPayment(t){let e=c.setupPayment;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readPaymentSetup(t){let e=c.readPaymentSetup;return p(e.response,await n.request(e.path,e.request.parse(t)))},async previewSubscriptionBatch(t){let e=c.previewSubscriptionBatch;return p(e.response,await n.request(e.path,e.request.parse(t)))},async confirmSubscriptionBatch(t){let e=c.confirmSubscriptionBatch;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readSubscriptionBatch(t){let e=c.readSubscriptionBatch;return p(e.response,await n.request(e.path,e.request.parse(t)))},async abandonSubscriptionBatch(t){let e=c.abandonSubscriptionBatch;return p(e.response,await n.request(e.path,e.request.parse(t)))},async manageSubscriptionTrial(t){let e=c.manageSubscriptionTrial;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readSubscriptionTrial(t){let e=c.readSubscriptionTrial;return p(e.response,await n.request(e.path,e.request.parse(t)))},async listSubscriptions(t){let e=c.listSubscriptions;return p(e.response,await n.request(e.path,e.request.parse(t)))},async listPurchases(t){let e=c.listPurchases;return p(e.response,await n.request(e.path,e.request.parse(t)))},async listSubscriptionConflicts(t){let e=c.listSubscriptionConflicts;return p(e.response,await n.request(e.path,e.request.parse(t)))},async retrySubscriptionConflict(t){let e=c.retrySubscriptionConflict;return p(e.response,await n.request(e.path,e.request.parse(t)))},async previewRefund(t){let e=c.previewRefund;return p(e.response,await n.request(e.path,e.request.parse(t)))},async refund(t){let e=c.refund;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readRefund(t){let e=c.readRefund;return p(e.response,await n.request(e.path,e.request.parse(t)))},async previewUpdate(t){let e=c.previewUpdate;return p(e.response,await n.request(e.path,e.request.parse(t)))},async update(t){let e=c.update;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readSubscriptionUpdate(t){let e=c.readSubscriptionUpdate;return p(e.response,await n.request(e.path,e.request.parse(t)))},async restoreNativePurchase(t){let e=c.restoreNativePurchase;return p(e.response,await n.request(e.path,e.request.parse(t)))},async verifySubscriptions(t){let e=c.verifySubscriptions;return p(e.response,await n.request(e.path,e.request.parse(t)))},async previewAttach(t){let e=c.previewAttach;return p(e.response,await n.request(e.path,e.request.parse(t)))},async attach(t){let e=c.attach;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readSubscriptionOperation(t){let e=c.readSubscriptionOperation;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readAiPricing(t){let e=c.readAiPricing;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readUsage(t){let e=c.readUsage;return p(e.response,await n.request(e.path,e.request.parse(t)))},async setUsage(t){let e=c.setUsage;return p(e.response,await n.request(e.path,e.request.parse(t)))},async manageBalanceGrant(t){let e=c.manageBalanceGrant;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readBalanceSource(t){let e=c.readBalanceSource;return p(e.response,await n.request(e.path,e.request.parse(t)))},async adjustBalance(t){let e=c.adjustBalance;return p(e.response,await n.request(e.path,e.request.parse(t)))},async listBalanceGrants(t){let e=c.listBalanceGrants;return p(e.response,await n.request(e.path,e.request.parse(t)))},async manageBillingLimits(t){let e=c.manageBillingLimits;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readSeats(t){let e=c.readSeats;return p(e.response,await n.request(e.path,e.request.parse(t)))},async manageSeat(t){let e=c.manageSeat;return p(e.response,await n.request(e.path,e.request.parse(t)))},async manageUsageEntity(t){let e=c.manageUsageEntity;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readUsageAnalytics(t){let e=c.readUsageAnalytics;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readCreditAnalytics(t){let e=c.readCreditAnalytics;return p(e.response,await n.request(e.path,e.request.parse(t)))},async submitUsageBatch(t){let e=c.submitUsageBatch;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readUsageBatch(t){let e=c.readUsageBatch;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readHoldings(t){let e=c.readHoldings;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readLedger(t){let e=c.readLedger;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readBillingInvoice(t){let e=c.readBillingInvoice;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readCreditStatement(t){let e=c.readCreditStatement;return p(e.response,await n.request(e.path,e.request.parse(t)))},async quoteBalance(t){let e=c.quoteBalance;return p(e.response,await n.request(e.path,e.request.parse(t)))},async trackUsage(t){let e=c.trackUsage;return p(e.response,await n.request(e.path,e.request.parse(t)))},async mutateBalance(t){let e=c.mutateBalance;return p(e.response,await n.request(e.path,e.request.parse(t)))},async getCustomer(t){let e=c.getCustomer,a=e.request.safeParse(t);if(!a.success)throw new o("INVALID_REQUEST","Invalid customer lookup");let s=e.response.safeParse(await n.request(e.path,a.data));if(!s.success)throw new o("INVALID_RESPONSE","Invalid customer response");return s.data},async listCustomers(t={}){let e=c.listCustomers,a=e.request.safeParse(t);if(!a.success)throw new o("INVALID_REQUEST","Invalid customer filters");let s=e.response.safeParse(await n.request(e.path,a.data));if(!s.success)throw new o("INVALID_RESPONSE","Invalid customer response");return s.data},async updateCustomer(t){let e=c.updateCustomer,a=e.request.safeParse(t);if(!a.success)throw new o("INVALID_REQUEST","Invalid customer patch");let s=e.response.safeParse(await n.request(e.path,a.data));if(!s.success)throw new o("INVALID_RESPONSE","Invalid customer response");return s.data},async createGuestCustomer(t){let e=c.createGuestCustomer;return e.response.parse(await n.request(e.path,e.request.parse(t)))},async resumeGuestSession(t){let e=c.resumeGuestSession;return e.response.parse(await n.request(e.path,e.request.parse(t)))},async claimGuestCustomer(t){let e=c.claimGuestCustomer;return e.response.parse(await n.request(e.path,e.request.parse(t)))},async renewCustomerSession(t){let e=c.renewSession;return e.response.parse(await n.request(e.path,e.request.parse(t)))},async revokeCustomerSessions(t){let e=c.revokeSessions;return e.response.parse(await n.request(e.path,e.request.parse(t)))},async createCustomerSession(t){let e=c.createSession.request.safeParse({customerId:t});if(!e.success)throw new o("INVALID_REQUEST","A customer ID is required");let a=c.createSession.response.safeParse(await n.request("customer-sessions",e.data));if(!a.success)throw new o("INVALID_RESPONSE","Invalid customer session response");return a.data},async getOrCreateCustomer(t){let e=c.createCustomer.request.safeParse(t);if(!e.success)throw new o("INVALID_REQUEST","Invalid customer input");let a=c.createCustomer.response.safeParse(await n.request("customers",e.data));if(!a.success)throw new o("INVALID_RESPONSE","Invalid customer response");return a.data},async grantOffer(t){let e=c.grantOffer.request.safeParse({...t,requestId:t.requestId??crypto.randomUUID()});if(!e.success)throw new o("INVALID_REQUEST","Invalid offer grant");let a=c.grantOffer.response.safeParse(await n.request("offers/grant",e.data));if(!a.success)throw new o("INVALID_RESPONSE","Invalid offer response");return a.data}}}async function rt(r,n){if(typeof window<"u")throw new o("SERVER_ONLY","Renewal requires your backend");let{funnelCredentialCommandSchema:t,funnelCredentialResponseSchema:e}=await import("./src-RZJKF6LQ.js"),a=I(r);return a.identify(r.apiKey),e.parse(await a.request("funnels",t.parse({...n,operation:"renew_run"})))}export{S as FunnelDecisionTimeoutError,o as IndianaError,D as aiPriceSnapshotSchema,x as aiTokenQuoteSchema,ce as createAiPricing,Ae as createAiUsageMiddleware,he as createConfiguredAiPricing,T as createFeatureClient,Ee as createFunnelCampaignClient,U as createFunnelDecisionClient,qe as createFunnelOrchestrationClient,de as createFunnelStartClient,tt as createGuestToken,nt as createIndianaServer,me as createNativeReceiptClient,le as createPaywallStartClient,pe as evaluateFunnelNode,rt as renewFunnelRun};
1
+ import{a as T,b as v,d as te,e as pe,f as de}from"./chunk-VTSEZ4GI.js";import{a as o,b as I}from"./chunk-LFNFVYC2.js";import{$g as z,Dj as P,Ej as Y,G as O,Gj as H,Ik as b,Jk as Z,Kj as C,Lj as _,Lk as J,Mj as W,Rl as X,Sl as ee,Xg as j,Yg as Q,Zg as K,_g as G,gi as $,ui as c}from"./chunk-PVJKOUNE.js";import"./chunk-TZ6REIUE.js";function p(r,n){try{return r.parse(n)}catch{throw new o("INVALID_RESPONSE","Invalid gateway response")}}function le(r){if(typeof window<"u")throw new o("SERVER_ONLY","Secret API keys must stay on the backend");return{start:n=>te(r,n)}}var S=class extends o{constructor(t,e){super("DECISION_PENDING","Decision is still pending; read this decision ID or retry the original request ID",202,e);this.decisionId=t;this.decisionRequestId=e}decisionId;decisionRequestId};function U(r){if("remoteEval"in r)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(r.apiKey))throw new o("INVALID_TOKEN","A server API key is required");async function n(a,s,i=!1){let u=I({...r,fetch:(m,f)=>{let d=new Headers(f?.headers);return d.set("Accept-Encoding","identity"),i&&d.set("Prefer","respond-async"),(r.fetch??globalThis.fetch)(m,{...f,headers:d})},timeoutMs:Math.min(r.timeoutMs??1e4,s?Math.max(1,s-Date.now()):12e4)});return u.identify(r.apiKey),u.request("funnels",a)}async function t(a,s){let i=_.parse(await n(C.parse({operation:"read_decision",decisionId:a}),s));if(i.decisionId!==a)throw new o("INVALID_RESPONSE","Decision identity changed");return i}async function e(a,s,i=!1){let u=C.options[0].parse({...a,operation:"decide",funnelId:r.funnelId}),m;try{m=_.parse(await n(u,s,i))}catch(f){throw f instanceof o&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE"].includes(f.code)?new o("DECISION_ACCEPTANCE_UNKNOWN","Decision acceptance is unknown; retry the original request ID and input",f.status,a.requestId):f}if(m.requestId!==a.requestId||m.decision&&!v(m.decision,u.customer))throw new o("INVALID_RESPONSE","Decision request or customer changed");return{response:m,customer:u.customer}}return{async configuration(){let a=J.parse(await n({operation:"configuration",funnelId:r.funnelId}));if(a.scope.projectId!==r.scope.projectId||a.scope.environment!==r.scope.environment||a.funnelId!==r.funnelId)throw new o("SCOPE_MISMATCH","Configuration scope changed");return a},features(a={}){return T({...a,scope:r.scope,load:async()=>$.parse(await n({operation:"feature_config",funnelId:r.funnelId}))})},read:a=>t(a),async submit(a){return(await e(a,void 0,!0)).response},async decide(a){let s=Date.now()+3e4,i=await e(a,s),u=i.response,m=u.decisionId,f=250;for(;;){if(u.requestId!==a.requestId||u.decision&&!v(u.decision,i.customer))throw new o("INVALID_RESPONSE","Decision request or customer changed");if(u.decision)return u.decision;if(u.status==="failed")throw new o("DECISION_FAILED","Decision execution failed",503,a.requestId);if(Date.now()>=s)throw new S(m,a.requestId);if(await new Promise(d=>setTimeout(d,Math.min(f,s-Date.now()))),Date.now()>=s)throw new S(m,a.requestId);try{f=Math.min(1e3,f*2),u=await t(m,s)}catch(d){if(d instanceof o&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE","RATE_LIMITED"].includes(d.code))continue;throw d}}},async reportUsed(a){let s=W.parse(await n(C.parse({...a,operation:"report_used"})));if(s.decisionId!==a.decisionId||s.eventId!==a.eventId)throw new o("INVALID_RESPONSE","Usage receipt identity changed");return s}}}function me(r){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(r.apiKey))throw new o("INVALID_TOKEN","Server API key required");let n=I({...r,timeoutMs:r.timeoutMs??35e3});return n.identify(r.apiKey),{async recover(t){let e=X.parse(t);if(e.orderId!==e.receiptId)throw new o("INVALID_REQUEST","Native recovery requires the accepted commercial intent");let a=e.nativeEvidence,s={requestId:e.requestId,customerToken:e.customerToken,purchaseIntentId:e.orderId,...a===null?{intent:"read"}:a.provider==="apple"?{provider:"apple",signedTransaction:a.signedTransaction}:{provider:"google",purchaseToken:a.purchaseToken}},i=c.restoreNativePurchase.response.parse(await n.request(c.restoreNativePurchase.path,s));if(i.operation.requestId!==e.requestId)throw new o("INVALID_RESPONSE","Native receipt request identity changed");let u=ee.parse({scope:i.scope,requestId:e.requestId,orderId:i.operation.orderId,receiptId:i.operation.orderId,orderStatus:i.operation.status,refunded:i.operation.refunded,...i.operation.completion===null?{}:{nativeCompletion:{orderId:i.operation.orderId,receiptId:i.operation.orderId,...i.operation.completion}}});if(u.requestId!==e.requestId||u.orderId!==e.orderId||u.receiptId!==e.receiptId||u.scope.projectId!==r.scope.projectId||u.scope.environment!==r.scope.environment)throw new o("INVALID_RESPONSE","Current order receipt scope changed");return u}}}import{z as l}from"zod";var q=j,fe=l.string().regex(/^(0|[1-9]\d{0,5})(\.\d{1,12})?$/),se=l.strictObject(Object.fromEntries(q.map(r=>[r,l.number().int().nonnegative().max(1e9)]))),ie=Q,we=K,D=l.strictObject({modelId:ie,source:l.enum(["models.dev","custom"]),fetchedAt:l.iso.datetime(),rates:G,contextTier:l.number().int().nonnegative(),markupPercent:we}),x=l.strictObject({pricing:D,tokens:se,quantity:O,digest:l.string().regex(/^[a-f0-9]{64}$/)}),oe=r=>{let[n,t=""]=r.split(".");return BigInt(n)*10n**12n+BigInt(t.padEnd(12,"0"))};function Ie(r){if(typeof r!="number"||!Number.isFinite(r)||r<0)throw new o("AI_PRICE_UNAVAILABLE","A published token price is missing");let n=String(r),t=n.includes("e")?r.toFixed(12).replace(/0+$/,"").replace(/\.$/,""):n;if(Number(t)!==r||!fe.safeParse(t).success)throw new o("AI_PRICE_UNAVAILABLE","Published price exceeds the supported precision");return t}var ne=l.strictObject({input:l.number().nonnegative(),output:l.number().nonnegative(),cache_read:l.number().nonnegative().optional(),cache_write:l.number().nonnegative().optional(),reasoning:l.number().nonnegative().optional(),input_audio:l.number().nonnegative().optional(),output_audio:l.number().nonnegative().optional()}),ge=ne.extend({context_over_200k:l.unknown().optional(),tiers:l.array(ne.extend({tier:l.strictObject({type:l.literal("context"),size:l.number().int().nonnegative()})})).max(20).refine(r=>new Set(r.map(n=>n.tier.size)).size===r.length).optional()});async function re(r,n,t){let e=new TextEncoder().encode(JSON.stringify({pricing:r,tokens:n,quantity:t}));return[...new Uint8Array(await crypto.subtle.digest("SHA-256",e))].map(a=>a.toString(16).padStart(2,"0")).join("")}function ae(r,n){let t=0n;for(let w of q){if(!n[w])continue;let g=r.rates[w];if(g===void 0)throw new o("AI_PRICE_UNAVAILABLE",`No published price for ${w}; report exclusive token pools`);t+=oe(g)*BigInt(n[w])}let[e,a="0"]=String(r.markupPercent).split("e"),s=(e.split(".")[1]?.length??0)-Number(a),i=10n**BigInt(Math.max(s,0)),u=BigInt(e.replace(".",""))*10n**BigInt(Math.max(-s,0)),m=100n*i+u,f=100n*i*1000000n,d=(t*m+f-1n)/f;return O.parse(`${d/1000000n}.${(d%1000000n).toString().padStart(6,"0")}`)}function ce(r={}){if(typeof window<"u")throw new o("SERVER_ONLY","AI token pricing belongs on your backend");let n=z.parse({defaultMarkup:r.defaultMarkup??0,providerMarkups:r.providerMarkups??{},modelMarkups:r.modelMarkups??{},customModels:r.customModels??{}}),t=null,e=0;async function a(){if(!t||Date.now()>=e){e=Date.now()+15*6e4;let s=(async()=>{let i=await(r.fetch??fetch)("https://models.dev/api.json",{signal:AbortSignal.timeout(3e4)});if(!i.ok)throw new o("AI_PRICE_UNAVAILABLE","Models.dev pricing is unavailable");return{data:l.record(l.string(),l.object({models:l.record(l.string(),l.unknown())})).parse(await i.json()),fetchedAt:new Date().toISOString()}})().catch(i=>{throw t===s&&(t=null),i});t=s}return t}return{refreshPrices(){t=null,e=0},async quoteTokens(s){let i=ie.parse(s.modelId),u=se.parse(s.tokens),[m,...f]=i.split("/"),d=n.customModels[i],w,g,h,L=0;if(d?.input!==void 0&&d.output!==void 0&&q.every(E=>u[E]===0||d[E]!==void 0))w={...d,input:d.input,output:d.output},g="custom",h=new Date().toISOString();else{let E=await a(),V=E.data[m]?.models[f.join("/")];if(!V)throw new o("AI_PRICE_UNAVAILABLE","Unknown model; configure a complete custom price");let{cost:k}=l.object({cost:ge}).parse(V),M=u.input+u.cache_read+u.cache_write+u.input_audio;if(k.tiers===void 0&&k.context_over_200k!==void 0&&M>2e5)throw new o("AI_PRICE_UNAVAILABLE","A current context tier is required for this model");let N=k.tiers?.filter(y=>M>y.tier.size).sort((y,ue)=>ue.tier.size-y.tier.size)[0],B=N??k;N&&(L=N.tier.size),w=Object.fromEntries(q.filter(y=>B[y]!==void 0).map(y=>[y,Ie(B[y])])),w={...w,...d},g=d?"custom":"models.dev",h=E.fetchedAt}let R=D.parse({modelId:i,source:g,fetchedAt:h,rates:w,contextTier:L,markupPercent:n.modelMarkups[i]??n.providerMarkups[m]??n.defaultMarkup}),F=ae(R,u);return x.parse({pricing:R,tokens:u,quantity:F,digest:await re(R,u,F)})},async trackTokens(s,i){let u=x.parse(i.quote);if(u.quantity!==ae(u.pricing,u.tokens)||u.digest!==await re(u.pricing,u.tokens,u.quantity))throw new o("INVALID_REQUEST","AI quote changed after pricing");let m=i.properties??{},f=i.providerCostUsd===void 0?void 0:l.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,18})?$/).parse(i.providerCostUsd),d=i.generationId===void 0?void 0:l.string().min(1).max(120).parse(i.generationId),w=8+ +(f!==void 0)+ +(d!==void 0);if(Object.keys(m).some(h=>h.startsWith("ai_")))throw new o("INVALID_REQUEST","AI tracking reserves ai_ event properties");if(Object.keys(m).length>16-w)throw new o("INVALID_REQUEST","AI tracking properties exceed the available event budget");let g={operation:"consume",internal_feature_id:i.internal_feature_id,quantity:u.quantity,idempotencyKey:i.idempotencyKey,properties:{...m,...f!==void 0?{ai_provider_cost_usd:f}:{},...d!==void 0?{ai_generation_id:d}:{},ai_model:u.pricing.modelId,ai_source:u.pricing.source,ai_price_at:u.pricing.fetchedAt,ai_quote_hash:u.digest,ai_markup:String(u.pricing.markupPercent),ai_tier:String(u.pricing.contextTier),ai_tokens:q.map(h=>u.tokens[h]).join(","),ai_rates:"v1:"+q.map(h=>u.pricing.rates[h]===void 0?"-":oe(u.pricing.rates[h]).toString(36)).join(",")},...i.entityId?{entityId:i.entityId}:{}};return s.mutateBalance({customerId:i.customerId,command:g})}}}async function he(r,n,t={}){let{config:e,model_markups:a}=await r.readAiPricing(n);return ce({defaultMarkup:e.default_markup??0,providerMarkups:Object.fromEntries(Object.entries(e.provider_markups??{}).map(([s,i])=>[s,i.markup])),modelMarkups:Object.fromEntries(Object.entries(a??{}).filter(([,s])=>s.markup!==void 0).map(([s,i])=>[s,i.markup])),customModels:Object.fromEntries(Object.entries(a??{}).filter(([,s])=>s.input_cost!==void 0||s.output_cost!==void 0).map(([s,i])=>[s,{...i.input_cost!==void 0?{input:String(i.input_cost)}:{},...i.output_cost!==void 0?{output:String(i.output_cost)}:{}}])),...t})}import{z as ye}from"zod";var A=ye.number().int().min(0).max(Number.MAX_SAFE_INTEGER);function Se(r,n){let t=A.parse(r.inputTokens.total),e=A.parse(r.outputTokens.total),a=A.parse(r.inputTokens.cacheRead??0),s=A.parse(r.inputTokens.cacheWrite??0),i=A.parse(r.outputTokens.reasoning??0);if(a+s>t||i>e||r.inputTokens.noCache!==void 0&&A.parse(r.inputTokens.noCache)!==t-a-s||r.outputTokens.text!==void 0&&A.parse(r.outputTokens.text)!==e-i)throw new o("AI_USAGE_UNAVAILABLE","Provider token counts do not conserve total usage");return{input:t-a-s,cache_read:a,cache_write:s,output:n==="output"?e:e-i,reasoning:n==="separate"?i:0,input_audio:0,output_audio:0}}function Ae(r){if(typeof window<"u")throw new o("SERVER_ONLY","AI usage belongs on the trusted backend");if(!r.modelId||!["output","separate"].includes(r.reasoning))throw new o("INVALID_REQUEST","Model ID and reasoning pricing are required");async function n(e){await r.persist({context:e,modelId:r.modelId,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"})}async function t(e,a){let s={context:e,modelId:r.modelId,usage:a,tokens:null,quote:null,receipt:null,phase:"captured"};await r.persist(s);let i=r.mapTokens?r.mapTokens(a):Se(a,r.reasoning),u=await r.pricing.quoteTokens({modelId:r.modelId,tokens:i});await r.persist({...s,tokens:i,quote:u,phase:"quoted"});let m=await r.pricing.trackTokens(r.client,{...e,quote:u});if(!m.receipt.accepted)throw new o("AI_BALANCE_REJECTED","AI usage was captured but the balance operation was rejected");await r.persist({...s,tokens:i,quote:u,receipt:m,phase:"settled"})}return{specificationVersion:"v4",async wrapGenerate({doGenerate:e}){let a=await r.context(),s;try{s=await e()}catch(i){throw await n(a),i}return await t(a,s.usage),s},async wrapStream({doStream:e}){let a=await r.context(),s;try{s=await e()}catch(d){throw await n(a),d}let i=!1,u=!1,m=s.stream.getReader();async function f(){i||u||(u=!0,await n(a))}return{...s,stream:new ReadableStream({async pull(d){try{let{value:w,done:g}=await m.read();if(g){if(!i)throw await f(),new o("AI_USAGE_UNAVAILABLE","Stream ended without final usage; no amount was invented");d.close();return}if(w.type==="finish"){if(i)throw new o("AI_USAGE_UNAVAILABLE","Provider sent more than one final usage record");i=!0,await t(a,w.usage)}d.enqueue(w)}catch(w){try{await f()}finally{d.error(w),await m.cancel(w)}}},async cancel(d){try{await f()}finally{await m.cancel(d)}}})}}}}function qe(r){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(r.apiKey))throw new o("INVALID_TOKEN","A server API key is required");let n=I(r);return n.identify(r.apiKey),{async signal(t){let e=P.parse({...t,operation:"signal"}),a=Y.parse(await n.request("funnels",e));if(a.runId!==t.runId||a.eventId!==t.eventId||a.scope.projectId!==r.scope.projectId||a.scope.environment!==r.scope.environment)throw new o("INVALID_RESPONSE","Receipt identity changed");return a},async readResults(t){let e=P.parse({operation:"read_results",runId:t}),a=H.parse(await n.request("funnels",e));if(a.runId!==t||a.scope.projectId!==r.scope.projectId||a.scope.environment!==r.scope.environment)throw new o("INVALID_RESPONSE","Result identity changed");return a}}}function Ee(r){if(typeof window<"u")throw new o("SERVER_ONLY","Campaign entry requires your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(r.apiKey))throw new o("INVALID_TOKEN","A server API key is required");let n=I({...r,timeoutMs:r.timeoutMs??35e3});n.identify(r.apiKey);let t=U(r);return{async decide(e){let a=b.parse({...e,funnelId:r.funnelId,operation:"campaign_decide"}),s=_.parse(await n.request("funnels",a));if(s.scope.projectId!==r.scope.projectId||s.scope.environment!==r.scope.environment)throw new o("SCOPE_MISMATCH","Campaign scope changed");let i=s.decisionId,u=s.requestId,m=Date.now()+(r.timeoutMs??3e4);for(;s.status==="pending";){if(Date.now()>=m)throw new S(i,u);if(await new Promise(f=>setTimeout(f,250)),s=await t.read(i),s.requestId!==u)throw new o("INVALID_RESPONSE","Campaign decision identity changed")}if(s.status==="failed")throw new o("DECISION_FAILED","Campaign decision execution failed");if(!s.decision||!v(s.decision,a.customer))throw new o("INVALID_RESPONSE","Campaign Customer changed");return s.decision},async start(e){let a=b.parse({...e,funnelId:r.funnelId,operation:"campaign_start"}),s=Z.parse(await n.request("funnels",a));if(s.scope.projectId!==r.scope.projectId||s.scope.environment!==r.scope.environment)throw new o("SCOPE_MISMATCH","Campaign scope changed");if(!("suppressed"in s)&&(s.run.source.id!==r.funnelId||!s.customerId||a.customer.type==="id"&&s.customerId!==a.customer.value))throw new o("INVALID_RESPONSE","Campaign Funnel or Customer changed");return s}}}function tt(){if(typeof window<"u")throw new o("SERVER_ONLY","Guest identity is issued by your backend");let r=crypto.getRandomValues(new Uint8Array(32));return"gg_gc_"+btoa(String.fromCharCode(...r)).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function nt(r){if(typeof window<"u")throw new o("SERVER_ONLY","Secret API keys must stay on your backend");let n=I(r);return n.identify(r.apiKey),{async getFeatures(t={}){let e=c.getFeatures;return p(e.response,await n.request(e.path,e.request.parse(t),e.method))},async evaluateFeatures(t){let e=c.evaluateFeatures;return p(e.response,await n.request(e.path,e.request.parse(t),e.method))},async trackEvents(t){let e=c.trackEvents;return p(e.response,await n.request(e.path,e.request.parse(t),e.method))},async resolvePaywall(t){let e=c.resolvePaywall;return p(e.response,await n.request(e.path,e.request.parse(t)))},async resolveOffering(t){let e=c.resolveOffering;return p(e.response,await n.request(e.path,e.request.parse(t)))},async checkEntitlement(t){let e=c.checkEntitlement;return p(e.response,await n.request(e.path,e.request.parse(t)))},async setupPayment(t){let e=c.setupPayment;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readPaymentSetup(t){let e=c.readPaymentSetup;return p(e.response,await n.request(e.path,e.request.parse(t)))},async previewSubscriptionBatch(t){let e=c.previewSubscriptionBatch;return p(e.response,await n.request(e.path,e.request.parse(t)))},async confirmSubscriptionBatch(t){let e=c.confirmSubscriptionBatch;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readSubscriptionBatch(t){let e=c.readSubscriptionBatch;return p(e.response,await n.request(e.path,e.request.parse(t)))},async abandonSubscriptionBatch(t){let e=c.abandonSubscriptionBatch;return p(e.response,await n.request(e.path,e.request.parse(t)))},async manageSubscriptionTrial(t){let e=c.manageSubscriptionTrial;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readSubscriptionTrial(t){let e=c.readSubscriptionTrial;return p(e.response,await n.request(e.path,e.request.parse(t)))},async listSubscriptions(t){let e=c.listSubscriptions;return p(e.response,await n.request(e.path,e.request.parse(t)))},async listPurchases(t){let e=c.listPurchases;return p(e.response,await n.request(e.path,e.request.parse(t)))},async listSubscriptionConflicts(t){let e=c.listSubscriptionConflicts;return p(e.response,await n.request(e.path,e.request.parse(t)))},async retrySubscriptionConflict(t){let e=c.retrySubscriptionConflict;return p(e.response,await n.request(e.path,e.request.parse(t)))},async previewRefund(t){let e=c.previewRefund;return p(e.response,await n.request(e.path,e.request.parse(t)))},async refund(t){let e=c.refund;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readRefund(t){let e=c.readRefund;return p(e.response,await n.request(e.path,e.request.parse(t)))},async previewUpdate(t){let e=c.previewUpdate;return p(e.response,await n.request(e.path,e.request.parse(t)))},async update(t){let e=c.update;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readSubscriptionUpdate(t){let e=c.readSubscriptionUpdate;return p(e.response,await n.request(e.path,e.request.parse(t)))},async restoreNativePurchase(t){let e=c.restoreNativePurchase;return p(e.response,await n.request(e.path,e.request.parse(t)))},async verifySubscriptions(t){let e=c.verifySubscriptions;return p(e.response,await n.request(e.path,e.request.parse(t)))},async previewAttach(t){let e=c.previewAttach;return p(e.response,await n.request(e.path,e.request.parse(t)))},async attach(t){let e=c.attach;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readSubscriptionOperation(t){let e=c.readSubscriptionOperation;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readAiPricing(t){let e=c.readAiPricing;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readUsage(t){let e=c.readUsage;return p(e.response,await n.request(e.path,e.request.parse(t)))},async setUsage(t){let e=c.setUsage;return p(e.response,await n.request(e.path,e.request.parse(t)))},async manageBalanceGrant(t){let e=c.manageBalanceGrant;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readBalanceSource(t){let e=c.readBalanceSource;return p(e.response,await n.request(e.path,e.request.parse(t)))},async adjustBalance(t){let e=c.adjustBalance;return p(e.response,await n.request(e.path,e.request.parse(t)))},async listBalanceGrants(t){let e=c.listBalanceGrants;return p(e.response,await n.request(e.path,e.request.parse(t)))},async manageBillingLimits(t){let e=c.manageBillingLimits;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readSeats(t){let e=c.readSeats;return p(e.response,await n.request(e.path,e.request.parse(t)))},async manageSeat(t){let e=c.manageSeat;return p(e.response,await n.request(e.path,e.request.parse(t)))},async manageUsageEntity(t){let e=c.manageUsageEntity;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readUsageAnalytics(t){let e=c.readUsageAnalytics;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readCreditAnalytics(t){let e=c.readCreditAnalytics;return p(e.response,await n.request(e.path,e.request.parse(t)))},async submitUsageBatch(t){let e=c.submitUsageBatch;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readUsageBatch(t){let e=c.readUsageBatch;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readHoldings(t){let e=c.readHoldings;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readLedger(t){let e=c.readLedger;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readBillingInvoice(t){let e=c.readBillingInvoice;return p(e.response,await n.request(e.path,e.request.parse(t)))},async readCreditStatement(t){let e=c.readCreditStatement;return p(e.response,await n.request(e.path,e.request.parse(t)))},async quoteBalance(t){let e=c.quoteBalance;return p(e.response,await n.request(e.path,e.request.parse(t)))},async trackUsage(t){let e=c.trackUsage;return p(e.response,await n.request(e.path,e.request.parse(t)))},async mutateBalance(t){let e=c.mutateBalance;return p(e.response,await n.request(e.path,e.request.parse(t)))},async getCustomer(t){let e=c.getCustomer,a=e.request.safeParse(t);if(!a.success)throw new o("INVALID_REQUEST","Invalid customer lookup");let s=e.response.safeParse(await n.request(e.path,a.data));if(!s.success)throw new o("INVALID_RESPONSE","Invalid customer response");return s.data},async listCustomers(t={}){let e=c.listCustomers,a=e.request.safeParse(t);if(!a.success)throw new o("INVALID_REQUEST","Invalid customer filters");let s=e.response.safeParse(await n.request(e.path,a.data));if(!s.success)throw new o("INVALID_RESPONSE","Invalid customer response");return s.data},async updateCustomer(t){let e=c.updateCustomer,a=e.request.safeParse(t);if(!a.success)throw new o("INVALID_REQUEST","Invalid customer patch");let s=e.response.safeParse(await n.request(e.path,a.data));if(!s.success)throw new o("INVALID_RESPONSE","Invalid customer response");return s.data},async createGuestCustomer(t){let e=c.createGuestCustomer;return e.response.parse(await n.request(e.path,e.request.parse(t)))},async resumeGuestSession(t){let e=c.resumeGuestSession;return e.response.parse(await n.request(e.path,e.request.parse(t)))},async claimGuestCustomer(t){let e=c.claimGuestCustomer;return e.response.parse(await n.request(e.path,e.request.parse(t)))},async renewCustomerSession(t){let e=c.renewSession;return e.response.parse(await n.request(e.path,e.request.parse(t)))},async revokeCustomerSessions(t){let e=c.revokeSessions;return e.response.parse(await n.request(e.path,e.request.parse(t)))},async createCustomerSession(t){let e=c.createSession.request.safeParse({customerId:t});if(!e.success)throw new o("INVALID_REQUEST","A customer ID is required");let a=c.createSession.response.safeParse(await n.request("customer-sessions",e.data));if(!a.success)throw new o("INVALID_RESPONSE","Invalid customer session response");return a.data},async getOrCreateCustomer(t){let e=c.createCustomer.request.safeParse(t);if(!e.success)throw new o("INVALID_REQUEST","Invalid customer input");let a=c.createCustomer.response.safeParse(await n.request("customers",e.data));if(!a.success)throw new o("INVALID_RESPONSE","Invalid customer response");return a.data},async grantOffer(t){let e=c.grantOffer.request.safeParse({...t,requestId:t.requestId??crypto.randomUUID()});if(!e.success)throw new o("INVALID_REQUEST","Invalid offer grant");let a=c.grantOffer.response.safeParse(await n.request("offers/grant",e.data));if(!a.success)throw new o("INVALID_RESPONSE","Invalid offer response");return a.data}}}async function rt(r,n){if(typeof window<"u")throw new o("SERVER_ONLY","Renewal requires your backend");let{funnelCredentialCommandSchema:t,funnelCredentialResponseSchema:e}=await import("./src-XEDJAKEB.js"),a=I(r);return a.identify(r.apiKey),e.parse(await a.request("funnels",t.parse({...n,operation:"renew_run"})))}export{S as FunnelDecisionTimeoutError,o as IndianaError,D as aiPriceSnapshotSchema,x as aiTokenQuoteSchema,ce as createAiPricing,Ae as createAiUsageMiddleware,he as createConfiguredAiPricing,T as createFeatureClient,Ee as createFunnelCampaignClient,U as createFunnelDecisionClient,qe as createFunnelOrchestrationClient,de as createFunnelStartClient,tt as createGuestToken,nt as createIndianaServer,me as createNativeReceiptClient,le as createPaywallStartClient,pe as evaluateFunnelNode,rt as renewFunnelRun};
@@ -0,0 +1 @@
1
+ import{$,$a as hb,$b as hc,$c as hd,$d as he,$e as hf,$f as ig,$g as ih,$h as ii,$i as ij,$j as ik,$k as il,$l as im,A,Aa as Ia,Ab as Ib,Ac as Ic,Ad as Id,Ae as Ie,Af as Jf,Ag as Jg,Ah as Jh,Ai as Ji,Aj as Jj,Ak as Jk,Al as Jl,Am as Jm,B,Ba as Ja,Bb as Jb,Bc as Jc,Bd as Jd,Be as Je,Bf as Kf,Bg as Kg,Bh as Kh,Bi as Ki,Bj as Kj,Bk as Kk,Bl as Kl,Bm as Km,C,Ca as Ka,Cb as Kb,Cc as Kc,Cd as Kd,Ce as Ke,Cf as Lf,Cg as Lg,Ch as Lh,Ci as Li,Cj as Lj,Ck as Lk,Cl as Ll,Cm as Lm,D,Da as La,Db as Lb,Dc as Lc,Dd as Ld,De as Le,Df as Mf,Dg as Mg,Dh as Mh,Di as Mi,Dj as Mj,Dk as Mk,Dl as Ml,Dm as Mm,E,Ea as Ma,Eb as Mb,Ec as Mc,Ed as Md,Ee as Me,Ef as Nf,Eg as Ng,Eh as Nh,Ei as Ni,Ej as Nj,Ek as Nk,El as Nl,Em as Nm,F,Fa as Na,Fb as Nb,Fc as Nc,Fd as Nd,Fe as Ne,Ff as Of,Fg as Og,Fh as Oh,Fi as Oi,Fj as Oj,Fk as Ok,Fl as Ol,Fm as Om,G,Ga as Oa,Gb as Ob,Gc as Oc,Gd as Od,Ge as Oe,Gf as Pf,Gg as Pg,Gh as Ph,Gi as Pi,Gj as Pj,Gk as Pk,Gl as Pl,Gm as Pm,H,Ha as Pa,Hb as Pb,Hc as Pc,Hd as Pd,He as Pe,Hf as Qf,Hg as Qg,Hh as Qh,Hi as Qi,Hj as Qj,Hk as Qk,Hl as Ql,Hm as Qm,I,Ia as Qa,Ib as Qb,Ic as Qc,Id as Qd,Ie as Qe,If as Rf,Ig as Rg,Ih as Rh,Ii as Ri,Ij as Rj,Ik as Rk,Il as Rl,Im as Rm,J,Ja as Ra,Jb as Rb,Jc as Rc,Jd as Rd,Je as Re,Jf as Sf,Jg as Sg,Jh as Sh,Ji as Si,Jj as Sj,Jk as Sk,Jl as Sl,K,Ka as Sa,Kb as Sb,Kc as Sc,Kd as Sd,Ke as Se,Kf as Tf,Kg as Tg,Kh as Th,Ki as Ti,Kj as Tj,Kk as Tk,Kl as Tl,L,La as Ta,Lb as Tb,Lc as Tc,Ld as Td,Le as Te,Lf as Uf,Lg as Ug,Lh as Uh,Li as Ui,Lj as Uj,Lk as Uk,Ll as Ul,M,Ma as Ua,Mb as Ub,Mc as Uc,Md as Ud,Me as Ue,Mf as Vf,Mg as Vg,Mh as Vh,Mi as Vi,Mj as Vj,Mk as Vk,Ml as Vl,N,Na as Va,Nb as Vb,Nc as Vc,Nd as Vd,Ne as Ve,Nf as Wf,Ng as Wg,Nh as Wh,Ni as Wi,Nj as Wj,Nk as Wk,Nl as Wl,O,Oa as Wa,Ob as Wb,Oc as Wc,Od as Wd,Oe as We,Of as Xf,Og as Xg,Oh as Xh,Oi as Xi,Oj as Xj,Ok as Xk,Ol as Xl,P,Pa as Xa,Pb as Xb,Pc as Xc,Pd as Xd,Pe as Xe,Pf as Yf,Pg as Yg,Ph as Yh,Pi as Yi,Pj as Yj,Pk as Yk,Pl as Yl,Q,Qa as Ya,Qb as Yb,Qc as Yc,Qd as Yd,Qe as Ye,Qf as Zf,Qg as Zg,Qh as Zh,Qi as Zi,Qj as Zj,Qk as Zk,Ql as Zl,R,Ra as Za,Rb as Zb,Rc as Zc,Rd as Zd,Re as Ze,Rf as _f,Rg as _g,Rh as _h,Ri as _i,Rj as _j,Rk as _k,Rl as _l,S,Sa as _a,Sb as _b,Sc as _c,Sd as _d,Se as _e,Sf as $f,Sg as $g,Sh as $h,Si as $i,Sj as $j,Sk as $k,Sl as $l,T,Ta as $a,Tb as $b,Tc as $c,Td as $d,Te as $e,Tf as ag,Tg as ah,Th as ai,Ti as aj,Tj as ak,Tk as al,Tl as am,U,Ua as ab,Ub as ac,Uc as ad,Ud as ae,Ue as af,Uf as bg,Ug as bh,Uh as bi,Ui as bj,Uj as bk,Uk as bl,Ul as bm,V,Va as bb,Vb as bc,Vc as bd,Vd as be,Ve as bf,Vf as cg,Vg as ch,Vh as ci,Vi as cj,Vj as ck,Vk as cl,Vl as cm,W,Wa as cb,Wb as cc,Wc as cd,Wd as ce,We as cf,Wf as dg,Wg as dh,Wh as di,Wi as dj,Wj as dk,Wk as dl,Wl as dm,X,Xa as db,Xb as dc,Xc as dd,Xd as de,Xe as df,Xf as eg,Xg as eh,Xh as ei,Xi as ej,Xj as ek,Xk as el,Xl as em,Y,Ya as eb,Yb as ec,Yc as ed,Yd as ee,Ye as ef,Yf as fg,Yg as fh,Yh as fi,Yi as fj,Yj as fk,Yk as fl,Yl as fm,Z,Za as fb,Zb as fc,Zc as fd,Zd as fe,Ze as ff,Zf as gg,Zg as gh,Zh as gi,Zi as gj,Zj as gk,Zk as gl,Zl as gm,_,_a as gb,_b as gc,_c as gd,_d as ge,_e as gf,_f as hg,_g as hh,_h as hi,_i as hj,_j as hk,_k as hl,_l as hm,a,aa,ab as ib,ac as ic,ad as id,ae as ie,af as jf,ag as jg,ah as jh,ai as ji,aj as jj,ak as jk,al as jl,am as jm,b,ba,bb as jb,bc as jc,bd as jd,be as je,bf as kf,bg as kg,bh as kh,bi as ki,bj as kj,bk as kk,bl as kl,bm as km,c,ca,cb as kb,cc as kc,cd as kd,ce as ke,cf as lf,cg as lg,ch as lh,ci as li,cj as lj,ck as lk,cl as ll,cm as lm,d,da,db as lb,dc as lc,dd as ld,de as le,df as mf,dg as mg,dh as mh,di as mi,dj as mj,dk as mk,dl as ml,dm as mm,e,ea,eb as mb,ec as mc,ed as md,ee as me,ef as nf,eg as ng,eh as nh,ei as ni,ej as nj,ek as nk,el as nl,em as nm,f,fa,fb as nb,fc as nc,fd as nd,fe as ne,ff as of,fg as og,fh as oh,fi as oi,fj as oj,fk as ok,fl as ol,fm as om,g,ga,gb as ob,gc as oc,gd as od,ge as oe,gf as pf,gg as pg,gh as ph,gi as pi,gj as pj,gk as pk,gl as pl,gm as pm,h,ha,hb as pb,hc as pc,hd as pd,he as pe,hf as qf,hg as qg,hh as qh,hi as qi,hj as qj,hk as qk,hl as ql,hm as qm,i,ia,ib as qb,ic as qc,id as qd,ie as qe,if as rf,ig as rg,ih as rh,ii as ri,ij as rj,ik as rk,il as rl,im as rm,j,ja,jb as rb,jc as rc,jd as rd,je as re,jf as sf,jg as sg,jh as sh,ji as si,jj as sj,jk as sk,jl as sl,jm as sm,k,ka,kb as sb,kc as sc,kd as sd,ke as se,kf as tf,kg as tg,kh as th,ki as ti,kj as tj,kk as tk,kl as tl,km as tm,l,la as ta,lb as tb,lc as tc,ld as td,le as te,lf as uf,lg as ug,lh as uh,li as ui,lj as uj,lk as uk,ll as ul,lm as um,m,ma as ua,mb as ub,mc as uc,md as ud,me as ue,mf as vf,mg as vg,mh as vh,mi as vi,mj as vj,mk as vk,ml as vl,mm as vm,n,na as va,nb as vb,nc as vc,nd as vd,ne as ve,nf as wf,ng as wg,nh as wh,ni as wi,nj as wj,nk as wk,nl as wl,nm as wm,o,oa as wa,ob as wb,oc as wc,od as wd,oe as we,of as xf,og as xg,oh as xh,oi as xi,oj as xj,ok as xk,ol as xl,om as xm,p,pa as xa,pb as xb,pc as xc,pd as xd,pe as xe,pf as yf,pg as yg,ph as yh,pi as yi,pj as yj,pk as yk,pl as yl,pm as ym,q,qa as ya,qb as yb,qc as yc,qd as yd,qe as ye,qf as zf,qg as zg,qh as zh,qi as zi,qj as zj,qk as zk,ql as zl,qm as zm,r,ra as za,rb as zb,rc as zc,rd as zd,re as ze,rf as Af,rg as Ag,rh as Ah,ri as Ai,rj as Aj,rk as Ak,rl as Al,rm as Am,s,sa as Aa,sb as Ab,sc as Ac,sd as Ad,se as Ae,sf as Bf,sg as Bg,sh as Bh,si as Bi,sj as Bj,sk as Bk,sl as Bl,sm as Bm,t,ta as Ba,tb as Bb,tc as Bc,td as Bd,te as Be,tf as Cf,tg as Cg,th as Ch,ti as Ci,tj as Cj,tk as Ck,tl as Cl,tm as Cm,u,ua as Ca,ub as Cb,uc as Cc,ud as Cd,ue as Ce,uf as Df,ug as Dg,uh as Dh,ui as Di,uj as Dj,uk as Dk,ul as Dl,um as Dm,v,va as Da,vb as Db,vc as Dc,vd as Dd,ve as De,vf as Ef,vg as Eg,vh as Eh,vi as Ei,vj as Ej,vk as Ek,vl as El,vm as Em,w,wa as Ea,wb as Eb,wc as Ec,wd as Ed,we as Ee,wf as Ff,wg as Fg,wh as Fh,wi as Fi,wj as Fj,wk as Fk,wl as Fl,wm as Fm,x,xa as Fa,xb as Fb,xc as Fc,xd as Fd,xe as Fe,xf as Gf,xg as Gg,xh as Gh,xi as Gi,xj as Gj,xk as Gk,xl as Gl,xm as Gm,y,ya as Ga,yb as Gb,yc as Gc,yd as Gd,ye as Ge,yf as Hf,yg as Hg,yh as Hh,yi as Hi,yj as Hj,yk as Hk,yl as Hl,ym as Hm,z,za as Ha,zb as Hb,zc as Hc,zd as Hd,ze as He,zf as If,zg as Ig,zh as Ih,zi as Ii,zj as Ij,zk as Ik,zl as Il,zm as Im}from"./chunk-PVJKOUNE.js";import{a as la,b as ma,c as na,d as oa,e as pa,f as qa,g as ra,h as sa}from"./chunk-TZ6REIUE.js";export{Pa as COMMON_LOCALES,Ra as COUPON_TERM_LOCALES,Cf as CUSTOMER_DATA_SOURCES,Cl as DEFAULT_AUDIENCE_GROUP,Ij as DEFAULT_FUNNEL_EXECUTION_POLICY,ak as FUNNEL_API_CAPABILITIES,Li as FUNNEL_LIMITS,Xk as FUNNEL_PREVIEW_LIMITS,Ue as OFFERING_MAX_DEPTH,We as OFFERING_MAX_ITEMS,Ve as OFFERING_MAX_PRODUCTS,wg as POPUP_WIDTHS,Nf as SCREEN_LIMITS,Fi as SCREEN_RENDER_PATH,Mf as SCREEN_SCHEMA_VERSION,Oi as SCREEN_TEMPLATES,vc as SDK_PROTOCOL_HEADER,xc as SDK_SUPPORT_HEADER,yc as SDK_SUPPORT_POLICY,wc as SDK_VERSION_HEADER,ug as SURFACE_PATHS,uf as SURFACE_VARIABLES,Ec as SdkProtocolError,Mi as UNBOUND_PRODUCT_VERSION_ID,Qm as VISUAL_EDITOR_PARAM,Cc as addSupportMonths,j as aiCreditSystemConfigSchema,gh as aiMarkupSchema,fh as aiModelIdSchema,hh as aiModelRatesSchema,ih as aiPricingConfigurationSchema,eh as aiTokenPools,w as amountToMinor,hi as analyticsConfigSchema,ji as analyticsEventEnabled,lc as apiErrorCatalog,mc as apiErrorCodeForStatus,gc as apiErrorCodeSchema,Di as apiOperations,wi as apiPermissionSchema,Wl as appResultsSchema,Vl as appRevenueSchema,dm as appendScreenTemplate,Bm as applyGrowthReleasePlan,nj as archiveSurfaceTemplateSchema,Fl as audienceCustomerSchema,Ol as audienceFunnelUsageSchema,Pl as audienceFunnelUsagesSchema,Gl as audienceMembersSchema,Hc as audienceSchema,El as audienceWriteSchema,xl as auditFieldSchema,Al as auditHistoryCursorSchema,Bl as auditHistorySchema,wl as auditResourceSchema,qb as autoTopupPurchaseLimitSchema,Cb as autoTopupStateSchema,Im as autumnAmountToMinor,ll as autumnCustomerAutoTopupSchema,ql as autumnCustomerControlsSchema,sl as autumnCustomerMetadataSchema,pl as autumnCustomerOverageAllowedSchema,ul as autumnCustomerProductSummarySchema,tl as autumnCustomerProfileRecordSchema,ml as autumnCustomerSpendLimitSchema,ol as autumnCustomerUsageAlertSchema,nl as autumnCustomerUsageLimitSchema,rl as autumnEntityControlsSchema,Jm as autumnMinorToAmount,Km as autumnUsageUnitAmountDecimal,$g as balanceAdjustmentCommandSchema,ah as balanceAdjustmentStateSchema,Yc as balanceAllocationSchema,Vc as balanceCommandSchema,bd as balanceGrantCommandSchema,ad as balanceGrantCreateSchema,ed as balanceGrantPageSchema,dd as balanceGrantReadSchema,cd as balanceGrantSchema,$c as balanceOperationSchema,Wc as balancePricingSegmentSchema,_c as balanceQuoteSchema,Xc as balanceReceiptUnitsSchema,Zc as balanceRejectionReasonSchema,jm as balanceSourceReasonSchema,bh as balanceSourceStateSchema,km as balanceSourceStatusSchema,mm as balanceSourcesPageSchema,lm as balanceSourcesQuerySchema,jb as billingAccruedMinorSchema,ib as billingAmountMinorSchema,tb as billingAuthorizationSchema,sb as billingAuthorizationTermsSchema,kb as billingBudgetMinorSchema,Db as billingControlInputSchema,Eb as billingControlsSchema,Mb as billingCouponsSchema,z as billingCurrencies,Fb as billingInvoiceLineSchema,Gb as billingInvoiceSchema,Jb as billingInvoicesSchema,xb as billingLimitSchema,jj as billingPortalInputSchema,kj as billingPortalSchema,D as billingSettingsMutationSchema,B as billingSettingsSchema,C as billingSettingsScopeSchema,Bb as billingUsageWindowSchema,$f as borderSchema,fg as buttonNodeSchema,Kc as campaignInputSchema,Ic as campaignOfferSchema,Lc as campaignSchema,Na as canonicalLocale,vf as capabilityBindingSchema,ob as cashPriceSchema,mb as cashPricingSchema,lb as cashPricingTiersSchema,hb as cashUnitAmountMinorSchema,Jh as claimRewardProductRequestSchema,Gd as commerceAccessSchema,Le as commerceContextSchema,ye as commerceCursorSchema,ze as commerceListQuerySchema,Hd as commerceMoneySchema,fm as commerceProductKind,Fd as commerceProductKindSchema,Ed as commerceProviderSchema,Ea as compileGrowthFeatures,Hb as confirmBillingAdjustmentInputSchema,vb as confirmBillingAuthorizationInputSchema,ic as consoleErrorCodeSchema,tc as consoleErrorResponseSchema,Fm as consoleHasPermission,ie as consoleRefundRequestSchema,Dm as consoleResources,Em as consoleRolePermissions,Cm as consoleRoleSchema,mg as countdownNodeSchema,Ya as couponAppliesToSchema,bb as couponChangeErrors,lg as couponCodeNodeSchema,Wa as couponDiscountSchema,Hl as couponDisplaySchema,Ti as couponDistributionBatchSchema,Vi as couponDistributionDetailSchema,Si as couponDistributionPreviewSchema,Ui as couponDistributionRecipientSchema,Wi as couponDistributionWriteSchema,Xa as couponDurationSchema,Za as couponEligibilitySchema,_a as couponInputSchema,Va as couponStatusSchema,kl as couponTemplateExample,il as couponTemplateKey,eb as couponWindow,Kl as createAccountOverviewPage,Jl as createCreditCenterPage,Ml as createCustomerPageTemplates,zi as createCustomerRequestSchema,Ai as createCustomerResponseSchema,Ll as createMembershipPage,Lh as createReferralCodeRequestSchema,F as creditAmountSchema,lh as creditAnalyticsFilterSchema,nh as creditAnalyticsPageSchema,mh as creditAnalyticsQuerySchema,jh as creditAnalyticsRangeSchema,kh as creditAnalyticsTimezoneSchema,L as creditDimensionSchema,M as creditMultiplierSchema,H as creditPriceAdjustmentSchema,N as creditPricingSchema,J as creditPropertiesSchema,G as creditQuantitySchema,O as creditRateSchema,Ob as creditResetCountSchema,Nb as creditResetSchema,I as creditResourceKeySchema,Pb as creditRolloverSchema,c as creditSchemaItemSchema,id as creditStatementInputSchema,jd as creditStatementSchema,i as creditSystemConfigSchema,K as creditTiersSchema,t as currencies,A as currencyAmountOptionsSchema,v as currencyDecimals,u as currencySchema,Ei as currentApiOperations,kd as currentNotificationEventTypeSchema,jg as customHtmlNodeSchema,ka as customerActivitySchema,Uh as customerAttributesSchema,Dl as customerAudienceSchema,Ef as customerDataConfigSchema,Hf as customerDataIntentSchema,hg as customerDataNodeSchema,_h as customerDataReferenceMessage,Zh as customerDataReferenced,Yh as customerDataSchema,Df as customerDataSourceSchema,Ci as customerEntitlementsSchema,fi as customerFiltersSchema,Vh as customerFingerprintSchema,Xl as customerFunnelDecisionsSchema,di as customerGetSchema,sd as customerHoldingsSchema,Wh as customerInputSchema,wd as customerLedgerEntrySchema,xd as customerLedgerPageSchema,vd as customerLedgerQuerySchema,bi as customerLookupSchema,ai as customerMutationSchema,Gf as customerPageDataSchema,Ff as customerPageNodeStateSchema,vl as customerPageSampleData,gi as customerPageSchema,ci as customerPatchSchema,ec as customerPlanCreateSchema,fc as customerPlanCreatedSchema,ja as customerPlanSchema,$h as customerProfileSchema,Xh as customerReferenceSchema,ij as customerScheduledChangeCancelSchema,gj as customerScheduledChangeSchema,hj as customerScheduledChangesSchema,Mc as customerSchema,Th as customerTagsSchema,ei as customerUpdateRequestSchema,Ni as defaultScreenTheme,cb as describeCoupon,_b as diffProductVariant,gg as dividerNodeSchema,If as emptyCustomerPageNode,Ne as entitlementCheckInputSchema,Oe as entitlementCheckReasonSchema,Qe as entitlementCheckResultSchema,Me as entitlementRequirementSchema,ga as entitlementSnapshotSchema,Bi as entitlementStatusSchema,X as environmentSchema,Cd as environmentSettingsSchema,oc as errorCodeMatchesStatus,uc as errorMetadata,qc as errorMetadataSchema,nc as errorPolicy,kc as errorReasonSchema,jc as errorRecoverySchema,rc as errorResponseSchema,Kf as escapeHtmlText,pa as evalCondition,sa as evalFeature,ri as evaluateFeaturesRequestSchema,ti as evaluateFeaturesResultSchema,Mk as executionSourceSchema,Da as experimentConfigurationSchema,Ca as experimentPhaseSchema,Ha as experimentSnapshotSchema,n as featureCollectionSchema,g as featureConfigOverrideSchema,k as featureDefinitionSchema,qi as featureDeliveryPayloadSchema,a as featureIdSchema,$ as featureInputSchema,f as featureMarkupsOverrideSchema,o as featureOptionsSchema,pi as featurePayloadSchema,m as featureRecordSchema,aa as featureSchema,Gm as featureTypes,Hm as featureUpdateBlockers,l as featureUpdateRulesSchema,od as featureUsageReadSchema,pd as featureUsageSetSchema,qd as featureUsageStateSchema,b as featureUsageTypeSchema,p as featureWriteSchema,Cg as fieldValue,Zf as fillSchema,rd as financialAmountSchema,ud as financialCursorSchema,td as financialEntryTypeSchema,Kg as findDocumentNode,Jg as findNode,hl as formatCouponConditions,Ta as formatCouponDiscount,Sa as formatCouponMoney,Ua as formatCouponTerms,y as formatCurrencyMinor,im as formatProductBillingPeriod,db as formatUsd,bk as funnelApiBindingSchema,_j as funnelApiProjectionSchema,Wj as funnelBundleDefinitionSchema,Xj as funnelBundleResultSchema,Rk as funnelCampaignCommandSchema,Sk as funnelCampaignStartResponseSchema,ck as funnelCapabilitySchema,Hk as funnelCollectionSchema,Dk as funnelCommandSchema,Uk as funnelConfigurationSchema,nk as funnelConsumedVariables,Pk as funnelCredentialCommandSchema,Qk as funnelCredentialResponseSchema,Ck as funnelDataQueriesSchema,Sj as funnelDecideShape,Tj as funnelDecisionCommandSchema,Qj as funnelDecisionOutputSchema,Uj as funnelDecisionResponseSchema,Rj as funnelDecisionSchema,Vj as funnelDecisionUsedResponseSchema,xk as funnelDocumentDraftSchema,zk as funnelDocumentSchema,pj as funnelEvaluationAttributes,Fk as funnelEvaluationModeSchema,Hj as funnelExecutionPolicySchema,tk as funnelExecutionStateSchema,ek as funnelExternalPageUrlSchema,Gj as funnelExternalTaskSchema,hk as funnelGraphDraftSchema,gk as funnelGraphNodeSchema,ik as funnelGraphSchema,jk as funnelGraphTargets,Nl as funnelGroupReferenceSchema,Lk as funnelInstructionSchema,rk as funnelNodeInputSchema,pk as funnelNodeKindSchema,sk as funnelNodeResultSchema,fk as funnelOpenInSchema,Mj as funnelOrchestrationCommandSchema,vj as funnelParametersFromUrl,Bk as funnelPresentationSubmissionSchema,Yk as funnelPreviewCommandSchema,$k as funnelPreviewDependencySchema,al as funnelPreviewJournalSchema,Zk as funnelPreviewOutcomeSchema,cl as funnelPreviewRequestSchema,dl as funnelPreviewResponseSchema,_k as funnelPreviewScenarioSchema,fl as funnelPreviewShareWriteSchema,el as funnelPreviewSnapshotSchema,bl as funnelPreviewSourceSchema,Yj as funnelProjectionFilterValueSchema,Zj as funnelProjectionWhereSchema,yk as funnelPublishableDraftSchema,Gk as funnelRecordSchema,qk as funnelResourceReferenceSchema,Ql as funnelResultsCursorSchema,Rl as funnelResultsQuerySchema,Pj as funnelResultsResponseSchema,Sl as funnelResultsSchema,Nk as funnelRunViewSchema,Ok as funnelRuntimeResponseSchema,Kk as funnelRuntimeStatusSchema,Nj as funnelSignalResponseSchema,gl as funnelStatisticsSchema,Fj as funnelTaskBindingSchema,Dj as funnelTaskDataSchema,Ej as funnelTaskOutputsSchema,Jj as funnelTaskResponseSchema,Oj as funnelTaskResultsSchema,cm as funnelTemplateDraft,am as funnelTemplateSchema,Vk as funnelTopology,Tk as funnelTopologySchema,uk as funnelTraceEventSchema,zj as funnelValueBindingSchema,wk as funnelValueDeclarationSchema,Ak as funnelValueMatches,yj as funnelValuePathSchema,oj as funnelValueSchema,ok as funnelWaitKindSchema,Ik as funnelWriteSchema,li as gbRuntimeExperimentResultSchema,ki as gbRuntimeExperimentSchema,mi as gbRuntimeFeatureRuleSchema,ni as gbRuntimeFeatureSchema,oi as gbRuntimeSavedGroupsSchema,la as getQueryStringOverride,Am as getRecommendedRolloutData,qa as getStickyBucketAttributes,sm as growthAttributeSchema,ua as growthAttributesSchema,um as growthCatalogSchema,xa as growthConditionGroupIds,rj as growthConditionPaths,va as growthConditionSchema,wm as growthDryRunSchema,xm as growthExperimentInspectionSchema,Fa as growthExperimentStop,Ga as growthFeatureExpiry,za as growthFeatureRuleSchema,Aa as growthFeatureSchema,Ba as growthFeaturesSchema,ym as growthGroupReferenceCursorSchema,zm as growthGroupReferencesSchema,wa as growthGroupSchema,tm as growthNamespaceSchema,vm as growthResourceWriteSchema,Ka as growthRuleContextSchema,ya as growthSavedGroupsSchema,Ia as growthSnapshotSchema,La as growthSplitResultSchema,Jf as htmlVariableErrors,Pf as identifierSchema,eg as imageNodeSchema,Yf as imagePositionSchema,Wf as insetsSchema,fd as invoiceDetailInputSchema,hd as invoiceDetailSchema,gd as invoiceProductItemSchema,he as invoiceRefundsSchema,pb as isInvoiceCreditPrice,rf as isProductGroup,em as isRecurringMembership,Lg as isRtlLocale,Bc as isStableSdkProtocol,na as isURLTargeted,nb as itemBillingCycleSchema,ta as jsonValueSchema,E as licenseOfferSchema,Ib as listBillingInvoicesInputSchema,Qa as localeLabel,Ma as localeSchema,Dg as localeStatuses,Ig as localizeScreen,zb as manageBillingLimitsInputSchema,yb as manageOveragePolicyInputSchema,hc as managementErrorCodeSchema,sc as managementErrorResponseSchema,Xf as marginSchema,Oa as matchLocale,qj as matchesGrowthCondition,T as membershipActionSchema,gm as membershipBillingCount,U as membershipChangeSchema,V as membershipHoldingSchema,R as membershipRulesSchema,W as membershipStateSchema,S as membershipTimingSchema,yl as mergeAuditSchema,_ as metadataSchema,h as meteredConfigSchema,x as minorToAmount,e as modelMarkupsSchema,Zl as nativeCompletionSchema,Id as nativeCouponStoreOfferLinkWriteSchema,Jd as nativeCouponStoreOfferLinksSchema,Rc as nativeProductBindingSchema,Tc as nativeProductBindingWriteSchema,Sc as nativeProductBindingsPageSchema,Yl as nativeProofSchema,Od as nativePurchaseInstructionSchema,_l as nativeReceiptCommandSchema,$l as nativeReceiptResponseSchema,Je as nativeRestoreCommandSchema,Ke as nativeRestoreResultSchema,Md as nativeStoreOfferForProduct,Kd as nativeStoreOfferSelectionSchema,Ld as nativeStoreOfferSelectionsSchema,Nd as nativeStoreSelectionMatches,$d as nativeSubscriptionUpdatePreviewSchema,ae as nativeSubscriptionUpdateResultSchema,Ri as newBlankSurface,ab as newCouponInput,ii as newEnvironmentAnalyticsConfig,Jk as newFunnelDocument,Pi as newScreenFromTemplate,Qi as newSurfaceFromTemplate,Of as nodeIdSchema,zl as objectAuditSchema,Tl as offerFlowInputSchema,Ul as offerFlowResultSchema,fb as offerSchema,gb as offerUnavailableReasonSchema,af as offeringAuthorSchema,ef as offeringCollectionSchema,$e as offeringDocumentSchema,Xe as offeringItemSchema,Ye as offeringItemsSchema,Te as offeringMetadataSchema,bf as offeringProductEvidenceSchema,Se as offeringProductIdSchema,Ze as offeringProductIds,jf as offeringProductOptionSchema,_e as offeringProductPaths,lf as offeringPublicationIssues,cf as offeringRecordSchema,hf as offeringSelectorSchema,mf as offeringValueSchema,df as offeringVersionSchema,kf as offeringWorkspaceSchema,gf as offeringWriteResultSchema,ff as offeringWriteSchema,Uc as overageBehaviorSchema,Ab as overagePolicySchema,vk as ownedFunnelScreenSchema,pm as pageExperimentEventSchema,qm as pageExperimentEventsRequestSchema,rm as pageExperimentEventsResponseSchema,om as pageExperimentPayloadSchema,nm as pageExperimentSchema,Uf as paintColorSchema,pc as parseRetryAfter,Ji as parseScreenRenderPath,se as paymentSetupCommandSchema,te as paymentSetupReadSchema,ve as paymentSetupSchema,Pe as paywallCandidateSchema,Pg as paywallClientActionSchema,Vg as paywallCollectionSchema,Qg as paywallDocumentDraftSchema,Rg as paywallDocumentSchema,Tg as paywallFlowIssues,Yg as paywallLibrarySchema,Sg as paywallProductIssues,pf as paywallProductsSchema,Ug as paywallRecordSchema,Re as paywallRequestSchema,_g as paywallResolutionSchema,Zg as paywallResolveInputSchema,Wg as paywallSummarySchema,Xg as paywallWriteSchema,da as planConfigSchema,ea as planInputSchema,ca as planItemSchema,ng as planPickerNodeSchema,fa as planSchema,ha as planVersionSchema,Jc as popupSchema,dc as prepaidAllowanceAmount,r as prepaidPriceAmount,s as prepaidQuantityAmount,Nc as prepaidQuantitySchema,q as prepaidTierPricingSchema,rb as prepareBillingAuthorizationInputSchema,jl as prepareCouponTemplate,oa as prepareSavedGroups,ub as preparedBillingAuthorizationSchema,vg as presentationSchema,kg as priceNodeSchema,ba as priceSchema,Sb as productAllowanceSchema,Oc as productBindingSchema,Qc as productBindingWriteSchema,Pc as productBindingsPageSchema,bc as productCollectionSchema,Vb as productConfigurationSchema,Yb as productDefinitionSchema,cc as productEditorOptionsSchema,of as productGroupingMatches,nf as productGroupingSchema,Ub as productLicenseSchema,Xi as productMigrationBlockReasonSchema,cj as productMigrationDetailSchema,Yi as productMigrationErrorCodeSchema,bj as productMigrationItemSchema,$i as productMigrationItemStatusSchema,dj as productMigrationListSchema,Zi as productMigrationPreviewSchema,fj as productMigrationQuerySchema,_i as productMigrationRunStatusSchema,aj as productMigrationSchema,ej as productMigrationWriteSchema,$b as productOptionsSchema,Rb as productPrepaidPriceSchema,Qb as productPricesSchema,ac as productRecordSchema,Ng as productSelectionSchema,Tb as productTrialSchema,Wb as productVariantOverridesSchema,Xb as productVariantSchema,$j as projectFunnelApiOutputs,Wk as projectFunnelConfiguration,Bd as projectSettingsSchema,$a as promotionCodeInputSchema,Ac as protocolForSdkVersion,d as providerMarkupsSchema,Eg as publishChecks,Be as purchaseListItemSchema,He as purchaseListPageSchema,Rf as radiusSchema,Aj as readFunnelValuePath,Ih as redeemRewardRequestSchema,Mh as referralCodeSchema,Oh as referralProgramCollectionSchema,Bh as referralProgramInputSchema,Dh as referralProgramRecordSchema,Gh as referralProgramWriteSchema,si as remoteFeatureResultSchema,yg as replaceFirstPageRoot,Il as resolveCouponDisplay,dk as resolveFunnelCapabilityInputs,Lj as resolveFunnelTaskInputs,Bj as resolveFunnelValueBinding,Cj as resolveFunnelValueBindings,Zb as resolveProductVariant,Hg as resolveScreenLocale,Fc as resolveSdkProtocol,yi as responseMetaSchema,wb as revokeBillingAuthorizationInputSchema,Qh as rewardActivityRedemptionSchema,Rh as rewardActivitySchema,Ah as rewardCodeInputSchema,Ph as rewardCodeSchema,Sh as rewardCodeWriteSchema,Nh as rewardCollectionSchema,xh as rewardConfigurationSchema,vh as rewardGrantExpirySchema,wh as rewardGrantSchema,zh as rewardInputSchema,yh as rewardKeySchema,Eh as rewardOptionSchema,Kh as rewardProductCheckoutSchema,Ch as rewardRecordSchema,Hh as rewardRedemptionSchema,uh as rewardStatusSchema,th as rewardTypeSchema,Fh as rewardWriteSchema,ra as runExperiment,hm as sameMembershipBillingCycle,mj as saveSurfaceTemplateSchema,Y as scopeSchema,rg as screenActionSchema,tj as screenAnswersSchema,sj as screenDataCursorSchema,zg as screenDocumentSchema,Sf as screenImageSourceSchema,wj as screenInputBindingsSchema,qg as screenNodeSchema,uj as screenParametersSchema,Og as screenPresentationSchema,sf as screenProductScopes,tf as screenProductSelections,Ii as screenRenderPath,Gi as screenRenderPathSchema,Ki as screenRenderTags,Hi as screenRenderUrlSchema,xj as screenRendererInputSchema,Mg as screenSelections,sg as screenStringsSchema,zc as sdkProtocolRegistry,Gc as sdkProtocolResponseHeaders,zd as seatCommandSchema,yd as seatReadSchema,Ad as seatsStateSchema,lk as selectFunnelCondition,qf as selectedPaywallProduct,Bf as selectedSurfaceValue,Gg as servableLocales,Lb as setBillingCouponsInputSchema,ag as shadowSchema,_f as shapeSchema,Vf as sizeSchema,Qf as spaceSchema,ig as spacerNodeSchema,Z as stableKeySchema,og as stackInteractionSchema,pg as stackNodeSchema,Ja as stickyAssignmentDocumentSchema,Sd as stripeAppendContextSchema,Rd as stripeCouponTermsSchema,Td as stripePurchaseExecutionSchema,ee as stripeRefundExecutionSchema,ue as stripeSetupExecutionSchema,Yd as stripeSubscriptionUpdateExecutionSchema,Zd as stripeSubscriptionUpdatePreviewSchema,_d as stripeSubscriptionUpdateResultSchema,pe as stripeTrialExecutionSchema,cg as styleSchema,Pd as subscriptionAttachCommandSchema,Ud as subscriptionAttachQuoteSchema,je as subscriptionBatchCommandSchema,le as subscriptionBatchGroupSchema,ke as subscriptionBatchReadSchema,me as subscriptionBatchSchema,Wd as subscriptionCarryOptionsSchema,Ie as subscriptionConflictPageSchema,De as subscriptionConflictQuerySchema,Fe as subscriptionConflictRetryResultSchema,Ee as subscriptionConflictRetrySchema,Ce as subscriptionConflictSchema,Kb as subscriptionCouponExecutionSchema,Ae as subscriptionListItemSchema,Ge as subscriptionListPageSchema,Qd as subscriptionOperationInputSchema,Vd as subscriptionOperationSchema,de as subscriptionRefundCommandSchema,fe as subscriptionRefundPreviewSchema,ge as subscriptionRefundResultSchema,ne as subscriptionTrialCommandSchema,re as subscriptionTrialPolicySchema,oe as subscriptionTrialReadSchema,qe as subscriptionTrialResultSchema,Xd as subscriptionUpdateCommandSchema,be as subscriptionUpdatePreviewSchema,ce as subscriptionUpdateResultSchema,we as subscriptionVerificationInputSchema,xe as subscriptionVerificationSchema,Lf as substituteHtmlVariables,Af as substituteSurfaceVariables,xf as surfaceDataSchema,tg as surfaceSchema,lj as surfaceTemplateSchema,wf as surfaceValueSchema,yf as surfaceVariableNames,Fg as templateChecks,bm as templateScreen,dg as textNodeSchema,bg as textStyleSchema,Tf as themeSchema,ma as toAttributeString,ui as trackEventsRequestSchema,vi as trackEventsResultSchema,mk as transitionFunnelGraph,Bg as translatableFields,P as trialPolicySchema,Q as trialRecordSchema,zf as unknownSurfaceVariables,md as usageAlertNotificationDataSchema,nd as usageAllowanceNotificationDataSchema,ph as usageAnalyticsPageSchema,oh as usageAnalyticsQuerySchema,sh as usageBatchPageSchema,rh as usageBatchReadSchema,qh as usageBatchSubmitSchema,ch as usageEntityCommandSchema,dh as usageEntitySchema,ld as usageLimitNotificationDataSchema,kk as validateFunnelGraph,Kj as validateFunnelTaskData,Ek as validateScreenAnswers,Dc as validateSdkProtocolRegistry,ia as validitySchema,xi as verifiedPrincipalSchema,Mm as visualChangeSchema,Pm as visualExperimentPayloadSchema,Om as visualExperimentSchema,Lm as visualMutationSchema,Rm as visualSelectedElementSchema,Nm as visualVariationSchema,xg as walkDocument,Ag as walkScreen,Dd as workspaceSettingsSchema};
@@ -0,0 +1 @@
1
+ import{a as y,c as w}from"./chunk-ZT523F45.js";function f(r){return CSS.escape(r)}function b(r){for(let t of["id","data-indiana-id","data-testid"]){let s=r.getAttribute(t);if(!s)continue;let a=t==="id"?`#${f(s)}`:`[${t}="${f(s)}"]`;if(document.querySelectorAll(a).length===1)return a}let c=[];for(let t=r;t&&t!==document.documentElement;t=t.parentElement){let s=t.tagName.toLowerCase(),a=[...t.classList].filter(o=>o.length<80).slice(0,3);a.length&&(s+=a.map(o=>`.${f(o)}`).join(""));let m=t.parentElement?[...t.parentElement.children].filter(o=>o.tagName===t.tagName):[];m.length>1&&(s+=`:nth-of-type(${m.indexOf(t)+1})`),c.unshift(s);let d=c.join(" > ");if(document.querySelectorAll(d).length===1)return d}return c.join(" > ")}function k(r,c={}){let t=window.opener;if(!t||r.expiresAt<=Date.now())return()=>{};let s=!1,a=!1,m=!1,d,o=document.createElement("div");o.setAttribute("data-indiana-editor-highlight",""),o.style.cssText="position:fixed;pointer-events:none;z-index:2147483647;outline:2px solid #6655ee;background:rgba(102,85,238,.1);display:none",document.body.append(o);function l(n,e={}){t.postMessage({channel:"indiana-visual",nonce:r.nonce,type:n,...e},r.origin)}let g=n=>n.composedPath().find(e=>e instanceof Element&&e!==o),h=n=>{if(!a)return;let e=g(n);if(!e)return;let i=e.getBoundingClientRect();Object.assign(o.style,{display:"block",left:`${i.left}px`,top:`${i.top}px`,width:`${i.width}px`,height:`${i.height}px`})},v=n=>{if(!a)return;let e=g(n);if(!e)return;n.preventDefault(),n.stopImmediatePropagation(),a=!1,o.style.display="none";let i=b(e),u={selector:i,tag:e.tagName.toLowerCase(),text:(e.textContent??"").slice(0,1e3),href:e.getAttribute("href")??"",src:e.getAttribute("src")??"",matches:document.querySelectorAll(i).length};l("selected",{element:u})};function p(){m||(m=!0,d?.revert(),o.remove(),clearInterval(x),removeEventListener("message",E),removeEventListener("mousemove",h,!0),removeEventListener("click",v,!0),removeEventListener("pagehide",p))}function E(n){if(n.source!==t||n.origin!==r.origin||!n.data||n.data.channel!=="indiana-visual"||n.data.nonce!==r.nonce||r.expiresAt<=Date.now())return;let e=n.data;if(e.type==="connect"&&(s=!0,l("connected")),!!s){if(e.type==="disconnect"){p();return}if(e.type==="pick"&&(a=!0),e.type==="preview")try{let i=y(e.value);d?.revert(),d=w(i,{allowJs:c.allowJs===!0&&e.allowJs,nonce:c.nonce,onError:u=>l("error",{message:String(u)})}),l("previewed",{matches:i.domMutations.map(u=>({selector:u.selector,count:document.querySelectorAll(u.selector).length}))})}catch(i){l("error",{message:String(i)})}}}addEventListener("message",E),addEventListener("mousemove",h,!0),addEventListener("click",v,!0),addEventListener("pagehide",p);let x=setInterval(()=>{if(t.closed||r.expiresAt<=Date.now()){p();return}s||l("ready")},500);return l("ready"),p}export{k as startVisualEditorAgent,b as visualElementSelector};
@@ -0,0 +1,38 @@
1
+ import { J as JsonValue, R as Result } from './growth-rules-D64pEvg9.js';
2
+
3
+ type VisualExperimentsOptions = {
4
+ environmentId: string;
5
+ baseUrl: string;
6
+ attributes?: Record<string, JsonValue>;
7
+ disableJsInjection?: boolean;
8
+ nonce?: string;
9
+ deviceIdCookie?: string;
10
+ trackExposures?: boolean;
11
+ antiFlicker?: boolean;
12
+ antiFlickerTimeout?: number;
13
+ fetch?: typeof globalThis.fetch;
14
+ log?: (message: string, details: Record<string, unknown>) => void;
15
+ };
16
+ declare function createVisualExperiments(options: VisualExperimentsOptions): {
17
+ start(): Promise<void>;
18
+ refresh(): Promise<void>;
19
+ setAttributes(attributes: Record<string, JsonValue>): void;
20
+ flush: () => Promise<void>;
21
+ getResults(): Map<string, Result<{
22
+ css: string;
23
+ js: string;
24
+ domMutations: {
25
+ selector: string;
26
+ action: "set" | "remove" | "append";
27
+ attribute: string;
28
+ value?: string | undefined;
29
+ parentSelector?: string | undefined;
30
+ insertBeforeSelector?: string | undefined;
31
+ }[];
32
+ }>>;
33
+ readonly generation: string | null;
34
+ destroy(): void;
35
+ };
36
+ type VisualExperiments = ReturnType<typeof createVisualExperiments>;
37
+
38
+ export { type VisualExperiments, type VisualExperimentsOptions, createVisualExperiments };
package/dist/visual.js ADDED
@@ -0,0 +1 @@
1
+ import{b as _,c as z}from"./chunk-ZT523F45.js";import{a as $,b as j,c as G,d as K,e as N,f as q,h as H}from"./chunk-2UFPTDCV.js";import{d as F,g as L,i as p}from"./chunk-TZ6REIUE.js";function ne(e){let E=G(e.baseUrl);if(!/^[0-9a-f-]{36}$/i.test(e.environmentId))throw new Error("Invalid App environment ID");let V=e.fetch??globalThis.fetch.bind(globalThis),b=`${E}/api/v1/visual-experiments/${e.environmentId}`,I=$(e.deviceIdCookie??"indiana_did"),w=j(),u=null,o=!1,k=!1,v="",T={...e.attributes??{}},S,m,y=0,s=new Map,J=new Map,R=new Set,h=[],x,C,d;function f(){clearTimeout(C),d?.remove(),d=void 0}function c(){clearTimeout(x),x=void 0;let t=h.splice(0,20);return t.length?V(`${b}/events`,{method:"POST",headers:{"Content-Type":"text/plain"},body:JSON.stringify({events:t}),credentials:"omit",keepalive:!0}).then(()=>{}).catch(i=>e.log?.("Visual exposure not sent",{error:i})):Promise.resolve()}function P(t,i){let l=p(t,i);R.has(l)||e.trackExposures===!1||u?.trackExposures===!1||o||(R.add(l),h.push({eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString(),deviceId:I,...w?{sessionId:w}:{},url:location.href,pageTitle:document.title.slice(0,512),experimentKey:t.key,variationKey:i.key}),h.length>=20?c():x??=setTimeout(()=>{c()},1e3))}function g(){if(!u||o)return;let t=new Set,i={onExperimentViewed:(n,a)=>{t.add(p(n,a))},url:location.href,attributes:{...H(I,location),...T},savedGroups:F(u.savedGroups),log:e.log},l=new Set;for(let n of u.experiments){let a=n;try{let r=L(a,i);if(J.set(n.changeId,r),!r.inExperiment)continue;l.add(n.changeId);let U=JSON.stringify([r.key,r.value]),A=s.get(n.changeId);if(A?.signature===U){A.applied()&&t.has(p(a,r))&&P(a,r);continue}s.get(n.changeId)?.revert(),s.delete(n.changeId);let D=z(r.value,{allowJs:e.disableJsInjection===!1,nonce:e.nonce,onApplied:()=>{t.has(p(a,r))&&P(a,r)},onError:Q=>e.log?.("Visual experiment stopped",{experiment:n.key,error:String(Q)})});s.set(n.changeId,{signature:U,revert:D.revert,applied:()=>D.applied})}catch(r){e.log?.("Skipping visual experiment",{experiment:n.key,error:String(r)})}}for(let[n,a]of s)l.has(n)||(a.revert(),s.delete(n));f()}async function O(){let t=++y,i=await V(b,{cache:"no-cache",credentials:"omit"});if(!i.ok)throw new Error(`Visual experiments unavailable (${i.status})`);let l=_(await i.json());if(l.environmentId.toLowerCase()!==e.environmentId.toLowerCase())throw new Error("Visual payload scope changed");!o&&t===y&&(u=l)}let B=()=>{v!==location.href&&(v=location.href,g())},M=()=>{c()};return{async start(){if(k||o)return;k=!0;let t=N(E,e.environmentId);if(t){q();let i=await import("./visual-editor-agent-PYMKMPY3.js");o||(m=i.startVisualEditorAgent(t,{allowJs:e.disableJsInjection===!1,nonce:e.nonce}));return}e.antiFlicker&&(d=document.createElement("style"),e.nonce&&(d.nonce=e.nonce),d.textContent="body { visibility: hidden !important }",document.head.append(d),C=setTimeout(f,Math.min(3e3,Math.max(0,e.antiFlickerTimeout??1e3))));try{if(await O(),o)return;S=K(B),addEventListener("pagehide",M),v=location.href,g()}finally{f()}},async refresh(){o||m||(await O(),g())},setAttributes(t){T={...t},m||g()},flush:c,getResults(){return new Map(J)},get generation(){return u?.generation??null},destroy(){o=!0,y++,S?.(),m?.(),removeEventListener("pagehide",M),f();for(let t of s.values())t.revert();s.clear(),c()}}}export{ne as createVisualExperiments};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinkerlandai/indiana-sdk",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Framework-independent Indiana SDK for customer identity, entitlements, credits, offers and growth surfaces.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -48,12 +48,17 @@
48
48
  "./page": {
49
49
  "types": "./dist/page.d.ts",
50
50
  "import": "./dist/page.js"
51
+ },
52
+ "./visual": {
53
+ "types": "./dist/visual.d.ts",
54
+ "import": "./dist/visual.js"
51
55
  }
52
56
  },
53
57
  "dependencies": {
54
58
  "@ai-sdk/provider": "4.0.26",
55
59
  "@types/json-schema": "7.0.15",
56
60
  "css-tree": "^3.2.1",
61
+ "dom-mutator": "0.7.0",
57
62
  "dompurify": "^3.4.15",
58
63
  "zod": "4.6.5"
59
64
  },
@@ -1 +0,0 @@
1
- import{Y as S,_b as C,gc as k,jc as L,mc as T,nc as v,oc as j,rc as R,ui as V}from"./chunk-D37O6FAW.js";var U={name:"@tinkerlandai/indiana-sdk",version:"0.3.1",description:"Framework-independent Indiana SDK for customer identity, entitlements, credits, offers and growth surfaces.",license:"UNLICENSED",repository:{type:"git",url:"git+https://github.com/tinkerlandai/Indiana.git",directory:"packages/sdk"},engines:{node:">=22"},publishConfig:{access:"public",tag:"beta"},type:"module",sideEffects:!1,files:["dist","README.md","README.zh-CN.md","CHANGELOG.md","THIRD_PARTY_NOTICES.md"],exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./popup":{types:"./dist/popup.d.ts",import:"./dist/popup.js"},"./server":{types:"./dist/server.d.ts",import:"./dist/server.js"},"./openrouter":{types:"./dist/openrouter.d.ts",import:"./dist/openrouter.js"},"./native-shell":{types:"./dist/native-shell.d.ts",import:"./dist/native-shell.js"},"./page":{types:"./dist/page.d.ts",import:"./dist/page.js"}},scripts:{build:"tsup",prepack:"pnpm run build",typecheck:"tsc --noEmit"},dependencies:{"@ai-sdk/provider":"4.0.26","@types/json-schema":"7.0.15","css-tree":"^3.2.1",dompurify:"^3.4.15",zod:"4.6.5"},devDependencies:{"@indiana/contracts":"workspace:*","@openrouter/sdk":"^1.4.25","@types/css-tree":"^3.2.0",ai:"7.0.136",tsup:"^8.5.1",typescript:"^5.9.3"},peerDependencies:{"@openrouter/sdk":"^1.4.25"},peerDependenciesMeta:{"@openrouter/sdk":{optional:!0}}};var e=class extends Error{constructor(h,d,n,N,i){super(d);this.code=h;this.status=n;this.requestId=N;this.name="IndianaError",this.reason=i?.reason;let c=T(h,n??0,{...i,retryAfter:i?.retryAfterSeconds===void 0?void 0:String(i.retryAfterSeconds)});this.retryable=c.retryable,this.recovery=c.recovery,this.retryAfterSeconds=c.retryAfterSeconds}code;status;requestId;retryable;recovery;retryAfterSeconds;reason},$=Symbol("IndianaNoContent");function J(l,A){let h=l.webView??"hosted";if(!["hosted","embedded"].includes(h))throw new e("INVALID_REQUEST","Invalid Web View mode");let d=l.scope?S.parse(l.scope):void 0,n=new URL(l.baseUrl);if(n.username||n.password||n.search||n.hash)throw new e("INVALID_URL","baseUrl must not contain credentials, query, or fragment");if(n.protocol!=="https:"&&!(n.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(n.hostname)))throw new e("INVALID_URL","Use HTTPS, or HTTP on localhost during development");let N=l.fetch??globalThis.fetch.bind(globalThis),i=l.timeoutMs??1e4;if(!Number.isFinite(i)||i<=0||i>12e4)throw new e("INVALID_TIMEOUT","timeoutMs must be between 1 and 120000");let c=null,b,u=0,p=null,f=new Set;function D(){u+=1,c=null,p=null;for(let s of f)s.abort();f.clear()}async function M(s,q={},O="POST",H={}){if(!c)throw new e("NOT_IDENTIFIED","Call identify with a server-issued customer token first");let g=u,o=new AbortController;f.add(o);let y=()=>g!==u?new e("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):new e("TIMEOUT","Indiana request timed out"),I,x=new Promise((r,a)=>{I=()=>a(y()),o.signal.addEventListener("abort",I,{once:!0})}),K=setTimeout(()=>o.abort(),i),G=async()=>{let r=await N(`${n.href.replace(/\/$/,"")}/api/v1/${s}`,{method:O,headers:{"Content-Type":"application/json",Authorization:`Bearer ${c}`,[v]:R.current,[j]:U.version,...d?{"X-Indiana-Project":d.projectId,"X-Indiana-Environment":d.environment}:{}},body:O==="POST"?JSON.stringify(q):void 0,signal:o.signal,credentials:"omit",cache:"no-store",redirect:"error",...H.keepalive?{keepalive:!0}:{}});if(o.signal.aborted)throw y();let a;try{a=r.status===204?$:await r.json()}catch{throw o.signal.aborted?y():new e(r.ok?"INVALID_RESPONSE":"HTTP_ERROR","The gateway returned an unreadable response",r.status,r.headers.get("X-Request-Id")??void 0)}if(o.signal.aborted)throw y();if(g!==u)throw new e("IDENTITY_CHANGED","Customer identity changed while the request was in flight");if(!r.ok){let t=L.safeParse(a),m=t.success&&(!C.safeParse(t.data.error.code).success||k(t.data.error.code,r.status)),_=m?t.data.error.code:"HTTP_ERROR",P=T(_,r.status,{retryAfter:r.headers.get("Retry-After"),recovery:m?t.data.error.recovery:void 0,reason:m?t.data.error.reason:void 0});throw new e(_,m?t.data.error.message:"Indiana request failed",r.status,r.headers.get("X-Request-Id")??(t.success?t.data.requestId:void 0),{...P,...t.success&&t.data.error.retryable===!1?{retryable:!1}:{},...P.retryAfterSeconds===void 0&&t.success&&t.data.error.retryAfterSeconds!==void 0?{retryAfterSeconds:t.data.error.retryAfterSeconds}:{}})}if(r.headers.get(v)!==R.current)throw new e("PROTOCOL_MISMATCH","Response protocol does not match this SDK");if(d&&a&&typeof a=="object"&&"scope"in a){let t=S.safeParse(a.scope);if(!t.success||t.data.projectId!==d.projectId||t.data.environment!==d.environment)throw new e("SCOPE_MISMATCH","Response scope does not match this SDK instance")}let E=r.headers.get("X-Indiana-Web-View");if(E){if(!/^\/web-view\/renderer\/[a-f0-9]{64}$/.test(E))throw new e("INVALID_RESPONSE","Invalid Web View renderer metadata");b=E}let w=r.headers.get("X-Indiana-Telemetry-Subject");if(w){if(!/^[a-f0-9]{64}$/.test(w))throw new e("INVALID_RESPONSE","Invalid telemetry identity");p!==w&&(p=w,A?.(p))}return a};try{return await Promise.race([G(),x])}catch(r){throw g!==u?new e("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):r instanceof e?r:new e(o.signal.aborted?"TIMEOUT":"NETWORK_ERROR",o.signal.aborted?"Indiana request timed out":"Unable to read the Indiana response")}finally{clearTimeout(K),o.signal.removeEventListener("abort",I),f.delete(o)}}return{subjectKey:()=>p,screenUrl(s){if(!V.safeParse(s).success)throw new e("INVALID_RESPONSE","Invalid published screen render address");return new URL(s,n).href},webViewUrl(){if(h!=="embedded"){if(!b)throw new e("INVALID_RESPONSE","The gateway did not provide a hosted Web View renderer");return new URL(b,n).href}},identify(s){if(!s.trim()||/\s/.test(s)||s.length>4096)throw new e("INVALID_TOKEN","A nonempty server-issued token is required");D(),c=s},reset:D,request:M}}export{e as a,J as b};