@tinkerlandai/indiana-sdk 0.7.0 → 0.8.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/README.md +11 -10
  3. package/README.zh-CN.md +16 -11
  4. package/dist/{ai-usage-BsrSG955.d.ts → ai-usage-Bigjb8MS.d.ts} +468 -274
  5. package/dist/chunk-2A6UYUFA.js +1 -0
  6. package/dist/chunk-3BQFJANQ.js +1 -0
  7. package/dist/chunk-3ENVRJE6.js +350 -0
  8. package/dist/chunk-A3N4ZZTM.js +7 -0
  9. package/dist/chunk-AE4CUTUE.js +1 -0
  10. package/dist/chunk-CXYOZSOF.js +1 -0
  11. package/dist/{chunk-4AWSZWZD.js → chunk-G2R56FKU.js} +1 -1
  12. package/dist/{chunk-6MO6Y24B.js → chunk-OVMNCZYC.js} +1 -1
  13. package/dist/{configuration-sync-Bvd956GL.d.ts → configuration-sync-VFbY1pCN.d.ts} +34 -35
  14. package/dist/content-K2HCZVC2.js +1 -0
  15. package/dist/{customer-page-B4LkIr5q.d.ts → customer-page-BrCZxcaQ.d.ts} +279 -6
  16. package/dist/funnel-runtime-host-HNZ47TZW.js +1 -0
  17. package/dist/{funnel-runtime-start-ChVYbLzV.d.ts → funnel-runtime-start-DKcTCRrd.d.ts} +1646 -1913
  18. package/dist/index.d.ts +13975 -13679
  19. package/dist/index.js +1 -1
  20. package/dist/native-shell.js +1 -1
  21. package/dist/openrouter.d.ts +3 -2
  22. package/dist/openrouter.js +1 -1
  23. package/dist/page.d.ts +9 -9
  24. package/dist/paywall-PD62B2AY.js +1 -0
  25. package/dist/popup.d.ts +3 -271
  26. package/dist/popup.js +1 -350
  27. package/dist/react-native.d.ts +8 -8
  28. package/dist/react-native.js +1 -1
  29. package/dist/{screen-iFngkxaL.d.ts → screen-BazUOjwM.d.ts} +168 -165
  30. package/dist/server.d.ts +5 -5
  31. package/dist/server.js +1 -1
  32. package/dist/src-4MRSESVS.js +1 -0
  33. package/dist/visual.d.ts +5 -2
  34. package/dist/visual.js +2 -2
  35. package/package.json +1 -7
  36. package/dist/chunk-3SONNXFG.js +0 -1
  37. package/dist/chunk-467Z5ISI.js +0 -11
  38. package/dist/chunk-4K25DELJ.js +0 -1
  39. package/dist/chunk-HD74AAFS.js +0 -1
  40. package/dist/chunk-J4RHVU3W.js +0 -1
  41. package/dist/chunk-NOFNOHUI.js +0 -1
  42. package/dist/chunk-QO4YQLZ4.js +0 -1
  43. package/dist/chunk-U6S6AZM6.js +0 -1
  44. package/dist/chunk-WCFVNF5D.js +0 -1
  45. package/dist/client-F6UPJMHR.js +0 -1
  46. package/dist/controls-XG46TKUU.js +0 -2
  47. package/dist/funnel-runtime-host-26QI2W3S.js +0 -1
  48. package/dist/iam.d.ts +0 -131
  49. package/dist/iam.js +0 -1
  50. package/dist/paywall-WKOHBYW7.js +0 -1
  51. package/dist/src-UHLPVD6E.js +0 -1
  52. package/dist/{errors-DrdTlPwf.d.ts → errors-BpCmukJr.d.ts} +1 -1
