@tinkerlandai/indiana-sdk 0.6.1 → 0.6.3

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 (48) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/README.md +13 -9
  3. package/README.zh-CN.md +19 -16
  4. package/dist/{ai-usage-C4Eg6sSr.d.ts → ai-usage-B4W5m4Ie.d.ts} +346 -346
  5. package/dist/chunk-4K25DELJ.js +1 -0
  6. package/dist/chunk-CB63JLGT.js +1 -0
  7. package/dist/chunk-D7YHFS6B.js +4 -0
  8. package/dist/chunk-FF3LWJ26.js +11 -0
  9. package/dist/chunk-FVUPV6YE.js +1 -0
  10. package/dist/chunk-ISUXYPYL.js +1 -0
  11. package/dist/{chunk-GJGI34Q7.js → chunk-QG4GM4RI.js} +1 -1
  12. package/dist/chunk-U6S6AZM6.js +1 -0
  13. package/dist/chunk-VVSQKVE7.js +1 -0
  14. package/dist/chunk-YAMBRNJ2.js +1 -0
  15. package/dist/client-OYRHOMUQ.js +1 -0
  16. package/dist/{configuration-sync-BWn1YZ78.d.ts → configuration-sync-C2mytNwU.d.ts} +59 -41
  17. package/dist/funnel-runtime-host-KPYLOYYN.js +1 -0
  18. package/dist/{funnel-runtime-start-CKVuIOFs.d.ts → funnel-runtime-start-CVb2YonU.d.ts} +826 -789
  19. package/dist/iam.d.ts +131 -0
  20. package/dist/iam.js +1 -0
  21. package/dist/index.d.ts +639 -603
  22. package/dist/index.js +1 -1
  23. package/dist/native-shell.js +1 -1
  24. package/dist/openrouter.d.ts +2 -2
  25. package/dist/openrouter.js +1 -1
  26. package/dist/page.d.ts +19 -18
  27. package/dist/page.js +1 -1
  28. package/dist/paywall-5WU6PX5C.js +1 -0
  29. package/dist/popup.d.ts +18 -17
  30. package/dist/popup.js +174 -15
  31. package/dist/server.d.ts +4 -4
  32. package/dist/server.js +1 -1
  33. package/dist/src-U7PBAUBN.js +1 -0
  34. package/dist/visual.d.ts +10 -1
  35. package/dist/visual.js +2 -1
  36. package/package.json +15 -8
  37. package/dist/chunk-46S4DTCD.js +0 -11
  38. package/dist/chunk-4JBIKJMU.js +0 -4
  39. package/dist/chunk-BIFEEVQO.js +0 -1
  40. package/dist/chunk-FRZNOXK6.js +0 -1
  41. package/dist/chunk-OHDY27EI.js +0 -1
  42. package/dist/chunk-U3TULZCD.js +0 -1
  43. package/dist/funnel-runtime-host-YXWVCKAJ.js +0 -1
  44. package/dist/paywall-GRSGZLVG.js +0 -1
  45. package/dist/src-UWBQFGYH.js +0 -1
  46. package/dist/visual-editor-agent-WW65CMKW.js +0 -1
  47. package/dist/{customer-page-OBB82t8_.d.ts → customer-page-B4FGCVpt.d.ts} +4 -4
  48. package/dist/{screen-BbLE1OMn.d.ts → screen-16d-xADb.d.ts} +160 -160