@@ -0,0 +1 @@
1
+ import{a as u,c as d}from"./chunk-RRII2DMC.js";import{z as b}from"zod";var z=b.enum(["sandbox","live"]),k=b.object({projectId:b.string().min(1),environment:z}).strict();import{z as t}from"zod";var f=t.tuple([t.number().min(0).max(1),t.number().min(0).max(1)]).refine(([n,g])=>n<=g),C=t.strictObject({attribute:t.string().optional(),seed:t.string(),hashVersion:t.literal(2),ranges:t.array(f).max(100)}),E=t.strictObject({id:t.string().min(1).max(255),condition:d,gate:t.boolean().optional()}),H=t.strictObject({key:t.string().optional(),name:t.string().optional(),passthrough:t.boolean().optional()}),M={condition:d.optional(),parentConditions:t.array(E).max(100).optional(),weights:t.array(t.number().min(0).max(1)).max(20).optional(),coverage:t.number().min(0).max(1).optional(),hashAttribute:t.string().optional(),fallbackAttribute:t.string().optional(),hashVersion:t.literal(2).optional(),disableStickyBucketing:t.boolean().optional(),bucketVersion:t.number().int().nonnegative().optional(),minBucketVersion:t.number().int().nonnegative().optional(),filters:t.array(C).max(100).optional(),ranges:t.array(f).max(20).optional(),meta:t.array(H).max(20).optional(),seed:t.string().optional(),name:t.string().optional(),phase:t.string().optional()},y=t.strictObject({...M,key:t.string().min(1).max(255),variations:t.tuple([u,u]).rest(u).refine(n=>n.length<=20),urlPatterns:t.array(t.strictObject({include:t.boolean(),type:t.enum(["regex","simple"]),pattern:t.string()})).max(100).optional(),force:t.number().int().nonnegative().optional(),active:t.boolean().optional(),persistQueryString:t.boolean().optional()}),N=t.strictObject({value:u,variationId:t.number().int(),key:t.string(),name:t.string().optional(),bucket:t.number().optional(),passthrough:t.boolean().optional(),inExperiment:t.boolean(),hashUsed:t.boolean().optional(),hashAttribute:t.string(),hashValue:t.string(),featureId:t.string().nullable(),stickyBucketUsed:t.boolean().optional()}),U=t.strictObject({...M,id:t.string().max(255).optional(),force:u.optional(),variations:t.array(u).min(2).max(20).optional(),key:t.string().optional(),range:f.optional(),tracks:t.array(t.strictObject({experiment:y,result:N})).max(100).optional()}),D=t.strictObject({defaultValue:u.optional(),rules:t.array(U).max(500).optional()}),h=t.record(t.string(),t.union([t.strictObject({type:t.literal("hashed"),attributeKey:t.string(),values:t.array(t.string().regex(/^[a-f0-9]{64}$/))}),t.strictObject({type:t.literal("list"),attributeKey:t.string(),values:t.array(t.union([t.string(),t.number()]))}),t.strictObject({type:t.literal("condition"),condition:d})])),te=t.strictObject({scope:k,generation:t.string().regex(/^[a-f0-9]{64}$/),evaluatedAt:t.iso.datetime({offset:!0}),expiresAt:t.iso.datetime({offset:!0}).nullable(),features:t.record(t.string(),D),savedGroups:h,experiments:t.record(t.uuid(),y)});import{z as a}from"zod";import{z as e}from"zod";import{z as r}from"zod";var P=r.strictObject({schemaVersion:r.literal(1),renderKey:r.string().min(1).max(256),routeTemplate:r.string().startsWith("/").max(2048),selectors:r.array(r.string().regex(/^[a-z][a-z0-9-]*\[(?:id|data-testid|data-test|data-qa|data-indiana-id)="(?:[^"\\\x00-\x1f\x7f]|\\["\\])*"\]$/).max(512)),present:r.array(r.number().int().min(0)).min(1),absent:r.array(r.number().int().min(0))}).superRefine((n,g)=>{let s=[...n.present,...n.absent];(new Set(n.selectors).size!==n.selectors.length||new Set(s).size!==s.length||s.length!==n.selectors.length||s.some(o=>o>=n.selectors.length))&&g.addIssue({code:"custom",message:"Incomplete or ambiguous render signature"})}),w=r.strictObject({renderKey:r.string().min(1).max(256),routeKey:r.string().min(1).max(256),stateKey:r.string().min(1).max(256),documentKey:r.string().min(1).max(256),documentHash:r.string().regex(/^[a-f0-9]{64}$/),compositionKey:r.string().min(1).max(256),entryMode:r.enum(["hard","soft"]),match:r.strictObject({present:r.array(r.number().int().min(0)),absent:r.array(r.number().int().min(0))})});import{z as m}from"zod";var B={"enterprise-internal-indiana-test":"indiana-admin-vercel@enterprise-internal-490516.iam.gserviceaccount.com","tinkerland-indiana-prod":"indiana-admin-vercel@tinkerland-indiana.iam.gserviceaccount.com"},x="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",T=m.string().regex(new RegExp(`^${x}/${x}/${x}/manifest\\.json$`)),X="content-length;content-type;host;x-goog-if-generation-match",A=m.strictObject({kind:m.literal("gcs-v4-put"),url:m.url(),bucket:m.enum(["enterprise-internal-indiana-test","tinkerland-indiana-prod"]),objectKey:T,byteLength:m.number().int().min(1),expiresAt:m.iso.datetime(),headers:m.strictObject({"Content-Type":m.literal("application/json"),"x-goog-if-generation-match":m.literal("0")})}).superRefine((n,g)=>{let s=new URL(n.url),o=s.searchParams,R=["X-Goog-Algorithm","X-Goog-Credential","X-Goog-Date","X-Goog-Expires","X-Goog-Signature","X-Goog-SignedHeaders"],l=o.get("X-Goog-Date")??"",O=/^\d{8}T\d{6}Z$/.test(l)?Date.parse(`${l.slice(0,4)}-${l.slice(4,6)}-${l.slice(6,8)}T${l.slice(9,11)}:${l.slice(11,13)}:${l.slice(13,15)}Z`):NaN,p=Number(o.get("X-Goog-Expires"));(s.origin!=="https://storage.googleapis.com"||s.username||s.password||s.hash||s.pathname!==`/${n.bucket}/app-manifests/${n.objectKey}`||[...o.keys()].length!==R.length||R.some($=>o.getAll($).length!==1)||o.get("X-Goog-Algorithm")!=="GOOG4-RSA-SHA256"||o.get("X-Goog-Credential")!==`${B[n.bucket]}/${l.slice(0,8)}/auto/storage/goog4_request`||o.get("X-Goog-SignedHeaders")!==X||!/^[a-f0-9]{512,1024}$/.test(o.get("X-Goog-Signature")??"")||!Number.isFinite(O)||!Number.isInteger(p)||p<1||p>900||O+p*1e3!==Date.parse(n.expiresAt))&&g.addIssue({code:"custom",message:"Invalid IAM upload capability"})});var i=e.string().min(1).max(256),c=e.string().regex(/^[a-f0-9]{64}$/),le=e.strictObject({versionId:e.uuid(),manifestDigest:c,sourceGraphDigest:c,pageKey:i,stateKey:i,documentKey:i,documentHash:c,elementKey:i.optional(),nodeId:i.optional(),contentHash:c.optional(),renderKey:i.optional()}),G=e.strictObject({pageKey:i,documentKey:i,expectedDocumentHash:c,renderKey:i.optional(),nodeId:i,elementKey:i,expectedContentHash:c,property:e.enum(["text","fontSize","color"]),value:e.union([e.string().max(4e3),e.number().finite()])}),V=e.strictObject({versionId:e.uuid(),manifestDigest:c,sourceGraphDigest:c,pageKey:i,stateKey:i,documentKey:i,documentHash:c,renderKey:i.optional(),patches:e.array(G.omit({pageKey:!0,documentKey:!0,expectedDocumentHash:!0,renderKey:!0})).min(1).max(200)}),_=/^[a-z][a-z0-9-]{0,39}$/,K=e.string().regex(_),I=e.enum(["web","ios","android"]),ue=e.discriminatedUnion("action",[e.strictObject({action:e.literal("register"),requestId:e.uuid(),client:K,platform:I,label:e.string().trim().min(1).max(100),sha256:c,bytes:e.number().int().min(1),transferBytes:e.number().int().min(1)}),e.strictObject({action:e.literal("complete"),versionId:e.uuid()}),e.strictObject({action:e.literal("current"),versionId:e.uuid(),expectedCurrent:e.uuid().nullable()}),e.strictObject({action:e.literal("delivery"),enabled:e.boolean()}),e.strictObject({action:e.literal("changes"),versionId:e.uuid(),experimentId:e.uuid(),variationId:i,changesetId:e.uuid().nullable(),expectedRevision:c.nullable(),editorUrl:e.string().url().max(2048),patches:e.array(G).min(1).max(200)})]),S=e.strictObject({id:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),clientKey:K,platform:I,label:e.string(),sha256:c,bytes:e.number().int().positive(),objectKey:e.string(),state:e.enum(["uploading","ready","rejected"]),isCurrent:e.boolean(),revision:e.number().int().nonnegative(),createdAt:e.string(),expiresAt:e.string(),readyAt:e.string().nullable(),summary:e.record(e.string(),e.json()),routeTree:e.json().nullable(),validation:e.record(e.string(),e.json())}),F=e.strictObject({key:K,platform:I,currentId:e.uuid().nullable()}),ge=e.strictObject({rows:e.array(S).max(100),nextCursor:e.uuid().nullable(),clients:e.array(F).max(20)}),v=e.strictObject({storedBytes:e.number().int().nonnegative(),reservedBytes:e.number().int().nonnegative(),chargedBytes:e.number().int().nonnegative(),versions:e.number().int().nonnegative(),objects:e.number().int().nonnegative(),orphanObjects:e.number().int().nonnegative(),missingReadyObjects:e.number().int().nonnegative(),unknownObjectSizes:e.number().int().nonnegative(),byteLimit:e.number().int().positive(),versionLimit:e.number().int().positive(),remainingBytes:e.number().int().nonnegative()}),pe=e.strictObject({asOf:e.iso.datetime({offset:!0}),reclamation:e.literal("manual-review-required"),buckets:e.strictObject({source:v,runtime:v,previews:v})}),de=e.strictObject({asOf:e.iso.datetime({offset:!0}),reviewOnly:e.literal(!0),complete:e.boolean(),issues:e.strictObject({scanLimit:e.boolean(),invalidReferences:e.number().int().nonnegative(),missingVersions:e.number().int().nonnegative()}),totals:e.strictObject({versions:e.number().int().nonnegative(),protected:e.number().int().nonnegative(),reviewCandidates:e.number().int().nonnegative()}),rows:e.array(e.strictObject({versionId:e.uuid(),kind:e.enum(["source","runtime"]),state:e.enum(["uploading","ready","rejected"]),createdAt:e.iso.datetime({offset:!0}),reviewAfter:e.iso.datetime({offset:!0}),reasons:e.array(e.enum(["current","upload-capability","retention-grace","incomplete-inventory","retained-observation","gb","gb-observation","funnel-draft","funnel-draft-observation","funnel-version","funnel-version-observation"])).max(11)})).max(50),nextCursor:e.uuid().nullable()}),ye=e.strictObject({version:S,actorId:e.uuid(),claims:e.record(e.string(),e.json())}),be=e.strictObject({version:S,upload:A.nullable()}),fe=e.object({format:e.literal("indiana-route-state-index"),schemaVersion:e.literal(3),routes:e.array(e.object({routeKey:i,path:e.string(),documentKey:i,documentHash:c,initialStateKey:i,initialRenderKey:i})),renders:e.array(w)}).loose().superRefine((n,g)=>{(!n.renders||n.routes.some(s=>!n.renders?.some(o=>o.renderKey===s.initialRenderKey&&o.routeKey===s.routeKey&&o.documentKey===s.documentKey&&o.stateKey===s.initialStateKey&&o.documentHash===s.documentHash&&o.entryMode==="hard")))&&g.addIssue({code:"custom",message:"Incomplete render catalog"})}),he=e.strictObject({rows:e.array(e.object({id:e.uuid(),name:e.string(),status:e.string(),variations:e.array(e.object({id:i,key:i,name:e.string().optional()}).loose())}).loose()),limited:e.boolean()}),xe=e.strictObject({enabled:e.boolean(),allowedOrigins:e.array(e.string())});var L=a.strictObject({selector:a.string().min(1).max(2048),action:a.enum(["set","append","remove"]),attribute:a.string().min(1).max(128).refine(n=>["html","class","style","position","href","src","alt","title","id","role","hidden"].includes(n)||/^(aria|data)-[a-z0-9_-]+$/.test(n)),value:a.string().max(5e4).optional(),parentSelector:a.string().max(2048).optional(),insertBeforeSelector:a.string().max(2048).optional()}),q=a.strictObject({variation:a.string().min(1).max(128),description:a.string().max(2e3).default(""),css:a.string().max(1e5).default(""),js:a.string().max(1e5).default(""),domMutations:a.array(L).max(200).default([]),iam:V.optional(),renderGuard:P.optional()}),j=q.omit({variation:!0,description:!0,iam:!0}),J=y.omit({variations:!0,active:!0}).extend({changeId:a.string().regex(/^[a-f0-9]{64}$/),variations:a.tuple([j,j]).rest(j).refine(n=>n.length<=20)}),Re=a.strictObject({trackExposures:a.boolean(),environmentId:a.uuid(),generation:a.string().regex(/^[a-f0-9]{64}$/),experiments:a.array(J).max(100),savedGroups:h});export{z as a,k as b,y as c,N as d,U as e,D as f,h as g,te as h,le as i,L as j,q as k,j as l,J as m,Re as n};
@@ -0,0 +1 @@
1
+ import{a as T,b as C,e as E}from"./chunk-A3N4ZZTM.js";import{a as t}from"./chunk-OVMNCZYC.js";import{a as A,j as N,m as D,p as O}from"./chunk-3BQFJANQ.js";import{b as I}from"./chunk-AE4CUTUE.js";import{a as k}from"./chunk-S5TVMQRC.js";var _={name:"@tinkerlandai/indiana-sdk",version:"0.8.0",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:{"./react-native":{types:"./dist/react-native.d.ts","react-native":"./dist/react-native.js",import:"./dist/react-native.js",default:"./dist/react-native.js"},".":{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"},"./visual":{types:"./dist/visual.d.ts",import:"./dist/visual.js"}},scripts:{build:"tsup",prepack:"pnpm run build",typecheck:"tsc --noEmit",lint:"node ../../scripts/lint.mjs --workspace packages/sdk"},dependencies:{"@ai-sdk/provider":"4.0.26","@types/json-schema":"7.0.15","css-tree":"^3.2.1","dom-mutator":"0.7.0",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","whatwg-url-minimum":"0.2.0"},peerDependencies:{"@openrouter/sdk":"^1.4.25"},peerDependenciesMeta:{"@openrouter/sdk":{optional:!0}}};var F=Symbol("IndianaNoContent");function J(d,j,P=URL){let a=d.scope?I.parse(d.scope):void 0,o=new P(d.baseUrl??k);if(o.username||o.password||o.search||o.hash)throw new t("INVALID_URL","baseUrl must not contain credentials, query, or fragment");if(o.protocol!=="https:"&&!(o.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(o.hostname)))throw new t("INVALID_URL","Use HTTPS, or HTTP on localhost during development");let L=d.fetch??globalThis.fetch.bind(globalThis),u=d.timeoutMs??1e4;if(!Number.isFinite(u)||u<=0||u>12e4)throw new t("INVALID_TIMEOUT","timeoutMs must be between 1 and 120000");let p=null,c=0,l=null,m=new Set;function b(){c+=1,p=null,l=null;for(let i of m)i.abort();m.clear()}async function M(i,U={},v="POST",H={}){if(!p)throw new t("NOT_IDENTIFIED","Call identify with a server-issued customer token first");let w=c,n=new AbortController;m.add(n);let f=()=>w!==c?new t("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):new t("TIMEOUT","Indiana request timed out"),y,q=new Promise((r,s)=>{y=()=>s(f()),n.signal.addEventListener("abort",y,{once:!0})}),K=setTimeout(()=>n.abort(),u),x=async()=>{let r=await L(`${o.href.replace(/\/$/,"")}/api/v1/${i}`,{method:v,headers:{"Content-Type":"application/json",Authorization:`Bearer ${p}`,[T]:E.current,[C]:_.version,...a?{"X-Indiana-Project":a.projectId,"X-Indiana-Environment":a.environment}:{}},body:v==="POST"?JSON.stringify(U):void 0,signal:n.signal,credentials:"omit",cache:"no-store",redirect:"error",...H.keepalive?{keepalive:!0}:{}});if(n.signal.aborted)throw f();let s;try{s=r.status===204?F:await r.json()}catch{throw n.signal.aborted?f():new t(r.ok?"INVALID_RESPONSE":"HTTP_ERROR","The gateway returned an unreadable response",r.status,r.headers.get("X-Request-Id")??void 0)}if(n.signal.aborted)throw f();if(w!==c)throw new t("IDENTITY_CHANGED","Customer identity changed while the request was in flight");if(!r.ok){let e=D.safeParse(s),g=e.success&&(!A.safeParse(e.data.error.code).success||N(e.data.error.code,r.status)),S=g?e.data.error.code:"HTTP_ERROR",R=O(S,r.status,{retryAfter:r.headers.get("Retry-After"),recovery:g?e.data.error.recovery:void 0,reason:g?e.data.error.reason:void 0});throw new t(S,g?e.data.error.message:"Indiana request failed",r.status,r.headers.get("X-Request-Id")??(e.success?e.data.requestId:void 0),{...R,...e.success&&e.data.error.retryable===!1?{retryable:!1}:{},...R.retryAfterSeconds===void 0&&e.success&&e.data.error.retryAfterSeconds!==void 0?{retryAfterSeconds:e.data.error.retryAfterSeconds}:{}})}if(r.headers.get(T)!==E.current)throw new t("PROTOCOL_MISMATCH","Response protocol does not match this SDK");if(a&&s&&typeof s=="object"&&"scope"in s){let e=I.safeParse(s.scope);if(!e.success||e.data.projectId!==a.projectId||e.data.environment!==a.environment)throw new t("SCOPE_MISMATCH","Response scope does not match this SDK instance")}let h=r.headers.get("X-Indiana-Telemetry-Subject");if(h){if(!/^[a-f0-9]{64}$/.test(h))throw new t("INVALID_RESPONSE","Invalid telemetry identity");l!==h&&(l=h,j?.(l))}return s};try{return await Promise.race([x(),q])}catch(r){throw w!==c?new t("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):r instanceof t?r:new t(n.signal.aborted?"TIMEOUT":"NETWORK_ERROR",n.signal.aborted?"Indiana request timed out":"Unable to read the Indiana response")}finally{clearTimeout(K),n.signal.removeEventListener("abort",y),m.delete(n)}}return{subjectKey:()=>l,identify(i){if(!i.trim()||/\s/.test(i)||i.length>4096)throw new t("INVALID_TOKEN","A nonempty server-issued token is required");b(),p=i},reset:b,request:M}}export{J as a};
@@ -1 +1 @@
1
- import{Qg as E,Rg as M,Sg as j,Tg as O,Ug as T}from"./chunk-467Z5ISI.js";import{a as u}from"./chunk-6MO6Y24B.js";import{h as w}from"./chunk-HD74AAFS.js";import{z as t}from"zod";var _=E,V=t.string().regex(/^(0|[1-9]\d{0,5})(\.\d{1,12})?$/),C=t.strictObject(Object.fromEntries(_.map(i=>[i,t.number().int().nonnegative().max(1e9)]))),L=M,D=j,q=t.strictObject({modelId:L,source:t.enum(["models.dev","custom"]),fetchedAt:t.iso.datetime(),rates:O,contextTier:t.number().int().nonnegative(),markupPercent:D}),U=t.strictObject({pricing:q,tokens:C,quantity:w,digest:t.string().regex(/^[a-f0-9]{64}$/)}),z=i=>{let[s,o=""]=i.split(".");return BigInt(s)*10n**12n+BigInt(o.padEnd(12,"0"))};function $(i){if(typeof i!="number"||!Number.isFinite(i)||i<0)throw new u("AI_PRICE_UNAVAILABLE","A published token price is missing");let s=String(i),o=s.includes("e")?i.toFixed(12).replace(/0+$/,"").replace(/\.$/,""):s;if(Number(o)!==i||!V.safeParse(o).success)throw new u("AI_PRICE_UNAVAILABLE","Published price exceeds the supported precision");return o}var R=t.strictObject({input:t.number().nonnegative(),output:t.number().nonnegative(),cache_read:t.number().nonnegative().optional(),cache_write:t.number().nonnegative().optional(),reasoning:t.number().nonnegative().optional(),input_audio:t.number().nonnegative().optional(),output_audio:t.number().nonnegative().optional()}),F=R.extend({context_over_200k:t.unknown().optional(),tiers:t.array(R.extend({tier:t.strictObject({type:t.literal("context"),size:t.number().int().nonnegative()})})).max(20).refine(i=>new Set(i.map(s=>s.tier.size)).size===i.length).optional()});async function N(i,s,o){let d=new TextEncoder().encode(JSON.stringify({pricing:i,tokens:s,quantity:o}));return[...new Uint8Array(await crypto.subtle.digest("SHA-256",d))].map(m=>m.toString(16).padStart(2,"0")).join("")}function B(i,s){let o=0n;for(let c of _){if(!s[c])continue;let f=i.rates[c];if(f===void 0)throw new u("AI_PRICE_UNAVAILABLE",`No published price for ${c}; report exclusive token pools`);o+=z(f)*BigInt(s[c])}let[d,m="0"]=String(i.markupPercent).split("e"),r=(d.split(".")[1]?.length??0)-Number(m),e=10n**BigInt(Math.max(r,0)),n=BigInt(d.replace(".",""))*10n**BigInt(Math.max(-r,0)),g=100n*e+n,l=100n*e*1000000n,a=(o*g+l-1n)/l;return w.parse(`${a/1000000n}.${(a%1000000n).toString().padStart(6,"0")}`)}function K(i={}){if(typeof window<"u")throw new u("SERVER_ONLY","AI token pricing belongs on your backend");let s=T.parse({defaultMarkup:i.defaultMarkup??0,providerMarkups:i.providerMarkups??{},modelMarkups:i.modelMarkups??{},customModels:i.customModels??{}}),o=null,d=0;async function m(){if(!o||Date.now()>=d){d=Date.now()+15*6e4;let r=(async()=>{let e=await(i.fetch??fetch)("https://models.dev/api.json",{signal:AbortSignal.timeout(3e4)});if(!e.ok)throw new u("AI_PRICE_UNAVAILABLE","Models.dev pricing is unavailable");return{data:t.record(t.string(),t.object({models:t.record(t.string(),t.unknown())})).parse(await e.json()),fetchedAt:new Date().toISOString()}})().catch(e=>{throw o===r&&(o=null),e});o=r}return o}return{refreshPrices(){o=null,d=0},async quoteTokens(r){let e=L.parse(r.modelId),n=C.parse(r.tokens),[g,...l]=e.split("/"),a=s.customModels[e],c,f,p,y=0;if(a?.input!==void 0&&a.output!==void 0&&_.every(A=>n[A]===0||a[A]!==void 0))c={...a,input:a.input,output:a.output},f="custom",p=new Date().toISOString();else{let A=await m(),x=A.data[g]?.models[l.join("/")];if(!x)throw new u("AI_PRICE_UNAVAILABLE","Unknown model; configure a complete custom price");let{cost:I}=t.object({cost:F}).parse(x),P=n.input+n.cache_read+n.cache_write+n.input_audio;if(I.tiers===void 0&&I.context_over_200k!==void 0&&P>2e5)throw new u("AI_PRICE_UNAVAILABLE","A current context tier is required for this model");let b=I.tiers?.filter(k=>P>k.tier.size).sort((k,Q)=>Q.tier.size-k.tier.size)[0],v=b??I;b&&(y=b.tier.size),c=Object.fromEntries(_.filter(k=>v[k]!==void 0).map(k=>[k,$(v[k])])),c={...c,...a},f=a?"custom":"models.dev",p=A.fetchedAt}let h=q.parse({modelId:e,source:f,fetchedAt:p,rates:c,contextTier:y,markupPercent:s.modelMarkups[e]??s.providerMarkups[g]??s.defaultMarkup}),S=B(h,n);return U.parse({pricing:h,tokens:n,quantity:S,digest:await N(h,n,S)})},async trackTokens(r,e){let n=U.parse(e.quote);if(n.quantity!==B(n.pricing,n.tokens)||n.digest!==await N(n.pricing,n.tokens,n.quantity))throw new u("INVALID_REQUEST","AI quote changed after pricing");let g=e.properties??{},l=e.providerCostUsd===void 0?void 0:t.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,18})?$/).parse(e.providerCostUsd),a=e.generationId===void 0?void 0:t.string().min(1).max(120).parse(e.generationId),c=8+ +(l!==void 0)+ +(a!==void 0);if(Object.keys(g).some(p=>p.startsWith("ai_")))throw new u("INVALID_REQUEST","AI tracking reserves ai_ event properties");if(Object.keys(g).length>16-c)throw new u("INVALID_REQUEST","AI tracking properties exceed the available event budget");let f={operation:"consume",internal_feature_id:e.internal_feature_id,quantity:n.quantity,idempotencyKey:e.idempotencyKey,properties:{...g,...l!==void 0?{ai_provider_cost_usd:l}:{},...a!==void 0?{ai_generation_id:a}:{},ai_model:n.pricing.modelId,ai_source:n.pricing.source,ai_price_at:n.pricing.fetchedAt,ai_quote_hash:n.digest,ai_markup:String(n.pricing.markupPercent),ai_tier:String(n.pricing.contextTier),ai_tokens:_.map(p=>n.tokens[p]).join(","),ai_rates:"v1:"+_.map(p=>n.pricing.rates[p]===void 0?"-":z(n.pricing.rates[p]).toString(36)).join(",")},...e.entityId?{entityId:e.entityId}:{}};return r.mutateBalance({customerId:e.customerId,command:f})}}}async function Y(i,s,o={}){let{config:d,model_markups:m}=await i.readAiPricing(s);return K({defaultMarkup:d.default_markup??0,providerMarkups:Object.fromEntries(Object.entries(d.provider_markups??{}).map(([r,e])=>[r,e.markup])),modelMarkups:Object.fromEntries(Object.entries(m??{}).filter(([,r])=>r.markup!==void 0).map(([r,e])=>[r,e.markup])),customModels:Object.fromEntries(Object.entries(m??{}).filter(([,r])=>r.input_cost!==void 0||r.output_cost!==void 0).map(([r,e])=>[r,{...e.input_cost!==void 0?{input:String(e.input_cost)}:{},...e.output_cost!==void 0?{output:String(e.output_cost)}:{}}])),...o})}export{q as a,U as b,K as c,Y as d};
1
+ import{Jg as E,Kg as M,Lg as j,Mg as O,Ng as T}from"./chunk-A3N4ZZTM.js";import{a as u}from"./chunk-OVMNCZYC.js";import{x as w}from"./chunk-3BQFJANQ.js";import{z as t}from"zod";var _=E,V=t.string().regex(/^(0|[1-9]\d{0,5})(\.\d{1,12})?$/),C=t.strictObject(Object.fromEntries(_.map(i=>[i,t.number().int().nonnegative().max(1e9)]))),L=M,D=j,q=t.strictObject({modelId:L,source:t.enum(["models.dev","custom"]),fetchedAt:t.iso.datetime(),rates:O,contextTier:t.number().int().nonnegative(),markupPercent:D}),U=t.strictObject({pricing:q,tokens:C,quantity:w,digest:t.string().regex(/^[a-f0-9]{64}$/)}),z=i=>{let[s,o=""]=i.split(".");return BigInt(s)*10n**12n+BigInt(o.padEnd(12,"0"))};function $(i){if(typeof i!="number"||!Number.isFinite(i)||i<0)throw new u("AI_PRICE_UNAVAILABLE","A published token price is missing");let s=String(i),o=s.includes("e")?i.toFixed(12).replace(/0+$/,"").replace(/\.$/,""):s;if(Number(o)!==i||!V.safeParse(o).success)throw new u("AI_PRICE_UNAVAILABLE","Published price exceeds the supported precision");return o}var R=t.strictObject({input:t.number().nonnegative(),output:t.number().nonnegative(),cache_read:t.number().nonnegative().optional(),cache_write:t.number().nonnegative().optional(),reasoning:t.number().nonnegative().optional(),input_audio:t.number().nonnegative().optional(),output_audio:t.number().nonnegative().optional()}),F=R.extend({context_over_200k:t.unknown().optional(),tiers:t.array(R.extend({tier:t.strictObject({type:t.literal("context"),size:t.number().int().nonnegative()})})).max(20).refine(i=>new Set(i.map(s=>s.tier.size)).size===i.length).optional()});async function N(i,s,o){let d=new TextEncoder().encode(JSON.stringify({pricing:i,tokens:s,quantity:o}));return[...new Uint8Array(await crypto.subtle.digest("SHA-256",d))].map(m=>m.toString(16).padStart(2,"0")).join("")}function B(i,s){let o=0n;for(let c of _){if(!s[c])continue;let f=i.rates[c];if(f===void 0)throw new u("AI_PRICE_UNAVAILABLE",`No published price for ${c}; report exclusive token pools`);o+=z(f)*BigInt(s[c])}let[d,m="0"]=String(i.markupPercent).split("e"),r=(d.split(".")[1]?.length??0)-Number(m),e=10n**BigInt(Math.max(r,0)),n=BigInt(d.replace(".",""))*10n**BigInt(Math.max(-r,0)),g=100n*e+n,l=100n*e*1000000n,a=(o*g+l-1n)/l;return w.parse(`${a/1000000n}.${(a%1000000n).toString().padStart(6,"0")}`)}function K(i={}){if(typeof window<"u")throw new u("SERVER_ONLY","AI token pricing belongs on your backend");let s=T.parse({defaultMarkup:i.defaultMarkup??0,providerMarkups:i.providerMarkups??{},modelMarkups:i.modelMarkups??{},customModels:i.customModels??{}}),o=null,d=0;async function m(){if(!o||Date.now()>=d){d=Date.now()+15*6e4;let r=(async()=>{let e=await(i.fetch??fetch)("https://models.dev/api.json",{signal:AbortSignal.timeout(3e4)});if(!e.ok)throw new u("AI_PRICE_UNAVAILABLE","Models.dev pricing is unavailable");return{data:t.record(t.string(),t.object({models:t.record(t.string(),t.unknown())})).parse(await e.json()),fetchedAt:new Date().toISOString()}})().catch(e=>{throw o===r&&(o=null),e});o=r}return o}return{refreshPrices(){o=null,d=0},async quoteTokens(r){let e=L.parse(r.modelId),n=C.parse(r.tokens),[g,...l]=e.split("/"),a=s.customModels[e],c,f,p,y=0;if(a?.input!==void 0&&a.output!==void 0&&_.every(A=>n[A]===0||a[A]!==void 0))c={...a,input:a.input,output:a.output},f="custom",p=new Date().toISOString();else{let A=await m(),x=A.data[g]?.models[l.join("/")];if(!x)throw new u("AI_PRICE_UNAVAILABLE","Unknown model; configure a complete custom price");let{cost:I}=t.object({cost:F}).parse(x),P=n.input+n.cache_read+n.cache_write+n.input_audio;if(I.tiers===void 0&&I.context_over_200k!==void 0&&P>2e5)throw new u("AI_PRICE_UNAVAILABLE","A current context tier is required for this model");let b=I.tiers?.filter(k=>P>k.tier.size).sort((k,Q)=>Q.tier.size-k.tier.size)[0],v=b??I;b&&(y=b.tier.size),c=Object.fromEntries(_.filter(k=>v[k]!==void 0).map(k=>[k,$(v[k])])),c={...c,...a},f=a?"custom":"models.dev",p=A.fetchedAt}let h=q.parse({modelId:e,source:f,fetchedAt:p,rates:c,contextTier:y,markupPercent:s.modelMarkups[e]??s.providerMarkups[g]??s.defaultMarkup}),S=B(h,n);return U.parse({pricing:h,tokens:n,quantity:S,digest:await N(h,n,S)})},async trackTokens(r,e){let n=U.parse(e.quote);if(n.quantity!==B(n.pricing,n.tokens)||n.digest!==await N(n.pricing,n.tokens,n.quantity))throw new u("INVALID_REQUEST","AI quote changed after pricing");let g=e.properties??{},l=e.providerCostUsd===void 0?void 0:t.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,18})?$/).parse(e.providerCostUsd),a=e.generationId===void 0?void 0:t.string().min(1).max(120).parse(e.generationId),c=8+ +(l!==void 0)+ +(a!==void 0);if(Object.keys(g).some(p=>p.startsWith("ai_")))throw new u("INVALID_REQUEST","AI tracking reserves ai_ event properties");if(Object.keys(g).length>16-c)throw new u("INVALID_REQUEST","AI tracking properties exceed the available event budget");let f={operation:"consume",internal_feature_id:e.internal_feature_id,quantity:n.quantity,idempotencyKey:e.idempotencyKey,properties:{...g,...l!==void 0?{ai_provider_cost_usd:l}:{},...a!==void 0?{ai_generation_id:a}:{},ai_model:n.pricing.modelId,ai_source:n.pricing.source,ai_price_at:n.pricing.fetchedAt,ai_quote_hash:n.digest,ai_markup:String(n.pricing.markupPercent),ai_tier:String(n.pricing.contextTier),ai_tokens:_.map(p=>n.tokens[p]).join(","),ai_rates:"v1:"+_.map(p=>n.pricing.rates[p]===void 0?"-":z(n.pricing.rates[p]).toString(36)).join(",")},...e.entityId?{entityId:e.entityId}:{}};return r.mutateBalance({customerId:e.customerId,command:f})}}}async function Y(i,s,o={}){let{config:d,model_markups:m}=await i.readAiPricing(s);return K({defaultMarkup:d.default_markup??0,providerMarkups:Object.fromEntries(Object.entries(d.provider_markups??{}).map(([r,e])=>[r,e.markup])),modelMarkups:Object.fromEntries(Object.entries(m??{}).filter(([,r])=>r.markup!==void 0).map(([r,e])=>[r,e.markup])),customModels:Object.fromEntries(Object.entries(m??{}).filter(([,r])=>r.input_cost!==void 0||r.output_cost!==void 0).map(([r,e])=>[r,{...e.input_cost!==void 0?{input:String(e.input_cost)}:{},...e.output_cost!==void 0?{output:String(e.output_cost)}:{}}])),...o})}export{q as a,U as b,K as c,Y as d};
@@ -1 +1 @@
1
- import{K as o}from"./chunk-HD74AAFS.js";var n=class extends Error{constructor(t,s,y,i,r){super(s);this.code=t;this.status=y;this.requestId=i;this.name="IndianaError",this.reason=r?.reason;let e=o(t,y??0,{...r,retryAfter:r?.retryAfterSeconds===void 0?void 0:String(r.retryAfterSeconds)});this.retryable=e.retryable,this.recovery=e.recovery,this.retryAfterSeconds=e.retryAfterSeconds}code;status;requestId;retryable;recovery;retryAfterSeconds;reason};export{n as a};
1
+ import{p as o}from"./chunk-3BQFJANQ.js";var n=class extends Error{constructor(t,s,y,i,r){super(s);this.code=t;this.status=y;this.requestId=i;this.name="IndianaError",this.reason=r?.reason;let e=o(t,y??0,{...r,retryAfter:r?.retryAfterSeconds===void 0?void 0:String(r.retryAfterSeconds)});this.retryable=e.retryable,this.recovery=e.recovery,this.retryAfterSeconds=e.retryAfterSeconds}code;status;requestId;retryable;recovery;retryAfterSeconds;reason};export{n as a};
@@ -1,11 +1,11 @@
1
1
  import { z } from 'zod';
2
- import { S as StackNode } from './screen-iFngkxaL.js';
2
+ import { S as StackNode } from './screen-BazUOjwM.js';
3
3
 
4
4
  declare const configurationScopeSchema: z.ZodObject<{
5
5
  projectId: z.ZodString;
6
6
  environment: z.ZodEnum<{
7
- sandbox: "sandbox";
8
7
  live: "live";
8
+ sandbox: "sandbox";
9
9
  }>;
10
10
  environmentId: z.ZodUUID;
11
11
  }, z.core.$strict>;
@@ -15,8 +15,8 @@ declare const sdkConfigurationManifestSchema: z.ZodObject<{
15
15
  scope: z.ZodObject<{
16
16
  projectId: z.ZodString;
17
17
  environment: z.ZodEnum<{
18
- sandbox: "sandbox";
19
18
  live: "live";
19
+ sandbox: "sandbox";
20
20
  }>;
21
21
  environmentId: z.ZodUUID;
22
22
  }, z.core.$strict>;
@@ -104,7 +104,7 @@ type Listener = () => void;
104
104
  declare function createConfigurationSync(options: ConfigurationSyncOptions): {
105
105
  scope: Readonly<{
106
106
  projectId: string;
107
- environment: "sandbox" | "live";
107
+ environment: "live" | "sandbox";
108
108
  environmentId: string;
109
109
  }>;
110
110
  refresh: () => Promise<Manifest>;
@@ -117,7 +117,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
117
117
  schemaVersion: 1;
118
118
  scope: {
119
119
  projectId: string;
120
- environment: "sandbox" | "live";
120
+ environment: "live" | "sandbox";
121
121
  environmentId: string;
122
122
  };
123
123
  revision: number;
@@ -268,7 +268,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
268
268
  }>;
269
269
  scope: {
270
270
  projectId: string;
271
- environment: "sandbox" | "live";
271
+ environment: "live" | "sandbox";
272
272
  };
273
273
  generation: string;
274
274
  savedGroups: Record<string, {
@@ -341,13 +341,18 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
341
341
  variations: {
342
342
  urlRedirect: string;
343
343
  }[];
344
+ name?: string | undefined;
345
+ meta?: {
346
+ key?: string | undefined;
347
+ name?: string | undefined;
348
+ passthrough?: boolean | undefined;
349
+ }[] | undefined;
344
350
  filters?: {
345
351
  seed: string;
346
352
  hashVersion: 2;
347
353
  ranges: [number, number][];
348
354
  attribute?: string | undefined;
349
355
  }[] | undefined;
350
- name?: string | undefined;
351
356
  seed?: string | undefined;
352
357
  hashVersion?: 2 | undefined;
353
358
  ranges?: [number, number][] | undefined;
@@ -371,11 +376,6 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
371
376
  disableStickyBucketing?: boolean | undefined;
372
377
  bucketVersion?: number | undefined;
373
378
  minBucketVersion?: number | undefined;
374
- meta?: {
375
- key?: string | undefined;
376
- name?: string | undefined;
377
- passthrough?: boolean | undefined;
378
- }[] | undefined;
379
379
  phase?: string | undefined;
380
380
  }[];
381
381
  savedGroups: Record<string, {
@@ -657,11 +657,6 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
657
657
  nodeId?: string | undefined;
658
658
  contentHash?: string | undefined;
659
659
  renderKey?: string | undefined;
660
- observed?: {
661
- versionId: string;
662
- sha256: string;
663
- contentHash: string;
664
- } | undefined;
665
660
  } | undefined;
666
661
  position?: {
667
662
  x: number;
@@ -669,7 +664,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
669
664
  } | undefined;
670
665
  } | {
671
666
  type: "end";
672
- outcome: "failed" | "completed" | "closed" | "ineligible";
667
+ outcome: "closed" | "failed" | "completed" | "ineligible";
673
668
  id: string;
674
669
  name: string;
675
670
  output?: {
@@ -720,7 +715,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
720
715
  kind: "screen";
721
716
  schemaVersion: 4;
722
717
  name: string;
723
- surface: "popup" | "paywall" | "page" | "onboarding";
718
+ surface: "paywall" | "popup" | "onboarding" | "page" | "banner";
724
719
  presentation: {
725
720
  type: "modal";
726
721
  size: "sm" | "md" | "lg";
@@ -729,12 +724,14 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
729
724
  size: "sm" | "md" | "lg";
730
725
  } | {
731
726
  type: "fullscreen";
727
+ } | {
728
+ type: "inline";
732
729
  };
733
730
  theme: {
734
731
  primary: string;
735
732
  background: string;
736
733
  text: string;
737
- radius: "none" | "full" | "sm" | "md" | "lg";
734
+ radius: "sm" | "md" | "lg" | "none" | "full";
738
735
  font: "system" | "serif" | "rounded" | "mono";
739
736
  };
740
737
  pages: {
@@ -745,7 +742,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
745
742
  primary: string;
746
743
  background: string;
747
744
  text: string;
748
- radius: "none" | "full" | "sm" | "md" | "lg";
745
+ radius: "sm" | "md" | "lg" | "none" | "full";
749
746
  font: "system" | "serif" | "rounded" | "mono";
750
747
  } | undefined;
751
748
  editorPosition?: {
@@ -795,20 +792,20 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
795
792
  };
796
793
  publicData?: {
797
794
  couponDigests: Record<string, string>;
798
- variables: Record<string, Record<string, Partial<Record<"offer.headline" | "offer.name" | "offer.description" | "offer.eligibility" | "offer.validity" | "offer.terms" | "offer.discount" | "offer.months" | "offer.ends_at", string>>>>;
795
+ variables: Record<string, Record<string, Partial<Record<"offer.ends_at" | "offer.headline" | "offer.name" | "offer.description" | "offer.eligibility" | "offer.validity" | "offer.terms" | "offer.discount" | "offer.months", string>>>>;
799
796
  locales: Record<string, {
800
- plans: Record<string, never>;
801
797
  nodes: Record<string, {
802
798
  base: {
803
- couponId?: string | undefined;
804
799
  text?: string | undefined;
805
800
  label?: string | undefined;
806
801
  alt?: string | undefined;
807
802
  html?: string | undefined;
808
803
  countdownAt?: string | undefined;
804
+ couponId?: string | undefined;
809
805
  missing?: string[] | undefined;
810
806
  };
811
807
  }>;
808
+ plans: Record<string, never>;
812
809
  pickers: Record<string, never>;
813
810
  diagnostics: {
814
811
  nodeId: string;
@@ -986,7 +983,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
986
983
  }>;
987
984
  scope: {
988
985
  projectId: string;
989
- environment: "sandbox" | "live";
986
+ environment: "live" | "sandbox";
990
987
  };
991
988
  generation: string;
992
989
  savedGroups: Record<string, {
@@ -1072,7 +1069,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
1072
1069
  schemaVersion: 1;
1073
1070
  scope: {
1074
1071
  projectId: string;
1075
- environment: "sandbox" | "live";
1072
+ environment: "live" | "sandbox";
1076
1073
  environmentId: string;
1077
1074
  };
1078
1075
  revision: number;
@@ -1143,7 +1140,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
1143
1140
  kind: "screen";
1144
1141
  schemaVersion: 4;
1145
1142
  name: string;
1146
- surface: "popup" | "paywall" | "page" | "onboarding";
1143
+ surface: "paywall" | "popup" | "onboarding" | "page" | "banner";
1147
1144
  presentation: {
1148
1145
  type: "modal";
1149
1146
  size: "sm" | "md" | "lg";
@@ -1152,12 +1149,14 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
1152
1149
  size: "sm" | "md" | "lg";
1153
1150
  } | {
1154
1151
  type: "fullscreen";
1152
+ } | {
1153
+ type: "inline";
1155
1154
  };
1156
1155
  theme: {
1157
1156
  primary: string;
1158
1157
  background: string;
1159
1158
  text: string;
1160
- radius: "none" | "full" | "sm" | "md" | "lg";
1159
+ radius: "sm" | "md" | "lg" | "none" | "full";
1161
1160
  font: "system" | "serif" | "rounded" | "mono";
1162
1161
  };
1163
1162
  pages: {
@@ -1168,7 +1167,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
1168
1167
  primary: string;
1169
1168
  background: string;
1170
1169
  text: string;
1171
- radius: "none" | "full" | "sm" | "md" | "lg";
1170
+ radius: "sm" | "md" | "lg" | "none" | "full";
1172
1171
  font: "system" | "serif" | "rounded" | "mono";
1173
1172
  } | undefined;
1174
1173
  editorPosition?: {
@@ -1236,7 +1235,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
1236
1235
  };
1237
1236
  catalog: Record<string, {
1238
1237
  name: string;
1239
- interval: "week" | "month" | "year" | "free" | "one_time";
1238
+ interval: "free" | "week" | "month" | "year" | "one_time";
1240
1239
  intervalCount: number;
1241
1240
  trial: {
1242
1241
  days: number;
@@ -1346,7 +1345,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
1346
1345
  schemaVersion: 1;
1347
1346
  scope: {
1348
1347
  projectId: string;
1349
- environment: "sandbox" | "live";
1348
+ environment: "live" | "sandbox";
1350
1349
  environmentId: string;
1351
1350
  };
1352
1351
  revision: number;
@@ -1401,7 +1400,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
1401
1400
  growth: {
1402
1401
  scope: {
1403
1402
  projectId: string;
1404
- environment: "sandbox" | "live";
1403
+ environment: "live" | "sandbox";
1405
1404
  };
1406
1405
  generation: string;
1407
1406
  evaluatedAt: string;
@@ -1562,7 +1561,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
1562
1561
  }[]>;
1563
1562
  scope: {
1564
1563
  projectId: string;
1565
- environment: "sandbox" | "live";
1564
+ environment: "live" | "sandbox";
1566
1565
  };
1567
1566
  funnelId: string;
1568
1567
  versionId: string;
@@ -1572,7 +1571,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
1572
1571
  entry: string;
1573
1572
  nodes: {
1574
1573
  id: string;
1575
- type: "output" | "feature" | "split" | "action" | "condition" | "coupon" | "end" | "screen" | "offering" | "coupons" | "entry" | "external_page" | "wait";
1574
+ type: "output" | "action" | "screen" | "end" | "coupon" | "feature" | "split" | "condition" | "offering" | "coupons" | "entry" | "external_page" | "wait";
1576
1575
  outputs: Record<string, string>;
1577
1576
  writes: Record<string, string>;
1578
1577
  resources: {
@@ -1617,7 +1616,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
1617
1616
  } | undefined;
1618
1617
  };
1619
1618
  terminals: Record<string, {
1620
- outcome: "failed" | "completed" | "closed" | "ineligible";
1619
+ outcome: "closed" | "failed" | "completed" | "ineligible";
1621
1620
  output: {
1622
1621
  type: "literal";
1623
1622
  value: z.core.util.JSONType;
@@ -0,0 +1 @@
1
+ import{h as H}from"./chunk-3ENVRJE6.js";import{a as b}from"./chunk-6X42DWOM.js";import"./chunk-CXYOZSOF.js";import{jc as D}from"./chunk-A3N4ZZTM.js";import{a as f}from"./chunk-OVMNCZYC.js";import{Eb as T,Mb as L,Ob as j,tb as k}from"./chunk-3BQFJANQ.js";import"./chunk-AE4CUTUE.js";import"./chunk-S5TVMQRC.js";import{a as I}from"./chunk-RRII2DMC.js";import"./chunk-KQCTDXVD.js";import{z as l}from"zod";var x=new WeakMap;function P(o){let t={string:l.string(),number:l.number().finite(),boolean:l.boolean(),strings:l.array(l.string()),json:I}[o.type];return o.nullable?t.nullable():t}async function J(o,t){let S=D.parse(t.content),r=S.document;if(x.has(o))throw new f("CONFLICT","Content is already mounted in this container");let u=l.record(l.string(),I).parse(t.inputs??{});if(Object.keys(u).length>40)throw new f("INVALID_REQUEST","Too many content inputs");for(let[e,i]of Object.entries(u))L.parse({[e]:i});if(Object.keys(u).some(e=>!Object.hasOwn(r.contract.inputs,e)))throw new f("INVALID_REQUEST","Undeclared content input");for(let[e,i]of Object.entries(r.contract.inputs))if(Object.hasOwn(u,e))P(i).parse(u[e]);else if(i.required)throw new f("INVALID_REQUEST",`Missing content input ${e}`);for(let e of Object.keys(r.contract.outputs))if(typeof t.actions[e]!="function")throw new f("INVALID_REQUEST",`Missing host handler for ${e}`);let R=j.parse(t.bindings??[]),d=o.ownerDocument,v=d.activeElement,A=r.kind==="popup",n=A?d.createElement("dialog"):null,s=d.createElement("div");if(s.dataset.indianaContent=r.kind,s.setAttribute("aria-label",r.name),s.style.cssText="width:100%;min-width:0",n){n.setAttribute("aria-label",r.name);let e=r.screen.presentation;n.style.cssText="box-sizing:border-box;padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto",e.type==="modal"||e.type==="sheet"?(n.style.width=`${k[e.size]}px`,e.type==="sheet"&&(n.style.margin="auto auto 0")):n.style.width="100vw",n.append(s),o.append(n)}else o.append(s);let m=!1,g=!1,a=null,w=structuredClone(r.screen);w.actions=w.actions.map(e=>e.type==="event"?{...e,close:!1}:e);let h;function E(){m||(m=!0,h?.destroy(),n?.close(),n?.remove(),s.remove(),x.delete(o),n&&v instanceof HTMLElement&&v.isConnected&&v.focus())}let C=()=>{E(),b(t.onDismiss)};if(n){let e=d.createElement("button");e.type="button",e.textContent="\xD7",e.setAttribute("aria-label",t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),e.style.cssText="position:absolute;right:8px;top:8px;width:30px;height:30px;z-index:1",e.addEventListener("click",C),n.prepend(e)}n?.addEventListener("cancel",e=>{e.preventDefault(),C()});async function V(){if(m||g||!a)return;let e=a;g=!0,s.setAttribute("aria-busy","true");try{await t.actions[e.actionId](structuredClone(e)),a=null}catch(i){b(t.onError,i)}finally{g=!1,m||s.removeAttribute("aria-busy")}}try{n?.showModal(),h=H(s,{mode:"live",title:r.name,viewportHeight:r.kind==="page"?o.clientHeight||d.defaultView?.innerHeight||800:void 0,onError:c=>b(t.onError,new Error(c)),onEscape:A?C:void 0,onAction:(c,U,M)=>{if(m||g||a)return;let p=r.screen.actions.find(y=>y.id===c),O=r.contract.outputs[c];if(!(p?.type!=="event"||!O))try{let y=P(O).parse(Object.hasOwn(p.properties,"value")?p.properties.value:p.properties);a={requestId:crypto.randomUUID(),contentVersionId:S.id,actionId:c,event:p.event,value:y,selection:U??{},answers:M??{},requestedClose:p.close},V()}catch(y){b(t.onError,y)}}});let e={destroy:E,get pendingAction(){return a?structuredClone(a):null},retryAction:V,updateCapabilities:c=>h?.updateCapabilities(c)};x.set(o,e);let i=T(w,[t.locale,...d.defaultView?.navigator.languages??[]]);return h.update(w,i,{capabilities:t.capabilities,serverInput:{bindings:R,answers:{},values:u}}),await h.ready,e}catch(e){throw E(),e}}export{J as mountContent};