@@ -0,0 +1 @@
1
+ import{kb as T,lb as P,ob as S}from"./chunk-FF3LWJ26.js";import{a as e}from"./chunk-5TEZEOHX.js";import{D as _,G as C,J as k,v as O}from"./chunk-RMJJOSVZ.js";import{a as j}from"./chunk-S5TVMQRC.js";import{b as E}from"./chunk-ISUXYPYL.js";var L={name:"@tinkerlandai/indiana-sdk",version:"0.6.3",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"},"./visual":{types:"./dist/visual.d.ts",import:"./dist/visual.js"},"./iam":{types:"./dist/iam.d.ts",import:"./dist/iam.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","rrweb-snapshot":"2.1.7","@rrweb/types":"2.1.7"},peerDependencies:{"@openrouter/sdk":"^1.4.25"},peerDependenciesMeta:{"@openrouter/sdk":{optional:!0}}};var X=Symbol("IndianaNoContent");function Q(a,V){let v=a.webView??"hosted";if(!["hosted","embedded"].includes(v))throw new e("INVALID_REQUEST","Invalid Web View mode");let d=a.scope?E.parse(a.scope):void 0,s=new URL(a.baseUrl??j);if(s.username||s.password||s.search||s.hash)throw new e("INVALID_URL","baseUrl must not contain credentials, query, or fragment");if(s.protocol!=="https:"&&!(s.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(s.hostname)))throw new e("INVALID_URL","Use HTTPS, or HTTP on localhost during development");let U=a.fetch??globalThis.fetch.bind(globalThis),u=a.timeoutMs??1e4;if(!Number.isFinite(u)||u<=0||u>12e4)throw new e("INVALID_TIMEOUT","timeoutMs must be between 1 and 120000");let p=null,g,c=0,l=null,m=new Set;function R(){c+=1,p=null,l=null;for(let i of m)i.abort();m.clear()}async function M(i,H={},N="POST",q={}){if(!p)throw new e("NOT_IDENTIFIED","Call identify with a server-issued customer token first");let y=c,n=new AbortController;m.add(n);let f=()=>y!==c?new e("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):new e("TIMEOUT","Indiana request timed out"),I,K=new Promise((t,o)=>{I=()=>o(f()),n.signal.addEventListener("abort",I,{once:!0})}),x=setTimeout(()=>n.abort(),u),F=async()=>{let t=await U(`${s.href.replace(/\/$/,"")}/api/v1/${i}`,{method:N,headers:{"Content-Type":"application/json",Authorization:`Bearer ${p}`,[T]:S.current,[P]:L.version,...d?{"X-Indiana-Project":d.projectId,"X-Indiana-Environment":d.environment}:{}},body:N==="POST"?JSON.stringify(H):void 0,signal:n.signal,credentials:"omit",cache:"no-store",redirect:"error",...q.keepalive?{keepalive:!0}:{}});if(n.signal.aborted)throw f();let o;try{o=t.status===204?X:await t.json()}catch{throw n.signal.aborted?f():new e(t.ok?"INVALID_RESPONSE":"HTTP_ERROR","The gateway returned an unreadable response",t.status,t.headers.get("X-Request-Id")??void 0)}if(n.signal.aborted)throw f();if(y!==c)throw new e("IDENTITY_CHANGED","Customer identity changed while the request was in flight");if(!t.ok){let r=C.safeParse(o),w=r.success&&(!O.safeParse(r.data.error.code).success||_(r.data.error.code,t.status)),A=w?r.data.error.code:"HTTP_ERROR",D=k(A,t.status,{retryAfter:t.headers.get("Retry-After"),recovery:w?r.data.error.recovery:void 0,reason:w?r.data.error.reason:void 0});throw new e(A,w?r.data.error.message:"Indiana request failed",t.status,t.headers.get("X-Request-Id")??(r.success?r.data.requestId:void 0),{...D,...r.success&&r.data.error.retryable===!1?{retryable:!1}:{},...D.retryAfterSeconds===void 0&&r.success&&r.data.error.retryAfterSeconds!==void 0?{retryAfterSeconds:r.data.error.retryAfterSeconds}:{}})}if(t.headers.get(T)!==S.current)throw new e("PROTOCOL_MISMATCH","Response protocol does not match this SDK");if(d&&o&&typeof o=="object"&&"scope"in o){let r=E.safeParse(o.scope);if(!r.success||r.data.projectId!==d.projectId||r.data.environment!==d.environment)throw new e("SCOPE_MISMATCH","Response scope does not match this SDK instance")}let b=t.headers.get("X-Indiana-Web-View");if(b){if(!/^\/web-view\/renderer\/[a-f0-9]{64}$/.test(b))throw new e("INVALID_RESPONSE","Invalid Web View renderer metadata");g=b}let h=t.headers.get("X-Indiana-Telemetry-Subject");if(h){if(!/^[a-f0-9]{64}$/.test(h))throw new e("INVALID_RESPONSE","Invalid telemetry identity");l!==h&&(l=h,V?.(l))}return o};try{return await Promise.race([F(),K])}catch(t){throw y!==c?new e("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):t instanceof e?t:new e(n.signal.aborted?"TIMEOUT":"NETWORK_ERROR",n.signal.aborted?"Indiana request timed out":"Unable to read the Indiana response")}finally{clearTimeout(x),n.signal.removeEventListener("abort",I),m.delete(n)}}return{subjectKey:()=>l,webViewUrl(){if(v!=="embedded"){if(!g)throw new e("INVALID_RESPONSE","The gateway did not provide a hosted Web View renderer");return new URL(g,s).href}},identify(i){if(!i.trim()||/\s/.test(i)||i.length>4096)throw new e("INVALID_TOKEN","A nonempty server-issued token is required");R(),p=i},reset:R,request:M}}export{Q as a};
@@ -0,0 +1 @@
1
+ import{r as g}from"./chunk-U6S6AZM6.js";import{l as u,n as y}from"./chunk-S2MSIA57.js";import{z as x}from"zod";var E=x.enum(["sandbox","live"]),O=x.object({projectId:x.string().min(1),environment:E}).strict();import{z as t}from"zod";var f=t.tuple([t.number().min(0).max(1),t.number().min(0).max(1)]).refine(([r,p])=>r<=p),$=t.strictObject({attribute:t.string().optional(),seed:t.string(),hashVersion:t.literal(2),ranges:t.array(f).max(100)}),H=t.strictObject({id:t.string().min(1).max(255),condition:y,gate:t.boolean().optional()}),C=t.strictObject({key:t.string().optional(),name:t.string().optional(),passthrough:t.boolean().optional()}),k={condition:y.optional(),parentConditions:t.array(H).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($).max(100).optional(),ranges:t.array(f).max(20).optional(),meta:t.array(C).max(20).optional(),seed:t.string().optional(),name:t.string().optional(),phase:t.string().optional()},b=t.strictObject({...k,key:t.string().min(1).max(255),variations:t.tuple([u,u]).rest(u).refine(r=>r.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()}),U=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()}),_=t.strictObject({...k,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:b,result:U})).max(100).optional()}),D=t.strictObject({defaultValue:u.optional(),rules:t.array(_).max(500).optional()}),v=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:y})])),J=t.strictObject({scope:O,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:v,experiments:t.record(t.uuid(),b)});import{z as n}from"zod";import{z as e}from"zod";import{z as i}from"zod";var M=i.strictObject({schemaVersion:i.literal(1),renderKey:i.string().min(1).max(256),routeTemplate:i.string().startsWith("/").max(2048),selectors:i.array(i.string().regex(/^[a-z][a-z0-9-]*\[data-indiana-id="(?:[^"\\\x00-\x1f]|\\["\\])*"\]$/).max(512)).max(512),present:i.array(i.number().int().min(0).max(511)).min(1).max(512),absent:i.array(i.number().int().min(0).max(511)).max(512)}).superRefine((r,p)=>{let o=[...r.present,...r.absent];(new Set(r.selectors).size!==r.selectors.length||new Set(o).size!==o.length||o.length!==r.selectors.length||o.some(s=>s>=r.selectors.length))&&p.addIssue({code:"custom",message:"Incomplete or ambiguous render signature"})}),w=i.strictObject({renderKey:i.string().min(1).max(256),routeKey:i.string().min(1).max(256),stateKey:i.string().min(1).max(256),documentKey:i.string().min(1).max(256),documentHash:i.string().regex(/^[a-f0-9]{64}$/),compositionKey:i.string().min(1).max(256),entryMode:i.enum(["hard","soft"]),match:i.strictObject({present:i.array(i.number().int().min(0).max(511)).max(512),absent:i.array(i.number().int().min(0).max(511)).max(512)})});import{z as m}from"zod";var N={"enterprise-internal-indiana-test":"indiana-admin-vercel@enterprise-internal-490516.iam.gserviceaccount.com","tinkerland-indiana-prod":"indiana-admin-vercel@tinkerland-indiana.iam.gserviceaccount.com"},S="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",B=m.string().regex(new RegExp(`^${S}/${S}/${S}/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:B,byteLength:m.number().int().min(1).max(8388608),expiresAt:m.iso.datetime(),headers:m.strictObject({"Content-Type":m.literal("application/json"),"x-goog-if-generation-match":m.literal("0")})}).superRefine((r,p)=>{let o=new URL(r.url),s=o.searchParams,j=["X-Goog-Algorithm","X-Goog-Credential","X-Goog-Date","X-Goog-Expires","X-Goog-Signature","X-Goog-SignedHeaders"],l=s.get("X-Goog-Date")??"",R=/^\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,d=Number(s.get("X-Goog-Expires"));(o.origin!=="https://storage.googleapis.com"||o.username||o.password||o.hash||o.pathname!==`/${r.bucket}/app-manifests/${r.objectKey}`||[...s.keys()].length!==j.length||j.some(z=>s.getAll(z).length!==1)||s.get("X-Goog-Algorithm")!=="GOOG4-RSA-SHA256"||s.get("X-Goog-Credential")!==`${N[r.bucket]}/${l.slice(0,8)}/auto/storage/goog4_request`||s.get("X-Goog-SignedHeaders")!==X||!/^[a-f0-9]{512,1024}$/.test(s.get("X-Goog-Signature")??"")||!Number.isFinite(R)||!Number.isInteger(d)||d<1||d>900||R+d*1e3!==Date.parse(r.expiresAt))&&p.addIssue({code:"custom",message:"Invalid IAM upload capability"})});var G=8388608;var a=e.string().min(1).max(256),c=e.string().regex(/^[a-f0-9]{64}$/),me=e.strictObject({versionId:e.uuid(),manifestDigest:c,sourceGraphDigest:c,pageKey:a,stateKey:a,documentKey:a,documentHash:c,elementKey:a.optional(),nodeId:a.optional(),contentHash:c.optional(),renderKey:a.optional(),observed:e.optional(g)}),P=e.strictObject({observed:e.optional(g),pageKey:a,documentKey:a,expectedDocumentHash:c,renderKey:a.optional(),nodeId:a,elementKey:a,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:a,stateKey:a,documentKey:a,documentHash:c,renderKey:a.optional(),observed:e.optional(g),patches:e.array(P.omit({pageKey:!0,documentKey:!0,expectedDocumentHash:!0,renderKey:!0})).min(1).max(200)}),le=e.discriminatedUnion("action",[e.strictObject({action:e.literal("register"),requestId:e.uuid(),label:e.string().trim().min(1).max(100),sha256:c,bytes:e.number().int().min(1).max(G),transferBytes:e.number().int().min(1).max(G)}),e.strictObject({action:e.literal("complete"),versionId:e.uuid()}),e.strictObject({action:e.literal("materialize"),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(),observed:e.optional(g),variationId:a,changesetId:e.uuid().nullable(),expectedRevision:c.nullable(),editorUrl:e.string().url().max(2048),patches:e.array(P).min(1).max(200)})]),h=e.strictObject({id:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),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())}),ue=e.strictObject({rows:e.array(h).max(100),nextCursor:e.uuid().nullable(),currentId:e.uuid().nullable()}),I=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:I,runtime:I,previews:I})}),ge=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()}),de=e.strictObject({version:h,actorId:e.uuid(),claims:e.record(e.string(),e.json())}),ye=e.strictObject({version:h,upload:A.nullable()}),be=e.strictObject({version:h,readOnly:e.boolean(),download:e.strictObject({url:e.url(),origin:e.url(),expiresIn:e.number().int().positive()})}),he=e.object({format:e.literal("indiana-route-state-index"),schemaVersion:e.literal(3),routes:e.array(e.object({routeKey:a,path:e.string(),documentKey:a,documentHash:c,initialStateKey:a,initialRenderKey:a})),renders:e.array(w).max(1e3)}).loose().superRefine((r,p)=>{(!r.renders||r.routes.some(o=>!r.renders?.some(s=>s.renderKey===o.initialRenderKey&&s.routeKey===o.routeKey&&s.documentKey===o.documentKey&&s.stateKey===o.initialStateKey&&s.documentHash===o.documentHash&&s.entryMode==="hard")))&&p.addIssue({code:"custom",message:"Incomplete render catalog"})}),xe=e.strictObject({rows:e.array(e.object({id:e.uuid(),name:e.string(),status:e.string(),variations:e.array(e.object({id:a,key:a,name:e.string().optional()}).loose())}).loose()),limited:e.boolean()}),fe=e.strictObject({enabled:e.boolean(),allowedOrigins:e.array(e.string())});var T=n.strictObject({selector:n.string().min(1).max(2048),action:n.enum(["set","append","remove"]),attribute:n.string().min(1).max(128).refine(r=>["html","class","style","position","href","src","alt","title","id","role","hidden"].includes(r)||/^(aria|data)-[a-z0-9_-]+$/.test(r)),value:n.string().max(5e4).optional(),parentSelector:n.string().max(2048).optional(),insertBeforeSelector:n.string().max(2048).optional()}),F=n.strictObject({variation:n.string().min(1).max(128),description:n.string().max(2e3).default(""),css:n.string().max(1e5).default(""),js:n.string().max(1e5).default(""),domMutations:n.array(T).max(200).default([]),iam:V.optional(),renderGuard:M.optional()}),K=F.omit({variation:!0,description:!0,iam:!0}),L=b.omit({variations:!0,active:!0}).extend({changeId:n.string().regex(/^[a-f0-9]{64}$/),variations:n.tuple([K,K]).rest(K).refine(r=>r.length<=20)}),Re=n.strictObject({trackExposures:n.boolean(),environmentId:n.uuid(),generation:n.string().regex(/^[a-f0-9]{64}$/),experiments:n.array(L).max(100),savedGroups:v}),Oe="__indiana_visual_editor",ke=n.object({selector:n.string().max(2048),tag:n.string().max(64),text:n.string().max(1e3),href:n.string().max(2048),src:n.string().max(2048),alt:n.string().max(2048).optional(),matches:n.number().int().nonnegative(),html:n.string().max(5e4).optional(),inlineStyle:n.string().max(5e4).optional(),styles:n.record(n.string(),n.string().max(1e3)).optional()});export{E as a,O as b,b as c,U as d,_ as e,D as f,v as g,J as h,me as i,T as j,F as k,K as l,L as m,Re as n,Oe as o,ke as p};
@@ -1 +1 @@
1
- import{a as u}from"./chunk-5TEZEOHX.js";import{$d as M,_d as E,ae as j,be as O,ce as T}from"./chunk-46S4DTCD.js";import{h as w}from"./chunk-RMJJOSVZ.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{$d as M,_d as E,ae as j,be as O,ce as T}from"./chunk-FF3LWJ26.js";import{a as u}from"./chunk-5TEZEOHX.js";import{h as w}from"./chunk-RMJJOSVZ.js";import{z as t}from"zod";var _=E,V=t.string().regex(/^(0|[1-9]\d{0,5})(\.\d{1,12})?$/),C=t.strictObject(Object.fromEntries(_.map(i=>[i,t.number().int().nonnegative().max(1e9)]))),L=M,D=j,q=t.strictObject({modelId:L,source:t.enum(["models.dev","custom"]),fetchedAt:t.iso.datetime(),rates:O,contextTier:t.number().int().nonnegative(),markupPercent:D}),U=t.strictObject({pricing:q,tokens:C,quantity:w,digest:t.string().regex(/^[a-f0-9]{64}$/)}),z=i=>{let[s,o=""]=i.split(".");return BigInt(s)*10n**12n+BigInt(o.padEnd(12,"0"))};function $(i){if(typeof i!="number"||!Number.isFinite(i)||i<0)throw new u("AI_PRICE_UNAVAILABLE","A published token price is missing");let s=String(i),o=s.includes("e")?i.toFixed(12).replace(/0+$/,"").replace(/\.$/,""):s;if(Number(o)!==i||!V.safeParse(o).success)throw new u("AI_PRICE_UNAVAILABLE","Published price exceeds the supported precision");return o}var R=t.strictObject({input:t.number().nonnegative(),output:t.number().nonnegative(),cache_read:t.number().nonnegative().optional(),cache_write:t.number().nonnegative().optional(),reasoning:t.number().nonnegative().optional(),input_audio:t.number().nonnegative().optional(),output_audio:t.number().nonnegative().optional()}),F=R.extend({context_over_200k:t.unknown().optional(),tiers:t.array(R.extend({tier:t.strictObject({type:t.literal("context"),size:t.number().int().nonnegative()})})).max(20).refine(i=>new Set(i.map(s=>s.tier.size)).size===i.length).optional()});async function N(i,s,o){let d=new TextEncoder().encode(JSON.stringify({pricing:i,tokens:s,quantity:o}));return[...new Uint8Array(await crypto.subtle.digest("SHA-256",d))].map(m=>m.toString(16).padStart(2,"0")).join("")}function B(i,s){let o=0n;for(let c of _){if(!s[c])continue;let f=i.rates[c];if(f===void 0)throw new u("AI_PRICE_UNAVAILABLE",`No published price for ${c}; report exclusive token pools`);o+=z(f)*BigInt(s[c])}let[d,m="0"]=String(i.markupPercent).split("e"),r=(d.split(".")[1]?.length??0)-Number(m),e=10n**BigInt(Math.max(r,0)),n=BigInt(d.replace(".",""))*10n**BigInt(Math.max(-r,0)),g=100n*e+n,l=100n*e*1000000n,a=(o*g+l-1n)/l;return w.parse(`${a/1000000n}.${(a%1000000n).toString().padStart(6,"0")}`)}function K(i={}){if(typeof window<"u")throw new u("SERVER_ONLY","AI token pricing belongs on your backend");let s=T.parse({defaultMarkup:i.defaultMarkup??0,providerMarkups:i.providerMarkups??{},modelMarkups:i.modelMarkups??{},customModels:i.customModels??{}}),o=null,d=0;async function m(){if(!o||Date.now()>=d){d=Date.now()+15*6e4;let r=(async()=>{let e=await(i.fetch??fetch)("https://models.dev/api.json",{signal:AbortSignal.timeout(3e4)});if(!e.ok)throw new u("AI_PRICE_UNAVAILABLE","Models.dev pricing is unavailable");return{data:t.record(t.string(),t.object({models:t.record(t.string(),t.unknown())})).parse(await e.json()),fetchedAt:new Date().toISOString()}})().catch(e=>{throw o===r&&(o=null),e});o=r}return o}return{refreshPrices(){o=null,d=0},async quoteTokens(r){let e=L.parse(r.modelId),n=C.parse(r.tokens),[g,...l]=e.split("/"),a=s.customModels[e],c,f,p,y=0;if(a?.input!==void 0&&a.output!==void 0&&_.every(A=>n[A]===0||a[A]!==void 0))c={...a,input:a.input,output:a.output},f="custom",p=new Date().toISOString();else{let A=await m(),x=A.data[g]?.models[l.join("/")];if(!x)throw new u("AI_PRICE_UNAVAILABLE","Unknown model; configure a complete custom price");let{cost:I}=t.object({cost:F}).parse(x),P=n.input+n.cache_read+n.cache_write+n.input_audio;if(I.tiers===void 0&&I.context_over_200k!==void 0&&P>2e5)throw new u("AI_PRICE_UNAVAILABLE","A current context tier is required for this model");let b=I.tiers?.filter(k=>P>k.tier.size).sort((k,Q)=>Q.tier.size-k.tier.size)[0],v=b??I;b&&(y=b.tier.size),c=Object.fromEntries(_.filter(k=>v[k]!==void 0).map(k=>[k,$(v[k])])),c={...c,...a},f=a?"custom":"models.dev",p=A.fetchedAt}let h=q.parse({modelId:e,source:f,fetchedAt:p,rates:c,contextTier:y,markupPercent:s.modelMarkups[e]??s.providerMarkups[g]??s.defaultMarkup}),S=B(h,n);return U.parse({pricing:h,tokens:n,quantity:S,digest:await N(h,n,S)})},async trackTokens(r,e){let n=U.parse(e.quote);if(n.quantity!==B(n.pricing,n.tokens)||n.digest!==await N(n.pricing,n.tokens,n.quantity))throw new u("INVALID_REQUEST","AI quote changed after pricing");let g=e.properties??{},l=e.providerCostUsd===void 0?void 0:t.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,18})?$/).parse(e.providerCostUsd),a=e.generationId===void 0?void 0:t.string().min(1).max(120).parse(e.generationId),c=8+ +(l!==void 0)+ +(a!==void 0);if(Object.keys(g).some(p=>p.startsWith("ai_")))throw new u("INVALID_REQUEST","AI tracking reserves ai_ event properties");if(Object.keys(g).length>16-c)throw new u("INVALID_REQUEST","AI tracking properties exceed the available event budget");let f={operation:"consume",internal_feature_id:e.internal_feature_id,quantity:n.quantity,idempotencyKey:e.idempotencyKey,properties:{...g,...l!==void 0?{ai_provider_cost_usd:l}:{},...a!==void 0?{ai_generation_id:a}:{},ai_model:n.pricing.modelId,ai_source:n.pricing.source,ai_price_at:n.pricing.fetchedAt,ai_quote_hash:n.digest,ai_markup:String(n.pricing.markupPercent),ai_tier:String(n.pricing.contextTier),ai_tokens:_.map(p=>n.tokens[p]).join(","),ai_rates:"v1:"+_.map(p=>n.pricing.rates[p]===void 0?"-":z(n.pricing.rates[p]).toString(36)).join(",")},...e.entityId?{entityId:e.entityId}:{}};return r.mutateBalance({customerId:e.customerId,command:f})}}}async function Y(i,s,o={}){let{config:d,model_markups:m}=await i.readAiPricing(s);return K({defaultMarkup:d.default_markup??0,providerMarkups:Object.fromEntries(Object.entries(d.provider_markups??{}).map(([r,e])=>[r,e.markup])),modelMarkups:Object.fromEntries(Object.entries(m??{}).filter(([,r])=>r.markup!==void 0).map(([r,e])=>[r,e.markup])),customModels:Object.fromEntries(Object.entries(m??{}).filter(([,r])=>r.input_cost!==void 0||r.output_cost!==void 0).map(([r,e])=>[r,{...e.input_cost!==void 0?{input:String(e.input_cost)}:{},...e.output_cost!==void 0?{output:String(e.output_cost)}:{}}])),...o})}export{q as a,U as b,K as c,Y as d};
@@ -0,0 +1 @@
1
+ import{a as z}from"./chunk-4K25DELJ.js";var W=new Set(["script","noscript","iframe","object","embed","base","link","meta","canvas","video","audio","source","track"]),M='[data-indiana-private],[data-private],input,textarea,select,[contenteditable]:not([contenteditable="false"])',R=/password|passwd|secret|token|authorization|api.?key|email|phone|ssn|card.?number/i,b=e=>e.replace(/\b([a-z][a-z0-9+.-]*:\/\/)[^\s/?#]*@/gi,"$1[redacted-credentials]@").replace(/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi,"[redacted]").replace(/\b(?:sk_(?:live|test)_\w{12,}|gh[pousr]_\w{16,}|eyJ[\w-]{8,}\.[\w-]{8,}\.[\w-]+)\b/g,"[redacted]").replace(/\bBearer\s+[\w.~+/=-]{12,}/gi,"[redacted]"),y=e=>/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}|\d{7,}|[a-f0-9]{32,}/i.test(e)||b(e)!==e;function O(e,i){let r=e;for(let s=0;r&&s<=80;s++){if(r.closest(i))return!0;let n=r.getRootNode();if(!("host"in n))return!1;r=n.host}return!0}function D(e,i){return!!(O(e,[M,...i.blockedSelectors].join(","))||e.matches("input,textarea,select")&&R.test(e.getAttribute("name")||e.id))}function K(e,i,r){return!i||D(i,r)||!r.publicSelectors.some(s=>i.closest(s))?e.replace(/\S/g,"\u2022"):b(e)}function Z(e,i){let r={};for(let s of e.getAttributeNames()){let n=s.toLowerCase(),a=e.getAttribute(s);if(a!==null&&/^(?:class|id|role|type|dir|lang|hidden|open|disabled|checked|width|height|viewbox|preserveaspectratio|transform|opacity|fill-opacity|stroke-opacity|stroke-dasharray|stroke-dashoffset|stroke-miterlimit|clip-path|gradientunits|gradienttransform|spreadmethod|offset|stop-color|stop-opacity|fx|fy|fr|d|fill|fill-rule|clip-rule|stroke|stroke-width|stroke-linecap|stroke-linejoin|cx|cy|r|rx|ry|x|y|x1|x2|y1|y2|points|data-indiana-id|data-indiana-public|data-indiana-private|data-(?:state|side|align|orientation|disabled|highlighted|slot|variant|size)|aria-(?:hidden|expanded|selected|checked|disabled|modal|busy|invalid|required))$/.test(n)&&!(b(a)!==a||R.test(a)&&n==="id")){if(/(?:[a-z][a-z0-9+.-]*:\/\/|\b(?:data|blob):|url\s*\()/i.test(a)){let t=/^(?:fill|stroke|clip-path)$/.test(n)&&/^url\(\s*["']?#([\w:-]{1,160})["']?\s*\)$/i.exec(a);t&&t[1]!==void 0&&!y(t[1])&&(r[n]=a);continue}{if(n==="data-indiana-id"&&!i?.sourceAnchors.includes(a)||n==="id"&&(y(a)||!/^[\w:-]{1,160}$/.test(a)))continue;if(n==="class"){let t=a.split(/\s+/).filter(d=>d&&!y(d));t.length&&(r[n]=t.join(" "));continue}}if(n==="data-indiana-public"||n==="data-indiana-private"){r[n]="";continue}if(/^data-(?:slot|variant|size)$/.test(n)){/^[a-z][a-z0-9-]{0,63}$/.test(a)&&!y(a)&&(r[n]=a);continue}n.startsWith("data-")&&n!=="data-indiana-id"&&!/^(?:open|closed|checked|unchecked|on|off|active|inactive|top|bottom|left|right|start|center|end|horizontal|vertical|true|false|)$/.test(a)||(r[n]=a)}}return e.hasAttribute("style")&&(r.style=e.getAttribute("style")||""),e.tagName==="INPUT"&&["checkbox","radio"].includes(e.type)&&(e.checked?r.checked="":delete r.checked),e.tagName==="DIALOG"&&e.open&&(r.open=""),r}function V(e){let i=new Map,r=new Map,s=0,n=0,a=0;for(let t of e){if(i.has(t.id)||Object.keys(t.attributes).length>40)throw Error("Invalid capture tree");if(t.parentId===null){if(++s>1||t.kind!=="element"||t.tag!=="html")throw Error("Invalid capture root");i.set(t.id,0)}else{let d=i.get(t.parentId),u=r.get(t.parentId);if(d===void 0||d>=80||u?.kind!=="element")throw Error("Invalid capture depth");i.set(t.id,d+1)}if(t.shadow&&(t.parentId===null||t.tag==="html"||t.tag==="body"||t.tag==="head"))throw Error("Invalid shadow root");if(t.tag==="html"&&t.parentId!==null)throw Error("Nested document");if((t.tag==="head"||t.tag==="body")&&(r.get(t.parentId)?.tag!=="html"||(t.tag==="head"?++n:++a)>1))throw Error("Invalid document structure");if(t.kind==="element"&&(!t.tag||t.text!==null)||t.kind==="text"&&(t.tag!==null||t.text===null||Object.keys(t.attributes).length))throw Error("Invalid capture node");r.set(t.id,t)}if(s!==1||a!==1)throw Error("Missing capture root/body")}import{array as f,boolean as B,discriminatedUnion as N,enum as U,literal as l,number as c,record as j,string as p,url as $,uuid as g}from"zod";import{refine as P,strictObject as o}from"zod/mini";function Q(e,i,r){try{let s=new URL(i).origin,n=new URL(e,i);if(n.origin!==s||n.username||n.password||n.hash)return null;if(!n.search)return r.includes(n.pathname)?n.pathname:null;if(n.pathname!=="/_next/image")return null;let a=[...n.searchParams];if(a.length!==3||new Set(a.map(([x])=>x)).size!==3||a.some(([x])=>!["url","w","q"].includes(x)))return null;let t=n.searchParams.get("w"),d=n.searchParams.get("q");if(!/^[1-9]\d{0,4}$/.test(t)||Number(t)>8192||!/^[1-9]\d?$|^100$/.test(d))return null;let u=n.searchParams.get("url");if(!u.startsWith("/")||u.startsWith("//")||u.includes("\\")||/[\u0000-\u0020]/.test(u))return null;let m=new URL(u,s);return m.origin!==s||m.search||m.hash||m.pathname==="/_next/image"?null:r.includes(m.pathname)?m.pathname:null}catch{return null}}var h=p().regex(/^[a-f0-9]{64}$/),v=p().min(1).max(256),q=p().regex(/^[\p{L}\p{N} _.-]{1,64}$/u).refine(e=>b(e)===e&&!y(e),"Use a public state label");var S=Object.freeze({maxNodes:5e3,maxDepth:80,maxAttributes:40,maxText:4096,maxBytes:2097152,maxCssBytes:524288,maxStyleSheets:256,maxCssRules:5e3,sliceMs:1,maxSliceMs:8,deadlineMs:3e3,quietMs:300,minIntervalMs:1e3,maxSnapshots:10,urgentIntervalMs:250,maxBufferedSnapshots:2}),F=o({pageKey:v,path:p().startsWith("/").max(2048)}),w=p().regex(/^(?:#[A-Za-z][\w-]{0,80}|\.[A-Za-z][\w-]{0,80}|\[data-indiana-(?:public|private)\])$/),L=o({environmentId:g(),privacy:l("masked-default-v2"),sourceAnchors:f(p().min(1).max(256)).max(1e3).default([]),sourceVersionId:g(),manifestDigest:h,origin:$(),routes:f(F).min(1).max(200),publicSelectors:f(w).max(8),blockedSelectors:f(w).max(8),assetPaths:f(p().startsWith("/").max(2048)).max(128)}),re=o({policy:L.check(P(e=>e.privacy==="masked-default-v2"&&!!e.environmentId)),expiresAt:c().int().positive(),serverTime:c().int().positive(),progress:o({sequence:c().int().min(0).max(10),lastContentHash:h.nullable(),readyCount:c().int().min(0).max(10)}).check(P(e=>e.readyCount<=e.sequence))}),ae=N("ready",[o({versionId:g(),ready:l(!0),upload:l(null)}),o({versionId:g(),ready:l(!1),upload:o({mode:l("proxy")})})]),ie=o({versionId:g(),ready:l(!0)}),H=o({id:c().int().nonnegative().max(5e3),parentId:c().int().nonnegative().max(5e3).nullable(),kind:U(["element","text"]),tag:p().regex(/^[a-z][a-z0-9-]*$/).max(64).nullable(),text:p().max(4096).nullable(),attributes:j(p().max(100),p().max(4096)),shadow:B()}),J=o({nodes:f(H).min(1).max(S.maxNodes),css:p().max(S.maxCssBytes),shadowCss:f(o({hostId:c().int().nonnegative().max(5e3),css:p().max(S.maxCssBytes)})).max(128),scroll:o({x:c().finite().nonnegative().max(1e7),y:c().finite().nonnegative().max(1e7)})}),oe=o({format:l("indiana-runtime-snapshot"),schemaVersion:l(1),collector:o({name:l("indiana-bounded-dom"),version:l(2),buildSha256:h.optional()}),sourceVersionId:g(),manifestDigest:h,pageKey:v,routeTemplate:p().startsWith("/").max(2048),sequence:c().int().min(1).max(10),label:q,viewport:o({width:c().int().min(100).max(8192),height:c().int().min(100).max(8192),dpr:c().finite().min(.1).max(10)}),privacy:l("masked-default-v2"),contentHash:h,previousContentHash:h.nullable(),document:J,gaps:f(p().regex(/^[A-Z_]{1,80}$/)).max(32),metrics:o({maxSliceMs:c().finite().nonnegative(),totalWorkMs:c().finite().nonnegative(),elapsedMs:c().finite().nonnegative()})});function se(e){let{sourceVersionId:i,manifestDigest:r,pageKey:s,viewport:n,document:a,privacy:t}=e;return{sourceVersionId:i,manifestDigest:r,pageKey:s,viewport:n,document:a,privacy:t}}function E(e){if(e===null||typeof e=="boolean")return JSON.stringify(e);if(typeof e=="string"){if(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(e))throw Error("Invalid Unicode");return JSON.stringify(e)}if(typeof e=="number"&&Number.isFinite(e))return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(E).join(",")+"]";if(e&&typeof e=="object"&&Object.getPrototypeOf(e)===Object.prototype)return"{"+Object.keys(e).sort().map(i=>JSON.stringify(i)+":"+E(e[i])).join(",")+"}";throw Error("Invalid capture JSON")}function ce(e,i){let r=i.replace(/\/$/,"").split("/").filter(Boolean),s=[];for(let t of e){let d=t.path.replace(/\/$/,"").split("/").filter(Boolean),u=[],m=0,x=!0;for(let[_,k]of d.entries()){let I=/^\[\[\.\.\.[^\[\]]+\]\]$/.test(k),T=I||/^\[\.\.\.[^\[\]]+\]$/.test(k),A=/^\[[^\[\]]+\]$/.test(k);if(T){(_!==d.length-1||!I&&m===r.length)&&(x=!1),m=r.length,u.push(I?0:1);break}let C=r[m++];if(C===void 0){x=!1;break}try{!A&&decodeURIComponent(k)!==decodeURIComponent(C)&&(x=!1),decodeURIComponent(C)}catch{x=!1}u.push(A?2:3)}x&&m===r.length&&s.push({route:t,rank:u})}s.sort((t,d)=>{for(let u=0;u<Math.max(t.rank.length,d.rank.length);u++){let m=(d.rank[u]??4)-(t.rank[u]??4);if(m)return m}return 0});let[n,a]=s;if(n&&a&&JSON.stringify(n.rank)===JSON.stringify(a.rank))throw Error("Ambiguous capture route");return n?.route??null}var ue=N("action",[o({action:l("authorize")}),o({action:l("policy")}),o({action:l("register"),requestId:g(),sha256:h,bytes:c().int().min(1).max(S.maxBytes),pageKey:v,sequence:c().int().min(1).max(10),contentHash:h}),o({action:l("complete"),versionId:g()})]),le=o({action:l("capture-grant"),versionId:g(),origin:$().refine(z,"Capture requires HTTPS or loopback HTTP"),routeKeys:f(v).min(1).max(20),publicSelectors:f(w).max(8),blockedSelectors:f(w).max(8)}),pe=o({versionId:g(),sha256:h,contentHash:h});export{Q as a,W as b,b as c,y as d,O as e,D as f,K as g,Z as h,V as i,q as j,S as k,re as l,ae as m,ie as n,se as o,E as p,ce as q,pe as r};
@@ -0,0 +1 @@
1
+ import{a as k,b as L,c as O}from"./chunk-4K25DELJ.js";function N(r){let e=r.document,o=/^zh\b/i.test(e.documentElement.lang),t=e.createElement("div"),v=t.attachShadow({mode:"open"}),h=e.createElement("style");t.setAttribute("data-indiana-private",""),t.setAttribute("data-indiana-capture-controls",""),t.setAttribute("aria-live","off");let b=typeof t.showPopover=="function";b&&t.setAttribute("popover","manual"),t.hidden=!0,r.nonce&&(h.nonce=r.nonce),h.textContent=":host{all:initial!important;position:fixed!important;margin:0!important;inset:auto!important;right:12px!important;bottom:12px!important;z-index:2147483647!important;display:block!important;width:340px!important;max-width:calc(100vw - 24px)!important;color:#17202d!important;font:13px/1.4 system-ui,sans-serif!important;color-scheme:light!important}:host([hidden]){display:none!important}*{box-sizing:border-box}.panel{background:white;border:1px solid #98a4b4;border-radius:2px;padding:12px;box-shadow:0 2px 10px #17202d20}.top,.actions{display:flex;align-items:center;gap:8px}.top{justify-content:space-between}strong{font-weight:600}small{font-size:12px;font-variant-numeric:tabular-nums}.message{margin:6px 0;color:#465467;overflow-wrap:anywhere}.actions{justify-content:flex-end}button{font:inherit;min-height:40px;border:1px solid #98a4b4;border-radius:2px;padding:6px 12px;background:white;color:#17202d;cursor:pointer}button:focus-visible{outline:2px solid #155eef;outline-offset:2px}button:disabled{cursor:default;color:#5b6778;background:#f2f4f7}button.primary:enabled{background:#155eef;border-color:#155eef;color:white}@media(forced-colors:active){.panel,button{border:1px solid CanvasText}button:focus-visible{outline:2px solid Highlight}}";let l=e.createElement("section"),u=e.createElement("div"),f=e.createElement("strong"),I=e.createElement("small"),g=e.createElement("p"),R=e.createElement("div"),d=e.createElement("button"),A=e.createElement("button");if(l.className="panel",u.className="top",R.className="actions",l.setAttribute("aria-label",o?"Indiana \u9875\u9762\u91C7\u96C6":"Indiana page capture"),l.setAttribute("role","region"),f.textContent=o?"Indiana \u9875\u9762\u91C7\u96C6":"Indiana page capture",g.className="message",g.setAttribute("role","status"),d.type=A.type="button",d.className="primary",d.textContent=o?"\u91CD\u8BD5\u91C7\u96C6":"Retry capture",u.append(f,I),R.append(d,A),l.append(u,g,R),v.append(h,l),(e.body??e.documentElement).append(t),!h.sheet)throw t.remove(),Object.assign(Error("Authoring controls blocked by style policy"),{code:"AUTHORING_CONTROLS_BLOCKED"});t.hidden=!1;let a={state:"connecting",snapshots:0},E=!1,w,p;function y(c=e.activeElement){if(E||c===t||c&&t.contains(c))return;let i,m=c;for(let S=0;m&&S<80;S++,m=m.parentElement)if(m.matches('dialog[open],[role="dialog"],[role="alertdialog"],[role="menu"],[role="listbox"]')&&m.getAttribute("aria-hidden")!=="true"){i=m;break}w=i;let x=i??e.body??e.documentElement;if(t.parentElement!==x&&x.append(t),t.removeAttribute("aria-hidden"),b)try{t.showPopover()}catch{}}let C=c=>{c.target instanceof e.defaultView.Element&&y(c.target)},_=c=>{c.target===w&&y(e.body)};e.addEventListener("focusin",C,!0),e.addEventListener("close",_,!0);let n={connecting:["\u6B63\u5728\u8FDE\u63A5\u91C7\u96C6\u670D\u52A1\u2026","Connecting to capture service\u2026"],authorized:["\u91C7\u96C6\u6388\u6743\u5DF2\u786E\u8BA4\uFF0C\u6B63\u5728\u52A0\u8F7D\u2026","Capture authorized; loading\u2026"],idle:["\u9875\u9762\u7A33\u5B9A\u540E\u81EA\u52A8\u91C7\u96C6\uFF0C\u8F93\u5165\u6587\u672C\u4F1A\u906E\u853D\u3002","Stable page states are captured automatically. Input text is masked."],capturing:["\u6B63\u5728\u91C7\u96C6\u9875\u9762\u7ED3\u6784\u2026","Capturing page structure\u2026"],uploading:["\u6B63\u5728\u4FDD\u5B58\u8131\u654F\u5FEB\u7167\u2026","Saving a masked snapshot\u2026"],waiting:["\u4E0A\u4F20\u5904\u7406\u4E2D\uFF0C\u540E\u7EED\u53D8\u5316\u5DF2\u5408\u5E76\u7B49\u5F85\u3002","Upload in progress; later changes are coalesced."],paused:["\u91C7\u96C6\u5DF2\u6682\u505C\u3002\u68C0\u67E5\u9875\u9762\u6216\u8FDE\u63A5\u540E\uFF0C\u53EF\u624B\u52A8\u91CD\u8BD5\u3002","Capture paused. Check the page or connection, then retry."],stopped:["\u91C7\u96C6\u5DF2\u505C\u6B62\u3002\u5237\u65B0\u9875\u9762\u540E\u6062\u590D\u666E\u901A\u8BBF\u95EE\u3002","Capture stopped. Reload the page to resume ordinary delivery."]};function s(){if(E)return;if(t.isConnected||w&&!w.isConnected&&y(),!t.isConnected){E=!0,clearInterval(p),e.removeEventListener("focusin",C,!0),e.removeEventListener("close",_,!0),r.stop();return}let c=Number.isInteger(a.snapshots)?Math.min(10,Math.max(0,a.snapshots)):0,i=a.expiresAt&&Number.isFinite(a.expiresAt)?Math.max(0,Math.ceil((a.expiresAt-Date.now())/1e3)):null;I.textContent=(o?`\u5DF2\u4FDD\u5B58 ${c} \u4EFD`:`${c} saved`)+(i===null?"":` \xB7 ${Math.floor(i/60)}:${String(i%60).padStart(2,"0")}`);let m=n[a.state]??n.paused;a.state==="paused"&&/(?:429|QUOTA)/.test(a.reason??"")&&(m=["\u5DF2\u8FBE\u5230\u91C7\u96C6\u914D\u989D\uFF0C\u8BF7\u8FD4\u56DE\u63A7\u5236\u53F0\u67E5\u770B\u3002","Capture quota reached. Check the Console before retrying."]),a.state==="paused"&&a.reason==="OFFLINE"&&(m=["\u7F51\u7EDC\u5DF2\u65AD\u5F00\u3002\u6062\u590D\u8FDE\u63A5\u540E\uFF0C\u8BF7\u624B\u52A8\u91CD\u8BD5\u3002","You are offline. Reconnect, then retry explicitly."]),a.state==="paused"&&/(?:SLICE|ENCODING|NODE|BYTE|TEXT|ATTRIBUTE|CSS|DEADLINE)/.test(a.reason??"")&&(m=["\u9875\u9762\u8D85\u51FA\u91C7\u96C6\u9884\u7B97\u3002\u7F29\u5C0F\u9875\u9762\u72B6\u6001\u540E\u518D\u8BD5\u3002","This page exceeds the capture budget. Reduce the page state before retrying."]),a.state==="stopped"&&a.reason==="QUOTA"&&(m=["\u672C\u6B21\u6388\u6743\u6B21\u6570\u5DF2\u7528\u5B8C\u3002\u8BF7\u8FD4\u56DE\u63A7\u5236\u53F0\u91CD\u65B0\u6388\u6743\u3002","This grant is exhausted. Request another grant from the Console."]),a.state==="stopped"&&/EXPIRED|REVOKED/.test(a.reason??"")&&(m=["\u91C7\u96C6\u6388\u6743\u5DF2\u5931\u6548\u3002\u8BF7\u8FD4\u56DE\u63A7\u5236\u53F0\u91CD\u65B0\u6388\u6743\u3002","Capture authority has expired or changed. Return to the Console."]),a.state==="stopped"&&a.reason==="CAPTURE_UPGRADE_REQUIRED"&&(m=["\u91C7\u96C6\u7248\u672C\u4E0D\u5339\u914D\uFF0C\u8BF7\u5237\u65B0\u9875\u9762\u6216\u66F4\u65B0 SDK \u540E\u91CD\u65B0\u6388\u6743\u3002","Capture versions differ. Reload or update the SDK, then request another grant."]),g.textContent!==m[o?0:1]&&(g.textContent=m[o?0:1]),d.disabled=a.state!=="paused"||i===0,A.textContent=a.state==="stopped"?o?"\u5173\u95ED":"Close":o?"\u505C\u6B62\u91C7\u96C6":"Stop capture"}for(let c of["click","pointerdown","pointerup","keydown","keyup"])v.addEventListener(c,i=>i.stopPropagation());return d.onclick=()=>{d.disabled||r.retry()},A.onclick=()=>{a.state==="stopped"?r.close():r.stop()},y(),s(),{update(c){E||(a=c,p&&clearInterval(p),p=void 0,a.state!=="stopped"&&a.expiresAt&&Number.isFinite(a.expiresAt)&&(p=setInterval(s,1e3)),s())},destroy(){E||(E=!0,clearInterval(p),e.removeEventListener("focusin",C,!0),e.removeEventListener("close",_,!0),t.remove())},get active(){return!E&&t.isConnected}}}function U(r){let e=r.document??document,o=e.defaultView;if(!o)return{destroy(){},checkpoint(n){},retry(){}};let t="indiana:iam:authoring:v2:"+new URL(r.baseUrl).origin+":"+r.environmentId;function v(n){if(n.length>12e3||!/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(n))return!1;try{let s=JSON.parse(o.atob(n.split(".")[0].replaceAll("-","+").replaceAll("_","/")));return k(o.location.origin)&&typeof s=="object"&&s!==null&&"version"in s&&"environmentId"in s&&"origin"in s&&s.version===2&&s.environmentId===r.environmentId&&s.origin===o.location.origin}catch{return!1}}let h=!1,b=!1,l=0,u=!1,f="",I,g,R=0,d,A=()=>{try{o.sessionStorage.removeItem(t)}catch{}},a=n=>{if(b!==n){b=n;try{r.onAuthoringChange?.(n)}catch{}}},E=n=>{R=n.snapshots,g?.update(n);try{r.onStatus?.(n)}catch{}e.dispatchEvent(new o.CustomEvent("indiana:iam:status",{detail:n}))};function w(){h||(l++,I?.abort(),d?.destroy("USER_STOPPED"),d=void 0,u=!1,A(),f="",a(!1),e.removeEventListener("indiana:iam:checkpoint",p),E({state:"stopped",reason:"USER_STOPPED",snapshots:R}))}let p=n=>{let s=n instanceof o.CustomEvent?n.detail:void 0,c=s&&typeof s=="object"&&"label"in s?s.label:void 0;if(typeof c=="string"&&/^[\p{L}\p{N} _.-]{1,64}$/u.test(c))try{d?d.checkpoint(c):f&&!u&&C(f)}catch{}};function y(){let n=new URLSearchParams(o.location.hash.slice(1)),s=n.get("indiana-capture");if(!s)return null;v(s)&&a(!0),n.delete("indiana-capture");let c=new URL(o.location.href);return c.hash=n.toString(),o.history.replaceState(o.history.state,"",c),/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(s)&&s.length<=12e3?s:null}function C(n){if(h||!v(n))return;let s=++l;I?.abort(),I=new AbortController;let c=I.signal;d?.destroy("REPLACED"),d=void 0,f=n,u=!0,a(!0),e.addEventListener("indiana:iam:checkpoint",p);try{o.sessionStorage.setItem(t,n)}catch{}(async()=>{if(r.controls!==!1&&!g?.active&&(g?.destroy(),g=N({document:e,nonce:r.nonce,retry(){d?d.retry():f&&!u&&C(f)},stop:w,close(){g?.destroy(),g=void 0}})),g?.update({state:"connecting",snapshots:0}),!o.navigator.onLine)throw Object.assign(Error("Capture offline"),{code:"OFFLINE"});if(await r.prepare?.(),h||s!==l)return;let i=await fetch(new URL("/api/app-manifest-captures",r.baseUrl),{method:"POST",credentials:"omit",redirect:"error",cache:"no-store",headers:{Authorization:"Bearer "+n,[L]:O,"Content-Type":"application/json"},body:JSON.stringify({action:"authorize"}),signal:AbortSignal.any([c,AbortSignal.timeout(3e4)])});if(i.status!==204||i.headers.get(L)!==O)throw i.body?.cancel().catch(()=>{}),Object.assign(new Error("Capture authorization refused"),{code:i.ok?i.status===204?"CAPTURE_VERSION_MISMATCH":"SERVICE_RESPONSE_INVALID":"AUTH_OR_SERVICE_"+i.status});if(h||s!==l)return;E({state:"authorized",snapshots:0});let{startCapture:m}=await import("./client-OYRHOMUQ.js");if(h||s!==l)return;let x=await m({environmentId:r.environmentId,grant:n,baseUrl:r.baseUrl,document:e,signal:c,onStatus(S){h||s!==l||(S.state==="stopped"&&(A(),f="",a(!1),e.removeEventListener("indiana:iam:checkpoint",p)),E(S))}});if(h||s!==l){x.destroy("REPLACED");return}d=x,e.addEventListener("indiana:iam:checkpoint",p)})().catch(i=>{if(!h&&s===l){let m=i instanceof Error&&["TypeError","TimeoutError"].includes(i.name)||i&&typeof i=="object"&&"code"in i&&/^(?:AUTH_OR_SERVICE_(?:408|429|5\d\d)|SERVICE_RESPONSE_INVALID|OFFLINE)$/.test(String(i.code));m||(A(),f="",a(!1),e.removeEventListener("indiana:iam:checkpoint",p));let x=i&&typeof i=="object"&&"code"in i?String(i.code):"",S={state:m?"paused":"stopped",reason:["CAPTURE_VERSION_MISMATCH","AUTH_OR_SERVICE_426"].includes(x)?"CAPTURE_UPGRADE_REQUIRED":x==="OFFLINE"?"OFFLINE":i&&typeof i=="object"&&"code"in i&&i.code==="AUTHORING_CONTROLS_BLOCKED"?"AUTHORING_CONTROLS_BLOCKED":m?"SERVICE_UNAVAILABLE":"AUTH_OR_SERVICE_UNAVAILABLE",snapshots:0};E(S)}}).finally(()=>{s===l&&(u=!1)})}let _=()=>{let n=y();n&&C(n)};o.addEventListener("hashchange",_);try{let n=y()??o.sessionStorage.getItem(t);n&&C(n)}catch{}return{destroy(){h=!0,l++,I?.abort(),d?.destroy(),g?.destroy(),g=void 0,o.removeEventListener("hashchange",_),e.removeEventListener("indiana:iam:checkpoint",p),A(),f="",a(!1)},checkpoint(n){d?d.checkpoint(n):f&&!u&&C(f)},retry(){d?d.retry():f&&!u&&C(f)}}}async function D(r,e,o){let t=new URL(r,e.baseURI),v=e.defaultView?.location.origin,h=/^\/\.well-known\/indiana\/releases\/([a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12})\.json$/.exec(t.pathname)?.[1];if(!h||t.origin!==v||t.search||t.hash||t.username||t.password)throw Error("Invalid IAM release URL");let b=AbortSignal.any([o,AbortSignal.timeout(2e3)]),l=await fetch(t,{credentials:"omit",redirect:"error",cache:"force-cache",signal:b}),u=l.headers.get("content-length");if(!l.ok||!/^application\/json(?:;|$)/i.test(l.headers.get("content-type")??"")||u!==null&&(!/^\d+$/.test(u)||Number(u)>512))throw l.body?.cancel().catch(()=>{}),Error("IAM release is unavailable");let f=l.body?.getReader();if(!f)throw Error("IAM release is unavailable");let I=[],g=0,R=()=>{},d=new Promise((y,C)=>{R=()=>C(Error("IAM release timeout")),b.addEventListener("abort",R,{once:!0}),b.aborted&&R()}),A=!1;try{for(;;){let y=await Promise.race([f.read(),d]);if(y.done){A=!0;break}if(g+=y.value.length,g>512)throw Error("IAM release budget");I.push(y.value)}}finally{b.removeEventListener("abort",R),A||f.cancel().catch(()=>{}),f.releaseLock()}let a=new Uint8Array(g),E=0;for(let y of I)a.set(y,E),E+=y.length;let w=new TextDecoder("utf-8",{fatal:!0}).decode(a),p=JSON.parse(w);if(w.trim()!==JSON.stringify(p))throw Error("Noncanonical IAM release descriptor");if(!p||typeof p!="object"||Array.isArray(p)||Object.keys(p).sort().join(",")!=="format,manifestDigest,releaseId,schemaVersion"||Reflect.get(p,"format")!=="indiana-app-manifest-release"||Reflect.get(p,"schemaVersion")!==2||Reflect.get(p,"releaseId")!==h||!/^[a-f0-9]{64}$/.test(String(Reflect.get(p,"manifestDigest"))))throw Error("Invalid IAM release descriptor");return Reflect.get(p,"manifestDigest")}var T=new WeakMap;function F(r,e=document){if(!/^[a-f0-9]{64}$/.test(r))throw new Error("Invalid IAM manifest digest");let o=T.get(e);o||(o=new Map,T.set(e,o));let t="data-indiana-release",v=e.documentElement,h=()=>new Set((v.getAttribute(t)??"").split(/\s+/).filter(Boolean)),b=o.get(r);if(!b){let u=h();b={count:0,owned:!u.has(r)},o.set(r,b),u.add(r),v.setAttribute(t,[...u].join(" "))}b.count++;let l=!1;return{attributes:{indianaAppManifestRelease:r},destroy(){if(!l&&(l=!0,b.count--,!b.count&&(o.delete(r),b.owned))){let u=h();u.delete(r),u.size?v.setAttribute(t,[...u].join(" ")):v.removeAttribute(t)}}}}async function $(r){return(await import("./client-OYRHOMUQ.js")).startCapture(r)}export{U as a,D as b,F as c,$ as d};
@@ -0,0 +1 @@
1
+ import{a as we}from"./chunk-FVUPV6YE.js";import{$k as Ke,Bf as Ue,Ei as Ee,Ek as H,Fi as ke,Fk as je,Gd as Le,Jk as Pe,Kk as M,Lk as Je,Mk as Be,Nk as ze,Oi as Se,Ok as He,Pi as qe,Rh as be,Vf as ce,al as $e,bl as Qe,cl as Ye,hk as Ge,ui as te,xf as Ve,yf as Me}from"./chunk-FF3LWJ26.js";import{a as d}from"./chunk-5TEZEOHX.js";import{a as Ae}from"./chunk-S5TVMQRC.js";import{b as _e,h as ge}from"./chunk-ISUXYPYL.js";import{f as De,j as xe,m as Ne}from"./chunk-S2MSIA57.js";function yn(e){let n=null,i=null,t=0,m=0,y=new Set,o=null,u=null,r=new Set,s=()=>{for(let I of r)try{I()}catch{}},g={attributes:Ne.parse(e.attributes??{}),onFeatureUsage:e.onFeatureUsage?(I,P)=>{!y.has(I)&&(!n||!("analyticsConfig"in n)||n.analyticsConfig.featureUsageEnabled)&&e.onFeatureUsage(I,structuredClone(P))}:void 0,onExperimentViewed:e.onExperimentViewed?(I,P)=>(!n||!("analyticsConfig"in n)||n.analyticsConfig.experimentViewsEnabled)&&e.onExperimentViewed(structuredClone(I),structuredClone(P)):void 0,stickyBucketAssignmentDocs:structuredClone(e.stickyBucketAssignmentDocs),saveStickyBucketAssignmentDoc:e.saveStickyBucketAssignmentDoc?I=>e.saveStickyBucketAssignmentDoc(structuredClone(I)):void 0,trackedFeatureUsage:{},trackedExperiments:new Set},w=()=>({value:null,source:"unknownFeature",on:!1,off:!0,ruleId:""});function v(I,P=new Set){return y.has(I)?!o||!o.features[I]||["unknownFeature","cyclicPrerequisite"].includes(o.features[I].source):P.has(I)?!1:(P.add(I),(n?.features[I]?.rules??[]).some(F=>[...F.parentConditions??[],...(F.tracks??[]).flatMap(D=>D.experiment.parentConditions??[])].some(D=>v(D.id,P))))}let A=I=>{if(e.assertUsable?.(n?.generation),!n)throw new Error("Initialize the Feature client before evaluation");if(n.expiresAt&&Date.parse(n.expiresAt)<=Date.now())throw new Error("Feature configuration expired; refresh before evaluation");return o?.expiresAt&&Date.parse(o.expiresAt)<=Date.now()&&(o=null,g.features=n.features),y.has(I)?!o||o.expiresAt&&Date.parse(o.expiresAt)<=Date.now()?w():structuredClone(o.features[I]??w()):v(I)?w():structuredClone(xe(I,g))};async function E(){if(!n||!y.size)return;if(!e.evaluateRemote)throw new Error("Remote Feature evaluation requires a server loader");let I=m;if(u?.revision===I)return u.loading;let P=t,F=n,D=[...y],T=(async()=>{let _=Ue.parse(await e.evaluateRemote({attributes:structuredClone(g.attributes),features:D}));if(!(P!==t||I!==m||F!==n)){if(e.assertUsable?.(F.generation),_.generation!==F.generation)throw new Error("Feature configuration changed; refresh before evaluation");if(D.some(U=>!Object.hasOwn(_.features,U))||Object.keys(_.features).some(U=>!y.has(U)))throw new Error("Invalid remote Feature results");o=structuredClone(_),g.features={...F.features,...Object.fromEntries(Object.entries(o.features).map(([U,j])=>[U,{defaultValue:j.value}]))},s()}})();u={revision:I,loading:T};try{await T}finally{u?.loading===T&&(u=null)}}function S(){E().catch(I=>{try{e.onError?.(I)}catch{}})}async function V(){if(i)return i;let I=t,P=(async()=>{let F=await e.load(),D="remoteFeatures"in F?Ve.parse(F):null,T=D??ge.parse(F);if(T.scope.projectId!==e.scope.projectId||T.scope.environment!==e.scope.environment)throw new Error("Feature payload scope changed");if(I!==t)throw new Error("Feature client was reset");if(e.assertUsable&&n?.generation===T.generation){let{evaluatedAt:U,expiresAt:j,...oe}=n,{evaluatedAt:X,expiresAt:ee,...l}=T;if(M(oe)!==M(l))throw new Error("Immutable Feature generation changed content");return n.evaluatedAt=T.evaluatedAt,n.expiresAt=T.expiresAt,s(),(!o||o.expiresAt&&Date.parse(o.expiresAt)<=Date.now())&&S(),structuredClone(n)}let _=new Set(D?.remoteFeatures??[]);if([..._].some(U=>Object.hasOwn(T.features,U)))throw new Error("Remote Feature definitions must not be delivered locally");return n&&"analyticsConfig"in n&&"analyticsConfig"in T&&!n.analyticsConfig.experimentViewsEnabled&&D?.analyticsConfig.experimentViewsEnabled&&g.trackedExperiments?.clear(),n=structuredClone(T),y=_,o=null,u=null,m++,g.features=n.features,g.savedGroups=De(n.savedGroups),g.trackedFeatureUsage={},s(),S(),structuredClone(n)})();i=P;try{return await P}finally{i===P&&(i=null)}}return{init:V,refresh:V,refreshRemote:E,get generation(){return n?.generation??null},get expiresAt(){return n?.expiresAt??null},subscribe(I){return r.add(I),()=>{r.delete(I)}},setAttributes(I){g.attributes=Ne.parse(I),m++,o=null,u=null,g.features=n?.features??{},g.trackedFeatureUsage={},s(),S()},evalFeature:A,isOn(I){return A(I).on},isOff(I){return A(I).off},getFeatureValue(I,P){let F=A(I).value;return structuredClone(F===null?P:F)},reset(){t++,m++,i=null,u=null,n=null,o=null,y.clear(),g.features={},g.savedGroups={},g.stickyBucketAssignmentDocs={},g.attributes={},g.trackedFeatureUsage={},g.trackedExperiments?.clear(),s()}}}function Ze(e){let n,i,t=()=>new d("COMMAND_STORAGE_INVALID","Durable command storage is unavailable"),m=Promise.resolve().then(async()=>{if(n=e.storage??globalThis.localStorage,i=e.locks??globalThis.navigator?.locks,!n||!i||!globalThis.crypto?.subtle)throw t();let u=new TextEncoder().encode(JSON.stringify([new URL(e.baseUrl??Ae).href,e.runToken])),r=new Uint8Array(await crypto.subtle.digest("SHA-256",u));return"indiana.funnel.commands.v1."+Array.from(r,s=>s.toString(16).padStart(2,"0")).join("")});m.catch(()=>{});async function y(u){try{let r=await m;return await i.request(r,{mode:"exclusive"},()=>u(r))}catch(r){throw r instanceof d?r:t()}}function o(u){let r=n.getItem(u);if(r===null)return{revision:0,entry:null};if(r.length>1048576)throw t();let s=JSON.parse(r);if(!s||typeof s!="object"||!("revision"in s)||!("entry"in s)||!Number.isSafeInteger(s.revision)||Number(s.revision)<0)throw t();return{revision:Number(s.revision),entry:s.entry}}return{read:()=>y(o),write:(u,r)=>y(s=>{if(o(s).revision!==u)return null;if(!Number.isSafeInteger(u+1))throw t();return n.setItem(s,JSON.stringify({revision:u+1,entry:r})),u+1})}}function Rn(e,n){return n.type==="id"?e.customerId===n.value:e.externalUserId===n.value}function ye(e,n){if(e===n)return!0;if(Array.isArray(e)||Array.isArray(n))return Array.isArray(e)&&Array.isArray(n)&&e.length===n.length&&e.every((m,y)=>ye(m,n[y]));if(!e||!n||typeof e!="object"||typeof n!="object")return!1;let i=Object.entries(e),t=Object.entries(n);return i.length===t.length&&i.every(([m,y])=>Object.hasOwn(n,m)&&ye(y,Reflect.get(n,m)))}var de=(e,n)=>new d(e,n);function Fn(e){return Ke(e,de)}function ln(e,n,i){return Qe(e,n,i,de)}async function We(e,n){let i=n.instruction;if(i?.type!=="evaluate")throw new Error("Evaluation instruction required");if(!e)throw new d("CONFIGURATION_UNAVAILABLE","Local conditions require the shared public configuration manager");let t=await e.funnel(n.source.id,n.source.versionId);if(!t.growth||t.control.evaluationMode!=="local"||t.control.evaluationRevision!==i.policyRevision)throw new d("EVALUATION_MODE","Refresh the original Funnel evaluation policy");let{analyticsConfig:m,remoteFeatures:y,...o}=t.growth,u=Se({scope:{projectId:e.scope.projectId,environment:e.scope.environment},funnelId:n.source.id,versionId:n.source.versionId,evaluationMode:"local",evaluationRevision:i.policyRevision,document:t.document,payload:ge.parse(o)});if(e.scope.environmentId!==i.environmentId)throw new d("SCOPE_MISMATCH","Evaluation environment changed");let r=ln(u,n.nodeId,i);return e.assertFunnel(n.source.id,void 0,n.source.versionId),{generation:t.manifest.generation,result:r}}async function Xe(e,n){let i=n.instruction;if(i?.type!=="evaluate_segment")throw new Error("Local segment instruction required");if(!e)throw new d("CONFIGURATION_UNAVAILABLE","Local execution requires public configuration");let t=await e.funnel(n.source.id,n.source.versionId);if(!t.growth||t.control.evaluationMode!=="local"||t.control.evaluationRevision!==i.policyRevision)throw new d("EVALUATION_MODE","Refresh the original Funnel evaluation policy");if(e.scope.environmentId!==i.environmentId)throw new d("SCOPE_MISMATCH","Evaluation environment changed");let{analyticsConfig:m,remoteFeatures:y,...o}=t.growth,u=Se({scope:{projectId:e.scope.projectId,environment:e.scope.environment},funnelId:n.source.id,versionId:n.source.versionId,evaluationMode:"local",evaluationRevision:i.policyRevision,document:t.document,payload:ge.parse(o)}),r=cn(u,t.document,{...n,...i});return e.assertFunnel(n.source.id,void 0,n.source.versionId),{...r,generation:t.manifest.generation,policyRevision:i.policyRevision}}function cn(e,n,i){return Ye(e,n,i,de)}import{z as Q}from"zod";var en=te.refine(e=>!["start","get","review"].includes(e.operation)&&!("customerToken"in e),"Persist only the original mutation, without credentials").transform(e=>{if(e.operation==="start"||e.operation==="get"||e.operation==="review")throw new d("COMMAND_STORAGE_INVALID","Stored mutation required");return e}),nn=Q.strictObject({schemaVersion:Q.literal(1),scope:_e,runId:Q.uuid(),funnelId:Q.uuid(),versionId:Q.uuid(),command:en.optional(),closeCommand:en.refine(e=>e.operation==="close").optional(),purchase:Q.strictObject({receiptId:Q.uuid(),operationId:Q.uuid(),generation:Q.number().int().nonnegative()}).optional(),closed:Q.literal(!0).optional()}).refine(e=>!e.closeCommand||e.command&&e.command.operation!=="close"&&e.command.requestId!==e.closeCommand.requestId,"Close requires a separate request identity").refine(e=>e.command!==void 0||e.purchase!==void 0,"A recovery record requires an original obligation"),J=()=>new d("COMMAND_STORAGE_CONFLICT","Another host changed this Run's pending command"),Fe=(e,n)=>JSON.stringify(e)===JSON.stringify(n);function tn(e){let n=0,i=null,t=r=>JSON.stringify([r.scope,r.runId,r.funnelId,r.versionId]),m=Promise.resolve();async function y(){let r=await e.read();if(!Number.isSafeInteger(r.revision)||r.revision<0)throw new d("COMMAND_STORAGE_INVALID","Invalid command storage revision");return{revision:r.revision,entry:r.entry===null?null:nn.parse(r.entry)}}function o(r){let s=m.then(r);return m=s.catch(()=>{}),s}async function u(r){for(let s=0;s<4;s++){let g=await y();if(g.entry&&i!==null&&t(g.entry)!==i)throw J();let w=r(g.entry,g.revision);if(Fe(g.entry,w)){n=g.revision;return}let v=await e.write(g.revision,w);if(v!==null){if(!Number.isSafeInteger(v)||v<=g.revision)throw J();n=v;return}}throw J()}return{bind(r){let s=JSON.stringify([r.scope,r.runId,r.funnelId,r.versionId]);if(i!==null&&i!==s)throw J();i=s},async load(){let r=await y();return n=r.revision,i=r.entry?t(r.entry):null,r.entry},retain(r){let s=nn.parse(r),g=s.command;return!g||i!==null&&t(s)!==i?Promise.reject(J()):(i??=t(s),o(()=>u((w,v)=>{if(w&&!Fe(t(w),t(s)))throw J();if(!w){if(v!==n&&g.operation!=="close")throw J();return s}if(!w.command)return{...w,command:g,...g.operation==="close"?{closed:!0}:{}};if(g.operation==="close"&&w.command.operation!=="close"){if(w.command.requestId===g.requestId||w.closeCommand&&!Fe(w.closeCommand,g))throw J();return{...w,closeCommand:g,closed:!0}}if(!Fe(w.command,g))throw J();return w})))},observePurchase(r,s,g){return o(()=>u((w,v)=>{if(!w&&v!==n||w&&t(w)!==t({...r,schemaVersion:1}))throw J();if(w?.purchase&&w.purchase.generation>s.generation)return w;if(w?.purchase&&w.purchase.generation===s.generation&&w.purchase.operationId!==s.operationId)throw J();return g?!w?.purchase||w.purchase.operationId!==s.operationId?w:w.command?{...w,purchase:void 0}:null:{schemaVersion:1,...r,...w,purchase:s}}))},settle(r){return o(()=>u(s=>s?s.command&&"requestId"in s.command&&s.command.requestId===r?s.closeCommand?{...s,command:s.closeCommand,closeCommand:void 0}:s.purchase?{...s,command:void 0}:null:s.closeCommand&&"requestId"in s.closeCommand&&s.closeCommand.requestId===r?{...s,closeCommand:void 0}:s:null))}}}function fe(e){let{customerToken:n,...i}=e;return i}var dn=e=>!(e instanceof d)||e.status===void 0||e.status>=500||[401,425].includes(e.status);function rn(e){if(e={...e},typeof e.runToken!="string"||!/^gg_fr_[A-Za-z0-9_-]{43}$/.test(e.runToken))throw new d("INVALID_TOKEN","Run credential required");if(e.serverKey&&(typeof window<"u"||!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(e.serverKey)))throw new d("SERVER_ONLY","Run Server-Key proof belongs to the merchant backend");let n=we({...e,...e.serverKey?{fetch:(l,c)=>{let N=new Headers(c?.headers);return N.set(ke,e.serverKey),(e.fetch??globalThis.fetch)(l,{...c,headers:N})}}:{},timeoutMs:e.timeoutMs??35e3});n.identify(e.runToken);let i,t=null,m=0,y=0,o=null,u=null,r=!1,s=null,g=!1,w=null,v=new Set,A=e.funnelCommandStorage??(typeof window<"u"&&window.isSecureContext?Ze(e):void 0),E=A&&tn(A),S,V=null,I=!1,P=E?E.load().then(l=>{if(I)throw new d("IDENTITY_CHANGED","Controller was reset during command restoration");if(V=l,!l)return;if(e.scope&&(l.scope.projectId!==e.scope.projectId||l.scope.environment!==e.scope.environment))throw new d("SCOPE_MISMATCH","Pending command belongs to another scope");if(S=l.purchase,r=l.closed===!0,!l.command)return;let c=te.parse(l.command);if(c.operation==="start"||c.operation==="get"||c.operation==="review")throw new d("COMMAND_STORAGE_INVALID","Stored mutation required");o=c,l.closeCommand&&(u=l.closeCommand,r=!0),c.operation==="close"&&(r=!0),g=!0}):Promise.resolve();P.catch(()=>{});async function F(l,c,N){E&&await P;let k=m,Y=t,a=Ee.parse(await n.request("funnels",te.parse(l)));if(l.operation==="review"&&!a.review)throw new d("INVALID_RESPONSE","Historical projection is missing");if(k!==m)throw new d("IDENTITY_CHANGED","Run identity changed during the request");if(a.runToken&&a.runToken!==e.runToken)throw new d("INVALID_RESPONSE","Run credential changed");let B=l.operation==="get"?l.settlementRequestId:"requestId"in l&&l.operation!=="start"?l.requestId:void 0;if(B&&a.settlement?.requestId!==B)throw new d("INVALID_RESPONSE","Exact command settlement is missing or belongs to another command");if(V&&(a.run.id!==V.runId||a.run.source.id!==V.funnelId||a.run.source.versionId!==V.versionId))throw new d("SCOPE_MISMATCH","Stored command belongs to another Run or Version");if(t&&(a.run.id!==t.id||a.run.source.type!==t.source.type||a.run.source.id!==t.source.id||a.run.source.versionId!==t.source.versionId||a.run.locale!==t.locale||!ye(a.run.parameters,t.parameters)))throw new d("INVALID_RESPONSE","Run version changed");if(e.funnelId&&a.run.source.id!==e.funnelId)throw new d("INVALID_RESPONSE","Run belongs to another Funnel");E?.bind({scope:a.scope,runId:a.run.id,funnelId:a.run.source.id,versionId:a.run.source.versionId}),A&&!e.scope&&(e.scope=a.scope);let K=a.run.paywall,z=K??a.purchase,me=z?.operation,pe=a.settlement&&(!K||K.purchaseRequestId===a.settlement.requestId)&&(!S||S.operationId===a.settlement.operationId)?a.settlement:void 0,ie=me?.operationId??z?.quote?.operationId??pe?.operationId,ae=z?.receiptId??pe?.receiptId,Ie=K?.selectionGeneration??S?.generation??0;if(E&&ie&&ae&&l.operation!=="review"&&(!t||a.run.revision>=t.revision)&&(N===void 0||N>=y)&&(!S||Ie>=S.generation)){let $={receiptId:ae,operationId:ie,generation:Ie},Ce=me?.status==="complete"||z?.canReselect===!0;await E.observePurchase({scope:a.scope,runId:a.run.id,funnelId:a.run.source.id,versionId:a.run.source.versionId},$,Ce),Ce?S?.operationId===$.operationId&&(S=void 0):S=$}if(!a.run.stopped&&["running","waiting"].includes(a.run.status)&&l.operation==="get"&&l.settlementRequestId)return a;let se=c?.(a),he=typeof se=="boolean"?se:se?await se:!1;if(["running","waiting"].includes(a.run.status)||(r=!0),l.operation==="review"&&t&&t!==Y&&a.run.revision<=t.revision||t&&a.run.revision===t.revision&&N!==void 0&&N<y||(l.operation==="review"&&!a.run.stopped&&["running","waiting"].includes(a.run.status)&&t&&a.run.nodeId===t.nodeId&&a.run.visit===t.visit&&a.run.revision===t.revision&&(a.run.screen=t.screen,(t.paywall?.quote?.operationId===a.review?.activeOperationId||!t.paywall?.quote&&a.review?.activeOperationId===null)&&(a.run.paywall=t.paywall)),t?.paywall&&a.run.paywall&&t.paywall.receiptId===a.run.paywall.receiptId&&(a.run.paywall.selectionGeneration??0)<(t.paywall.selectionGeneration??0)))return a;if(!t||a.run.revision>=t.revision)t=a.run;else if(!he)return a;if(t)for(let $ of v)try{$(structuredClone(t))}catch{}return a}async function D(l=o){if(E&&await P,!l)throw new d("INVALID_REQUEST","No command is pending");let c=l,N=m;if(E){if(!t||!e.scope)throw new d("COMMAND_STORAGE_INVALID","Read the original scoped Run before persisting a mutation");await E.retain({schemaVersion:1,scope:e.scope,runId:t.id,funnelId:t.source.id,versionId:t.source.versionId,command:fe(c)})}if(N!==m||o!==c&&u!==c)throw new d("IDENTITY_CHANGED","Run changed before command dispatch");let k={...c,...i?{customerToken:i}:{}},Y=g;g=!0;try{return await F(k,a=>{if(!a.settlement)throw new d("INVALID_RESPONSE","Exact command settlement is missing");if(a.settlement.requestId!==c.requestId)throw new d("INVALID_RESPONSE","Command settlement identity changed");if(N===m&&(o===c||u===c)&&a.run.pendingRequest?.requestId!==c.requestId&&a.settlement.state==="settled"&&(!r||c.operation==="close"||a.settlement?.state==="settled"&&!["running","waiting"].includes(a.run.status))){let B=()=>N!==m||o!==c&&u!==c?!1:(o===c&&(o=null),u===c&&(u=null),g=o!==null,V=null,!0);return E?E.settle(c.requestId).then(B):B()}return!1})}catch(a){throw N===m&&o===c&&!Y&&!dn(a)&&(E&&await E.settle(c.requestId),N===m&&o===c&&(o=null,g=!1,V=null)),a}}function T(l){let c=te.parse(l);if(c.operation==="start"||c.operation==="get"||c.operation==="review")throw new d("INVALID_REQUEST","Mutation required");if(t?.recoveryRestricted&&c.operation!=="close"&&c.operation!=="resume"&&o?.requestId!==c.requestId)throw new d("PRECONDITION_FAILED","Original Run requires restricted recovery");if(r&&c.operation!=="close"){if(o?.requestId===c.requestId)return ee.settle(c.requestId);throw new d("COMMAND_PENDING","Close preserves the original recovery record; settle it by identity")}if(c.operation==="close"&&o?.operation!=="close"){if(r=!0,u&&JSON.stringify(fe(u))!==JSON.stringify(fe(c)))throw new d("COMMAND_PENDING","Retry the original Close");if(u??=c,s)return s;let k=D(u);return s=k,k.then(()=>{s===k&&(s=null)},()=>{s===k&&(s=null)}),k}if(o){if(JSON.stringify(fe(o))!==JSON.stringify(fe(c)))throw new d("COMMAND_PENDING","Retry the original command before sending another");if(w)return w}else o=c,g=!1;let N=D();return w=N,N.then(()=>{w===N&&(w=null)},()=>{w===N&&(w=null)}),N}let _=null,U=new WeakMap;function j(l){let c=U.get(l);if(c)return c;let N=X(l);return U.set(l,N),N}let oe=!1;async function X(l){let c=await l;if(c.run.recoveryRestricted||!["evaluate","evaluate_segment"].includes(c.run.instruction?.type??""))return c;if(_)return _;oe=!0;let N=m,k=(async()=>{for(let Y=0;Y<32&&["evaluate","evaluate_segment"].includes(c.run.instruction?.type??"");Y++){if(o||r)return c;let a=c.run,B=c.run.instruction;if(B?.type==="evaluate_segment"){let z=await Xe(e.configuration,a);if(N!==m)throw new d("IDENTITY_CHANGED","Run identity changed during segment calculation");if(o||r)return c;if(t&&(t.revision!==a.revision||t.visit!==a.visit||t.nodeId!==a.nodeId))return F({operation:"get",...i?{customerToken:i}:{}});c=await T({operation:"commit_segment",requestId:be(a.id,a.visit,`segment:${a.revision}`),nodeId:a.nodeId,visit:a.visit,revision:a.revision,...z});continue}if(B?.type!=="evaluate")return c;let K=await We(e.configuration,a);if(N!==m)throw new d("IDENTITY_CHANGED","Run identity changed during evaluation");if(o||r)return c;if(t&&(t.revision!==a.revision||t.visit!==a.visit||t.nodeId!==a.nodeId))return F({operation:"get",...i?{customerToken:i}:{}});c=await T({operation:"evaluate",requestId:be(a.id,a.visit,"evaluation"),nodeId:a.nodeId,visit:a.visit,revision:a.revision,receiptId:B.receiptId,policyRevision:B.policyRevision,...K})}return c})();_=k;try{return await k}finally{_===k&&(_=null)}}let ee={get configuration(){return oe?e.configuration:void 0},get configurationReady(){return!0},get view(){return t?structuredClone(t):null},get pendingCommand(){let l=u??o;return l?structuredClone(fe(l)):null},get pendingCommands(){return[o,u].filter(l=>l!==null).map(l=>structuredClone(fe(l)))},get pendingPurchase(){return S?structuredClone(S):null},async settle(l){let c=await F({operation:"get",settlementRequestId:l,...i?{customerToken:i}:{}});if(c.settlement?.requestId!==l)throw new d("INVALID_RESPONSE","Exact command settlement is missing");return c.settlement.state==="settled"&&(E&&await E.settle(l),o?.requestId===l&&(o=null,g=!1),u?.requestId===l&&(u=null)),c},get webViewUrl(){return n.webViewUrl()},review(l){return F({operation:"review",...l?{receiptId:l}:{},...i?{customerToken:i}:{}},void 0,++y)},async get(l,c){E&&await P,c??=S&&{receiptId:S.receiptId,operationId:S.operationId};let N=++y;return j(F({operation:"get",...l?{data:l}:{},...c?{purchase:c}:{},...i?{customerToken:i}:{}},void 0,N))},resume(l=t?.pendingRequest?.requestId){return l?r?ee.settle(l):o?.requestId===l?j(T(o)):j(T({operation:"resume",requestId:l})):Promise.reject(new d("INVALID_REQUEST","No interrupted command is available"))},submit(l){return j(T(l))},retry(){return s||(u?D(u):r&&o?ee.settle(o.requestId):w?j(w):o?j(T(o)):Promise.reject(new d("INVALID_REQUEST","No command is pending")))},identify(l){if(!/^gg_ct_[A-Za-z0-9_-]{43}$/.test(l))throw new d("INVALID_TOKEN","Customer credential required");m++,i=l,n.identify(e.runToken)},subscribe(l){return v.add(l),()=>v.delete(l)},reset(){I=!0,m++,i=void 0,t=null,o=null,u=null,s=null,g=!1,w=null,n.reset(),v.clear()}};return ee}async function Zn(e,n){if(!/^gg_ct_[A-Za-z0-9_-]{43}$/.test(n.customerToken))throw new d("INVALID_TOKEN","A verified Customer credential is required");let i=we(e);i.identify(n.customerToken);let t=ce.resolvePaywall.request.parse({funnelId:n.funnelId,funnelVersionId:n.funnelVersionId,selector:n.paywallVersionId?{type:"version",versionId:n.paywallVersionId}:{type:"paywall",paywallId:n.paywallId},commerce:n.commerce,locale:n.locale,...n.requirement?{requirement:n.requirement}:{}}),m=null,y=null,o=null,u=null,r=null;async function s(){let v=ce.resolvePaywall,A=v.response.parse(await i.request(v.path,v.request.parse({...t,selector:m?{type:"version",versionId:m.id}:t.selector})));if(n.paywallVersionId?A.paywall.id!==n.paywallVersionId:A.paywall.paywallId!==n.paywallId)throw new d("INVALID_RESPONSE","The requested Paywall changed");if(m&&(A.paywall.id!==m.id||A.paywall.paywallId!==m.paywallId||A.paywall.offering.id!==m.offering.id))throw new d("INVALID_RESPONSE","The pinned Paywall or Offering Version changed");return m=A.paywall,structuredClone(m)}async function g(v){if(!y)throw new d("INVALID_REQUEST","A quoted purchase is required");let A=v==="read"?ce.readSubscriptionOperation:ce.attach,E=A.response.parse(await i.request(A.path,A.request.parse({operationId:y.operationId,...v==="read"?{}:{intent:v}})));if(E.operation.operationId!==y.operationId||E.operation.currency!==t.commerce.currency)throw new d("INVALID_RESPONSE","The purchase operation changed");return o?.status==="complete"&&E.operation.status!=="complete"||o&&o.status!=="pending"&&E.operation.status==="pending"||(o=E.operation),structuredClone(o)}let w={get view(){return m?structuredClone(m):null},get quote(){return y?structuredClone(y):null},get operation(){return o?structuredClone(o):null},get webViewUrl(){return i.webViewUrl()},refresh:s,async preview(v){if(!m)throw new d("INVALID_REQUEST","Load the Paywall first");let A=m.document.buttons[v.actionId];if(A?.type!=="checkout")throw new d("INVALID_REQUEST","Choose an authored purchase action");let E=Le(A.product,v.selection,m.capabilities);if(!E)throw new d("PRODUCT_UNAVAILABLE","Choose an available Product");let S=ce.previewAttach.request.parse({funnelId:t.funnelId,funnelVersionId:t.funnelVersionId,requestId:v.requestId,plans:[{productVersionId:E}],provider:t.commerce.provider,currency:t.commerce.currency,...v.offerId?{offerId:v.offerId}:{},...v.nativeOffer?{nativeOffer:v.nativeOffer}:{}}),V=JSON.stringify(S);if(u&&u!==V&&(!o||o.status==="pending"))throw new d("COMMAND_PENDING","Finish or cancel the original purchase before changing it");if(u===V){if(r)return r;if(y)return structuredClone(y)}u=V;let I=(async()=>{let P=ce.previewAttach,F=P.response.parse(await i.request(P.path,S));if(F.quote.currency!==t.commerce.currency||F.quote.provider!==t.commerce.provider||F.quote.lines.length!==1||F.quote.lines[0].productVersionId!==E)throw new d("INVALID_RESPONSE","The purchase quote changed its selected Product or presentment");return y=F.quote,o=null,structuredClone(y)})();r=I;try{return await I}finally{r===I&&(r=null)}},confirm:()=>g("confirm"),cancel:()=>g("cancel"),read:()=>g("read"),destroy(){i.reset(),m=null,y=null,o=null,u=null}};return await s(),w}import{z as gn}from"zod";import{z as ve}from"zod";var fn=ve.record(ve.string().regex(/^[a-f0-9]{64}$/),ve.strictObject({at:ve.number(),text:ve.string()})),on=2*1048576,mn=100;function pn(){try{return typeof window>"u"?void 0:window.localStorage}catch{return}}function an(e,n){let i=n===void 0?pn():n,t=Promise.resolve();async function m(o){if(!i)return null;let u;try{return await Promise.race([Promise.resolve().then(()=>i.getItem(o)),new Promise(r=>{u=setTimeout(()=>r(null),mn)})])}catch{return null}finally{clearTimeout(u)}}async function y(){try{let o=await m(`${e}:artifacts`);if(o&&o.length<=on)return fn.parse(JSON.parse(o))}catch{}return{}}return{async readManifest(){return m(e)},writeManifest(o){Promise.resolve().then(()=>i?.setItem(e,o)).catch(()=>{})},async readArtifact(o){let u=(await y())[o];return u&&Date.now()>=u.at&&Date.now()-u.at<=H.retentionMs?u.text:void 0},writeArtifact(o,u){i&&(t=t.catch(()=>{}).then(async()=>{let r=await y(),s=Date.now();r[o]={at:s,text:u};let g={},w=2,v=0;for(let[A,E]of Object.entries(r).sort(([,S],[,V])=>V.at-S.at)){if(E.at>s||s-E.at>H.retentionMs)continue;let S=new TextEncoder().encode(JSON.stringify({[A]:E})).byteLength;w+S>on||v>=128||(g[A]=E,w+=S,v++)}await i.setItem(`${e}:artifacts`,JSON.stringify(g))}).catch(()=>{}))}}}var R=(e,n)=>new d(e,n),re=()=>performance.now(),sn=e=>{typeof e=="object"&&"unref"in e&&e.unref()};function st(e){let n=je.parse(e.scope),i=new URL(e.origin??Ae);if(i.username||i.password||i.search||i.hash||i.pathname!=="/"||i.protocol!=="https:"&&!(i.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(i.hostname)))throw R("INVALID_URL","Configuration requires a trusted HTTPS origin");let t=new Set([i.origin,...(e.assetOrigins??[]).map(p=>{let f=new URL(p);if(f.protocol!=="https:"||f.username||f.password||f.search||f.hash||f.pathname!=="/")throw R("INVALID_URL","Invalid configuration asset origin");return f.origin})]),m=e.fetch??globalThis.fetch.bind(globalThis),y=`/api/v1/configuration/${n.environmentId}`,o=`indiana:configuration:1:${i.origin}:${M(n)}`,u=an(o,e.storage),r,s=0,g=0,w=!1,v=!1,A=0,E=0,S,V,I,P,F=0,D=new Set,T=new Set,_=new Map,U=new Map,j=0,oe=!1;function X(){for(let p of D)try{p()}catch{}}function ee(p){try{e.onError?.(p)}catch{}}let l=()=>!v&&!w&&!!r&&re()<s&&Date.now()<g;function c(){if(!l())throw R("CONFIGURATION_EXPIRED","Refresh configuration before using it")}function N(p,f){let C=new TextEncoder().encode(f).byteLength;if(!_.has(p)){for(;_.size&&(_.size>=128||j+C>H.maxCacheBytes);){let h=_.entries().next().value;j-=new TextEncoder().encode(h[1]).byteLength,_.delete(h[0])}_.set(p,f),j+=C}}async function k(p,f,C){if(Number(p.headers.get("content-length"))>f)throw R("INVALID_RESPONSE","Configuration exceeds its byte limit");let h=p.body?.getReader();if(!h)throw R("INVALID_RESPONSE","Configuration body is missing");let b=[],L=0;try{for(;;){C.throwIfAborted();let x=await h.read();if(x.done)break;if(L+=x.value.length,L>f)throw R("INVALID_RESPONSE","Configuration exceeds its byte limit");b.push(x.value)}}finally{await h.cancel().catch(()=>{})}C.throwIfAborted();let O=new Uint8Array(L),G=0;for(let x of b)O.set(x,G),G+=x.length;return new TextDecoder("utf-8",{fatal:!0}).decode(O)}function Y(p){let f=new URL(p,i);if(!t.has(f.origin)||f.username||f.password||f.hash||f.search)throw R("INVALID_URL","Configuration artifact origin is not trusted");return f.href}async function a(p,f,C=!1){let h=await m(Y(p),{method:"GET",credentials:"omit",redirect:"error",cache:C?"default":"no-cache",signal:f,headers:{}});if(h.status===429){let b=h.headers.get("retry-after")??"";F=/^\d+$/.test(b)?Number(b)*1e3:Math.max(0,Date.parse(b)-Date.now())||15e3}if(!h.ok&&h.status!==304)throw R(`CONFIGURATION_HTTP_${h.status}`,"Configuration synchronization failed");return h}function B(p,f,C){let h=Date.parse(p.headers.get("x-indiana-config-validated-at")??""),b=Date.parse(p.headers.get("x-indiana-config-valid-until")??""),L=Date.parse(p.headers.get("date")??""),O=p.headers.get("age"),G=O!==null&&/^\d+(\.\d+)?$/.test(O)?Number(O)*1e3:NaN;if(![h,b,L,G].every(Number.isFinite)||b<=h||b-h>H.maxControlAgeMs||h>L+1e3)throw R("INVALID_RESPONSE","Configuration freshness evidence is invalid");let q=Math.min(b-h,C.maxControlAgeSeconds*1e3,H.maxControlAgeMs)-Math.max(G,L-h,0)-(re()-f);if(q<=0)throw R("CONFIGURATION_EXPIRED","Configuration validation expired in transit");return re()+q}function K(){if(clearTimeout(I),clearTimeout(P),v||!D.size)return;l()&&(P=setTimeout(()=>{l()?K():X()},Math.max(1,s-re())),sn(P));let p=E?Math.min(15e3,1e3*2**Math.min(E-1,4)):Math.min(15e3,(r?.policy.refreshIntervalSeconds??15)*1e3);I=setTimeout(()=>{z().catch(ee)},Math.max(F,p*(.8+Math.random()*.2))),sn(I)}async function z(){if(v)throw R("CONFIGURATION_DISPOSED","Configuration manager was destroyed");if(S)return S;let p=A,f=new AbortController;V=f;let C=(async()=>{if(!oe){oe=!0;try{let Re=await u.readManifest();if(Re&&!r){let W=Pe.parse(JSON.parse(Re));M(W.scope)===M(n)&&(r=W)}}catch{}}f.signal.throwIfAborted();let O=r,G=re(),x=await a(y,f.signal);x.status===304&&(!O||!x.headers.has("x-indiana-config-validated-at")||!x.headers.has("x-indiana-config-valid-until")||!x.headers.has("age"))&&(x=await a(y,f.signal));let q=x.status===304?O:Pe.parse(JSON.parse(await k(x,H.maxManifestBytes,f.signal))),{generation:Z,...ne}=q,ue=x.headers.get("etag");if(M(q.scope)!==M(n)||Be(ne)!==Z||ue!==`"${Z}"`&&ue!==`W/"${Z}"`)throw R("INVALID_RESPONSE","Configuration scope or content identity changed");if(O&&(q.revision<O.revision||q.revision===O.revision&&q.generation!==O.generation))throw R("INVALID_RESPONSE","Configuration revision moved backwards or changed identity");for(let[Re,W]of Object.entries(O?.funnels??{})){let le=q.funnels[Re];if(le&&(le.controlRevision<W.controlRevision||le.evaluationRevision<W.evaluationRevision||le.controlRevision===W.controlRevision&&le.state!==W.state||le.evaluationRevision===W.evaluationRevision&&le.evaluationMode!==W.evaluationMode))throw R("INVALID_RESPONSE","Funnel control revision changed identity")}let Te=B(x,G,q.policy);if(f.signal.throwIfAborted(),p!==A)throw R("CONFIGURATION_DISPOSED","Configuration scope changed");return r=q,s=Te,g=Date.now()+Math.max(0,Te-re()),w=!1,E=0,F=0,u.writeManifest(M(q)),X(),structuredClone(q)})(),h=setTimeout(()=>f.abort(R("CONFIGURATION_UNAVAILABLE","Configuration initialization timed out")),H.initializationMs),b=new Promise((O,G)=>f.signal.addEventListener("abort",()=>G(f.signal.reason),{once:!0})),L=Promise.race([C,b]).catch(O=>{throw E++,(O instanceof gn.ZodError||O instanceof SyntaxError||O instanceof d&&["CONFIGURATION_HTTP_404","CONFIGURATION_HTTP_410","INVALID_RESPONSE"].includes(O.code))&&(s=0,w=!0,X()),O}).finally(()=>{clearTimeout(h),S===L&&(S=void 0),K()});return S=L,L}async function me(p){let f=p.sha256,C=Z=>new TextEncoder().encode(Z).byteLength===p.byteLength&&Je(Z)===f;Y(p.url);let h=_.get(f);if(h&&C(h))return _.delete(f),_.set(f,h),h;if(U.has(f))return U.get(f);let b=new AbortController;T.add(b);let L=A,O=(async()=>{try{let ue=await u.readArtifact(f);if(ue&&C(ue))return N(f,ue),ue}catch{}b.signal.throwIfAborted();let Z=await a(p.url,b.signal,!0),ne=await k(Z,p.byteLength,b.signal);if(!C(ne))throw R("INVALID_RESPONSE","Configuration artifact digest or size mismatch");if(v||L!==A)throw R("CONFIGURATION_DISPOSED","Configuration scope changed");return N(f,ne),u.writeArtifact(f,ne),ne})(),G=setTimeout(()=>b.abort(R("CONFIGURATION_UNAVAILABLE","Configuration artifact timed out")),H.initializationMs),x=new Promise((Z,ne)=>b.signal.addEventListener("abort",()=>ne(b.signal.reason),{once:!0})),q=Promise.race([O,x]).finally(()=>{clearTimeout(G),T.delete(b),U.delete(f)});return U.set(f,q),q}async function pe(){return l()||await z(),c(),r}async function ie(p){let f,C=new Promise((h,b)=>{f=setTimeout(()=>b(R("CONFIGURATION_UNAVAILABLE","Configuration initialization timed out")),H.initializationMs)});try{return await Promise.race([p(),C])}finally{clearTimeout(f)}}function ae(p,f){if(c(),r?.generation!==p.generation)throw R("CONFIGURATION_CHANGED","Configuration changed while preparing a snapshot");if(f&&r.funnels[f]?.state!=="active")throw R("FUNNEL_STOPPED","Funnel is paused or unavailable")}async function Ie(p){let f=p.gb.features;if(!f)throw R("CONFIGURATION_UNAVAILABLE","Public Feature delivery is disabled");let C=p.artifacts[f];if(C.formatVersion!==1)throw R("UNSUPPORTED_SCHEMA","Unsupported public GB configuration format");let h=Me.parse(JSON.parse(await me(C)));if(M(h.scope)!==M({projectId:n.projectId,environment:n.environment})||h.generation!==C.generation||h.remoteFeatures.some(b=>Object.hasOwn(h.features,b)))throw R("INVALID_RESPONSE","Public GB configuration scope or generation is invalid");return ae(p),{...h,evaluatedAt:new Date().toISOString(),expiresAt:new Date(Date.now()+Math.max(0,s-re())).toISOString()}}async function se(p,f){let C=await pe();ae(C,p);let h=C.funnels[p];if(h.evaluationMode!=="local")throw R("EVALUATION_MODE","This Funnel executes at Indiana; public graph loading is disabled");let b=f??h.currentVersionId,L=h.versions[b];if(!L)throw R("CONFIGURATION_UNAVAILABLE","Pinned Funnel Version is unavailable");if(C.artifacts[L.artifact].formatVersion!==3)throw R("UNSUPPORTED_SCHEMA","Unsupported public Funnel format");let[O,G]=await Promise.all([me(C.artifacts[L.artifact]).then(x=>He(JSON.parse(x))),h.evaluationMode==="local"?Ie(C):void 0]);if(G&&M(ze(O,G))!==M(L.dependencies))throw R("INVALID_RESPONSE","Funnel and GB dependency contract do not match");return ae(C,p),{document:O,growth:G,versionId:b,control:structuredClone(h),manifest:structuredClone(C)}}function he(){w=!0,X(),z().catch(ee)}let $=()=>{(typeof document>"u"||document.visibilityState==="visible")&&he()};function Ce(p){if(v)throw R("CONFIGURATION_DISPOSED","Configuration manager was destroyed");return D.add(p),D.size===1&&(typeof window<"u"&&(window.addEventListener("online",he),window.addEventListener("focus",$),document.addEventListener("visibilitychange",$)),K()),()=>{D.delete(p),D.size||(clearTimeout(I),clearTimeout(P),Oe())}}function Oe(){typeof window<"u"&&(window.removeEventListener("online",he),window.removeEventListener("focus",$),document.removeEventListener("visibilitychange",$))}return{scope:Object.freeze({...n}),refresh:z,subscribe:Ce,assertFresh:c,assertFeatures(p){c();let f=r.gb.features;if(!f)throw R("CONFIGURATION_UNAVAILABLE","Public Feature delivery is disabled");if(p!==void 0&&r.artifacts[f].generation!==p)throw R("CONFIGURATION_CHANGED","Refresh changed Feature configuration before evaluation")},get fresh(){return l()},get snapshot(){return r?structuredClone(r):null},get remainingMs(){return l()?Math.max(0,s-re()):0},async features(){return ie(async()=>Ie(await pe()))},pageExperiments:()=>ie(async()=>{let p=await pe(),f=p.gb.pageExperiments;if(!f)throw R("CONFIGURATION_UNAVAILABLE","Public page experiments are disabled");let C=p.artifacts[f];if(C.formatVersion!==1)throw R("UNSUPPORTED_SCHEMA","Unsupported page experiment format");let h=Ge.parse(JSON.parse(await me(C)));if(h.environmentId!==n.environmentId||h.generation!==C.generation)throw R("INVALID_RESPONSE","Page experiment scope or generation changed");return ae(p),h}),funnel:(p,f)=>ie(()=>se(p,f)),async localFunnel(p,f){let C=await ie(()=>se(p,f));if(!C.growth)throw R("EVALUATION_MODE","This Funnel requires remote execution");let{analyticsConfig:h,remoteFeatures:b,...L}=C.growth;return qe({scope:{projectId:n.projectId,environment:n.environment},funnelId:p,versionId:C.versionId,evaluationMode:"local",evaluationRevision:C.control.evaluationRevision,document:C.document,payload:L})},assertFunnel(p,f,C){c();let h=r.funnels[p];if(!h||h.state!=="active")throw R("FUNNEL_STOPPED","Funnel is paused or unavailable");if(h.evaluationMode!=="local")throw R("EVALUATION_MODE","This Funnel now executes at Indiana");if(f!==void 0&&h.controlRevision!==f)throw R("RUN_RECONCILIATION_REQUIRED","Reconcile the original Run after a control change");if(C!==void 0&&!h.versions[C])throw R("CONFIGURATION_UNAVAILABLE","Pinned Funnel Version is unavailable")},destroy(){if(!v){v=!0,A++,s=0,V?.abort(R("CONFIGURATION_DISPOSED","Configuration manager was destroyed")),clearTimeout(I),clearTimeout(P),Oe(),X(),D.clear();for(let p of T)p.abort(R("CONFIGURATION_DISPOSED","Configuration manager was destroyed"));_.clear(),j=0}}}}function dt(e,n,i){return $e(e,n,i,de)}function un(e){let n=/^gg_ct_[A-Za-z0-9_-]{32,128}$/.test(e.apiKey);if(typeof window<"u"&&!n)throw new d("SERVER_ONLY","Funnel starts are issued by your backend");if(!n&&!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(e.apiKey))throw new d("INVALID_TOKEN","A customer credential or server API key is required");let i=we({...e,timeoutMs:e.timeoutMs??35e3});return i.identify(e.apiKey),{async start(t){let m=te.safeParse({...t,operation:"start"});if(!m.success||m.data.operation!=="start"||(n?m.data.customer!==void 0:m.data.customer===void 0))throw new d("INVALID_REQUEST","Invalid current Funnel start");let y=m.data,o=Ee.safeParse(await i.request("funnels",y));if(!o.success||!o.data.runToken)throw new d("INVALID_RESPONSE","Funnel start credentials are missing");let u=o.data;if(u.run.source.id!==y.funnelId||u.run.locale!==(y.locale??"en")||!ye(u.run.parameters,y.parameters??{})||(y.customer?!u.customerId||y.customer.type==="id"&&u.customerId!==y.customer.value:u.customerId!==void 0))throw new d("INVALID_RESPONSE","Funnel start contract changed");return{...u,runToken:u.runToken}}}}async function Ct(e){e={...e};let n=e.configuration;if(!n)throw new d("CONFIGURATION_UNAVAILABLE","Local conditions require public configuration");let i={projectId:n.scope.projectId,environment:n.scope.environment};if(e.scope&&M(i)!==M(e.scope))throw new d("SCOPE_MISMATCH","Configuration and transport scopes differ");if((await n.funnel(e.funnelId)).control.evaluationMode!=="local")throw new d("EVALUATION_MODE","This Funnel uses Remote evaluation");let m=/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(e.credential);if(m?!e.customerId:e.customerId!==void 0)throw new d("INVALID_REQUEST","Only Server-Key starts name their Customer");let y=un({...e,scope:i,apiKey:e.credential}),o=u=>{let r=rn({...e,scope:i,runToken:u,...m?{serverKey:e.credential}:{}});return m||r.identify(e.credential),r};return{async start(u){let r=await y.start({...u,funnelId:e.funnelId,...m?{customer:{type:"id",value:e.customerId}}:{}}),s=o(r.runToken),g=await s.get();return{...r,...g,controller:s}},async restore(u){let r=o(u),s=await r.get();if(s.run.source.id!==e.funnelId)throw r.reset(),new d("SCOPE_MISMATCH","Run belongs to another Funnel");return{...s,runToken:u,controller:r}}}}export{yn as a,Rn as b,ye as c,Fn as d,ln as e,cn as f,Ze as g,rn as h,Zn as i,st as j,dt as k,un as l,Ct as m};
@@ -0,0 +1 @@
1
+ import{a as Fe}from"./chunk-CB63JLGT.js";import{a as Ue,b as ve,c as Pe,d as ce,e as Le,f as pe,g as De,h as Me,i as xe,j as he,k as S,l as ke,m as Be,n as He,o as Ve,p as Ge,q as Ye}from"./chunk-U6S6AZM6.js";import{a as Ce,b as se,c as ie}from"./chunk-4K25DELJ.js";function me(c){return c.nodeType===1&&c.hasAttribute("data-indiana-capture-controls")&&c.hasAttribute("data-indiana-private")}async function Se(c,l){let o=[];async function e(a){if(a===null||typeof a!="object"){o.push(Ge(a));return}let _=Array.isArray(a),U=_?Object.keys(a):Object.keys(a).sort();o.push(_?"[":"{");for(let y=0;y<U.length;y++)y&&o.push(","),_||o.push(JSON.stringify(U[y]),":"),await e(a[U[y]]),await l();o.push(_?"]":"}")}return await e(c),o.join("")}async function We(c,l,o){if(!Number.isSafeInteger(l)||l<0)throw new RangeError("Invalid byte limit");if(c.length>l)return null;let e=new TextEncoder,a=[],_=0;for(let f=0;f<c.length;){let r=Math.min(c.length,f+4096),T=c.charCodeAt(r-1),h=c.charCodeAt(r);r<c.length&&T>=55296&&T<=56319&&h>=56320&&h<=57343&&r--;let D=e.encode(c.slice(f,r));if(_+=D.byteLength,_>l)return null;a.push(D),f=r,await o()}let U=new Uint8Array(_),y=0;for(let f of a)U.set(f,y),y+=f.byteLength,await o();return U}import{default as qe}from"css-tree/parser";import{default as J}from"css-tree/walker";import{default as Ee}from"css-tree/generator";function we(c,l=[],o=!1,e="https://iam.invalid/",a="masked-default-v2",_=new URL(e).origin){if(a!=="masked-default-v2")throw Error("Unsupported capture privacy");if(c.length>524288||/<\/(?:style|script)/i.test(c))throw Error("CSS budget or boundary");let U=new Set,y=new Set(l),f=qe(c,{context:o?"declarationList":"stylesheet",parseCustomProperty:!0,onParseError:()=>{U.add("CSS_SYNTAX_RECOVERED")}});return J(f,function(r,T,h){if((r.type==="Rule"||r.type==="Atrule")&&r.prelude){let D=Ee(r.prelude);if(ce(D)||Pe(D)!==D)return T&&h&&h.remove(T),U.add("CSS_PRIVATE_SELECTOR_OMITTED"),J.skip}}),J(f,{visit:"Atrule",enter(r,T,h){if(["import","namespace","charset"].includes(r.name.toLowerCase()))return T&&h&&h.remove(T),U.add("CSS_EXTERNAL_RULE_OMITTED"),J.skip}}),J(f,{visit:"Declaration",enter(r,T,h){if(/^(?:content|-moz-binding|behavior)$/i.test(r.property))return T&&h&&h.remove(T),U.add("CSS_CONTENT_OMITTED"),J.skip;let D=Ee(r.value),k=!1;if(k=/(?:password|secret|token|email|phone|(?:user|customer|session|account|tenant)[_-]?id)/i.test(r.property),J(r.value,u=>{(u.type==="Identifier"&&ce(u.name)||(u.type==="String"||u.type==="Hash")&&ce(u.value)||u.type==="Dimension"&&ce(u.unit))&&(k=!0)}),/(?:[\w.%+-]+@[\w.-]+\.[a-z]{2,}|sk_(?:live|test)_\w{12,}|\bBearer\s+|eyJ[\w-]+\.[\w-]+\.)/i.test(D)||k)return T&&h&&h.remove(T),U.add("CSS_PRIVATE_VALUE_OMITTED"),J.skip}}),J(f,r=>{if(r.type==="Raw")throw Error("Unparsed CSS cannot be captured");if(r.type==="Url"){let T="";try{let h=new URL(r.value,e);h.origin===_&&!h.search&&!h.hash&&!h.username&&!h.password&&(T=h.pathname)}catch{}y.has(T)?r.value=T:(r.value="",U.add("CSS_RESOURCE_OMITTED"))}}),{css:Ee(f),gaps:[...U]}}async function Ke(c,l,o,e,a,_,U,y){let f=new Set,r=(u,v=!1)=>{if(u.length>8192)throw Error("Atomic CSS budget");let g=we(u,l.assetPaths,v,o,l.privacy,l.origin);return g.gaps.forEach(p=>a.add(p)),g.css};function T(u){let v;try{v=r(u+(u.startsWith("@keyframes ")?"{from{opacity:1}}":u.startsWith("@")?"{.iam-capture-probe{opacity:1}}":"{opacity:1}"))}catch(p){if(p instanceof Error&&p.message==="Unparsed CSS cannot be captured")return a.add("CSS_SELECTOR_UNSUPPORTED"),"";throw p}let g=v.indexOf("{");return g<0?"":v.slice(0,g+1)}async function h(u){if(u.length>512)throw Error("Atomic CSS budget");let v=0,g=!1,p=[];for(let n=0;n<u.length;n++){await _();let d=u[n],R=u.getPropertyValue(d),C=u.getPropertyPriority(d);if(v+=d.length+R.length+C.length+3,v>8192)throw Error("Atomic CSS budget");p.push({property:d,value:R,priority:C})}if(p.some(n=>n.value==="")){let n=r(u.cssText,!0);return n&&e(n),await _(),!!n}for(let{property:n,value:d,priority:R}of p){await _(),y.cssText="",y.setProperty(n,d,R);let C=r(y.cssText,!0);C&&(g&&e(";"),e(C),g=!0),await _()}return g}async function D(u,v){if(v>20)throw Error("CSS nesting budget");for(let g of u){if(await _(),++U.count>S.maxCssRules)throw Error("CSS rule budget");let p=g.constructor.name;if(p==="CSSImportRule"){let n=g;if(!n.styleSheet){a.add("CSS_EXTERNAL_RULE_OMITTED");continue}let d=n,R=[d.layerName!==null&&d.layerName!==void 0?"@layer "+d.layerName:null,d.supportsText?"@supports "+d.supportsText:null,n.media?.mediaText?"@media "+n.media.mediaText:null].filter(G=>G!==null),C=R.map(T);if(C.some(G=>!G)){a.add("CSS_GROUP_UNSUPPORTED");continue}C.forEach(e),await k(n.styleSheet,v+1),C.forEach(()=>e("}"))}else if(p==="CSSKeyframesRule"){let n=g,d=T("@keyframes "+n.name);if(!d){a.add("CSS_GROUP_UNSUPPORTED");continue}e(d);for(let R of n.cssRules){if(++U.count>S.maxCssRules)throw Error("CSS rule budget");let C=R,G=C.keyText.replace(/\s/g,"");if(!/^(?:(?:from|to|\d+(?:\.\d+)?%)(?:,|$))+$/.test(G)){a.add("CSS_GROUP_UNSUPPORTED");continue}e(G+"{"),await h(C.style),e("}"),await _()}e("}")}else{let n=g,d="cssRules"in g?n.cssRules:null,R=null;if(p==="CSSLayerBlockRule"?R="@layer "+(n.name??""):p==="CSSMediaRule"?R="@media "+n.conditionText:p==="CSSSupportsRule"?R="@supports "+n.conditionText:p==="CSSContainerRule"?R="@container "+n.conditionText:p==="CSSStartingStyleRule"?R="@starting-style":p==="CSSStyleRule"&&(R=n.selectorText??null),R!==null&&(d||p==="CSSStyleRule")){let C=T(R);if(!C){a.add("CSS_GROUP_UNSUPPORTED");continue}e(C),p==="CSSStyleRule"&&n.style&&await h(n.style)&&d?.length&&e(";"),d&&await D(d,v+1),e("}")}else if(d?.length)a.add("CSS_GROUP_UNSUPPORTED");else{let C=g.cssText;if(C.length>32768)throw Error("Atomic CSS budget");e(r(C))}}await _()}}async function k(u,v){if(u.disabled){a.add("DISABLED_STYLESHEET_OMITTED");return}if(f.has(u)){a.add("CSS_IMPORT_CYCLE");return}let g;try{g=u.cssRules}catch{a.add("CROSS_ORIGIN_STYLESHEET");return}f.add(u);let p=o;o=u.href||o;try{let n=u.media?.mediaText,d=n&&n!=="all"?T("@media "+n):"";if(n&&n!=="all"&&!d){a.add("CSS_GROUP_UNSUPPORTED");return}d&&e(d),await D(g,v),d&&e("}")}finally{o=p,f.delete(u)}}await k(c,0)}var i=class extends Error{constructor(o,e){super(o);this.code=o;this.metrics=e}code;metrics},z=()=>performance.now(),je=new URL(import.meta.url).pathname.match(/^\/web-view\/visual-sdk\/([a-f0-9]{64})\//)?.[1],nt=async c=>[...new Uint8Array(await crypto.subtle.digest("SHA-256",c))].map(l=>l.toString(16).padStart(2,"0")).join("");async function Je(c){let{document:l,policy:o,signal:e}=c,a=l.defaultView;if(!he.safeParse(c.label).success)throw new i("PRIVATE_OR_INVALID_LABEL");if(!a||l.hidden||a.location.origin!==o.origin||!l.documentElement.getAttribute("data-indiana-release")?.split(/\s+/).includes(o.manifestDigest))throw new i("SCOPE_OR_VISIBILITY");let _=Ye(o.routes,a.location.pathname);if(!_)throw new i("ROUTE_NOT_ALLOWED");for(let P of[...o.publicSelectors,...o.blockedSelectors])l.querySelector(P);let U=a.location.href,y=z(),f=new Set,r=[],T=[],h=z(),D=0,k=0,u=0,v=0,g="dom",p=()=>{if(e.throwIfAborted(),l.hidden||c.changed()||a.location.origin!==o.origin||a.location.href!==U||!l.documentElement.getAttribute("data-indiana-release")?.split(/\s+/).includes(o.manifestDigest))throw new i("UNSTABLE");if(z()-y>S.deadlineMs)throw new i("DEADLINE")};async function n(P=!1){let M=z()-h;if(!(!P&&M<S.sliceMs)){if(D=Math.max(D,M),k+=M,M>S.maxSliceMs)throw new i("SLICE_BUDGET",{maxSliceMs:D,totalWorkMs:k,elapsedMs:z()-y,phase:g});p(),await new Promise((V,ne)=>{let X=()=>{clearTimeout(re),ne(new i("ABORTED"))},re=setTimeout(()=>{e.removeEventListener("abort",X),V()},0);e.addEventListener("abort",X,{once:!0})}),h=z(),p()}}let d=[{node:l.documentElement,parent:null,depth:0,shadow:!1}],R=[],C=new Map,G=new WeakMap,$=new Map,B=new Map,Q=[],ee=l.adoptedStyleSheets??[];if(l.styleSheets.length+ee.length>S.maxStyleSheets)throw new i("STYLESHEET_BUDGET");function Y(P,M){let V=B.get(M);if(!V?.has(P)){if(R.length>=S.maxStyleSheets)throw new i("STYLESHEET_BUDGET");V||(V=new Set,B.set(M,V)),V.add(P),R.push({sheet:P,hostId:M})}}try{for(;d.length;){await n(),p();let b=d.pop(),E=b.node;if(r.length>=S.maxNodes||b.depth>S.maxDepth)throw new i("NODE_BUDGET");if(E.nodeType!==1&&E.nodeType!==3)continue;let t=E.nodeType===1?E:null;if(me(E))continue;if(t&&(t.tagName==="STYLE"||t.tagName==="LINK")){if(pe(t,o)){f.add("PRIVATE_STYLESHEET_OMITTED");continue}let m=t.sheet;if(m){let N=t.getRootNode(),W=N instanceof a.ShadowRoot?G.get(N):null;W===void 0?f.add("STYLESHEET_SCOPE_UNKNOWN"):($.set(m,W),Y(m,W))}continue}if(t&&ve.has(t.tagName.toLowerCase())){["IFRAME","CANVAS","IMG","PICTURE","VIDEO","AUDIO","OBJECT","EMBED"].includes(t.tagName)&&f.add("NON_DOM_OR_EXTERNAL_OMITTED");continue}if(t){let m=t.getAttributeNames();if(m.length>S.maxAttributes)throw new i("ATTRIBUTE_BUDGET");let N=0;for(let W of m){let oe=t.getAttribute(W)??"";if(N+=oe.length,oe.length>S.maxText||N>8192)throw new i("ATTRIBUTE_BUDGET")}}else if((E.nodeValue?.length??0)>S.maxText)throw new i("TEXT_BUDGET");let H=t&&pe(t,o);if(H&&!["INPUT","TEXTAREA","SELECT"].includes(t.tagName)){f.add("PRIVATE_SUBTREE_OMITTED");continue}let A=t?Me(t,o):{};if(t&&["fill","stroke"].some(m=>/url\s*\(/i.test(t.getAttribute(m)??"")&&!A[m])&&f.add("SVG_RESOURCE_OMITTED"),t?.hasAttribute("data-indiana-id")&&!A["data-indiana-id"]&&f.add("UNKNOWN_ANCHOR_OMITTED"),t?.tagName==="IMG"){let m=Ue(t.getAttribute("src")||"",l.baseURI,o.assetPaths);m?A["data-indiana-asset"]=m:f.add("UNKNOWN_IMAGE_OMITTED")}if(t?.tagName==="DIALOG"&&t.open)try{A.rr_open_mode=t.matches("dialog:modal")?"modal":"non-modal"}catch{A.rr_open_mode="non-modal"}if(A.style){let m=we(A.style,o.assetPaths,!0,l.baseURI,o.privacy,o.origin);A.style=m.css,m.gaps.forEach(N=>f.add(N))}let I=r.length,F={id:I,parentId:b.parent,kind:t?"element":"text",tag:t?.tagName.toLowerCase()??null,text:t?null:De(E.nodeValue??"",E.parentElement,o),attributes:A,shadow:b.shadow};if(u+=new TextEncoder().encode(JSON.stringify(F)).length,u>S.maxBytes-S.maxCssBytes-4096)throw new i("BYTE_BUDGET");if(r.push(F),t&&Q.push({element:t,id:I}),t&&!H){if(r.length+d.length+t.childNodes.length+(t.shadowRoot?.childNodes.length??0)>S.maxNodes)throw new i("NODE_BUDGET");if(t.shadowRoot){if(C.size>=128)throw new i("SHADOW_BUDGET");c.onShadowRoot?.(t.shadowRoot),C.set(I,[]),G.set(t.shadowRoot,I);let m=t.shadowRoot.adoptedStyleSheets??[];if(m.length>S.maxStyleSheets)throw new i("STYLESHEET_BUDGET");for(let N of m)Y(N,I);for(let N=t.shadowRoot.childNodes.length-1;N>=0;N--)d.push({node:t.shadowRoot.childNodes[N],parent:I,depth:b.depth+1,shadow:!0})}for(let m=E.childNodes.length-1;m>=0;m--)d.push({node:E.childNodes[m],parent:I,depth:b.depth+1,shadow:!1})}}await n(!0),g="css";for(let b of l.styleSheets){await n();let E=b.ownerNode;if(E instanceof a.Element&&pe(E,o)){f.add("PRIVATE_STYLESHEET_OMITTED");continue}$.has(b)?Y(b,$.get(b)):E&&E.getRootNode()===l?Y(b,null):f.add("STYLESHEET_OWNER_UNKNOWN")}for(let b of ee)Y(b,null);let P={count:0},M=l.createElement("span").style;for(let{sheet:b,hostId:E}of R)p(),await Ke(b,o,l.baseURI,t=>{if(v+=new TextEncoder().encode(t).length,v>S.maxCssBytes)throw new i("CSS_BUDGET");(E===null?T:C.get(E)).push(t)},f,()=>n(),P,M);await n(!0),g="scroll",await new Promise((b,E)=>{let t=0,H,A=!1,I=N=>{A||(A=!0,a.cancelAnimationFrame(t),clearTimeout(H),clearTimeout(m),e.removeEventListener("abort",F),N?E(N):b())},F=()=>I(new i("ABORTED"));e.addEventListener("abort",F,{once:!0}),t=a.requestAnimationFrame(()=>{H=setTimeout(()=>I(),0)});let m=setTimeout(()=>I(new i("FRAME_UNAVAILABLE")),250);e.aborted&&F()}),h=z(),p();for(let{element:b,id:E}of Q){for(let[t,H]of[["scrollLeft","rr_scrollLeft"],["scrollTop","rr_scrollTop"]]){let A=b[t];if(!Number.isFinite(A)||Math.abs(A)>1e7)throw new i("SCROLL_BUDGET");A&&(r[E].attributes[H]=String(A))}if(Object.keys(r[E].attributes).length>S.maxAttributes)throw new i("ATTRIBUTE_BUDGET");await n()}await n(!0),g="hash",xe(r),await n(!0),p();let V={nodes:r,css:T.join(""),shadowCss:[...C].map(([b,E])=>({hostId:b,css:E.join("")})),scroll:{x:Math.max(0,a.scrollX),y:Math.max(0,a.scrollY)}},ne={width:Math.max(100,a.innerWidth),height:Math.max(100,a.innerHeight),dpr:a.devicePixelRatio},X={sourceVersionId:o.sourceVersionId,manifestDigest:o.manifestDigest,pageKey:_.pageKey,viewport:ne,document:V,privacy:o.privacy},re=await Se(Ve(X),n),le=new TextEncoder().encode(re);await n(!0);let ue=await nt(le);return h=z(),p(),{format:"indiana-runtime-snapshot",schemaVersion:1,collector:{name:"indiana-bounded-dom",version:2,...je?{buildSha256:je}:{}},...X,routeTemplate:_.path,sequence:c.sequence,label:c.label,contentHash:ue,previousContentHash:c.previousContentHash,gaps:[...f].slice(0,32),metrics:{maxSliceMs:D,totalWorkMs:k,elapsedMs:z()-y}}}catch(P){throw P instanceof i||e.aborted?P:new i(g==="css"?"CSS_UNSUPPORTED":"SERIALIZATION_UNSUPPORTED",{maxSliceMs:D,totalWorkMs:k,elapsedMs:z()-y,phase:g})}finally{Q.length=0,d.length=0,R.length=0}}var ze=1081344,Re=16*1024;function be(c,l,o){return Fe(c,l,o,{message:"CAPTURE_SERVICE_RESPONSE"})}async function Ut(c){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(c.environmentId))throw Error("Invalid capture environment");let l=c.document??document,o=l.defaultView;if(!o)throw Error("Capture requires a window");let e=o;if(!e.navigator.onLine)throw new i("OFFLINE");let a=c.grant,_=c.onStatus,U=c.transport,y=new URL(c.baseUrl);if(y.pathname!=="/"||y.search||y.hash||y.username||y.password||!Ce(y.origin))throw Error("Invalid capture service origin");let f=new AbortController,r=c.signal?AbortSignal.any([f.signal,c.signal]):f.signal;r.throwIfAborted();let T=y.origin+"/api/app-manifest-captures",h=async s=>{let O=AbortSignal.any([r,AbortSignal.timeout(45e3)]),L=await fetch(T,{method:"POST",credentials:"omit",redirect:"error",cache:"no-store",headers:{Authorization:"Bearer "+a,[se]:ie,"Content-Type":"application/json"},body:JSON.stringify(s),signal:O});if(!L.ok)throw L.body?.cancel().catch(()=>{}),new i("AUTH_OR_SERVICE_"+L.status);if(L.headers.get(se)!==ie)throw L.body?.cancel().catch(()=>{}),new i("CAPTURE_VERSION_MISMATCH");try{return await be(L,s.action==="policy"?ze:Re,O)}catch{throw new i("SERVICE_RESPONSE_INVALID")}},D=performance.now(),k;try{k=ke.parse(await h({action:"policy"}))}catch(s){throw s instanceof i?s:new i("SERVICE_RESPONSE_INVALID")}let{policy:u,progress:v}=k,g=Math.min(k.expiresAt-k.serverTime,9e5)-(performance.now()-D),p=Date.now()+g;if(u.environmentId!==c.environmentId)throw Error("Foreign capture environment");if(g<=0||u.origin!==e.location.origin||!Ce(u.origin))throw Error("Capture authorization expired or foreign origin");let n=0,d=v.sequence,R=v.readyCount,C=v.lastContentHash,G=-1/0,$=!0,B=!1,Q=!1,ee=!1,Y=!1,P=!1,M=!1,V=0,ne=-1/0,X=!1,re=performance.now(),le=performance.now(),ue=e.location.href,de="initial",b=!1,E=!1,t=null,H=null,A=null,I=(s,O,L)=>{try{_?.({state:s,reason:O,snapshots:R,expiresAt:p,pending:+!!t+ +!!H,...L?{metrics:L}:{}})}catch{}},F=()=>{B||M||(M=!0,Y=!0,P=!0,A?.abort(),I("paused","OFFLINE"))};e.addEventListener("offline",F);let m=(s=!1)=>{$=!0,n++,re=performance.now(),s===!0&&(b=!0)},N=new e.MutationObserver(s=>{let O=["[data-indiana-private]","[data-private]",...u.blockedSelectors].join(","),L=!1,Z=!1;for(let w of s.slice(0,16)){if(w.type==="childList"){let K=w.addedNodes.length+w.removedNodes.length;if(K>0&&K<=8&&[...w.addedNodes,...w.removedNodes].every(me))continue}let x=w.target.nodeType===1?w.target:w.target.parentElement;x&&Le(x,O)||(L=!0,(x?.tagName==="DIALOG"||["dialog","menu","listbox","tooltip"].includes(x?.getAttribute("role")??""))&&(Z=!0))}(s.length>16||L)&&m(Z)}),W=new Set,oe=s=>{W.has(s)||(N.observe(s,{childList:!0,attributes:!0,characterData:!0,subtree:!0}),W.add(s))};oe(l);let _e=s=>{let O=s.target instanceof e.Element&&s.target.closest('input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]),textarea,[contenteditable="true"],[contenteditable=""]');O&&["input","beforeinput","compositionend"].includes(s.type)&&(ne=performance.now()),O&&s.type==="compositionstart"&&(X=!0),(s.type==="compositionend"||s.type==="focusout")&&(X=!1),m(s.type==="click"||s.type==="change")},Ae=["input","beforeinput","compositionstart","compositionend","change","click","focusout","popstate","hashchange","resize","scroll","visibilitychange"],Ie=new Set(["input","beforeinput","compositionstart","compositionend","change","click","focusout","scroll","visibilitychange"]);for(let s of Ae)(Ie.has(s)?l:e).addEventListener(s,_e,{capture:!0,passive:!0});let Xe=U??(async(s,O,L,Z)=>{let w=[...new Uint8Array(await crypto.subtle.digest("SHA-256",O))].map(Te=>Te.toString(16).padStart(2,"0")).join(""),x=Be.parse(await h({action:"register",requestId:Z,sha256:w,bytes:O.byteLength,pageKey:s.pageKey,sequence:s.sequence,contentHash:s.contentHash}));if(x.ready)return;let K=new URL(T+"/"+x.versionId+"/content"),q=AbortSignal.any([L,AbortSignal.timeout(9e4)]),j=await fetch(K,{method:"PUT",body:O,headers:{Authorization:"Bearer "+a,[se]:ie,"Content-Type":"application/json"},credentials:"omit",redirect:"error",signal:q});if(!j.ok)throw j.body?.cancel().catch(()=>{}),new i("UPLOAD_"+j.status);if(j.headers.get(se)!==ie)throw j.body?.cancel().catch(()=>{}),new i("CAPTURE_VERSION_MISMATCH");if(He.parse(await be(j,Re,q)).versionId!==x.versionId)throw new i("SERVICE_RESPONSE_INVALID")}),$e=e.setInterval(()=>{Ze()},250),Qe=e.setTimeout(()=>te("EXPIRED"),Math.min(p-Date.now(),9e5));async function ae(){if(B||ee||P)return;if(H||(H=t,t=null),!H){d>=S.maxSnapshots&&!Q&&te("QUOTA");return}ee=!0;let s=H;I("uploading",void 0,s.metrics);try{if(await Xe(s.snapshot,s.bytes,r,s.requestId),B)return;R++,H=null,E=!1,I(M?"paused":"idle",M?"OFFLINE":void 0)}catch(O){if(B)return;let L=O instanceof i?O.code:"UPLOAD_FAILED";if(L==="CAPTURE_VERSION_MISMATCH"||/^(?:AUTH_OR_SERVICE|UPLOAD)_426$/.test(L)){te("CAPTURE_UPGRADE_REQUIRED");return}if(/^(?:AUTH_OR_SERVICE|UPLOAD)_(?:401|403|409)$/.test(L)){te("REVOKED_OR_CHANGED");return}P=!0,I("paused",M?"OFFLINE":L)}finally{ee=!1,!B&&!P&&ae()}}async function Ze(){if(B||Q||r.aborted)return;if(!e.navigator.onLine){F();return}if(e.location.href!==ue&&(ue=e.location.href,de="navigation",Y=!1,V=0,m(!0)),Y||P)return;let s=!1;for(let w of W)w instanceof e.ShadowRoot&&!w.host.isConnected&&(W.delete(w),s=!0);if(s){N.takeRecords().length&&m(),N.disconnect();for(let w of W)N.observe(w,{childList:!0,attributes:!0,characterData:!0,subtree:!0})}if(d>=S.maxSnapshots){ae();return}if(performance.now()-le>15e3&&(le=performance.now(),m()),!$||l.hidden||!e.navigator.onLine||performance.now()-re<S.quietMs||performance.now()-G<(b?S.urgentIntervalMs:S.minIntervalMs)||X||performance.now()-ne<1e3)return;if(t&&H){E||(E=!0,I("waiting","UPLOAD_BACKPRESSURE"));return}Q=!0;let O=n,L=de;b=!1,A=new AbortController;let Z=AbortSignal.any([r,A.signal]);I("capturing");try{let w=await Je({document:l,policy:u,sequence:d+1,label:L,previousContentHash:C,signal:Z,changed:()=>n!==O,onShadowRoot:oe});if(B)return;if(w.contentHash===C){$=n!==O,I(ee?"uploading":"idle");return}let x=performance.now(),K=0,q=0,j=x,ge=async()=>{let fe=performance.now()-x;if(fe>=S.sliceMs){if(K+=fe,q=Math.max(q,fe),fe>S.maxSliceMs)throw new i("ENCODING_BUDGET",{maxSliceMs:q,totalWorkMs:K,elapsedMs:performance.now()-j,phase:"encoding"});await new Promise(et=>setTimeout(et,0)),Z.throwIfAborted(),x=performance.now()}},Te=await Se(w,ge),ye=await We(Te,S.maxBytes,ge);if(!ye)throw new i("BYTE_BUDGET");let Ne=performance.now()-x;if(K+=Ne,q=Math.max(q,Ne),q>S.maxSliceMs)throw new i("ENCODING_BUDGET",{maxSliceMs:q,totalWorkMs:K,elapsedMs:performance.now()-j,phase:"encoding"});if(ye.length>S.maxBytes)throw new i("BYTE_BUDGET");Z.throwIfAborted(),t={snapshot:w,bytes:ye,requestId:crypto.randomUUID(),metrics:{maxSliceMs:Math.max(w.metrics.maxSliceMs,q),totalWorkMs:w.metrics.totalWorkMs+K,elapsedMs:w.metrics.elapsedMs+performance.now()-j,phase:"capture-and-encoding"}},d=w.sequence,C=w.contentHash,G=performance.now(),$=n!==O,V=0,E=!1,ae()}catch(w){if(B)return;let x=w instanceof i?w.code:"CAPTURE_FAILED";G=performance.now(),["UNSTABLE","ROUTE_NOT_ALLOWED","SCOPE_OR_VISIBILITY"].includes(x)&&++V<3?I("idle",x):(Y=!0,I("paused",M?"OFFLINE":x,w instanceof i?w.metrics:void 0))}finally{Q=!1,A=null}}function te(s="DESTROYED"){if(!B){B=!0,r.removeEventListener("abort",Oe),f.abort(),A?.abort(),N.disconnect(),W.clear(),t=null,H=null,a="",e.clearInterval($e),e.clearTimeout(Qe),e.removeEventListener("offline",F);for(let O of Ae)(Ie.has(O)?l:e).removeEventListener(O,_e,!0);I("stopped",s)}}let Oe=()=>te("ABORTED");return r.addEventListener("abort",Oe,{once:!0}),r.aborted&&te("ABORTED"),B||(e.navigator.onLine?I("idle"):F()),{checkpoint(s="checkpoint"){if(!B){if(!he.safeParse(s).success)throw Error("Invalid checkpoint label");if(de=s,!e.navigator.onLine){F();return}M=!1,Y=!1,P=!1,V=0,m(!0),ae()}},retry(){if(!B){if(!e.navigator.onLine){F();return}M=!1,Y=!1,P=!1,V=0,ae()}},destroy:te,get paused(){return Y||P},get snapshots(){return R}}}export{Ut as startCapture};
@@ -1,11 +1,11 @@
1
1
  import { z } from 'zod';
2
- import { S as StackNode } from './screen-BbLE1OMn.js';
2
+ import { S as StackNode } from './screen-16d-xADb.js';
3
3
 
4
4
  declare const configurationScopeSchema: z.ZodObject<{
5
5
  projectId: z.ZodString;
6
6
  environment: z.ZodEnum<{
7
- live: "live";
8
7
  sandbox: "sandbox";
8
+ live: "live";
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
- live: "live";
19
18
  sandbox: "sandbox";
19
+ live: "live";
20
20
  }>;
21
21
  environmentId: z.ZodUUID;
22
22
  }, z.core.$strict>;
@@ -90,7 +90,7 @@ type Listener = () => void;
90
90
  declare function createConfigurationSync(options: ConfigurationSyncOptions): {
91
91
  scope: Readonly<{
92
92
  projectId: string;
93
- environment: "live" | "sandbox";
93
+ environment: "sandbox" | "live";
94
94
  environmentId: string;
95
95
  }>;
96
96
  refresh: () => Promise<Manifest>;
@@ -103,7 +103,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
103
103
  schemaVersion: 1;
104
104
  scope: {
105
105
  projectId: string;
106
- environment: "live" | "sandbox";
106
+ environment: "sandbox" | "live";
107
107
  environmentId: string;
108
108
  };
109
109
  revision: number;
@@ -146,6 +146,10 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
146
146
  features(): Promise<{
147
147
  evaluatedAt: string;
148
148
  expiresAt: string;
149
+ scope: {
150
+ projectId: string;
151
+ environment: "sandbox" | "live";
152
+ };
149
153
  features: Record<string, {
150
154
  defaultValue?: z.core.util.JSONType | undefined;
151
155
  rules?: {
@@ -242,10 +246,6 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
242
246
  phase?: string | undefined;
243
247
  }[] | undefined;
244
248
  }>;
245
- scope: {
246
- projectId: string;
247
- environment: "live" | "sandbox";
248
- };
249
249
  generation: string;
250
250
  savedGroups: Record<string, {
251
251
  type: "hashed";
@@ -318,41 +318,41 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
318
318
  urlRedirect: string;
319
319
  }[];
320
320
  name?: string | undefined;
321
- meta?: {
322
- key?: string | undefined;
323
- name?: string | undefined;
324
- passthrough?: boolean | undefined;
325
- }[] | undefined;
326
- filters?: {
327
- seed: string;
328
- hashVersion: 2;
329
- ranges: [number, number][];
330
- attribute?: string | undefined;
331
- }[] | undefined;
321
+ coverage?: number | undefined;
322
+ condition?: Record<string, z.core.util.JSONType> | undefined;
332
323
  seed?: string | undefined;
333
324
  hashVersion?: 2 | undefined;
334
325
  ranges?: [number, number][] | undefined;
335
- condition?: Record<string, z.core.util.JSONType> | undefined;
326
+ force?: number | undefined;
336
327
  urlPatterns?: {
337
328
  include: boolean;
338
329
  type: "regex" | "simple";
339
330
  pattern: string;
340
331
  }[] | undefined;
341
- force?: number | undefined;
342
332
  persistQueryString?: boolean | undefined;
343
333
  hashAttribute?: string | undefined;
334
+ phase?: string | undefined;
335
+ filters?: {
336
+ seed: string;
337
+ hashVersion: 2;
338
+ ranges: [number, number][];
339
+ attribute?: string | undefined;
340
+ }[] | undefined;
344
341
  parentConditions?: {
345
342
  id: string;
346
343
  condition: Record<string, z.core.util.JSONType>;
347
344
  gate?: boolean | undefined;
348
345
  }[] | undefined;
349
346
  weights?: number[] | undefined;
350
- coverage?: number | undefined;
351
347
  fallbackAttribute?: string | undefined;
352
348
  disableStickyBucketing?: boolean | undefined;
353
349
  bucketVersion?: number | undefined;
354
350
  minBucketVersion?: number | undefined;
355
- phase?: string | undefined;
351
+ meta?: {
352
+ key?: string | undefined;
353
+ name?: string | undefined;
354
+ passthrough?: boolean | undefined;
355
+ }[] | undefined;
356
356
  }[];
357
357
  savedGroups: Record<string, {
358
358
  type: "hashed";
@@ -584,7 +584,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
584
584
  event: string;
585
585
  } | {
586
586
  type: "api";
587
- operation: "update" | "attach" | "refund" | "readBalanceSource" | "adjustBalance" | "readUsage" | "setUsage" | "manageBalanceGrant" | "listBalanceGrants" | "restoreNativePurchase" | "setupPayment" | "readPaymentSetup" | "verifySubscriptions" | "previewAttach" | "readSubscriptionOperation" | "previewUpdate" | "readSubscriptionUpdate" | "previewRefund" | "readRefund" | "readBillingControls" | "prepareBillingAuthorization" | "confirmBillingAuthorization" | "setBillingCoupons" | "revokeBillingAuthorization" | "listBillingInvoices" | "confirmBillingAdjustment" | "manageBillingLimits" | "manageUsageEntity" | "readUsageAnalytics" | "readCreditAnalytics" | "submitUsageBatch" | "readUsageBatch" | "checkEntitlement" | "resolveOffering" | "readHoldings" | "readLedger" | "readBillingInvoice" | "readCreditStatement" | "quoteBalance" | "trackUsage" | "mutateBalance" | "redeemReward" | "createReferralCode" | "claimRewardProduct" | "readSeats" | "manageSeat" | "redeemCoupon" | "listOffers" | "grantOffer";
587
+ operation: "update" | "refund" | "setupPayment" | "readBalanceSource" | "adjustBalance" | "readUsage" | "setUsage" | "manageBalanceGrant" | "listBalanceGrants" | "restoreNativePurchase" | "readPaymentSetup" | "verifySubscriptions" | "previewAttach" | "attach" | "readSubscriptionOperation" | "previewUpdate" | "readSubscriptionUpdate" | "previewRefund" | "readRefund" | "readBillingControls" | "prepareBillingAuthorization" | "confirmBillingAuthorization" | "setBillingCoupons" | "revokeBillingAuthorization" | "listBillingInvoices" | "confirmBillingAdjustment" | "manageBillingLimits" | "manageUsageEntity" | "readUsageAnalytics" | "readCreditAnalytics" | "submitUsageBatch" | "readUsageBatch" | "checkEntitlement" | "resolveOffering" | "readHoldings" | "readLedger" | "readBillingInvoice" | "readCreditStatement" | "quoteBalance" | "trackUsage" | "mutateBalance" | "redeemReward" | "createReferralCode" | "claimRewardProduct" | "readSeats" | "manageSeat" | "redeemCoupon" | "listOffers" | "grantOffer";
588
588
  inputs: Record<string, {
589
589
  source: "literal";
590
590
  value: z.core.util.JSONType;
@@ -621,13 +621,31 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
621
621
  failed: string;
622
622
  id: string;
623
623
  name: string;
624
+ appManifest?: {
625
+ versionId: string;
626
+ manifestDigest: string;
627
+ sourceGraphDigest: string;
628
+ pageKey: string;
629
+ stateKey: string;
630
+ documentKey: string;
631
+ documentHash: string;
632
+ elementKey?: string | undefined;
633
+ nodeId?: string | undefined;
634
+ contentHash?: string | undefined;
635
+ renderKey?: string | undefined;
636
+ observed?: {
637
+ versionId: string;
638
+ sha256: string;
639
+ contentHash: string;
640
+ } | undefined;
641
+ } | undefined;
624
642
  position?: {
625
643
  x: number;
626
644
  y: number;
627
645
  } | undefined;
628
646
  } | {
629
647
  type: "end";
630
- outcome: "closed" | "failed" | "completed" | "ineligible";
648
+ outcome: "failed" | "completed" | "closed" | "ineligible";
631
649
  id: string;
632
650
  name: string;
633
651
  output?: {
@@ -692,7 +710,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
692
710
  primary: string;
693
711
  background: string;
694
712
  text: string;
695
- radius: "sm" | "md" | "lg" | "none" | "full";
713
+ radius: "none" | "full" | "sm" | "md" | "lg";
696
714
  font: "system" | "serif" | "rounded" | "mono";
697
715
  };
698
716
  pages: {
@@ -703,7 +721,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
703
721
  primary: string;
704
722
  background: string;
705
723
  text: string;
706
- radius: "sm" | "md" | "lg" | "none" | "full";
724
+ radius: "none" | "full" | "sm" | "md" | "lg";
707
725
  font: "system" | "serif" | "rounded" | "mono";
708
726
  } | undefined;
709
727
  editorPosition?: {
@@ -753,20 +771,20 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
753
771
  };
754
772
  publicData?: {
755
773
  couponDigests: Record<string, string>;
756
- 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>>>>;
774
+ 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>>>>;
757
775
  locales: Record<string, {
776
+ plans: Record<string, never>;
758
777
  nodes: Record<string, {
759
778
  base: {
760
- text?: string | undefined;
779
+ couponId?: string | undefined;
761
780
  label?: string | undefined;
781
+ text?: string | undefined;
762
782
  alt?: string | undefined;
763
783
  html?: string | undefined;
764
784
  countdownAt?: string | undefined;
765
- couponId?: string | undefined;
766
785
  missing?: string[] | undefined;
767
786
  };
768
787
  }>;
769
- plans: Record<string, never>;
770
788
  pickers: Record<string, never>;
771
789
  diagnostics: {
772
790
  nodeId: string;
@@ -846,6 +864,10 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
846
864
  growth: {
847
865
  evaluatedAt: string;
848
866
  expiresAt: string;
867
+ scope: {
868
+ projectId: string;
869
+ environment: "sandbox" | "live";
870
+ };
849
871
  features: Record<string, {
850
872
  defaultValue?: z.core.util.JSONType | undefined;
851
873
  rules?: {
@@ -942,10 +964,6 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
942
964
  phase?: string | undefined;
943
965
  }[] | undefined;
944
966
  }>;
945
- scope: {
946
- projectId: string;
947
- environment: "live" | "sandbox";
948
- };
949
967
  generation: string;
950
968
  savedGroups: Record<string, {
951
969
  type: "hashed";
@@ -1030,7 +1048,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
1030
1048
  schemaVersion: 1;
1031
1049
  scope: {
1032
1050
  projectId: string;
1033
- environment: "live" | "sandbox";
1051
+ environment: "sandbox" | "live";
1034
1052
  environmentId: string;
1035
1053
  };
1036
1054
  revision: number;
@@ -1075,7 +1093,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
1075
1093
  growth: {
1076
1094
  scope: {
1077
1095
  projectId: string;
1078
- environment: "live" | "sandbox";
1096
+ environment: "sandbox" | "live";
1079
1097
  };
1080
1098
  generation: string;
1081
1099
  evaluatedAt: string;
@@ -1236,7 +1254,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
1236
1254
  }[]>;
1237
1255
  scope: {
1238
1256
  projectId: string;
1239
- environment: "live" | "sandbox";
1257
+ environment: "sandbox" | "live";
1240
1258
  };
1241
1259
  funnelId: string;
1242
1260
  versionId: string;
@@ -1246,7 +1264,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
1246
1264
  entry: string;
1247
1265
  nodes: {
1248
1266
  id: string;
1249
- type: "output" | "action" | "screen" | "end" | "coupon" | "feature" | "split" | "condition" | "offering" | "coupons" | "entry" | "external_page" | "wait";
1267
+ type: "output" | "action" | "condition" | "split" | "end" | "coupon" | "coupons" | "screen" | "offering" | "feature" | "entry" | "external_page" | "wait";
1250
1268
  outputs: Record<string, string>;
1251
1269
  writes: Record<string, string>;
1252
1270
  resources: {
@@ -1291,7 +1309,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
1291
1309
  } | undefined;
1292
1310
  };
1293
1311
  terminals: Record<string, {
1294
- outcome: "closed" | "failed" | "completed" | "ineligible";
1312
+ outcome: "failed" | "completed" | "closed" | "ineligible";
1295
1313
  output: {
1296
1314
  type: "literal";
1297
1315
  value: z.core.util.JSONType;