palbase 0.61.0 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/index.js +2 -2
- package/dist/backend/engine.js +2 -2
- package/dist/backend/env.js +1 -1
- package/dist/backend/index.js +3 -3
- package/dist/backend/stack.js +1 -1
- package/dist/backend/test.js +2 -2
- package/dist/chunks/{NBDKXPPN.js → 5KIV2VHK.js} +2 -2
- package/dist/chunks/{WC3HNBTW.js → 5TXSFJYI.js} +2 -2
- package/dist/chunks/{F22F2L2Y.js → 7YRDXDVI.js} +2 -2
- package/dist/chunks/BP35TQMR.js +2 -0
- package/dist/chunks/{LFOLUSP4.js → BVR7H5RY.js} +1 -1
- package/dist/chunks/{XJE4UFKJ.js → COXA3LDU.js} +2 -2
- package/dist/chunks/{7ZUKYVMV.js → EJ7YD4YY.js} +1 -1
- package/dist/chunks/{RVBACOBJ.js → G4UNJNUL.js} +1 -1
- package/dist/chunks/{7VU43S76.js → IX4TWJ7J.js} +2 -2
- package/dist/chunks/{S7PQBQCI.js → IXFSQYJA.js} +2 -2
- package/dist/chunks/{6LLKAYLP.js → KGP3V3IA.js} +2 -2
- package/dist/chunks/{65C5W5GP.js → LGGBVI33.js} +2 -2
- package/dist/chunks/{AT63XMI4.js → RFRPB2IR.js} +1 -1
- package/dist/chunks/{COTQ6G5D.js → SWB2U22R.js} +2 -2
- package/dist/chunks/{36K6MLUX.js → T74PPGHJ.js} +2 -2
- package/dist/chunks/{IFR7ST2U.js → UDS4W77D.js} +1 -1
- package/dist/chunks/{XJQRIKMU.js → VHTT6VB5.js} +7 -7
- package/dist/chunks/{KBEH23G5.js → WUQWOSEI.js} +2 -2
- package/dist/chunks/{GVELS2KG.js → WXOQLEUW.js} +2 -2
- package/dist/chunks/{LSFTUWIC.js → XHTUT6AV.js} +2 -2
- package/dist/chunks/{CSV7LE7C.js → XPKA7LAF.js} +2 -2
- package/dist/chunks/{UW73ZLTE.js → YWG7F44Q.js} +1 -1
- package/dist/chunks/{DYW4ZAHJ.js → ZG2LQB5B.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/cloud/index.js +2 -2
- package/dist/refuse/ai.js +1 -1
- package/dist/refuse/backend.js +1 -1
- package/dist/refuse/cloud.js +1 -1
- package/dist/refuse/server.js +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/testing.js +2 -2
- package/dist/web/index.js +2 -2
- package/dist/web/message.js +2 -2
- package/dist/web/palbe.js +2 -2
- package/dist/web/paywall.js +2 -2
- package/dist/web/push-sw.js +1 -1
- package/dist/web/ssr.js +2 -2
- package/dist/web/vite.js +2 -2
- package/package.json +2 -2
- package/types/backend/src/runtime.d.ts +7 -4
- package/types/cloud/src/generated/studio.d.ts +67 -8
- package/types/internal/src/modules/ai.d.ts +1 -1
- package/types/internal/src/modules/analytics.d.ts +7 -7
- package/types/internal/src/modules/auth.d.ts +41 -30
- package/types/internal/src/modules/notify.d.ts +1 -1
- package/types/internal/src/modules/purchases.d.ts +19 -7
- package/types/internal/src/modules/stores.d.ts +3 -3
- package/types/web/src/screen/resolve.d.ts +2 -1
- package/dist/chunks/GGJDR6XK.js +0 -2
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/*! palbase 0.
|
|
2
|
+
/*! palbase 0.63.0 — Palbase SDK License (see LICENSE) */
|
|
3
3
|
var $$=Object.defineProperty;var Dt=(e,t)=>{for(var n in t)$$(e,n,{get:t[n],enumerable:!0})};import{parseArgs as ik}from"node:util";var k$=Symbol.for("palbase.data"),S$=globalThis,iu=S$[k$]??=new WeakSet;function A$(e){return e instanceof Date||ArrayBuffer.isView(e)||e instanceof ArrayBuffer}function Tr(e){let t=[e];for(;t.length>0;){let n=t.pop();if(!(typeof n!="object"||n===null||iu.has(n)||A$(n))){iu.add(n);for(let s of Array.isArray(n)?n:Object.values(n))t.push(s)}}return e}var P$="X-PoW-Challenge-ID",R$="X-PoW-Nonce";function ru(e){if(typeof e!="object"||e===null)return null;let t=e;if(t.error!=="pow_required"||typeof t.challenge!="object"||t.challenge===null)return null;let{id:n,prefix:s,difficulty:a}=t.challenge;return typeof n!="string"||typeof s!="string"||typeof a!="number"||!Number.isInteger(a)||a<0?null:{id:n,prefix:s,difficulty:a}}function E$(e){return 8*2**e}var ba;async function T$(){if(ba)return ba;let e=globalThis;if(e.process?.versions?.node!==void 0||e.process?.versions?.bun!==void 0)try{let s=(await import("node:crypto")).createHash;if(typeof s=="function")return ba=a=>new Uint8Array(s("sha256").update(a).digest()),ba}catch{}let t=new TextEncoder;return ba=async n=>new Uint8Array(await crypto.subtle.digest("SHA-256",t.encode(n))),ba}function C$(e){let t=0;for(let n of e){if(n===0){t+=8;continue}return t+Math.clz32(n)-24}return t}var j$=4096,O$=typeof globalThis.setImmediate=="function"?()=>new Promise(e=>globalThis.setImmediate(e)):()=>new Promise(e=>setTimeout(e,0));async function ou(e,t={}){if(e.difficulty>24)throw new Error(`proof-of-work: difficulty ${e.difficulty} is above auth's ceiling of 24`);let n=await T$(),s=E$(e.difficulty),a=Date.now()+(t.timeLimitMs??12e4);for(let i=0;i<s;i++){if(i%j$===0&&i>0){if(await O$(),t.signal?.aborted)throw t.signal.reason??new DOMException("proof-of-work aborted","AbortError");if(Date.now()>a)throw new Error(`proof-of-work: gave up on difficulty ${e.difficulty} after ${i} attempts`)}let r=n(e.prefix+i),o=r instanceof Uint8Array?r:await r;if(C$(o)>=e.difficulty)return{[P$]:e.id,[R$]:String(i)}}throw new Error(`proof-of-work: no nonce for difficulty ${e.difficulty} within ${s} attempts`)}var W=class extends Error{status;code;requestId;retryAfter;body;op;get isNetworkError(){return this.code==="network_error"}constructor(t){super(t.message,t.cause===void 0?void 0:{cause:t.cause}),this.name="PalbaseError",this.op=t.op,this.status=t.status,this.code=t.code,this.requestId=t.requestId,this.retryAfter=t.retryAfter,this.body=t.body}};function u(e,t,n){let s=String(n);if(s===""||s==="."||s==="..")throw new W({op:e,status:0,code:"invalid_path_parameter",message:`${e}: ${t} cannot be ${s===""?"empty":JSON.stringify(s)}`});return encodeURIComponent(s)}var N$=new Set(["apikey","authorization"]),I$=64*1024;function Dl(e){let t=Cr(e.baseUrl),n=e.fetch??globalThis.fetch,s=e.solveProofOfWork??!0,a=async(i,r)=>{let o=M$(t,i),l=new Headers;for(let[f,b]of Object.entries(i.headers??{}))b!=null&&!N$.has(f.toLowerCase())&&l.set(f,String(b));for(let[f,b]of Object.entries(r))l.set(f,b);await x$(i,e.credentials,l),l.has("accept")||l.set("accept","application/json");let d={method:i.method,headers:l,redirect:"manual",signal:i.signal,...i.keepalive?{keepalive:!0}:{}};i.body&&i.body.value!==void 0&&(l.set("content-type",i.body.contentType),d.body=G$(i.body.kind,i.body.value),wa(d.body)||(d.duplex="half"));let p;try{p=i.onUploadProgress&&e.xmlHttpRequest?await L$(e.xmlHttpRequest,i.op,o,d,i.onUploadProgress):await n(o,d)}catch(f){throw i.signal?.aborted||f instanceof W?f:new W({op:i.op,status:0,code:"network_error",message:`${i.op}: the request did not reach ${t.origin}`,cause:f})}let c=i.answers[p.status]??(i.ownResponse&&p.status>=200&&p.status<300?"raw":void 0);if(c===void 0)throw p.status>=200&&p.status<300?(await p.body?.cancel(),new W({op:i.op,status:p.status,code:"undeclared_answer",message:`${i.op}: the server answered ${p.status}, which its contract does not declare; the request may have taken effect`})):await U$(i.op,p);let m;switch(c){case"json":try{m=Tr(await p.json())}catch(f){throw new W({op:i.op,status:p.status,code:"invalid_json",message:`${i.op}: the answer is not JSON`,cause:f})}break;case"raw":m=p;break;default:await p.body?.cancel(),m=void 0}return{status:p.status,data:m,headers:p.headers}};return{async send(i){try{return await a(i,{})}catch(r){let o=s&&r instanceof W&&r.status===403?ru(r.body):null,l=i.body?.value;if(!o||i.body?.kind==="raw"&&!wa(l))throw r;let d=r,p;try{p=await ou(o,{signal:i.signal})}catch(c){throw i.signal?.aborted?c:new W({op:i.op,status:403,code:"pow_unsolved",message:`${i.op}: ${c instanceof Error?c.message:String(c)}`,requestId:d.requestId,body:d.body,cause:c})}return a(i,p)}}}}function L$(e,t,n,s,a){return new Promise((i,r)=>{let o=s.signal;if(o?.aborted)return r(o.reason);let l=new e,d=()=>l.abort();o?.addEventListener("abort",d,{once:!0});let p=c=>{o?.removeEventListener("abort",d),c()};l.open(s.method??"GET",n.href),l.responseType="arraybuffer",new Headers(s.headers).forEach((c,m)=>l.setRequestHeader(m,c)),l.upload&&(l.upload.onprogress=c=>{c.lengthComputable&&a(c.loaded,c.total)}),l.onload=()=>p(()=>{if(l.responseURL!==""&&l.responseURL!==n.href){r(new W({op:t,status:0,code:"undeclared_redirect",message:`${t}: the server redirected; the answer is another address's, and was not read`}));return}if(l.status<200||l.status>599)return r(new TypeError(`${t}: answered ${l.status}`));let c=l.status===204||l.status===205||l.status===304;i(new Response(c?null:l.response,{status:l.status,statusText:l.statusText,headers:D$(l.getAllResponseHeaders())}))}),l.onerror=()=>p(()=>r(new TypeError(`${t}: the request failed`))),l.onabort=()=>p(()=>r(o?.reason??new DOMException("The request was aborted","AbortError"))),l.send(s.body)})}function D$(e){let t=new Headers;for(let n of e.split(/\r?\n/)){let s=n.indexOf(":");if(!(s<=0))try{t.append(n.slice(0,s).trim(),n.slice(s+1).trim())}catch{}}return t}function Cr(e){let t;try{t=new URL(e)}catch{throw new TypeError(`baseUrl ${JSON.stringify(e)} is not an absolute URL`)}let n=t.hostname==="localhost"||t.hostname.endsWith(".localhost")||t.hostname==="127.0.0.1"||t.hostname==="[::1]";if(t.protocol!=="https:"&&!(t.protocol==="http:"&&n))throw new TypeError(`baseUrl must be https (http only for a loopback address): ${t.origin}`);if(t.username||t.password||t.search||t.hash)throw new TypeError("baseUrl carries no user, query or fragment");if(t.pathname!=="/"&&t.pathname!=="")throw new TypeError("baseUrl is the project origin alone, with no path");return t}function M$(e,t){if(!t.path.startsWith("/")||t.path.startsWith("//"))throw new W({op:t.op,status:0,code:"invalid_path",message:`${t.op}: path ${JSON.stringify(t.path)} is not absolute`});let n=new URL(t.path+q$(t.query),e);if(n.origin!==e.origin)throw new W({op:t.op,status:0,code:"invalid_path",message:`${t.op}: path leaves the project's origin`});return n}async function x$(e,t,n){if(e.auth.length===0)return;let s=e.auth.some(r=>r.includes("userJWT"))?await t.accessToken?.():void 0,a=r=>{switch(r){case"ApiKeyAuth":return!!(t.publishableKey??t.secretKey);case"SecretKeyAuth":case"AdminAuth":return!!(t.secretKey??t.token);case"PalbaseBearer":return!!t.token;case"userJWT":return!!s&&!t.token;default:return!1}},i=e.auth.filter(r=>r.every(a)).reduce((r,o)=>r===void 0||o.length>r.length?o:r,void 0);if(!i)throw new W({op:e.op,status:0,code:"missing_credential",message:`${e.op} needs one of: ${e.auth.map(r=>r.length===0?"nothing":r.join(" + ")).join(" | ")}`});for(let r of i)r==="ApiKeyAuth"?n.set("apikey",t.publishableKey??t.secretKey):(r==="SecretKeyAuth"||r==="AdminAuth"||r==="PalbaseBearer")&&t.token?n.set("authorization",`Bearer ${t.token}`):r==="SecretKeyAuth"||r==="AdminAuth"?n.set("apikey",t.secretKey):r==="userJWT"&&n.set("authorization",`Bearer ${s}`)}function G$(e,t){switch(e){case"json":return JSON.stringify(t);case"form":{let n=new URLSearchParams;for(let[s,a]of Object.entries(t))Ml(n,s,a);return n}case"raw":return t}}function wa(e){return!!(e==null||typeof e=="string"||e instanceof URLSearchParams||e instanceof Blob||e instanceof FormData||e instanceof ArrayBuffer||ArrayBuffer.isView(e))}function q$(e){if(!e)return"";let t=new URLSearchParams;for(let[s,a]of Object.entries(e))Ml(t,s,a);let n=t.toString();return n===""?"":`?${n}`}function Ml(e,t,n){if(n!=null){if(Array.isArray(n)){for(let s of n)Ml(e,t,s);return}if(n instanceof Date){e.append(t,n.toISOString());return}e.append(t,typeof n=="object"?JSON.stringify(n):String(n))}}async function U$(e,t){let n=await K$(t,I$).catch(()=>""),s;try{s=n===""?void 0:JSON.parse(n)}catch{s=n}let a=F$(s)?s:void 0,i=Number(t.headers.get("retry-after")),r=t.status>=300&&t.status<400;return new W({op:e,status:t.status,code:a?.error??(r?"undeclared_redirect":`http_${t.status}`),message:a?.error_description??(r?`${e}: the server redirected (${t.status}); the request was not followed, its credentials stay here`:`${e}: ${t.status} ${t.statusText}`.trim()),requestId:a?.request_id??t.headers.get("x-request-id")??void 0,retryAfter:a?.retry_after??(Number.isFinite(i)&&i>0?i:void 0),body:s})}async function K$(e,t){if(!e.body)return"";let n=e.body.getReader(),s=[],a=0;for(;a<t;){let{done:o,value:l}=await n.read();if(o)break;s.push(l),a+=l.byteLength}await n.cancel().catch(()=>{});let i=new Uint8Array(Math.min(a,t)),r=0;for(let o of s){let l=Math.min(o.byteLength,i.byteLength-r);if(i.set(o.subarray(0,l),r),r+=l,r>=i.byteLength)break}return new TextDecoder().decode(i)}function F$(e){return typeof e=="object"&&e!==null&&typeof e.error=="string"}var jr={project:{type:"string",short:"P",value:"project",description:"the project (name or id; org/project when the name is in two organizations)"},env:{type:"string",short:"E",value:"env",description:"the project's environment (slug or ref)"},json:{type:"boolean",description:"print the answer as JSON"},"non-interactive":{type:"boolean",description:"never ask: refuse what would need a question"},yes:{type:"boolean",short:"y",description:"confirm a change to a production environment without asking"},debug:{type:"boolean",description:"print each request the command sends"},help:{type:"boolean",short:"h",description:"show help"}};var y=class extends Error{exitCode;hint;code;reported;constructor(t,n,s={}){super(n),this.name="CliError",this.code=t,this.hint=s.hint,this.exitCode=s.exitCode??1,this.reported=s.reported??!1}};function g(e,t){return new y("usage",e,{hint:t,exitCode:2})}var Or=class{io;json;constructor(t,n){this.io=t,this.json=n}result(t,n){this.json?this.io.stdout(`${JSON.stringify(t,null,2)}
|
|
4
4
|
`):n()}line(t=""){this.io.stdout(`${re(t)}
|
|
5
5
|
`)}note(t){this.io.stderr(`${re(t)}
|
|
@@ -9,7 +9,7 @@ var $$=Object.defineProperty;var Dt=(e,t)=>{for(var n in t)$$(e,n,{get:t[n],enum
|
|
|
9
9
|
`);let r;try{r=await this.io.fetch(t,{method:n.method,headers:{...n.headers,...a},body:n.body,signal:n.signal,...s?{}:{duplex:"half"},redirect:"manual"})}catch(l){throw n.signal?.aborted?l:new y("network_error",`${new URL(t).origin} could not be reached: ${l instanceof Error?l.message:String(l)}`)}if(this.debug&&this.io.stderr(`< ${r.status} ${r.headers.get("x-request-id")??""}
|
|
10
10
|
`),r.status!==503||!s||i>=nk||!tk.has(await ql(r)??""))return r;await r.body?.cancel();let o=Number(r.headers.get("retry-after")??"");await this.io.sleep((Number.isFinite(o)&&o>0?Math.min(o,30):1)*1e3)}}async exchange(t,n,s){let a=await this.token(),i=await this.send(t,n,s,a.value);if(i.status===401&&a.renewable){let r=await this.renew(await this.currentSession());i=await this.send(t,n,s,r.access_token)}return{res:i,renewable:a.renewable}}async answered(t,n,s,a){if(s.status===204)return;let i=await s.text(),r=i===""?void 0:sk(i);if(s.ok)return r;let o=r??{};throw s.status===401?o.error==="token_not_for_machines"?ku(new URL(this.cloud.studioApi).host):a?va():this.tokenRefused("Studio"):new W({op:`${t} ${n}`,status:s.status,code:o.error??`http_${s.status}`,message:o.error_description??`Studio answered ${s.status}`,requestId:o.request_id??s.headers.get("x-request-id")??void 0,body:r})}tokenRefused(t){return(this.io.env.PALBASE_TOKEN??"").startsWith("pbe_")?new y("token_refused",`${t} refused PALBASE_TOKEN, an environment's token: it ended (a few hours at most), it was revoked, or what minted it no longer holds`,{hint:"mint another: palbase env:tokens:create --scope <scope> (an admin), or with the environment's secret key (Studio's POST /environments/{ref}/tokens)"}):(this.io.env.PALBASE_TOKEN??"").startsWith("pbu_")?new y("token_refused",`${t} refused PALBASE_TOKEN, an account token: it was revoked, it ended, or, in this organization, the one who made it left it`,{hint:"its maker makes a new one: palbase account:tokens:create <name>"}):new y("token_refused",`${t} refused PALBASE_TOKEN: it was revoked, it ended, or the one who made it no longer holds its role`,{hint:"an admin makes a new one: palbase tokens:create <name>"})}async token(){let t=this.io.env.PALBASE_TOKEN;return t&&t!==""?{value:t,renewable:!1}:{value:(await this.currentSession()).access_token,renewable:!0}}async renew(t){let n=await wu(this.io,this.cloud,t);return await this.state.writeSession(n),this.session=n,n}async send(t,n,s,a){let i=`${this.cloud.studioApi}${ek}${n}`;this.debug&&this.io.stderr(`> ${t} ${i}
|
|
11
11
|
`);try{let r=await this.io.fetch(i,{method:t,headers:{...a===void 0?{}:{authorization:`Bearer ${a}`},accept:"application/json",...s===void 0?{}:{"content-type":"application/json"}},body:s===void 0?void 0:JSON.stringify(s),redirect:"manual"});return this.debug&&this.io.stderr(`< ${r.status} ${r.headers.get("x-request-id")??""}
|
|
12
|
-
`),r}catch(r){throw new y("network_error",`Studio (${this.cloud.studioApi}) could not be reached: ${r instanceof Error?r.message:String(r)}`)}}};function ku(e){return new y("token_not_for_machines",`the platform's edge refused PALBASE_TOKEN at ${e}, taking it for a machine's address (token_not_for_machines): the token itself was not refused`,{hint:"nothing is wrong with the token: run this again in a few minutes, and tell Palbase if it lasts"})}async function ql(e){let t=await e.clone().json().catch(()=>null),n=t&&typeof t=="object"?t.error:void 0;return typeof n=="string"&&/^(console|token|edge)_/.test(n)?n:void 0}function sk(e){try{return JSON.parse(e)}catch{return e}}var Su={version:"0.
|
|
12
|
+
`),r}catch(r){throw new y("network_error",`Studio (${this.cloud.studioApi}) could not be reached: ${r instanceof Error?r.message:String(r)}`)}}};function ku(e){return new y("token_not_for_machines",`the platform's edge refused PALBASE_TOKEN at ${e}, taking it for a machine's address (token_not_for_machines): the token itself was not refused`,{hint:"nothing is wrong with the token: run this again in a few minutes, and tell Palbase if it lasts"})}async function ql(e){let t=await e.clone().json().catch(()=>null),n=t&&typeof t=="object"?t.error:void 0;return typeof n=="string"&&/^(console|token|edge)_/.test(n)?n:void 0}function sk(e){try{return JSON.parse(e)}catch{return e}}var Su={version:"0.63.0"};var Mr=Su.version;async function Tu(e,t,n){let s=new Map(n.map(r=>[r.name,r])),a=e.includes("--json"),i=e.includes("--debug");try{let{name:r,at:o}=rk(e);if(r===void 0)return e.includes("--version")?(t.stdout(`palbase ${Mr}
|
|
13
13
|
`),0):(t.stdout(Eu(n)),e.length===0||e.includes("--help")||e.includes("-h")?0:2);if(r==="help"){let C=e[o+1],N=C===void 0?void 0:s.get(C);if(C!==void 0&&!N)throw Au(C,n);return t.stdout(N?Ru(N):Eu(n)),0}let l=s.get(r);if(!l)throw Au(r,n);let d=[...e.slice(0,o),...e.slice(o+1)],p=d.includes("--")?d.slice(0,d.indexOf("--")):d;if(p.includes("--help")||p.includes("-h"))return t.stdout(Ru(l)),0;let{flags:c,positionals:m}=ok(l,d),f=l.args??{min:0,max:0};if(m.length<f.min)throw g(`${l.name} needs ${f.min===1?"an argument":`${f.min} arguments`}`,Kl(l));if(m.length>f.max)throw g(`${l.name} takes ${f.max===0?"no argument":`at most ${f.max}`}: ${JSON.stringify(m.slice(f.max))} is left over`,Kl(l));let b={project:c.project,env:c.env,json:c.json===!0,nonInteractive:c["non-interactive"]===!0,yes:c.yes===!0,debug:c.debug===!0},v=mu(t.env),R=new Nr(fu(t.configDir,v)),A={io:t,state:R,out:new Or(t,b.json),global:b,args:m,flags:c,interactive:t.interactive&&!b.nonInteractive,cloud:v,studio:new Dr(t,v,R,b.debug)};return await l.run(A)??0}catch(r){return lk(r,t,a,i)}}function rk(e){let t=new Set;for(let[n,s]of Object.entries(jr))s.type==="string"&&(t.add(`--${n}`),s.short&&t.add(`-${s.short}`));for(let n=0;n<e.length;n++){let s=e[n];if(s==="--")return{at:-1};if(t.has(s)){n++;continue}if(!s.startsWith("-"))return{name:s,at:n}}return{at:-1}}function ok(e,t){let n={...jr,...e.flags??{}},s={};for(let[a,i]of Object.entries(n))s[a]={type:i.type,...i.short?{short:i.short}:{},...i.multiple?{multiple:!0}:{}};try{let{values:a,positionals:i}=ik({args:t,options:s,strict:!0,allowPositionals:!0});return{flags:a,positionals:i}}catch(a){throw g(a instanceof Error?a.message.replace(/^.*?: /,""):String(a),`palbase help ${e.name}`)}}function lk(e,t,n,s){let a="error",i,r,o=1,l;return e instanceof y?(a=e.code,i=e.message,r=e.hint,o=e.exitCode):e instanceof W?(a=e.code,i=e.message,l=e.requestId,e.code==="token_out_of_scope"&&t.env.PALBASE_TOKEN&&(i=`${e.op} refused PALBASE_TOKEN: ${e.message}`,r="this is the token's reach, fixed when it was minted: a person's yes does not change it \u2014 mint a token whose scopes name this call, or have a person run it signed in")):i=e instanceof Error?e.message:String(e),n&&e instanceof y&&e.reported||(n&&t.stdout(`${JSON.stringify({error:a,message:i,...r?{hint:r}:{},...l?{request_id:l}:{}},null,2)}
|
|
14
14
|
`),t.stderr(`error: ${re(i)}${l?` (request ${re(l)})`:""}
|
|
15
15
|
`),r&&t.stderr(` ${re(r)}
|
|
@@ -18,7 +18,7 @@ var $$=Object.defineProperty;var Dt=(e,t)=>{for(var n in t)$$(e,n,{get:t[n],enum
|
|
|
18
18
|
`)}
|
|
19
19
|
`}function Eu(e){let t=new Map;for(let a of e){let i=a.name.includes(":")?a.name.slice(0,a.name.indexOf(":")):"";t.set(i,[...t.get(i)??[],a])}let n=Math.max(...e.map(a=>a.name.length)),s=["palbase \u2014 your Palbase organizations, projects and environments from the terminal","","usage: palbase <command> [flags]",""];for(let[a,i]of t){s.push(a===""?"Commands:":`${a}:`);for(let r of i)s.push(` ${r.name.padEnd(n)} ${r.summary}`);s.push("")}return s.push("palbase help <command> shows a command in full."),`${s.join(`
|
|
20
20
|
`)}
|
|
21
|
-
`}import{createHash as xG,randomBytes as GG,timingSafeEqual as qG}from"node:crypto";import{createServer as KG}from"node:http";var Fl="owner.json";var WG=300*1e3;function ee(e,t){try{return u("palbase",e,t)}catch(n){throw n instanceof W&&n.code==="invalid_path_parameter"?new y("unsafe_path",`${e} cannot be ${t===""?"empty":JSON.stringify(t)}: a request's path cannot carry it`):n}}var Cu={name:"login",summary:"sign in with your Studio account",details:["Shows a one-time code and opens Studio, where you approve it while signed in there.","The CLI then holds a session of yours: Studio lists it with your others, and ending it there signs the CLI out.","On a machine with no browser (a server, an agent), open the address it prints on any device."],flags:{"no-browser":{type:"boolean",description:"print the address instead of opening a browser"}},scope:"none",async run(e){if(e.io.env.PALBASE_TOKEN)throw new y("token_in_use","PALBASE_TOKEN is set: the CLI acts with that token, and a sign-in would not be used",{hint:"unset PALBASE_TOKEN to sign in as yourself"});let t=await yu(e.io,e.cloud),n=`${e.cloud.studioWeb}/device`;e.out.note(""),e.out.note(` Enter this code in your browser: ${t.user_code}`),e.out.note("");let s=e.flags["no-browser"]!==!0&&e.interactive&&await e.io.openBrowser(n);e.out.note(s?`Opened ${n} \u2014 sign in there if asked, then enter the code.`:`Open ${n} on any device, sign in, and enter the code.`),e.out.note("Waiting for the approval\u2026");let a=await bu(e.io,e.cloud,t);await e.state.writeSession(a),e.out.result({user:a.user},()=>e.out.line(`Signed in as ${a.user.email??a.user.id}.`))}},ju={name:"logout",summary:"sign out: the session is ended at Palbase and forgotten on this computer",scope:"none",async run(e){if(e.io.env.PALBASE_TOKEN)throw new y("token_in_use","PALBASE_TOKEN is set: logout ends your own sign-in, and the CLI acts with the token",{hint:"unset PALBASE_TOKEN to sign out"});let t=await e.state.readSession();if(!t){e.out.result({signed_out:!0},()=>e.out.line("You were not signed in."));return}for(let[n,s]of Object.entries(await e.state.personalKeys()))try{await e.studio.request("DELETE",`/environments/${ee("the environment's ref",n)}/personal-key/${ee("the personal key's id",s.id)}`)}catch(a){a instanceof Error&&"status"in a&&a.status===404||e.out.warn(`your key at ${n} (${s.label}) could not be revoked: ${a instanceof Error?a.message:String(a)} \u2014 revoke it in Studio, or it ends ${s.expires_at}`)}await e.state.forgetPersonalKeys(),await e.state.forget(Fl);try{await vu(e.io,e.cloud,t)}catch(n){e.out.warn(`${n instanceof Error?n.message:String(n)} \u2014 end the session in Studio (Account \u203A Sessions)`)}await e.state.clearSession(),e.out.result({signed_out:!0},()=>e.out.line(`Signed out ${t.user.email??t.user.id}.`))}},Ou={name:"whoami",summary:"the account the CLI acts as, and the environment chosen for this directory",scope:"account",async run(e){let t=e.io.env.PALBASE_TOKEN,n;if(t?.startsWith("pbu_")){let{organizations:a}=await e.studio.get("/orgs");n={id:`account token \u2026${t.slice(-4)}`,via:"token",organizations:a.length}}else if(t?.startsWith("pbo_")){let{organizations:a}=await e.studio.get("/orgs"),i=a[0];n={id:`token \u2026${t.slice(-4)}`,via:"token",...i&&{organization:{id:i.id,name:i.name,role:i.role}}}}else if(t){let a=Ir(t);n={id:String(a.sub??""),...typeof a.email=="string"?{email:a.email}:{},via:"token"}}else n={...(await e.studio.currentSession()).user,via:"session"};let s=await e.state.targetFor(e.io.cwd);e.out.result({user:n,target:s?.target??null,target_dir:s?.dir??null},()=>{e.out.line(n.organization?`an access token of ${re(n.organization.name)} (${n.organization.role}), ${n.id} (PALBASE_TOKEN)`:n.organizations!==void 0?`an ${n.id} (PALBASE_TOKEN): an admin of the ${n.organizations} organization${n.organizations===1?"":"s"} it opened`:`${n.email??n.id}${n.via==="token"?" (PALBASE_TOKEN)":""}`),s&&e.out.line(`${s.target.org_name} \u203A ${s.target.project_name} \u203A ${s.target.env_name} (${s.target.env_slug}) \u2014 chosen for ${s.dir}`)})}};var pk={name:"account:tokens:list",summary:"your account tokens (for a program that opens organizations): name, how many organizations they reach, when they end and were last used \u2014 never their values",scope:"account",async run(e){let{tokens:t}=await e.studio.get("/account/tokens");e.out.result({tokens:t},()=>{t.length===0?e.out.line("You have no account token yet: palbase account:tokens:create <name> makes one."):e.out.table(t,[{header:"name",value:n=>re(n.name)},{header:"token",value:n=>`pbu_\u2026${n.hint}`},{header:"organizations",value:n=>String(n.organizations)},{header:"ends",value:n=>n.expires_at.slice(0,10)},{header:"last used",value:n=>n.last_used_at?.slice(0,16).replace("T"," ")??"never"},{header:"id",value:n=>n.id}])})}},ck={name:"account:tokens:create",summary:"make an account token for a program that opens organizations; its value is shown this once",usage:"<name> [--days <n>]",details:["Give it to the program as its secret (PALBASE_TOKEN, or palbase/cloud's token): it opens organizations \u2014 you their owner, the token their admin \u2014 and builds projects and environments there.","It reaches only the organizations it opened, never your others; it makes no token or key and changes no one's place. It ends after --days (default 90, at most 365), when it is revoked, and, in an organization, when you leave it."],args:{min:1,max:1},flags:{days:{type:"string",value:"n",description:"how many days it is good for (default 90)"}},scope:"account",async run(e){let t=e.flags.days===void 0?90:Number(e.flags.days);if(!Number.isInteger(t)||t<1||t>365)throw g("--days is a whole number from 1 to 365");let n=await e.studio.post("/account/tokens",{name:e.args[0],expires_in_days:t});e.out.result(n,()=>{e.out.line(`Made the account token ${re(n.name)} (until ${n.expires_at.slice(0,10)}).`),e.out.line(`token (shown this once \u2014 keep it as the program's secret PALBASE_TOKEN): ${n.token}`)})}},uk={name:"account:tokens:revoke",summary:"revoke one of your account tokens (by its name or id): refused from its next request on; the organizations it opened stay yours",usage:"<name|id>",args:{min:1,max:1},scope:"account",async run(e){let{tokens:t}=await e.studio.get("/account/tokens"),n=t.filter(s=>s.id===e.args[0]||s.name===e.args[0]);if(n.length===0)throw new y("no_such_token",`you have no account token ${JSON.stringify(e.args[0])}`,{hint:"palbase account:tokens:list shows them"});if(n.length>1)throw new y("ambiguous_token",`${JSON.stringify(e.args[0])} names more than one token`,{hint:"pass its id"});await e.studio.request("DELETE",`/account/tokens/${ee("the token's id",n[0].id)}`),e.out.result({revoked:n[0].id},()=>e.out.line(`Revoked the account token ${re(n[0].name)}.`))}},Nu=[pk,ck,uk];var xr={};Dt(xr,{client:()=>mk});function mk(e){return{async draftAgent(t){return e.send({op:"DraftAgent",method:"POST",path:"/ai/agent-drafts",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listAgents(t){return e.send({op:"ListAgents",method:"GET",path:"/ai/agents",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getAgent(t){return e.send({op:"GetAgent",method:"GET",path:"/ai/agents/"+u("GetAgent","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putAgent(t){return e.send({op:"PutAgent",method:"PUT",path:"/ai/agents/"+u("PutAgent","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteAgent(t){return e.send({op:"DeleteAgent",method:"DELETE",path:"/ai/agents/"+u("DeleteAgent","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async publishAgent(t){return e.send({op:"PublishAgent",method:"POST",path:"/ai/agents/"+u("PublishAgent","name",t.path.name)+"/publish",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async rollbackAgent(t){return e.send({op:"RollbackAgent",method:"POST",path:"/ai/agents/"+u("RollbackAgent","name",t.path.name)+"/rollback",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listAgentVersions(t){return e.send({op:"ListAgentVersions",method:"GET",path:"/ai/agents/"+u("ListAgentVersions","name",t.path.name)+"/versions",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async listChats(t){return e.send({op:"ListChats",method:"GET",path:"/ai/chats",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async createChat(t){return e.send({op:"CreateChat",method:"POST",path:"/ai/chats",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getChat(t){return e.send({op:"GetChat",method:"GET",path:"/ai/chats/"+u("GetChat","chat_id",t.path.chat_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async deleteChat(t){return e.send({op:"DeleteChat",method:"DELETE",path:"/ai/chats/"+u("DeleteChat","chat_id",t.path.chat_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async decideChatApproval(t){return e.send({op:"DecideChatApproval",method:"POST",path:"/ai/chats/"+u("DecideChatApproval","chat_id",t.path.chat_id)+"/approvals/"+u("DecideChatApproval","approval_id",t.path.approval_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async forkChat(t){return e.send({op:"ForkChat",method:"POST",path:"/ai/chats/"+u("ForkChat","chat_id",t.path.chat_id)+"/fork",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getChatGoal(t){return e.send({op:"GetChatGoal",method:"GET",path:"/ai/chats/"+u("GetChatGoal","chat_id",t.path.chat_id)+"/goal",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async setChatGoal(t){return e.send({op:"SetChatGoal",method:"PUT",path:"/ai/chats/"+u("SetChatGoal","chat_id",t.path.chat_id)+"/goal",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async clearChatGoal(t){return e.send({op:"ClearChatGoal",method:"DELETE",path:"/ai/chats/"+u("ClearChatGoal","chat_id",t.path.chat_id)+"/goal",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{204:"empty"},query:t.query,signal:t.signal})},async updateChatGoal(t){return e.send({op:"UpdateChatGoal",method:"PATCH",path:"/ai/chats/"+u("UpdateChatGoal","chat_id",t.path.chat_id)+"/goal",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async putChatMember(t){return e.send({op:"PutChatMember",method:"PUT",path:"/ai/chats/"+u("PutChatMember","chat_id",t.path.chat_id)+"/members/"+u("PutChatMember","user_id",t.path.user_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteChatMember(t){return e.send({op:"DeleteChatMember",method:"DELETE",path:"/ai/chats/"+u("DeleteChatMember","chat_id",t.path.chat_id)+"/members/"+u("DeleteChatMember","user_id",t.path.user_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async listChatMessages(t){return e.send({op:"ListChatMessages",method:"GET",path:"/ai/chats/"+u("ListChatMessages","chat_id",t.path.chat_id)+"/messages",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async sendChatMessage(t){return e.send({op:"SendChatMessage",method:"POST",path:"/ai/chats/"+u("SendChatMessage","chat_id",t.path.chat_id)+"/messages",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json",202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getChatMessageAttachment(t){return e.send({op:"GetChatMessageAttachment",method:"GET",path:"/ai/chats/"+u("GetChatMessageAttachment","chat_id",t.path.chat_id)+"/messages/"+u("GetChatMessageAttachment","message_id",t.path.message_id)+"/attachments/"+u("GetChatMessageAttachment","position",t.path.position),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"raw"},signal:t.signal})},async listChatParts(t){return e.send({op:"ListChatParts",method:"GET",path:"/ai/chats/"+u("ListChatParts","chat_id",t.path.chat_id)+"/parts",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async putChatPipe(t){return e.send({op:"PutChatPipe",method:"PUT",path:"/ai/chats/"+u("PutChatPipe","chat_id",t.path.chat_id)+"/pipe",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteChatPipe(t){return e.send({op:"DeleteChatPipe",method:"DELETE",path:"/ai/chats/"+u("DeleteChatPipe","chat_id",t.path.chat_id)+"/pipe",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async sendSubagentMessage(t){return e.send({op:"SendSubagentMessage",method:"POST",path:"/ai/chats/"+u("SendSubagentMessage","chat_id",t.path.chat_id)+"/runs/"+u("SendSubagentMessage","run_id",t.path.run_id)+"/messages",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async stopSubagent(t){return e.send({op:"StopSubagent",method:"POST",path:"/ai/chats/"+u("StopSubagent","chat_id",t.path.chat_id)+"/runs/"+u("StopSubagent","run_id",t.path.run_id)+"/stop",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async stopChat(t){return e.send({op:"StopChat",method:"POST",path:"/ai/chats/"+u("StopChat","chat_id",t.path.chat_id)+"/stop",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listTurnToolCalls(t){return e.send({op:"ListTurnToolCalls",method:"GET",path:"/ai/chats/"+u("ListTurnToolCalls","chat_id",t.path.chat_id)+"/tool-calls",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getChatToolCall(t){return e.send({op:"GetChatToolCall",method:"GET",path:"/ai/chats/"+u("GetChatToolCall","chat_id",t.path.chat_id)+"/tool-calls/"+u("GetChatToolCall","call_id",t.path.call_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async answerChatToolCall(t){return e.send({op:"AnswerChatToolCall",method:"POST",path:"/ai/chats/"+u("AnswerChatToolCall","chat_id",t.path.chat_id)+"/tool-outputs/"+u("AnswerChatToolCall","call_id",t.path.call_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listChatTurnArtifacts(t){return e.send({op:"ListChatTurnArtifacts",method:"GET",path:"/ai/chats/"+u("ListChatTurnArtifacts","chat_id",t.path.chat_id)+"/turns/"+u("ListChatTurnArtifacts","response_id",t.path.response_id)+"/artifacts",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getChatTurnArtifact(t){return e.send({op:"GetChatTurnArtifact",method:"GET",path:"/ai/chats/"+u("GetChatTurnArtifact","chat_id",t.path.chat_id)+"/turns/"+u("GetChatTurnArtifact","response_id",t.path.response_id)+"/artifacts/"+u("GetChatTurnArtifact","artifact_id",t.path.artifact_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"raw"},signal:t.signal})},async getChatTurnCost(t){return e.send({op:"GetChatTurnCost",method:"GET",path:"/ai/chats/"+u("GetChatTurnCost","chat_id",t.path.chat_id)+"/turns/"+u("GetChatTurnCost","response_id",t.path.response_id)+"/cost",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async startChatVoice(t){return e.send({op:"StartChatVoice",method:"POST",path:"/ai/chats/"+u("StartChatVoice","chat_id",t.path.chat_id)+"/voice",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getChatVoice(t){return e.send({op:"GetChatVoice",method:"GET",path:"/ai/chats/"+u("GetChatVoice","chat_id",t.path.chat_id)+"/voice/"+u("GetChatVoice","voice_id",t.path.voice_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async closeChatVoice(t){return e.send({op:"CloseChatVoice",method:"DELETE",path:"/ai/chats/"+u("CloseChatVoice","chat_id",t.path.chat_id)+"/voice/"+u("CloseChatVoice","voice_id",t.path.voice_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async commandChatVoice(t){return e.send({op:"CommandChatVoice",method:"POST",path:"/ai/chats/"+u("CommandChatVoice","chat_id",t.path.chat_id)+"/voice/"+u("CommandChatVoice","voice_id",t.path.voice_id)+"/commands",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getChatWorkspaceFile(t){return e.send({op:"GetChatWorkspaceFile",method:"GET",path:"/ai/chats/"+u("GetChatWorkspaceFile","chat_id",t.path.chat_id)+"/workspace/files",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"raw"},query:t.query,signal:t.signal})},async putChatWorkspaceFile(t){return e.send({op:"PutChatWorkspaceFile",method:"PUT",path:"/ai/chats/"+u("PutChatWorkspaceFile","chat_id",t.path.chat_id)+"/workspace/files",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t.query,body:{kind:"raw",contentType:t.contentType??"application/octet-stream",value:t.body},signal:t.signal})},async deleteChatWorkspaceFile(t){return e.send({op:"DeleteChatWorkspaceFile",method:"DELETE",path:"/ai/chats/"+u("DeleteChatWorkspaceFile","chat_id",t.path.chat_id)+"/workspace/files",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async addChatWorkspaceRepo(t){return e.send({op:"AddChatWorkspaceRepo",method:"POST",path:"/ai/chats/"+u("AddChatWorkspaceRepo","chat_id",t.path.chat_id)+"/workspace/repos",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listChatWorkspaceTokens(t){return e.send({op:"ListChatWorkspaceTokens",method:"GET",path:"/ai/chats/"+u("ListChatWorkspaceTokens","chat_id",t.path.chat_id)+"/workspace/tokens",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async createChatWorkspaceToken(t){return e.send({op:"CreateChatWorkspaceToken",method:"POST",path:"/ai/chats/"+u("CreateChatWorkspaceToken","chat_id",t.path.chat_id)+"/workspace/tokens",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async revokeChatWorkspaceToken(t){return e.send({op:"RevokeChatWorkspaceToken",method:"DELETE",path:"/ai/chats/"+u("RevokeChatWorkspaceToken","chat_id",t.path.chat_id)+"/workspace/tokens/"+u("RevokeChatWorkspaceToken","token",t.path.token),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async createEmbeddings(t){return e.send({op:"CreateEmbeddings",method:"POST",path:"/ai/embeddings",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listEndpoints(t){return e.send({op:"ListEndpoints",method:"GET",path:"/ai/endpoints",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async putEndpoint(t){return e.send({op:"PutEndpoint",method:"PUT",path:"/ai/endpoints/"+u("PutEndpoint","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteEndpoint(t){return e.send({op:"DeleteEndpoint",method:"DELETE",path:"/ai/endpoints/"+u("DeleteEndpoint","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async listEnv(t){return e.send({op:"ListEnv",method:"GET",path:"/ai/env",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async putEnv(t){return e.send({op:"PutEnv",method:"PUT",path:"/ai/env/"+u("PutEnv","key",t.path.key),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteEnv(t){return e.send({op:"DeleteEnv",method:"DELETE",path:"/ai/env/"+u("DeleteEnv","key",t.path.key),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async createImage(t){return e.send({op:"CreateImage",method:"POST",path:"/ai/images",auth:[["SecretKeyAuth"]],answers:{202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getImage(t){return e.send({op:"GetImage",method:"GET",path:"/ai/images/"+u("GetImage","image_id",t.path.image_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getImageFile(t){return e.send({op:"GetImageFile",method:"GET",path:"/ai/images/"+u("GetImageFile","image_id",t.path.image_id)+"/files/"+u("GetImageFile","position",t.path.position),auth:[["SecretKeyAuth"]],answers:{200:"raw"},signal:t.signal})},async deleteMachine(t){return e.send({op:"DeleteMachine",method:"DELETE",path:"/ai/machines/"+u("DeleteMachine","machine",t.path.machine),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async cordonMachine(t){return e.send({op:"CordonMachine",method:"POST",path:"/ai/machines/"+u("CordonMachine","machine",t.path.machine)+"/cordon",auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async resumeMachine(t){return e.send({op:"ResumeMachine",method:"POST",path:"/ai/machines/"+u("ResumeMachine","machine",t.path.machine)+"/resume",auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async listModels(t){return e.send({op:"ListModels",method:"GET",path:"/ai/models",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async revokePoolKey(t){return e.send({op:"RevokePoolKey",method:"POST",path:"/ai/pool-keys/"+u("RevokePoolKey","key",t.path.key)+"/revoke",auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async listPools(t){return e.send({op:"ListPools",method:"GET",path:"/ai/pools",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async createPool(t){return e.send({op:"CreatePool",method:"POST",path:"/ai/pools",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deletePool(t){return e.send({op:"DeletePool",method:"DELETE",path:"/ai/pools/"+u("DeletePool","pool",t.path.pool),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async listPoolKeys(t){return e.send({op:"ListPoolKeys",method:"GET",path:"/ai/pools/"+u("ListPoolKeys","pool",t.path.pool)+"/keys",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async createPoolKey(t){return e.send({op:"CreatePoolKey",method:"POST",path:"/ai/pools/"+u("CreatePoolKey","pool",t.path.pool)+"/keys",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getPoolState(t){return e.send({op:"GetPoolState",method:"GET",path:"/ai/pools/"+u("GetPoolState","pool",t.path.pool)+"/state",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async listProviders(t){return e.send({op:"ListProviders",method:"GET",path:"/ai/providers",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async connectProvider(t){return e.send({op:"ConnectProvider",method:"PUT",path:"/ai/providers/"+u("ConnectProvider","provider",t.path.provider),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async disconnectProvider(t){return e.send({op:"DisconnectProvider",method:"DELETE",path:"/ai/providers/"+u("DisconnectProvider","provider",t.path.provider),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async listRepos(t){return e.send({op:"ListRepos",method:"GET",path:"/ai/repos",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async putRepo(t){return e.send({op:"PutRepo",method:"PUT",path:"/ai/repos/"+u("PutRepo","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteRepo(t){return e.send({op:"DeleteRepo",method:"DELETE",path:"/ai/repos/"+u("DeleteRepo","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async createResponse(t){return e.send({op:"CreateResponse",method:"POST",path:"/ai/responses",auth:[["SecretKeyAuth"]],answers:{200:"raw",202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getResponse(t){return e.send({op:"GetResponse",method:"GET",path:"/ai/responses/"+u("GetResponse","response_id",t.path.response_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async cancelResponse(t){return e.send({op:"CancelResponse",method:"POST",path:"/ai/responses/"+u("CancelResponse","response_id",t.path.response_id)+"/cancel",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async followResponse(t){return e.send({op:"FollowResponse",method:"GET",path:"/ai/responses/"+u("FollowResponse","response_id",t.path.response_id)+"/live",auth:[["SecretKeyAuth"]],answers:{200:"raw"},query:t.query,signal:t.signal})},async getSettings(t){return e.send({op:"GetSettings",method:"GET",path:"/ai/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async putSettings(t){return e.send({op:"PutSettings",method:"PUT",path:"/ai/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getSpend(t){return e.send({op:"GetSpend",method:"GET",path:"/ai/spend",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async askSupport(t){return e.send({op:"AskSupport",method:"POST",path:"/ai/support-questions",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listTools(t){return e.send({op:"ListTools",method:"GET",path:"/ai/tools",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async listUsage(t){return e.send({op:"ListUsage",method:"GET",path:"/ai/usage",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getWorkspaceSyncChanges(t){return e.send({op:"GetWorkspaceSyncChanges",method:"GET",path:"/ai/workspace-sync/changes",auth:[["WorkspaceTokenAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async createWorkspaceSyncChangeSet(t){return e.send({op:"CreateWorkspaceSyncChangeSet",method:"POST",path:"/ai/workspace-sync/changesets",auth:[["WorkspaceTokenAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getWorkspaceSyncConflict(t){return e.send({op:"GetWorkspaceSyncConflict",method:"GET",path:"/ai/workspace-sync/conflicts/"+u("GetWorkspaceSyncConflict","conflict_id",t.path.conflict_id),auth:[["WorkspaceTokenAuth"]],answers:{200:"json"},signal:t.signal})},async getWorkspaceSyncEvents(t){return e.send({op:"GetWorkspaceSyncEvents",method:"GET",path:"/ai/workspace-sync/events",auth:[["WorkspaceTokenAuth"]],answers:{200:"raw"},signal:t?.signal})},async createWorkspaceSyncGrants(t){return e.send({op:"CreateWorkspaceSyncGrants",method:"POST",path:"/ai/workspace-sync/grants",auth:[["WorkspaceTokenAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getWorkspaceSyncHead(t){return e.send({op:"GetWorkspaceSyncHead",method:"GET",path:"/ai/workspace-sync/head",auth:[["WorkspaceTokenAuth"]],answers:{200:"json"},signal:t?.signal})}}}var hi={};Dt(hi,{client:()=>hk});function hk(e){return{async listAudiences(t){return e.send({op:"ListAudiences",method:"GET",path:"/analytics/audiences",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async createAudience(t){return e.send({op:"CreateAudience",method:"POST",path:"/analytics/audiences",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async previewAudience(t){return e.send({op:"PreviewAudience",method:"POST",path:"/analytics/audiences/preview",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getAudience(t){return e.send({op:"GetAudience",method:"GET",path:"/analytics/audiences/"+u("GetAudience","id",t.path.id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async deleteAudience(t){return e.send({op:"DeleteAudience",method:"DELETE",path:"/analytics/audiences/"+u("DeleteAudience","id",t.path.id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async updateAudience(t){return e.send({op:"UpdateAudience",method:"PATCH",path:"/analytics/audiences/"+u("UpdateAudience","id",t.path.id),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listAudienceMembers(t){return e.send({op:"ListAudienceMembers",method:"GET",path:"/analytics/audiences/"+u("ListAudienceMembers","id",t.path.id)+"/members",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async alias(t){return e.send({op:"Alias",method:"POST",path:"/analytics/alias",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"empty"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async batch(t){return e.send({op:"Batch",method:"POST",path:"/analytics/batch",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"json",207:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getEventBreakdown(t){return e.send({op:"GetEventBreakdown",method:"GET",path:"/analytics/breakdown",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async capture(t){return e.send({op:"Capture",method:"POST",path:"/analytics/capture",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"empty"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async sendConsoleHistory(t){return e.send({op:"SendConsoleHistory",method:"POST",path:"/analytics/console-breadcrumbs",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getConsoleConfig(t){return e.send({op:"GetConsoleConfig",method:"GET",path:"/analytics/console-breadcrumbs/config",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async listConsoleRecords(t){return e.send({op:"ListConsoleRecords",method:"GET",path:"/analytics/console-records",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async listEventNames(t){return e.send({op:"ListEventNames",method:"GET",path:"/analytics/event-names",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async listEvents(t){return e.send({op:"ListEvents",method:"GET",path:"/analytics/events",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getEventTimeline(t){return e.send({op:"GetEventTimeline",method:"GET",path:"/analytics/events/timeline",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async runFunnel(t){return e.send({op:"RunFunnel",method:"POST",path:"/analytics/funnel",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async identify(t){return e.send({op:"Identify",method:"POST",path:"/analytics/identify",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"empty"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async page(t){return e.send({op:"Page",method:"POST",path:"/analytics/page",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"empty"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async sendPerf(t){return e.send({op:"SendPerf",method:"POST",path:"/analytics/perf",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listPerfGroups(t){return e.send({op:"ListPerfGroups",method:"GET",path:"/analytics/perf/client",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getPerfConfig(t){return e.send({op:"GetPerfConfig",method:"GET",path:"/analytics/perf/config",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json",304:"empty"},headers:t?.headers,signal:t?.signal})},async getPerfTimeline(t){return e.send({op:"GetPerfTimeline",method:"GET",path:"/analytics/perf/timeline",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async listRequestLines(t){return e.send({op:"ListRequestLines",method:"GET",path:"/analytics/requests",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getMachineTraffic(t){return e.send({op:"GetMachineTraffic",method:"GET",path:"/analytics/machines/"+u("GetMachineTraffic","name",t.path.name)+"/traffic",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async runRetention(t){return e.send({op:"RunRetention",method:"POST",path:"/analytics/retention",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async screen(t){return e.send({op:"Screen",method:"POST",path:"/analytics/screen",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"empty"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getSettings(t){return e.send({op:"GetSettings",method:"GET",path:"/analytics/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async putSettings(t){return e.send({op:"PutSettings",method:"PUT",path:"/analytics/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getSummary(t){return e.send({op:"GetSummary",method:"GET",path:"/analytics/summary",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async listTraces(t){return e.send({op:"ListTraces",method:"GET",path:"/analytics/traces",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async sendTrace(t){return e.send({op:"SendTrace",method:"POST",path:"/analytics/traces",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"empty"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async sendTraceBatch(t){return e.send({op:"SendTraceBatch",method:"POST",path:"/analytics/traces/batch",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"json",207:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getTraceHops(t){return e.send({op:"GetTraceHops",method:"GET",path:"/analytics/traces/by-trace",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async listSessionTraces(t){return e.send({op:"ListSessionTraces",method:"GET",path:"/analytics/traces/session",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getTraceSummary(t){return e.send({op:"GetTraceSummary",method:"GET",path:"/analytics/traces/summary",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getTraceTimeline(t){return e.send({op:"GetTraceTimeline",method:"GET",path:"/analytics/traces/timeline",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async searchPeople(t){return e.send({op:"SearchPeople",method:"GET",path:"/analytics/people",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async setPersonProperties(t){return e.send({op:"SetPersonProperties",method:"POST",path:"/analytics/people",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getPerson(t){return e.send({op:"GetPerson",method:"GET",path:"/analytics/people/"+u("GetPerson","person_id",t.path.person_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async listPersonEvents(t){return e.send({op:"ListPersonEvents",method:"GET",path:"/analytics/people/"+u("ListPersonEvents","person_id",t.path.person_id)+"/events",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getEventCatalog(t){return e.send({op:"GetEventCatalog",method:"GET",path:"/analytics/catalog",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async defineEvent(t){return e.send({op:"DefineEvent",method:"PUT",path:"/analytics/catalog/"+u("DefineEvent","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})}}}var gi={};Dt(gi,{client:()=>gk});function gk(e){return{async getAppleAppSiteAssociation(t){return e.send({op:"GetAppleAppSiteAssociation",method:"GET",path:"/.well-known/apple-app-site-association",auth:[],answers:{200:"json"},signal:t?.signal})},async getAssetLinks(t){return e.send({op:"GetAssetLinks",method:"GET",path:"/.well-known/assetlinks.json",auth:[],answers:{200:"json"},signal:t?.signal})},async getJwks(t){return e.send({op:"GetJWKS",method:"GET",path:"/.well-known/jwks.json",auth:[],answers:{200:"json"},signal:t?.signal})},async getOidcDiscovery(t){return e.send({op:"GetOIDCDiscovery",method:"GET",path:"/.well-known/openid-configuration",auth:[],answers:{200:"json"},signal:t?.signal})},async getWebAuthnRelatedOrigins(t){return e.send({op:"GetWebAuthnRelatedOrigins",method:"GET",path:"/.well-known/webauthn",auth:[],answers:{200:"json"},signal:t?.signal})},async adminVerifyDeviceAssertion(t){return e.send({op:"AdminVerifyDeviceAssertion",method:"POST",path:"/admin/attest/devices/assert",auth:[["AdminAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminGetAttestPolicy(t){return e.send({op:"AdminGetAttestPolicy",method:"GET",path:"/admin/attest/devices/attest-policy",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminGetAttestObservations(t){return e.send({op:"AdminGetAttestObservations",method:"GET",path:"/admin/attest/devices/observations",auth:[["AdminAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async adminRecordAttestObservations(t){return e.send({op:"AdminRecordAttestObservations",method:"POST",path:"/admin/attest/devices/observations",auth:[["AdminAuth"]],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminListAuditEvents(t){return e.send({op:"AdminListAuditEvents",method:"GET",path:"/admin/audit",auth:[["AdminAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async adminExportAuditEvents(t){return e.send({op:"AdminExportAuditEvents",method:"GET",path:"/admin/audit/export",auth:[["AdminAuth"]],answers:{200:"raw"},query:t?.query,signal:t?.signal})},async adminVerifyAuditTrail(t){return e.send({op:"AdminVerifyAuditTrail",method:"GET",path:"/admin/audit/verify",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminGetAuthSettings(t){return e.send({op:"AdminGetAuthSettings",method:"GET",path:"/admin/auth-settings",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminUpdateAuthSettings(t){return e.send({op:"AdminUpdateAuthSettings",method:"PUT",path:"/admin/auth-settings",auth:[["AdminAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminGetBreachWatch(t){return e.send({op:"AdminGetBreachWatch",method:"GET",path:"/admin/breach-watch",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminListHooks(t){return e.send({op:"AdminListHooks",method:"GET",path:"/admin/hooks",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminCreateHook(t){return e.send({op:"AdminCreateHook",method:"POST",path:"/admin/hooks",auth:[["AdminAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminUpdateHook(t){return e.send({op:"AdminUpdateHook",method:"PUT",path:"/admin/hooks/"+u("AdminUpdateHook","id",t.path.id),auth:[["AdminAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminDeleteHook(t){return e.send({op:"AdminDeleteHook",method:"DELETE",path:"/admin/hooks/"+u("AdminDeleteHook","id",t.path.id),auth:[["AdminAuth"]],answers:{204:"empty"},signal:t.signal})},async adminListHookExecutions(t){return e.send({op:"AdminListHookExecutions",method:"GET",path:"/admin/hooks/"+u("AdminListHookExecutions","id",t.path.id)+"/executions",auth:[["AdminAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async adminListIntegrations(t){return e.send({op:"AdminListIntegrations",method:"GET",path:"/admin/integrations",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminPutIntegration(t){return e.send({op:"AdminPutIntegration",method:"PUT",path:"/admin/integrations/"+u("AdminPutIntegration","name",t.path.name),auth:[["AdminAuth"]],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminDeleteIntegration(t){return e.send({op:"AdminDeleteIntegration",method:"DELETE",path:"/admin/integrations/"+u("AdminDeleteIntegration","name",t.path.name),auth:[["AdminAuth"]],answers:{204:"empty"},signal:t.signal})},async adminListOAuthClients(t){return e.send({op:"AdminListOAuthClients",method:"GET",path:"/admin/oauth-clients",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminCreateOAuthClient(t){return e.send({op:"AdminCreateOAuthClient",method:"POST",path:"/admin/oauth-clients",auth:[["AdminAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminGetOAuthClient(t){return e.send({op:"AdminGetOAuthClient",method:"GET",path:"/admin/oauth-clients/"+u("AdminGetOAuthClient","id",t.path.id),auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminDeleteOAuthClient(t){return e.send({op:"AdminDeleteOAuthClient",method:"DELETE",path:"/admin/oauth-clients/"+u("AdminDeleteOAuthClient","id",t.path.id),auth:[["AdminAuth"]],answers:{204:"empty"},signal:t.signal})},async adminUpdateOAuthClient(t){return e.send({op:"AdminUpdateOAuthClient",method:"PATCH",path:"/admin/oauth-clients/"+u("AdminUpdateOAuthClient","id",t.path.id),auth:[["AdminAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminListProviders(t){return e.send({op:"AdminListProviders",method:"GET",path:"/admin/providers",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminGetPhoneSettings(t){return e.send({op:"AdminGetPhoneSettings",method:"GET",path:"/admin/providers/phone/settings",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminUpdatePhoneSettings(t){return e.send({op:"AdminUpdatePhoneSettings",method:"PUT",path:"/admin/providers/phone/settings",auth:[["AdminAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminToggleProvider(t){return e.send({op:"AdminToggleProvider",method:"POST",path:"/admin/providers/"+u("AdminToggleProvider","name",t.path.name),auth:[["AdminAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminListRoles(t){return e.send({op:"AdminListRoles",method:"GET",path:"/admin/roles",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminUpsertRole(t){return e.send({op:"AdminUpsertRole",method:"PUT",path:"/admin/roles/"+u("AdminUpsertRole","name",t.path.name),auth:[["AdminAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminDeleteRole(t){return e.send({op:"AdminDeleteRole",method:"DELETE",path:"/admin/roles/"+u("AdminDeleteRole","name",t.path.name),auth:[["AdminAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async adminListServiceAccounts(t){return e.send({op:"AdminListServiceAccounts",method:"GET",path:"/admin/service-accounts",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminCreateServiceAccount(t){return e.send({op:"AdminCreateServiceAccount",method:"POST",path:"/admin/service-accounts",auth:[["AdminAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminGetServiceAccount(t){return e.send({op:"AdminGetServiceAccount",method:"GET",path:"/admin/service-accounts/"+u("AdminGetServiceAccount","id",t.path.id),auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminRevokeServiceAccount(t){return e.send({op:"AdminRevokeServiceAccount",method:"DELETE",path:"/admin/service-accounts/"+u("AdminRevokeServiceAccount","id",t.path.id),auth:[["AdminAuth"]],answers:{204:"empty"},signal:t.signal})},async adminRotateServiceAccount(t){return e.send({op:"AdminRotateServiceAccount",method:"POST",path:"/admin/service-accounts/"+u("AdminRotateServiceAccount","id",t.path.id)+"/rotate",auth:[["AdminAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async adminListSessions(t){return e.send({op:"AdminListSessions",method:"GET",path:"/admin/sessions",auth:[["AdminAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async adminRevokeSession(t){return e.send({op:"AdminRevokeSession",method:"DELETE",path:"/admin/sessions/"+u("AdminRevokeSession","id",t.path.id),auth:[["AdminAuth"]],answers:{204:"empty"},signal:t.signal})},async adminListSigningKeys(t){return e.send({op:"AdminListSigningKeys",method:"GET",path:"/admin/signing-keys",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminRotateSigningKey(t){return e.send({op:"AdminRotateSigningKey",method:"POST",path:"/admin/signing-keys/rotate",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async socialAdminConfig(t){return e.send({op:"SocialAdminConfig",method:"GET",path:"/admin/social-auth",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async socialCredentialPut(t){return e.send({op:"SocialCredentialPut",method:"PUT",path:"/admin/social-auth/credentials/"+u("SocialCredentialPut","key",t.path.key),auth:[["AdminAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async socialCredentialDelete(t){return e.send({op:"SocialCredentialDelete",method:"DELETE",path:"/admin/social-auth/credentials/"+u("SocialCredentialDelete","key",t.path.key),auth:[["AdminAuth"]],answers:{204:"empty"},headers:t.headers,signal:t.signal})},async socialProviderPatch(t){return e.send({op:"SocialProviderPatch",method:"PATCH",path:"/admin/social-auth/providers/"+u("SocialProviderPatch","provider",t.path.provider),auth:[["AdminAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminGetStats(t){return e.send({op:"AdminGetStats",method:"GET",path:"/admin/stats",auth:[["AdminAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async adminSendTestTemplate(t){return e.send({op:"AdminSendTestTemplate",method:"POST",path:"/admin/templates/"+u("AdminSendTestTemplate","key",t.path.key)+"/send-test",auth:[["AdminAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminListTestUsers(t){return e.send({op:"AdminListTestUsers",method:"GET",path:"/admin/test-users",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminCreateTestUsers(t){return e.send({op:"AdminCreateTestUsers",method:"POST",path:"/admin/test-users",auth:[["AdminAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminSetTestUserPhone(t){return e.send({op:"AdminSetTestUserPhone",method:"PUT",path:"/admin/test-users/phone",auth:[["AdminAuth"]],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminCreateTestSignupAddress(t){return e.send({op:"AdminCreateTestSignupAddress",method:"POST",path:"/admin/test-users/addresses",auth:[["AdminAuth"]],answers:{201:"json"},signal:t?.signal})},async adminDeleteTestUser(t){return e.send({op:"AdminDeleteTestUser",method:"DELETE",path:"/admin/test-users/"+u("AdminDeleteTestUser","uid",t.path.uid),auth:[["AdminAuth"]],answers:{204:"empty"},signal:t.signal})},async adminCreateCustomToken(t){return e.send({op:"AdminCreateCustomToken",method:"POST",path:"/admin/token/custom",auth:[["AdminAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminListUsers(t){return e.send({op:"AdminListUsers",method:"GET",path:"/admin/users",auth:[["AdminAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async adminCreateUser(t){return e.send({op:"AdminCreateUser",method:"POST",path:"/admin/users",auth:[["AdminAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminImportUsers(t){return e.send({op:"AdminImportUsers",method:"POST",path:"/admin/users/import",auth:[["AdminAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminGetUser(t){return e.send({op:"AdminGetUser",method:"GET",path:"/admin/users/"+u("AdminGetUser","uid",t.path.uid),auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminDeleteUser(t){return e.send({op:"AdminDeleteUser",method:"DELETE",path:"/admin/users/"+u("AdminDeleteUser","uid",t.path.uid),auth:[["AdminAuth"]],answers:{204:"empty"},signal:t.signal})},async adminUpdateUser(t){return e.send({op:"AdminUpdateUser",method:"PATCH",path:"/admin/users/"+u("AdminUpdateUser","uid",t.path.uid),auth:[["AdminAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminBanUser(t){return e.send({op:"AdminBanUser",method:"POST",path:"/admin/users/"+u("AdminBanUser","uid",t.path.uid)+"/ban",auth:[["AdminAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminGetUserConsents(t){return e.send({op:"AdminGetUserConsents",method:"GET",path:"/admin/users/"+u("AdminGetUserConsents","uid",t.path.uid)+"/consents",auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminRevokeUserCredentials(t){return e.send({op:"AdminRevokeUserCredentials",method:"POST",path:"/admin/users/"+u("AdminRevokeUserCredentials","uid",t.path.uid)+"/credentials/revoke-all",auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminExportUser(t){return e.send({op:"AdminExportUser",method:"GET",path:"/admin/users/"+u("AdminExportUser","uid",t.path.uid)+"/export",auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminListUserMfaFactors(t){return e.send({op:"AdminListUserMFAFactors",method:"GET",path:"/admin/users/"+u("AdminListUserMFAFactors","uid",t.path.uid)+"/mfa",auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminResetUserMfa(t){return e.send({op:"AdminResetUserMFA",method:"DELETE",path:"/admin/users/"+u("AdminResetUserMFA","uid",t.path.uid)+"/mfa",auth:[["AdminAuth"]],answers:{204:"empty"},signal:t.signal})},async adminResetUserPassword(t){return e.send({op:"AdminResetUserPassword",method:"POST",path:"/admin/users/"+u("AdminResetUserPassword","uid",t.path.uid)+"/reset-password",auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminListUserRoles(t){return e.send({op:"AdminListUserRoles",method:"GET",path:"/admin/users/"+u("AdminListUserRoles","uid",t.path.uid)+"/roles",auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminAssignUserRole(t){return e.send({op:"AdminAssignUserRole",method:"PUT",path:"/admin/users/"+u("AdminAssignUserRole","uid",t.path.uid)+"/roles/"+u("AdminAssignUserRole","role",t.path.role),auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminRevokeUserRole(t){return e.send({op:"AdminRevokeUserRole",method:"DELETE",path:"/admin/users/"+u("AdminRevokeUserRole","uid",t.path.uid)+"/roles/"+u("AdminRevokeUserRole","role",t.path.role),auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminRevokeUserSessions(t){return e.send({op:"AdminRevokeUserSessions",method:"POST",path:"/admin/users/"+u("AdminRevokeUserSessions","uid",t.path.uid)+"/sessions/revoke-all",auth:[["AdminAuth"]],answers:{204:"empty"},signal:t.signal})},async adminUnbanUser(t){return e.send({op:"AdminUnbanUser",method:"POST",path:"/admin/users/"+u("AdminUnbanUser","uid",t.path.uid)+"/unban",auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async signInAnonymously(t){return e.send({op:"SignInAnonymously",method:"POST",path:"/auth/anonymous",auth:[["ApiKeyAuth"]],answers:{201:"json"},headers:t?.headers,body:{kind:"json",contentType:"application/json",value:t?.body},signal:t?.signal})},async convertAnonymousUser(t){return e.send({op:"ConvertAnonymousUser",method:"POST",path:"/auth/anonymous/convert",auth:[["ApiKeyAuth","userJWT"]],answers:{202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async verifyAnonymousConversion(t){return e.send({op:"VerifyAnonymousConversion",method:"POST",path:"/auth/anonymous/convert/verify",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async devicePendingRequest(t){return e.send({op:"DevicePendingRequest",method:"GET",path:"/auth/device/requests/"+u("DevicePendingRequest","user_code",t.path.user_code),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async deviceVerifyPage(t){return e.send({op:"DeviceVerifyPage",method:"GET",path:"/auth/device/verify",auth:[["ApiKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async deviceVerifySubmit(t){return e.send({op:"DeviceVerifySubmit",method:"POST",path:"/auth/device/verify",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async listDevices(t){return e.send({op:"ListDevices",method:"GET",path:"/auth/devices",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async attestAndroidDevice(t){return e.send({op:"AttestAndroidDevice",method:"POST",path:"/auth/devices/attest/android",auth:[["ApiKeyAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async attestIosDevice(t){return e.send({op:"AttestIOSDevice",method:"POST",path:"/auth/devices/attest/ios",auth:[["ApiKeyAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async bindDeviceKey(t){return e.send({op:"BindDeviceKey",method:"POST",path:"/auth/devices/bind",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async createDeviceChallenge(t){return e.send({op:"CreateDeviceChallenge",method:"POST",path:"/auth/devices/challenge",auth:[["ApiKeyAuth"]],answers:{200:"json"},headers:t?.headers,signal:t?.signal})},async verifyAndroidIntegrity(t){return e.send({op:"VerifyAndroidIntegrity",method:"POST",path:"/auth/devices/verify/android",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteDevice(t){return e.send({op:"DeleteDevice",method:"DELETE",path:"/auth/devices/"+u("DeleteDevice","id",t.path.id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async verifyDeviceSignature(t){return e.send({op:"VerifyDeviceSignature",method:"POST",path:"/auth/devices/"+u("VerifyDeviceSignature","id",t.path.id)+"/verify",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listIdentities(t){return e.send({op:"ListIdentities",method:"GET",path:"/auth/identities",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async unlinkIdentity(t){return e.send({op:"UnlinkIdentity",method:"DELETE",path:"/auth/identities/"+u("UnlinkIdentity","id",t.path.id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async createInstallation(t){return e.send({op:"CreateInstallation",method:"POST",path:"/auth/installations",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async bindInstallation(t){return e.send({op:"BindInstallation",method:"POST",path:"/auth/installations/"+u("BindInstallation","id",t.path.id)+"/bind",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async refreshInstallation(t){return e.send({op:"RefreshInstallation",method:"POST",path:"/auth/installations/"+u("RefreshInstallation","id",t.path.id)+"/refresh",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async revokeInstallation(t){return e.send({op:"RevokeInstallation",method:"POST",path:"/auth/installations/"+u("RevokeInstallation","id",t.path.id)+"/revoke",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async unbindInstallation(t){return e.send({op:"UnbindInstallation",method:"POST",path:"/auth/installations/"+u("UnbindInstallation","id",t.path.id)+"/unbind",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async login(t){return e.send({op:"Login",method:"POST",path:"/auth/login",auth:[["ApiKeyAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async logout(t){return e.send({op:"Logout",method:"POST",path:"/auth/logout",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async magicLinkRequest(t){return e.send({op:"MagicLinkRequest",method:"POST",path:"/auth/magic-link",auth:[["ApiKeyAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async magicLinkVerify(t){return e.send({op:"MagicLinkVerify",method:"POST",path:"/auth/magic-link/verify",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getMe(t){return e.send({op:"GetMe",method:"GET",path:"/auth/me",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async updateMe(t){return e.send({op:"UpdateMe",method:"PATCH",path:"/auth/me",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async mfaChallenge(t){return e.send({op:"MfaChallenge",method:"POST",path:"/auth/mfa/challenge",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async mfaEmailChallenge(t){return e.send({op:"MfaEmailChallenge",method:"POST",path:"/auth/mfa/email/challenge",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async mfaEmailEnroll(t){return e.send({op:"MfaEmailEnroll",method:"POST",path:"/auth/mfa/email/enroll",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async mfaEmailVerify(t){return e.send({op:"MfaEmailVerify",method:"POST",path:"/auth/mfa/email/verify",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async mfaEnroll(t){return e.send({op:"MfaEnroll",method:"POST",path:"/auth/mfa/enroll",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async mfaListFactors(t){return e.send({op:"MfaListFactors",method:"GET",path:"/auth/mfa/factors",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async mfaRemoveFactor(t){return e.send({op:"MfaRemoveFactor",method:"DELETE",path:"/auth/mfa/factors/"+u("MfaRemoveFactor","id",t.path.id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async mfaRecovery(t){return e.send({op:"MfaRecovery",method:"POST",path:"/auth/mfa/recovery",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async mfaRegenerateRecoveryCodes(t){return e.send({op:"MfaRegenerateRecoveryCodes",method:"POST",path:"/auth/mfa/recovery-codes/regenerate",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async mfaSmsChallenge(t){return e.send({op:"MfaSMSChallenge",method:"POST",path:"/auth/mfa/sms/challenge",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async mfaSmsEnroll(t){return e.send({op:"MfaSMSEnroll",method:"POST",path:"/auth/mfa/sms/enroll",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async mfaSmsVerifyEnrollment(t){return e.send({op:"MfaSMSVerifyEnrollment",method:"POST",path:"/auth/mfa/sms/verify",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async mfaVerifyEnrollment(t){return e.send({op:"MfaVerifyEnrollment",method:"POST",path:"/auth/mfa/verify",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async socialCallbackApple(t){return e.send({op:"SocialCallbackApple",method:"GET",path:"/auth/oauth/callback/apple",auth:[],answers:{},signal:t?.signal})},async socialCallbackApplePost(t){return e.send({op:"SocialCallbackApplePost",method:"POST",path:"/auth/oauth/callback/apple",auth:[],answers:{303:"redirect"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async socialCallbackGitHub(t){return e.send({op:"SocialCallbackGitHub",method:"GET",path:"/auth/oauth/callback/github",auth:[],answers:{303:"redirect"},query:t.query,signal:t.signal})},async socialCallbackGitHubPost(t){return e.send({op:"SocialCallbackGitHubPost",method:"POST",path:"/auth/oauth/callback/github",auth:[],answers:{},signal:t?.signal})},async socialCallbackGoogle(t){return e.send({op:"SocialCallbackGoogle",method:"GET",path:"/auth/oauth/callback/google",auth:[],answers:{303:"redirect"},query:t.query,signal:t.signal})},async socialCallbackGooglePost(t){return e.send({op:"SocialCallbackGooglePost",method:"POST",path:"/auth/oauth/callback/google",auth:[],answers:{},signal:t?.signal})},async socialCallbackMicrosoft(t){return e.send({op:"SocialCallbackMicrosoft",method:"GET",path:"/auth/oauth/callback/microsoft",auth:[],answers:{303:"redirect"},query:t.query,signal:t.signal})},async socialCallbackMicrosoftPost(t){return e.send({op:"SocialCallbackMicrosoftPost",method:"POST",path:"/auth/oauth/callback/microsoft",auth:[],answers:{},signal:t?.signal})},async socialConfig(t){return e.send({op:"SocialConfig",method:"GET",path:"/auth/oauth/config",auth:[["ApiKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async socialBegin(t){return e.send({op:"SocialBegin",method:"POST",path:"/auth/oauth/transactions",auth:[["ApiKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async socialCancel(t){return e.send({op:"SocialCancel",method:"POST",path:"/auth/oauth/transactions/"+u("SocialCancel","id",t.path.id)+"/cancel",auth:[["ApiKeyAuth"]],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async socialComplete(t){return e.send({op:"SocialComplete",method:"POST",path:"/auth/oauth/transactions/"+u("SocialComplete","id",t.path.id)+"/complete",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async requestPhoneOtp(t){return e.send({op:"RequestPhoneOTP",method:"POST",path:"/auth/otp",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async verifyPhoneOtp(t){return e.send({op:"VerifyPhoneOTP",method:"POST",path:"/auth/otp/verify",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async hostedRecoveryApprovalPage(t){return e.send({op:"HostedRecoveryApprovalPage",method:"GET",path:"/auth/pages/recovery-approval",auth:[],answers:{200:"raw"},query:t?.query,signal:t?.signal})},async hostedRecoveryApprovalSubmit(t){return e.send({op:"HostedRecoveryApprovalSubmit",method:"POST",path:"/auth/pages/recovery-approval",auth:[],answers:{200:"raw"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async hostedRecoveryContactPage(t){return e.send({op:"HostedRecoveryContactPage",method:"GET",path:"/auth/pages/recovery-contact",auth:[],answers:{200:"raw"},query:t?.query,signal:t?.signal})},async hostedRecoveryContactSubmit(t){return e.send({op:"HostedRecoveryContactSubmit",method:"POST",path:"/auth/pages/recovery-contact",auth:[],answers:{200:"raw"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async hostedResetPasswordPage(t){return e.send({op:"HostedResetPasswordPage",method:"GET",path:"/auth/pages/reset-password",auth:[],answers:{200:"raw"},query:t?.query,signal:t?.signal})},async hostedResetPasswordSubmit(t){return e.send({op:"HostedResetPasswordSubmit",method:"POST",path:"/auth/pages/reset-password",auth:[],answers:{200:"raw"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async hostedVerifyEmailPage(t){return e.send({op:"HostedVerifyEmailPage",method:"GET",path:"/auth/pages/verify-email",auth:[],answers:{200:"raw"},query:t?.query,signal:t?.signal})},async hostedVerifyEmailSubmit(t){return e.send({op:"HostedVerifyEmailSubmit",method:"POST",path:"/auth/pages/verify-email",auth:[],answers:{200:"raw"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async passwordChange(t){return e.send({op:"PasswordChange",method:"POST",path:"/auth/password/change",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async passwordResetRequest(t){return e.send({op:"PasswordResetRequest",method:"POST",path:"/auth/password/reset",auth:[["ApiKeyAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async passwordResetConfirm(t){return e.send({op:"PasswordResetConfirm",method:"POST",path:"/auth/password/reset/confirm",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async setPassword(t){return e.send({op:"SetPassword",method:"POST",path:"/auth/password/set",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async powChallenge(t){return e.send({op:"PowChallenge",method:"POST",path:"/auth/pow/challenge",auth:[["ApiKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async approveRecovery(t){return e.send({op:"ApproveRecovery",method:"POST",path:"/auth/recovery/approve",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listRecoveryContacts(t){return e.send({op:"ListRecoveryContacts",method:"GET",path:"/auth/recovery/contacts",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async addRecoveryContact(t){return e.send({op:"AddRecoveryContact",method:"POST",path:"/auth/recovery/contacts",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteRecoveryContact(t){return e.send({op:"DeleteRecoveryContact",method:"DELETE",path:"/auth/recovery/contacts/"+u("DeleteRecoveryContact","id",t.path.id),auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},signal:t.signal})},async verifyRecoveryContact(t){return e.send({op:"VerifyRecoveryContact",method:"POST",path:"/auth/recovery/contacts/"+u("VerifyRecoveryContact","id",t.path.id)+"/verify",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async denyRecovery(t){return e.send({op:"DenyRecovery",method:"POST",path:"/auth/recovery/deny",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async initiateRecovery(t){return e.send({op:"InitiateRecovery",method:"POST",path:"/auth/recovery/initiate",auth:[["ApiKeyAuth"]],answers:{200:"json",202:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getRecoveryStatus(t){return e.send({op:"GetRecoveryStatus",method:"GET",path:"/auth/recovery/status",auth:[["ApiKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async resendVerification(t){return e.send({op:"ResendVerification",method:"POST",path:"/auth/resend-verification",auth:[["ApiKeyAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listSessions(t){return e.send({op:"ListSessions",method:"GET",path:"/auth/sessions",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async revokeAllSessions(t){return e.send({op:"RevokeAllSessions",method:"DELETE",path:"/auth/sessions",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async revokeSession(t){return e.send({op:"RevokeSession",method:"DELETE",path:"/auth/sessions/"+u("RevokeSession","id",t.path.id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async signup(t){return e.send({op:"Signup",method:"POST",path:"/auth/signup",auth:[["ApiKeyAuth"]],answers:{201:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async stepUp(t){return e.send({op:"StepUp",method:"POST",path:"/auth/step-up",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async stepUpStatus(t){return e.send({op:"StepUpStatus",method:"GET",path:"/auth/step-up/status",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async stepUpWebAuthnBegin(t){return e.send({op:"StepUpWebAuthnBegin",method:"POST",path:"/auth/step-up/webauthn/begin",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async stepUpSmsSend(t){return e.send({op:"StepUpSMSSend",method:"POST",path:"/auth/step-up/sms/send",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async exchangeCustomToken(t){return e.send({op:"ExchangeCustomToken",method:"POST",path:"/auth/token/exchange",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async refreshToken(t){return e.send({op:"RefreshToken",method:"POST",path:"/auth/token/refresh",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async revokeRefreshToken(t){return e.send({op:"RevokeRefreshToken",method:"POST",path:"/auth/token/revoke",auth:[["ApiKeyAuth"]],answers:{200:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listTransactions(t){return e.send({op:"ListTransactions",method:"GET",path:"/auth/transactions",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async createTransaction(t){return e.send({op:"CreateTransaction",method:"POST",path:"/auth/transactions",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getTransaction(t){return e.send({op:"GetTransaction",method:"GET",path:"/auth/transactions/"+u("GetTransaction","id",t.path.id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async approveTransaction(t){return e.send({op:"ApproveTransaction",method:"POST",path:"/auth/transactions/"+u("ApproveTransaction","id",t.path.id)+"/approve",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async denyTransaction(t){return e.send({op:"DenyTransaction",method:"POST",path:"/auth/transactions/"+u("DenyTransaction","id",t.path.id)+"/deny",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listTrustedDevices(t){return e.send({op:"ListTrustedDevices",method:"GET",path:"/auth/trusted-devices",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async registerTrustedDevice(t){return e.send({op:"RegisterTrustedDevice",method:"POST",path:"/auth/trusted-devices",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async revokeTrustedDevice(t){return e.send({op:"RevokeTrustedDevice",method:"DELETE",path:"/auth/trusted-devices/"+u("RevokeTrustedDevice","id",t.path.id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async verifyTokenUser(t){return e.send({op:"VerifyTokenUser",method:"GET",path:"/auth/user",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async deleteAccount(t){return e.send({op:"DeleteAccount",method:"DELETE",path:"/auth/user",auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t?.body},signal:t?.signal})},async verifyEmail(t){return e.send({op:"VerifyEmail",method:"POST",path:"/auth/verify-email",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async webauthnListCredentials(t){return e.send({op:"WebauthnListCredentials",method:"GET",path:"/auth/webauthn/credentials",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async webauthnRenameCredential(t){return e.send({op:"WebauthnRenameCredential",method:"PUT",path:"/auth/webauthn/credentials/"+u("WebauthnRenameCredential","id",t.path.id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async webauthnDeleteCredential(t){return e.send({op:"WebauthnDeleteCredential",method:"DELETE",path:"/auth/webauthn/credentials/"+u("WebauthnDeleteCredential","id",t.path.id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async webauthnLoginBegin(t){return e.send({op:"WebauthnLoginBegin",method:"POST",path:"/auth/webauthn/login/begin",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t?.body},signal:t?.signal})},async webauthnLoginFinish(t){return e.send({op:"WebauthnLoginFinish",method:"POST",path:"/auth/webauthn/login/finish",auth:[["ApiKeyAuth"]],answers:{200:"json"},query:t.query,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async webauthnRecoveryBegin(t){return e.send({op:"WebauthnRecoveryBegin",method:"POST",path:"/auth/webauthn/recovery/begin",auth:[["ApiKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async webauthnRecoveryFinish(t){return e.send({op:"WebauthnRecoveryFinish",method:"POST",path:"/auth/webauthn/recovery/finish",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async webauthnRecoveryRegisterBegin(t){return e.send({op:"WebauthnRecoveryRegisterBegin",method:"POST",path:"/auth/webauthn/recovery/register/begin",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t?.body},signal:t?.signal})},async webauthnRecoveryRegisterFinish(t){return e.send({op:"WebauthnRecoveryRegisterFinish",method:"POST",path:"/auth/webauthn/recovery/register/finish",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async webauthnRegisterBegin(t){return e.send({op:"WebauthnRegisterBegin",method:"POST",path:"/auth/webauthn/register/begin",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t?.body},signal:t?.signal})},async webauthnRegisterFinish(t){return e.send({op:"WebauthnRegisterFinish",method:"POST",path:"/auth/webauthn/register/finish",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async webauthnSignupBegin(t){return e.send({op:"WebauthnSignupBegin",method:"POST",path:"/auth/webauthn/signup/begin",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async webauthnSignupFinish(t){return e.send({op:"WebauthnSignupFinish",method:"POST",path:"/auth/webauthn/signup/finish",auth:[["ApiKeyAuth"]],answers:{201:"json"},query:t.query,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async oauthAuthorize(t){return e.send({op:"OauthAuthorize",method:"GET",path:"/oauth/authorize",auth:[],answers:{302:"redirect",303:"redirect"},query:t?.query,signal:t?.signal})},async oauthAuthorizePost(t){return e.send({op:"OauthAuthorizePost",method:"POST",path:"/oauth/authorize",auth:[],answers:{302:"redirect",303:"redirect"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async oauthAuthorizeCallback(t){return e.send({op:"OauthAuthorizeCallback",method:"GET",path:"/oauth/authorize/callback",auth:[],answers:{303:"redirect"},query:t.query,signal:t.signal})},async oauthAuthorizeEmailLink(t){return e.send({op:"OauthAuthorizeEmailLink",method:"GET",path:"/oauth/authorize/email",auth:[],answers:{200:"raw",303:"redirect"},query:t.query,signal:t.signal})},async oauthDeviceAuthorize(t){return e.send({op:"OauthDeviceAuthorize",method:"POST",path:"/oauth/device",auth:[["OAuthClient"],[]],answers:{200:"json"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async oauthIntrospect(t){return e.send({op:"OauthIntrospect",method:"POST",path:"/oauth/introspect",auth:[["AdminAuth"],["OAuthClient"],[]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async oauthLogout(t){return e.send({op:"OauthLogout",method:"GET",path:"/oauth/logout",auth:[],answers:{302:"redirect"},query:t?.query,signal:t?.signal})},async oauthLogoutPost(t){return e.send({op:"OauthLogoutPost",method:"POST",path:"/oauth/logout",auth:[],answers:{302:"redirect"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t?.body},signal:t?.signal})},async oauthPar(t){return e.send({op:"OauthPAR",method:"POST",path:"/oauth/par",auth:[["OAuthClient"],[]],answers:{201:"json"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async oauthRevoke(t){return e.send({op:"OauthRevoke",method:"POST",path:"/oauth/revoke",auth:[["OAuthClient"],[]],answers:{200:"empty"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async oauthToken(t){return e.send({op:"OauthToken",method:"POST",path:"/oauth/token",auth:[["OAuthClient"],[]],answers:{200:"json"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async oauthUserinfo(t){return e.send({op:"OauthUserinfo",method:"GET",path:"/oauth/userinfo",auth:[["OAuthAccessToken"]],answers:{200:"json"},signal:t?.signal})},async oauthUserinfoPost(t){return e.send({op:"OauthUserinfoPost",method:"POST",path:"/oauth/userinfo",auth:[["OAuthAccessToken"]],answers:{200:"json"},signal:t?.signal})},async ownerCliCode(t){return e.send({op:"OwnerCLICode",method:"POST",path:"/auth/cli/owner-code",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listConsentKeys(t){return e.send({op:"ListConsentKeys",method:"GET",path:"/auth/consents/keys",auth:[["ApiKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getConsents(t){return e.send({op:"GetConsents",method:"GET",path:"/auth/consents",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t.query,headers:t.headers,signal:t.signal})},async chooseConsents(t){return e.send({op:"ChooseConsents",method:"PUT",path:"/auth/consents",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async linkConsents(t){return e.send({op:"LinkConsents",method:"POST",path:"/auth/consents/link",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminGetInstallationConsents(t){return e.send({op:"AdminGetInstallationConsents",method:"GET",path:"/admin/installations/"+u("AdminGetInstallationConsents","installation_id",t.path.installation_id)+"/consents",auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminRefuseConsents(t){return e.send({op:"AdminRefuseConsents",method:"POST",path:"/admin/consents/refuse",auth:[["AdminAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminInviteUser(t){return e.send({op:"AdminInviteUser",method:"POST",path:"/admin/users/invite",auth:[["AdminAuth"]],answers:{200:"json",201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async acceptInvitation(t){return e.send({op:"AcceptInvitation",method:"POST",path:"/auth/invitations/accept",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async hostedAcceptInvitationPage(t){return e.send({op:"HostedAcceptInvitationPage",method:"GET",path:"/auth/pages/accept-invitation",auth:[],answers:{200:"raw"},query:t?.query,signal:t?.signal})},async hostedAcceptInvitationSubmit(t){return e.send({op:"HostedAcceptInvitationSubmit",method:"POST",path:"/auth/pages/accept-invitation",auth:[],answers:{200:"raw"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})}}}var Gr={};Dt(Gr,{client:()=>fk});function fk(e){return{async getCacheEntry(t){return e.send({op:"GetCacheEntry",method:"GET",path:"/cache/entry",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async putCacheEntry(t){return e.send({op:"PutCacheEntry",method:"PUT",path:"/cache/entry",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteCacheEntry(t){return e.send({op:"DeleteCacheEntry",method:"DELETE",path:"/cache/entry",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async incrementCacheEntry(t){return e.send({op:"IncrementCacheEntry",method:"POST",path:"/cache/entry/increment",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getCacheUsage(t){return e.send({op:"GetCacheUsage",method:"GET",path:"/cache/usage",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})}}}var qr={};Dt(qr,{client:()=>yk});function yk(e){return{async listCalls(t){return e.send({op:"ListCalls",method:"GET",path:"/calls",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async startCall(t){return e.send({op:"StartCall",method:"POST",path:"/calls",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json",201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminListCalls(t){return e.send({op:"AdminListCalls",method:"GET",path:"/calls/admin/calls",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async adminGetCall(t){return e.send({op:"AdminGetCall",method:"GET",path:"/calls/admin/calls/"+u("AdminGetCall","call_id",t.path.call_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async adminEndCall(t){return e.send({op:"AdminEndCall",method:"POST",path:"/calls/admin/calls/"+u("AdminEndCall","call_id",t.path.call_id)+"/end",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async createCallTicket(t){return e.send({op:"CreateCallTicket",method:"POST",path:"/calls/admin/calls/"+u("CreateCallTicket","call_id",t.path.call_id)+"/tickets",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getCallPlace(t){return e.send({op:"GetCallPlace",method:"GET",path:"/calls/places/"+u("GetCallPlace","place",t.path.place),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async watchCallPlace(t){return e.send({op:"WatchCallPlace",method:"POST",path:"/calls/places/"+u("WatchCallPlace","place",t.path.place)+"/watch",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async unwatchCallPlace(t){return e.send({op:"UnwatchCallPlace",method:"DELETE",path:"/calls/places/"+u("UnwatchCallPlace","place",t.path.place)+"/watch",auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},signal:t.signal})},async getCallSettings(t){return e.send({op:"GetCallSettings",method:"GET",path:"/calls/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async putCallSettings(t){return e.send({op:"PutCallSettings",method:"PUT",path:"/calls/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async rotateCallHookSecret(t){return e.send({op:"RotateCallHookSecret",method:"POST",path:"/calls/settings/hook-secret",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getCall(t){return e.send({op:"GetCall",method:"GET",path:"/calls/"+u("GetCall","call_id",t.path.call_id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async acceptCall(t){return e.send({op:"AcceptCall",method:"POST",path:"/calls/"+u("AcceptCall","call_id",t.path.call_id)+"/accept",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async declineCall(t){return e.send({op:"DeclineCall",method:"POST",path:"/calls/"+u("DeclineCall","call_id",t.path.call_id)+"/decline",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async callHeartbeat(t){return e.send({op:"CallHeartbeat",method:"POST",path:"/calls/"+u("CallHeartbeat","call_id",t.path.call_id)+"/heartbeat",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async joinCall(t){return e.send({op:"JoinCall",method:"POST",path:"/calls/"+u("JoinCall","call_id",t.path.call_id)+"/join",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async leaveCall(t){return e.send({op:"LeaveCall",method:"POST",path:"/calls/"+u("LeaveCall","call_id",t.path.call_id)+"/leave",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async getCallMedia(t){return e.send({op:"GetCallMedia",method:"POST",path:"/calls/"+u("GetCallMedia","call_id",t.path.call_id)+"/media",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async inviteToCall(t){return e.send({op:"InviteToCall",method:"POST",path:"/calls/"+u("InviteToCall","call_id",t.path.call_id)+"/participants",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})}}}var fi={};Dt(fi,{client:()=>bk});function bk(e){return{async getValues(t){return e.send({op:"GetValues",method:"GET",path:"/flags",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},headers:t?.headers,signal:t?.signal})},async batchUserValues(t){return e.send({op:"BatchUserValues",method:"POST",path:"/flags/batch",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getDelta(t){return e.send({op:"GetDelta",method:"GET",path:"/flags/delta",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json",304:"empty"},query:t?.query,headers:t?.headers,signal:t?.signal})},async getEvaluations(t){return e.send({op:"GetEvaluations",method:"GET",path:"/flags/evaluations",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async listExperiments(t){return e.send({op:"ListExperiments",method:"GET",path:"/flags/experiments",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async startExperiment(t){return e.send({op:"StartExperiment",method:"POST",path:"/flags/experiments",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getExperiment(t){return e.send({op:"GetExperiment",method:"GET",path:"/flags/experiments/"+u("GetExperiment","experiment_id",t.path.experiment_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getExperimentResults(t){return e.send({op:"GetExperimentResults",method:"GET",path:"/flags/experiments/"+u("GetExperimentResults","experiment_id",t.path.experiment_id)+"/results",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async stopExperiment(t){return e.send({op:"StopExperiment",method:"POST",path:"/flags/experiments/"+u("StopExperiment","experiment_id",t.path.experiment_id)+"/stop",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async declareExperimentWinner(t){return e.send({op:"DeclareExperimentWinner",method:"POST",path:"/flags/experiments/"+u("DeclareExperimentWinner","experiment_id",t.path.experiment_id)+"/winner",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getCurrentInstallations(t){return e.send({op:"GetCurrentInstallations",method:"GET",path:"/flags/installations/current",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getInstallationsDaily(t){return e.send({op:"GetInstallationsDaily",method:"GET",path:"/flags/installations/daily",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getSnapshot(t){return e.send({op:"GetSnapshot",method:"GET",path:"/flags/snapshot",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json",304:"empty"},headers:t?.headers,signal:t?.signal})},async listDefinitions(t){return e.send({op:"ListDefinitions",method:"GET",path:"/flags/system",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getDefinition(t){return e.send({op:"GetDefinition",method:"GET",path:"/flags/system/"+u("GetDefinition","key",t.path.key),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putDefinition(t){return e.send({op:"PutDefinition",method:"PUT",path:"/flags/system/"+u("PutDefinition","key",t.path.key),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteDefinition(t){return e.send({op:"DeleteDefinition",method:"DELETE",path:"/flags/system/"+u("DeleteDefinition","key",t.path.key),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async activateTemplates(t){return e.send({op:"ActivateTemplates",method:"POST",path:"/flags/templates/activation",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getActiveTemplate(t){return e.send({op:"GetActiveTemplate",method:"GET",path:"/flags/templates/active",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getTemplateCapabilities(t){return e.send({op:"GetTemplateCapabilities",method:"GET",path:"/flags/templates/capabilities",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getTemplateDraft(t){return e.send({op:"GetTemplateDraft",method:"GET",path:"/flags/templates/draft",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async createTemplateDraft(t){return e.send({op:"CreateTemplateDraft",method:"POST",path:"/flags/templates/draft",auth:[["SecretKeyAuth"]],answers:{201:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async discardTemplateDraft(t){return e.send({op:"DiscardTemplateDraft",method:"DELETE",path:"/flags/templates/draft",auth:[["SecretKeyAuth"]],answers:{204:"empty"},headers:t.headers,signal:t.signal})},async putTemplateParameter(t){return e.send({op:"PutTemplateParameter",method:"PUT",path:"/flags/templates/draft/parameters/"+u("PutTemplateParameter","key",t.path.key),auth:[["SecretKeyAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async removeTemplateParameter(t){return e.send({op:"RemoveTemplateParameter",method:"DELETE",path:"/flags/templates/draft/parameters/"+u("RemoveTemplateParameter","key",t.path.key),auth:[["SecretKeyAuth"]],answers:{200:"json"},headers:t.headers,signal:t.signal})},async reviewTemplateDraft(t){return e.send({op:"ReviewTemplateDraft",method:"GET",path:"/flags/templates/draft/review",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async publishTemplate(t){return e.send({op:"PublishTemplate",method:"POST",path:"/flags/templates/publish",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getPublishReceipt(t){return e.send({op:"GetPublishReceipt",method:"POST",path:"/flags/templates/publish/receipt",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async restoreTemplateVersion(t){return e.send({op:"RestoreTemplateVersion",method:"POST",path:"/flags/templates/restore/"+u("RestoreTemplateVersion","version",t.path.version),auth:[["SecretKeyAuth"]],answers:{201:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listTemplateVersions(t){return e.send({op:"ListTemplateVersions",method:"GET",path:"/flags/templates/versions",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getTemplateVersion(t){return e.send({op:"GetTemplateVersion",method:"GET",path:"/flags/templates/versions/"+u("GetTemplateVersion","version",t.path.version),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getUserValues(t){return e.send({op:"GetUserValues",method:"GET",path:"/flags/users/"+u("GetUserValues","user_id",t.path.user_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},headers:t.headers,signal:t.signal})},async putUserValues(t){return e.send({op:"PutUserValues",method:"PUT",path:"/flags/users/"+u("PutUserValues","user_id",t.path.user_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteUserValues(t){return e.send({op:"DeleteUserValues",method:"DELETE",path:"/flags/users/"+u("DeleteUserValues","user_id",t.path.user_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putUserValue(t){return e.send({op:"PutUserValue",method:"PUT",path:"/flags/users/"+u("PutUserValue","user_id",t.path.user_id)+"/"+u("PutUserValue","key",t.path.key),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteUserValue(t){return e.send({op:"DeleteUserValue",method:"DELETE",path:"/flags/users/"+u("DeleteUserValue","user_id",t.path.user_id)+"/"+u("DeleteUserValue","key",t.path.key),auth:[["SecretKeyAuth"]],answers:{200:"json"},headers:t.headers,signal:t.signal})}}}var yi={};Dt(yi,{client:()=>vk});function vk(e){return{async listMachines(t){return e.send({op:"ListMachines",method:"GET",path:"/machines",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async createMachine(t){return e.send({op:"CreateMachine",method:"POST",path:"/machines",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listMachineSizes(t){return e.send({op:"ListMachineSizes",method:"GET",path:"/machines/sizes",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getMachineNetwork(t){return e.send({op:"GetMachineNetwork",method:"GET",path:"/machines/network",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async connectGitHub(t){return e.send({op:"ConnectGitHub",method:"POST",path:"/machines/github/connect",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async listInstallations(t){return e.send({op:"ListInstallations",method:"GET",path:"/machines/github/installations",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async linkInstallation(t){return e.send({op:"LinkInstallation",method:"POST",path:"/machines/github/installations",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async shareInstallation(t){return e.send({op:"ShareInstallation",method:"POST",path:"/machines/github/installations/share",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async unlinkInstallation(t){return e.send({op:"UnlinkInstallation",method:"DELETE",path:"/machines/github/installations/"+u("UnlinkInstallation","installation",t.path.installation),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async listRepositories(t){return e.send({op:"ListRepositories",method:"GET",path:"/machines/github/repositories",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getMachine(t){return e.send({op:"GetMachine",method:"GET",path:"/machines/"+u("GetMachine","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async deleteMachine(t){return e.send({op:"DeleteMachine",method:"DELETE",path:"/machines/"+u("DeleteMachine","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async updateMachine(t){return e.send({op:"UpdateMachine",method:"PATCH",path:"/machines/"+u("UpdateMachine","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listBuilds(t){return e.send({op:"ListBuilds",method:"GET",path:"/machines/"+u("ListBuilds","name",t.path.name)+"/builds",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async deployMachine(t){return e.send({op:"DeployMachine",method:"POST",path:"/machines/"+u("DeployMachine","name",t.path.name)+"/builds",auth:[["SecretKeyAuth"]],answers:{202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listMachinePreviews(t){return e.send({op:"ListMachinePreviews",method:"GET",path:"/machines/"+u("ListMachinePreviews","name",t.path.name)+"/previews",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putMachinePreview(t){return e.send({op:"PutMachinePreview",method:"PUT",path:"/machines/"+u("PutMachinePreview","name",t.path.name)+"/previews/"+u("PutMachinePreview","pull_request",t.path.pull_request),auth:[["SecretKeyAuth"]],answers:{202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteMachinePreview(t){return e.send({op:"DeleteMachinePreview",method:"DELETE",path:"/machines/"+u("DeleteMachinePreview","name",t.path.name)+"/previews/"+u("DeleteMachinePreview","pull_request",t.path.pull_request),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async listMachineDomains(t){return e.send({op:"ListMachineDomains",method:"GET",path:"/machines/"+u("ListMachineDomains","name",t.path.name)+"/domains",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async addMachineDomain(t){return e.send({op:"AddMachineDomain",method:"POST",path:"/machines/"+u("AddMachineDomain","name",t.path.name)+"/domains",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteMachineDomain(t){return e.send({op:"DeleteMachineDomain",method:"DELETE",path:"/machines/"+u("DeleteMachineDomain","name",t.path.name)+"/domains/"+u("DeleteMachineDomain","host",t.path.host),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async updateMachineDomain(t){return e.send({op:"UpdateMachineDomain",method:"PATCH",path:"/machines/"+u("UpdateMachineDomain","name",t.path.name)+"/domains/"+u("UpdateMachineDomain","host",t.path.host),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getBuild(t){return e.send({op:"GetBuild",method:"GET",path:"/machines/"+u("GetBuild","name",t.path.name)+"/builds/"+u("GetBuild","build",t.path.build),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getBuildLog(t){return e.send({op:"GetBuildLog",method:"GET",path:"/machines/"+u("GetBuildLog","name",t.path.name)+"/builds/"+u("GetBuildLog","build",t.path.build)+"/log",auth:[["SecretKeyAuth"]],answers:{200:"raw"},signal:t.signal})},async rollbackMachine(t){return e.send({op:"RollbackMachine",method:"POST",path:"/machines/"+u("RollbackMachine","name",t.path.name)+"/rollback",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listDatabases(t){return e.send({op:"ListDatabases",method:"GET",path:"/databases",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async createDatabase(t){return e.send({op:"CreateDatabase",method:"POST",path:"/databases",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listDatabaseSizes(t){return e.send({op:"ListDatabaseSizes",method:"GET",path:"/databases/sizes",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getDatabase(t){return e.send({op:"GetDatabase",method:"GET",path:"/databases/"+u("GetDatabase","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async deleteDatabase(t){return e.send({op:"DeleteDatabase",method:"DELETE",path:"/databases/"+u("DeleteDatabase","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async updateDatabase(t){return e.send({op:"UpdateDatabase",method:"PATCH",path:"/databases/"+u("UpdateDatabase","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json",202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async undeleteDatabase(t){return e.send({op:"UndeleteDatabase",method:"POST",path:"/databases/"+u("UndeleteDatabase","name",t.path.name)+"/undelete",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async purgeDatabase(t){return e.send({op:"PurgeDatabase",method:"POST",path:"/databases/"+u("PurgeDatabase","name",t.path.name)+"/purge",auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async getDatabaseCredentials(t){return e.send({op:"GetDatabaseCredentials",method:"GET",path:"/databases/"+u("GetDatabaseCredentials","name",t.path.name)+"/credentials",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async changeDatabasePassword(t){return e.send({op:"ChangeDatabasePassword",method:"POST",path:"/databases/"+u("ChangeDatabasePassword","name",t.path.name)+"/password",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async readMachineLogs(t){return e.send({op:"ReadMachineLogs",method:"GET",path:"/machines/"+u("ReadMachineLogs","name",t.path.name)+"/logs",auth:[["SecretKeyAuth"]],answers:{200:"raw"},query:t.query,signal:t.signal})},async execInMachine(t){return e.send({op:"ExecInMachine",method:"POST",path:"/machines/"+u("ExecInMachine","name",t.path.name)+"/exec",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listMachineExecs(t){return e.send({op:"ListMachineExecs",method:"GET",path:"/machines/"+u("ListMachineExecs","name",t.path.name)+"/execs",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getMachineMetrics(t){return e.send({op:"GetMachineMetrics",method:"GET",path:"/machines/"+u("GetMachineMetrics","name",t.path.name)+"/metrics",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getMachineContract(t){return e.send({op:"GetMachineContract",method:"GET",path:"/machines/"+u("GetMachineContract","name",t.path.name)+"/openapi",auth:[["SecretKeyAuth"]],answers:{200:"json",304:"empty"},headers:t.headers,signal:t.signal})},async restoreDatabase(t){return e.send({op:"RestoreDatabase",method:"POST",path:"/databases/"+u("RestoreDatabase","name",t.path.name)+"/restore",auth:[["SecretKeyAuth"]],answers:{202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getDatabaseSchema(t){return e.send({op:"GetDatabaseSchema",method:"GET",path:"/databases/"+u("GetDatabaseSchema","name",t.path.name)+"/schema",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getDatabaseMetrics(t){return e.send({op:"GetDatabaseMetrics",method:"GET",path:"/databases/"+u("GetDatabaseMetrics","name",t.path.name)+"/metrics",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async queryDatabase(t){return e.send({op:"QueryDatabase",method:"POST",path:"/databases/"+u("QueryDatabase","name",t.path.name)+"/sql",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listCrons(t){return e.send({op:"ListCrons",method:"GET",path:"/machines/"+u("ListCrons","name",t.path.name)+"/crons",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async listCronRuns(t){return e.send({op:"ListCronRuns",method:"GET",path:"/machines/"+u("ListCronRuns","name",t.path.name)+"/crons/"+u("ListCronRuns","cron",t.path.cron)+"/runs",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async runCron(t){return e.send({op:"RunCron",method:"POST",path:"/machines/"+u("RunCron","name",t.path.name)+"/crons/"+u("RunCron","cron",t.path.cron)+"/run",auth:[["SecretKeyAuth"]],answers:{201:"json"},signal:t.signal})},async pauseCron(t){return e.send({op:"PauseCron",method:"POST",path:"/machines/"+u("PauseCron","name",t.path.name)+"/crons/"+u("PauseCron","cron",t.path.cron)+"/pause",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async resumeCron(t){return e.send({op:"ResumeCron",method:"POST",path:"/machines/"+u("ResumeCron","name",t.path.name)+"/crons/"+u("ResumeCron","cron",t.path.cron)+"/resume",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async listTasks(t){return e.send({op:"ListTasks",method:"GET",path:"/machines/"+u("ListTasks","name",t.path.name)+"/tasks",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async enqueueTask(t){return e.send({op:"EnqueueTask",method:"POST",path:"/machines/"+u("EnqueueTask","name",t.path.name)+"/tasks",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getTask(t){return e.send({op:"GetTask",method:"GET",path:"/machines/"+u("GetTask","name",t.path.name)+"/tasks/"+u("GetTask","task",t.path.task),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async cancelTask(t){return e.send({op:"CancelTask",method:"POST",path:"/machines/"+u("CancelTask","name",t.path.name)+"/tasks/"+u("CancelTask","task",t.path.task)+"/cancel",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async retryTask(t){return e.send({op:"RetryTask",method:"POST",path:"/machines/"+u("RetryTask","name",t.path.name)+"/tasks/"+u("RetryTask","task",t.path.task)+"/retry",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async listTaskTypes(t){return e.send({op:"ListTaskTypes",method:"GET",path:"/machines/"+u("ListTaskTypes","name",t.path.name)+"/task-types",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async makeTemplatedTestUsers(t){return e.send({op:"MakeTemplatedTestUsers",method:"POST",path:"/machines/"+u("MakeTemplatedTestUsers","name",t.path.name)+"/test-users",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async templateTestUser(t){return e.send({op:"TemplateTestUser",method:"POST",path:"/machines/"+u("TemplateTestUser","name",t.path.name)+"/test-users/"+u("TemplateTestUser","user",t.path.user)+"/templates/"+u("TemplateTestUser","template",t.path.template),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async deleteTemplatedTestUser(t){return e.send({op:"DeleteTemplatedTestUser",method:"DELETE",path:"/machines/"+u("DeleteTemplatedTestUser","name",t.path.name)+"/test-users/"+u("DeleteTemplatedTestUser","user",t.path.user),auth:[["SecretKeyAuth"]],answers:{200:"json",204:"empty"},headers:t.headers,signal:t.signal})},async listSites(t){return e.send({op:"ListSites",method:"GET",path:"/sites",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async createSite(t){return e.send({op:"CreateSite",method:"POST",path:"/sites",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getSite(t){return e.send({op:"GetSite",method:"GET",path:"/sites/"+u("GetSite","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async deleteSite(t){return e.send({op:"DeleteSite",method:"DELETE",path:"/sites/"+u("DeleteSite","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async updateSite(t){return e.send({op:"UpdateSite",method:"PATCH",path:"/sites/"+u("UpdateSite","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listSiteReleases(t){return e.send({op:"ListSiteReleases",method:"GET",path:"/sites/"+u("ListSiteReleases","name",t.path.name)+"/releases",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async createSiteRelease(t){return e.send({op:"CreateSiteRelease",method:"POST",path:"/sites/"+u("CreateSiteRelease","name",t.path.name)+"/releases",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async uploadSiteFile(t){return e.send({op:"UploadSiteFile",method:"PUT",path:"/sites/"+u("UploadSiteFile","name",t.path.name)+"/releases/"+u("UploadSiteFile","release",t.path.release)+"/files/"+u("UploadSiteFile","digest",t.path.digest),auth:[["SecretKeyAuth"]],answers:{204:"empty"},body:{kind:"raw",contentType:t.contentType??"application/octet-stream",value:t.body},signal:t.signal})},async finishSiteRelease(t){return e.send({op:"FinishSiteRelease",method:"POST",path:"/sites/"+u("FinishSiteRelease","name",t.path.name)+"/releases/"+u("FinishSiteRelease","release",t.path.release)+"/finish",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async rollbackSite(t){return e.send({op:"RollbackSite",method:"POST",path:"/sites/"+u("RollbackSite","name",t.path.name)+"/rollback",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listSiteBuilds(t){return e.send({op:"ListSiteBuilds",method:"GET",path:"/sites/"+u("ListSiteBuilds","name",t.path.name)+"/builds",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async deploySite(t){return e.send({op:"DeploySite",method:"POST",path:"/sites/"+u("DeploySite","name",t.path.name)+"/builds",auth:[["SecretKeyAuth"]],answers:{202:"json"},signal:t.signal})},async listSitePreviews(t){return e.send({op:"ListSitePreviews",method:"GET",path:"/sites/"+u("ListSitePreviews","name",t.path.name)+"/previews",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async listSiteDomains(t){return e.send({op:"ListSiteDomains",method:"GET",path:"/sites/"+u("ListSiteDomains","name",t.path.name)+"/domains",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async addSiteDomain(t){return e.send({op:"AddSiteDomain",method:"POST",path:"/sites/"+u("AddSiteDomain","name",t.path.name)+"/domains",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteSiteDomain(t){return e.send({op:"DeleteSiteDomain",method:"DELETE",path:"/sites/"+u("DeleteSiteDomain","name",t.path.name)+"/domains/"+u("DeleteSiteDomain","host",t.path.host),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async updateSiteDomain(t){return e.send({op:"UpdateSiteDomain",method:"PATCH",path:"/sites/"+u("UpdateSiteDomain","name",t.path.name)+"/domains/"+u("UpdateSiteDomain","host",t.path.host),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getSiteBuild(t){return e.send({op:"GetSiteBuild",method:"GET",path:"/sites/"+u("GetSiteBuild","name",t.path.name)+"/builds/"+u("GetSiteBuild","build",t.path.build),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async authorizeSitePreview(t){return e.send({op:"AuthorizeSitePreview",method:"POST",path:"/sites/"+u("AuthorizeSitePreview","name",t.path.name)+"/previews/"+u("AuthorizeSitePreview","pull_request",t.path.pull_request)+"/authorize",auth:[["SecretKeyAuth"]],answers:{202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async authorizeMachinePreview(t){return e.send({op:"AuthorizeMachinePreview",method:"POST",path:"/machines/"+u("AuthorizeMachinePreview","name",t.path.name)+"/previews/"+u("AuthorizeMachinePreview","pull_request",t.path.pull_request)+"/authorize",auth:[["SecretKeyAuth"]],answers:{202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async openMachinePreview(t){return e.send({op:"OpenMachinePreview",method:"POST",path:"/machines/"+u("OpenMachinePreview","name",t.path.name)+"/previews/"+u("OpenMachinePreview","pull_request",t.path.pull_request)+"/open",auth:[["SecretKeyAuth"]],answers:{202:"json"},signal:t.signal})},async moveMachine(t){return e.send({op:"MoveMachine",method:"POST",path:"/machines/"+u("MoveMachine","name",t.path.name)+"/move",auth:[["SecretKeyAuth"]],answers:{200:"json",202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async moveSite(t){return e.send({op:"MoveSite",method:"POST",path:"/sites/"+u("MoveSite","name",t.path.name)+"/move",auth:[["SecretKeyAuth"]],answers:{200:"json",202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async moveDatabase(t){return e.send({op:"MoveDatabase",method:"POST",path:"/databases/"+u("MoveDatabase","name",t.path.name)+"/move",auth:[["SecretKeyAuth"]],answers:{200:"json",202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async cancelSiteBuild(t){return e.send({op:"CancelSiteBuild",method:"POST",path:"/sites/"+u("CancelSiteBuild","name",t.path.name)+"/builds/"+u("CancelSiteBuild","build",t.path.build)+"/cancel",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async cancelBuild(t){return e.send({op:"CancelBuild",method:"POST",path:"/machines/"+u("CancelBuild","name",t.path.name)+"/builds/"+u("CancelBuild","build",t.path.build)+"/cancel",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async listSiteHooks(t){return e.send({op:"ListSiteHooks",method:"GET",path:"/sites/"+u("ListSiteHooks","name",t.path.name)+"/hooks",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async createSiteHook(t){return e.send({op:"CreateSiteHook",method:"POST",path:"/sites/"+u("CreateSiteHook","name",t.path.name)+"/hooks",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteSiteHook(t){return e.send({op:"DeleteSiteHook",method:"DELETE",path:"/sites/"+u("DeleteSiteHook","name",t.path.name)+"/hooks/"+u("DeleteSiteHook","hook",t.path.hook),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async listMachineHooks(t){return e.send({op:"ListMachineHooks",method:"GET",path:"/machines/"+u("ListMachineHooks","name",t.path.name)+"/hooks",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async createMachineHook(t){return e.send({op:"CreateMachineHook",method:"POST",path:"/machines/"+u("CreateMachineHook","name",t.path.name)+"/hooks",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteMachineHook(t){return e.send({op:"DeleteMachineHook",method:"DELETE",path:"/machines/"+u("DeleteMachineHook","name",t.path.name)+"/hooks/"+u("DeleteMachineHook","hook",t.path.hook),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async detectProject(t){return e.send({op:"DetectProject",method:"GET",path:"/machines/github/detect",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async createPreviewPass(t){return e.send({op:"CreatePreviewPass",method:"POST",path:"/sites/"+u("CreatePreviewPass","name",t.path.name)+"/previews/pass",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listPreviewLinks(t){return e.send({op:"ListPreviewLinks",method:"GET",path:"/sites/"+u("ListPreviewLinks","name",t.path.name)+"/previews/links",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async createPreviewLink(t){return e.send({op:"CreatePreviewLink",method:"POST",path:"/sites/"+u("CreatePreviewLink","name",t.path.name)+"/previews/links",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deletePreviewLink(t){return e.send({op:"DeletePreviewLink",method:"DELETE",path:"/sites/"+u("DeletePreviewLink","name",t.path.name)+"/previews/links/"+u("DeletePreviewLink","link",t.path.link),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async listEnvironmentDomains(t){return e.send({op:"ListEnvironmentDomains",method:"GET",path:"/domains",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async addEnvironmentDomain(t){return e.send({op:"AddEnvironmentDomain",method:"POST",path:"/domains",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteEnvironmentDomain(t){return e.send({op:"DeleteEnvironmentDomain",method:"DELETE",path:"/domains/"+u("DeleteEnvironmentDomain","host",t.path.host),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async setEnvironmentSignInDomain(t){return e.send({op:"SetEnvironmentSignInDomain",method:"PATCH",path:"/domains/"+u("SetEnvironmentSignInDomain","host",t.path.host),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})}}}var Ur={};Dt(Ur,{client:()=>_k});function _k(e){return{async adminAccessLog(t){return e.send({op:"AdminAccessLog",method:"GET",path:"/messaging/admin/access-log",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async adminListConversations(t){return e.send({op:"AdminListConversations",method:"GET",path:"/messaging/admin/conversations",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async adminCreateConversation(t){return e.send({op:"AdminCreateConversation",method:"POST",path:"/messaging/admin/conversations",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminGetConversation(t){return e.send({op:"AdminGetConversation",method:"GET",path:"/messaging/admin/conversations/"+u("AdminGetConversation","conversation_id",t.path.conversation_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async adminDeleteConversation(t){return e.send({op:"AdminDeleteConversation",method:"DELETE",path:"/messaging/admin/conversations/"+u("AdminDeleteConversation","conversation_id",t.path.conversation_id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async adminUpdateConversation(t){return e.send({op:"AdminUpdateConversation",method:"PATCH",path:"/messaging/admin/conversations/"+u("AdminUpdateConversation","conversation_id",t.path.conversation_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminAddMembers(t){return e.send({op:"AdminAddMembers",method:"POST",path:"/messaging/admin/conversations/"+u("AdminAddMembers","conversation_id",t.path.conversation_id)+"/members",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminRemoveMember(t){return e.send({op:"AdminRemoveMember",method:"DELETE",path:"/messaging/admin/conversations/"+u("AdminRemoveMember","conversation_id",t.path.conversation_id)+"/members/"+u("AdminRemoveMember","user_id",t.path.user_id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async adminListMessages(t){return e.send({op:"AdminListMessages",method:"GET",path:"/messaging/admin/conversations/"+u("AdminListMessages","conversation_id",t.path.conversation_id)+"/messages",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async adminSendMessage(t){return e.send({op:"AdminSendMessage",method:"POST",path:"/messaging/admin/conversations/"+u("AdminSendMessage","conversation_id",t.path.conversation_id)+"/messages",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminDeleteMessage(t){return e.send({op:"AdminDeleteMessage",method:"DELETE",path:"/messaging/admin/conversations/"+u("AdminDeleteMessage","conversation_id",t.path.conversation_id)+"/messages/"+u("AdminDeleteMessage","message_id",t.path.message_id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async adminFileUrl(t){return e.send({op:"AdminFileURL",method:"GET",path:"/messaging/admin/conversations/"+u("AdminFileURL","conversation_id",t.path.conversation_id)+"/messages/"+u("AdminFileURL","message_id",t.path.message_id)+"/attachments/"+u("AdminFileURL","attachment_id",t.path.attachment_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async adminPutProfile(t){return e.send({op:"AdminPutProfile",method:"PUT",path:"/messaging/admin/profiles/"+u("AdminPutProfile","user_id",t.path.user_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminListReports(t){return e.send({op:"AdminListReports",method:"GET",path:"/messaging/admin/reports",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async adminGetReport(t){return e.send({op:"AdminGetReport",method:"GET",path:"/messaging/admin/reports/"+u("AdminGetReport","report_id",t.path.report_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async adminReportFileUrl(t){return e.send({op:"AdminReportFileURL",method:"GET",path:"/messaging/admin/reports/"+u("AdminReportFileURL","report_id",t.path.report_id)+"/attachments/"+u("AdminReportFileURL","attachment_id",t.path.attachment_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async adminResolveReport(t){return e.send({op:"AdminResolveReport",method:"POST",path:"/messaging/admin/reports/"+u("AdminResolveReport","report_id",t.path.report_id)+"/resolve",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listBlocks(t){return e.send({op:"ListBlocks",method:"GET",path:"/messaging/blocks",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async block(t){return e.send({op:"Block",method:"PUT",path:"/messaging/blocks/"+u("Block","user_id",t.path.user_id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async unblock(t){return e.send({op:"Unblock",method:"DELETE",path:"/messaging/blocks/"+u("Unblock","user_id",t.path.user_id),auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},signal:t.signal})},async listConversations(t){return e.send({op:"ListConversations",method:"GET",path:"/messaging/conversations",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async openDirectConversation(t){return e.send({op:"OpenDirectConversation",method:"POST",path:"/messaging/conversations/direct",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json",201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async createGroup(t){return e.send({op:"CreateGroup",method:"POST",path:"/messaging/conversations/group",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getConversation(t){return e.send({op:"GetConversation",method:"GET",path:"/messaging/conversations/"+u("GetConversation","conversation_id",t.path.conversation_id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async deleteConversation(t){return e.send({op:"DeleteConversation",method:"DELETE",path:"/messaging/conversations/"+u("DeleteConversation","conversation_id",t.path.conversation_id),auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},signal:t.signal})},async updateConversation(t){return e.send({op:"UpdateConversation",method:"PATCH",path:"/messaging/conversations/"+u("UpdateConversation","conversation_id",t.path.conversation_id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async clearConversation(t){return e.send({op:"ClearConversation",method:"POST",path:"/messaging/conversations/"+u("ClearConversation","conversation_id",t.path.conversation_id)+"/clear",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async closeConversation(t){return e.send({op:"CloseConversation",method:"POST",path:"/messaging/conversations/"+u("CloseConversation","conversation_id",t.path.conversation_id)+"/close",auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},signal:t.signal})},async joinGroup(t){return e.send({op:"JoinGroup",method:"POST",path:"/messaging/conversations/"+u("JoinGroup","conversation_id",t.path.conversation_id)+"/join",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async listMembers(t){return e.send({op:"ListMembers",method:"GET",path:"/messaging/conversations/"+u("ListMembers","conversation_id",t.path.conversation_id)+"/members",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t.query,signal:t.signal})},async addMembers(t){return e.send({op:"AddMembers",method:"POST",path:"/messaging/conversations/"+u("AddMembers","conversation_id",t.path.conversation_id)+"/members",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async removeMember(t){return e.send({op:"RemoveMember",method:"DELETE",path:"/messaging/conversations/"+u("RemoveMember","conversation_id",t.path.conversation_id)+"/members/"+u("RemoveMember","user_id",t.path.user_id),auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},signal:t.signal})},async updateMember(t){return e.send({op:"UpdateMember",method:"PATCH",path:"/messaging/conversations/"+u("UpdateMember","conversation_id",t.path.conversation_id)+"/members/"+u("UpdateMember","user_id",t.path.user_id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listMessages(t){return e.send({op:"ListMessages",method:"GET",path:"/messaging/conversations/"+u("ListMessages","conversation_id",t.path.conversation_id)+"/messages",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t.query,signal:t.signal})},async sendMessage(t){return e.send({op:"SendMessage",method:"POST",path:"/messaging/conversations/"+u("SendMessage","conversation_id",t.path.conversation_id)+"/messages",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json",201:"json",202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getMessage(t){return e.send({op:"GetMessage",method:"GET",path:"/messaging/conversations/"+u("GetMessage","conversation_id",t.path.conversation_id)+"/messages/"+u("GetMessage","message_id",t.path.message_id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async deleteMessage(t){return e.send({op:"DeleteMessage",method:"DELETE",path:"/messaging/conversations/"+u("DeleteMessage","conversation_id",t.path.conversation_id)+"/messages/"+u("DeleteMessage","message_id",t.path.message_id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json",204:"empty"},query:t.query,signal:t.signal})},async editMessage(t){return e.send({op:"EditMessage",method:"PATCH",path:"/messaging/conversations/"+u("EditMessage","conversation_id",t.path.conversation_id)+"/messages/"+u("EditMessage","message_id",t.path.message_id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async attachmentUrl(t){return e.send({op:"AttachmentURL",method:"GET",path:"/messaging/conversations/"+u("AttachmentURL","conversation_id",t.path.conversation_id)+"/messages/"+u("AttachmentURL","message_id",t.path.message_id)+"/attachments/"+u("AttachmentURL","attachment_id",t.path.attachment_id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async react(t){return e.send({op:"React",method:"PUT",path:"/messaging/conversations/"+u("React","conversation_id",t.path.conversation_id)+"/messages/"+u("React","message_id",t.path.message_id)+"/reactions/"+u("React","emoji",t.path.emoji),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async unreact(t){return e.send({op:"Unreact",method:"DELETE",path:"/messaging/conversations/"+u("Unreact","conversation_id",t.path.conversation_id)+"/messages/"+u("Unreact","message_id",t.path.message_id)+"/reactions/"+u("Unreact","emoji",t.path.emoji),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async messageReaders(t){return e.send({op:"MessageReaders",method:"GET",path:"/messaging/conversations/"+u("MessageReaders","conversation_id",t.path.conversation_id)+"/messages/"+u("MessageReaders","message_id",t.path.message_id)+"/readers",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async listReplies(t){return e.send({op:"ListReplies",method:"GET",path:"/messaging/conversations/"+u("ListReplies","conversation_id",t.path.conversation_id)+"/messages/"+u("ListReplies","message_id",t.path.message_id)+"/replies",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t.query,signal:t.signal})},async viewOnce(t){return e.send({op:"ViewOnce",method:"POST",path:"/messaging/conversations/"+u("ViewOnce","conversation_id",t.path.conversation_id)+"/messages/"+u("ViewOnce","message_id",t.path.message_id)+"/view",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async setConversationNotifications(t){return e.send({op:"SetConversationNotifications",method:"PUT",path:"/messaging/conversations/"+u("SetConversationNotifications","conversation_id",t.path.conversation_id)+"/notifications",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async reportScreenshot(t){return e.send({op:"ReportScreenshot",method:"POST",path:"/messaging/conversations/"+u("ReportScreenshot","conversation_id",t.path.conversation_id)+"/screenshot",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},signal:t.signal})},async typing(t){return e.send({op:"Typing",method:"POST",path:"/messaging/conversations/"+u("Typing","conversation_id",t.path.conversation_id)+"/typing",auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async createUpload(t){return e.send({op:"CreateUpload",method:"POST",path:"/messaging/conversations/"+u("CreateUpload","conversation_id",t.path.conversation_id)+"/uploads",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listOpenGroups(t){return e.send({op:"ListOpenGroups",method:"GET",path:"/messaging/groups/open",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getMyProfile(t){return e.send({op:"GetMyProfile",method:"GET",path:"/messaging/me",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async updateMyProfile(t){return e.send({op:"UpdateMyProfile",method:"PATCH",path:"/messaging/me",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async presence(t){return e.send({op:"Presence",method:"POST",path:"/messaging/me/presence",auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},signal:t?.signal})},async getProfiles(t){return e.send({op:"GetProfiles",method:"GET",path:"/messaging/profiles",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t.query,signal:t.signal})},async receipts(t){return e.send({op:"Receipts",method:"POST",path:"/messaging/receipts",auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async report(t){return e.send({op:"Report",method:"POST",path:"/messaging/reports",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listScheduled(t){return e.send({op:"ListScheduled",method:"GET",path:"/messaging/scheduled",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async cancelScheduled(t){return e.send({op:"CancelScheduled",method:"DELETE",path:"/messaging/scheduled/"+u("CancelScheduled","scheduled_id",t.path.scheduled_id),auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},signal:t.signal})},async updateScheduled(t){return e.send({op:"UpdateScheduled",method:"PATCH",path:"/messaging/scheduled/"+u("UpdateScheduled","scheduled_id",t.path.scheduled_id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async searchMessages(t){return e.send({op:"SearchMessages",method:"GET",path:"/messaging/search",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getSettings(t){return e.send({op:"GetSettings",method:"GET",path:"/messaging/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async putSettings(t){return e.send({op:"PutSettings",method:"PUT",path:"/messaging/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async rotateHookSecret(t){return e.send({op:"RotateHookSecret",method:"POST",path:"/messaging/settings/hook-secret",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async sync(t){return e.send({op:"Sync",method:"GET",path:"/messaging/sync",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async listThreads(t){return e.send({op:"ListThreads",method:"GET",path:"/messaging/threads",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t?.query,signal:t?.signal})}}}var bi={};Dt(bi,{client:()=>$k});function $k(e){return{async getDeliverability(t){return e.send({op:"GetDeliverability",method:"GET",path:"/notify/deliverability",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async listDevices(t){return e.send({op:"ListDevices",method:"GET",path:"/notify/devices",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async registerDevice(t){return e.send({op:"RegisterDevice",method:"POST",path:"/notify/devices",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getDeviceStats(t){return e.send({op:"GetDeviceStats",method:"GET",path:"/notify/devices/stats",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async deleteMyDevice(t){return e.send({op:"DeleteMyDevice",method:"DELETE",path:"/notify/devices/"+u("DeleteMyDevice","device_id",t.path.device_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async sendEmail(t){return e.send({op:"SendEmail",method:"POST",path:"/notify/email",auth:[["SecretKeyAuth"]],answers:{202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listInAppCampaigns(t){return e.send({op:"ListInAppCampaigns",method:"GET",path:"/notify/in-app/campaigns",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async createInAppCampaign(t){return e.send({op:"CreateInAppCampaign",method:"POST",path:"/notify/in-app/campaigns",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getInAppCampaign(t){return e.send({op:"GetInAppCampaign",method:"GET",path:"/notify/in-app/campaigns/"+u("GetInAppCampaign","id",t.path.id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putInAppCampaign(t){return e.send({op:"PutInAppCampaign",method:"PUT",path:"/notify/in-app/campaigns/"+u("PutInAppCampaign","id",t.path.id),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteInAppCampaign(t){return e.send({op:"DeleteInAppCampaign",method:"DELETE",path:"/notify/in-app/campaigns/"+u("DeleteInAppCampaign","id",t.path.id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async getInAppCampaignStats(t){return e.send({op:"GetInAppCampaignStats",method:"GET",path:"/notify/in-app/campaigns/"+u("GetInAppCampaignStats","id",t.path.id)+"/stats",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async showInAppMessage(t){return e.send({op:"ShowInAppMessage",method:"POST",path:"/notify/in-app/impressions",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async reportInAppEvent(t){return e.send({op:"ReportInAppEvent",method:"POST",path:"/notify/in-app/impressions/"+u("ReportInAppEvent","id",t.path.id)+"/events",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"]],answers:{204:"empty"},idempotent:!0,query:t.query,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listMyInAppMessages(t){return e.send({op:"ListMyInAppMessages",method:"GET",path:"/notify/in-app/messages",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t.query,signal:t.signal})},async listInAppTemplates(t){return e.send({op:"ListInAppTemplates",method:"GET",path:"/notify/in-app/templates",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async listMyInbox(t){return e.send({op:"ListMyInbox",method:"GET",path:"/notify/inbox",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async sendInbox(t){return e.send({op:"SendInbox",method:"POST",path:"/notify/inbox",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listInboxMessages(t){return e.send({op:"ListInboxMessages",method:"GET",path:"/notify/inbox/messages",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async readMyInbox(t){return e.send({op:"ReadMyInbox",method:"POST",path:"/notify/inbox/read",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteMyInboxMessage(t){return e.send({op:"DeleteMyInboxMessage",method:"DELETE",path:"/notify/inbox/"+u("DeleteMyInboxMessage","id",t.path.id),auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async listNotifyMessages(t){return e.send({op:"ListNotifyMessages",method:"GET",path:"/notify/messages",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getNotifyMessage(t){return e.send({op:"GetNotifyMessage",method:"GET",path:"/notify/messages/"+u("GetNotifyMessage","id",t.path.id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async cancelMessage(t){return e.send({op:"CancelMessage",method:"POST",path:"/notify/messages/"+u("CancelMessage","id",t.path.id)+"/cancel",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getMetricsSummary(t){return e.send({op:"GetMetricsSummary",method:"GET",path:"/notify/metrics/summary",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getMyPreferences(t){return e.send({op:"GetMyPreferences",method:"GET",path:"/notify/preferences",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async setMyPreferences(t){return e.send({op:"SetMyPreferences",method:"PUT",path:"/notify/preferences",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listNotifyProviders(t){return e.send({op:"ListNotifyProviders",method:"GET",path:"/notify/providers",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async putNotifyProvider(t){return e.send({op:"PutNotifyProvider",method:"PUT",path:"/notify/providers/"+u("PutNotifyProvider","channel",t.path.channel)+"/"+u("PutNotifyProvider","provider",t.path.provider),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteNotifyProvider(t){return e.send({op:"DeleteNotifyProvider",method:"DELETE",path:"/notify/providers/"+u("DeleteNotifyProvider","channel",t.path.channel)+"/"+u("DeleteNotifyProvider","provider",t.path.provider),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async sendPush(t){return e.send({op:"SendPush",method:"POST",path:"/notify/push",auth:[["SecretKeyAuth"]],answers:{202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async recordPushReceipts(t){return e.send({op:"RecordPushReceipts",method:"POST",path:"/notify/receipts",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getNotifySettings(t){return e.send({op:"GetNotifySettings",method:"GET",path:"/notify/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async putNotifySettings(t){return e.send({op:"PutNotifySettings",method:"PUT",path:"/notify/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async sendSms(t){return e.send({op:"SendSMS",method:"POST",path:"/notify/sms",auth:[["SecretKeyAuth"]],answers:{202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listEmailTemplates(t){return e.send({op:"ListEmailTemplates",method:"GET",path:"/notify/templates/email",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getEmailTemplate(t){return e.send({op:"GetEmailTemplate",method:"GET",path:"/notify/templates/email/"+u("GetEmailTemplate","slug",t.path.slug)+"/"+u("GetEmailTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putEmailTemplate(t){return e.send({op:"PutEmailTemplate",method:"PUT",path:"/notify/templates/email/"+u("PutEmailTemplate","slug",t.path.slug)+"/"+u("PutEmailTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteEmailTemplate(t){return e.send({op:"DeleteEmailTemplate",method:"DELETE",path:"/notify/templates/email/"+u("DeleteEmailTemplate","slug",t.path.slug)+"/"+u("DeleteEmailTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async listPushTemplates(t){return e.send({op:"ListPushTemplates",method:"GET",path:"/notify/templates/push",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getPushTemplate(t){return e.send({op:"GetPushTemplate",method:"GET",path:"/notify/templates/push/"+u("GetPushTemplate","slug",t.path.slug)+"/"+u("GetPushTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putPushTemplate(t){return e.send({op:"PutPushTemplate",method:"PUT",path:"/notify/templates/push/"+u("PutPushTemplate","slug",t.path.slug)+"/"+u("PutPushTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deletePushTemplate(t){return e.send({op:"DeletePushTemplate",method:"DELETE",path:"/notify/templates/push/"+u("DeletePushTemplate","slug",t.path.slug)+"/"+u("DeletePushTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async listSmsTemplates(t){return e.send({op:"ListSMSTemplates",method:"GET",path:"/notify/templates/sms",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getSmsTemplate(t){return e.send({op:"GetSMSTemplate",method:"GET",path:"/notify/templates/sms/"+u("GetSMSTemplate","slug",t.path.slug)+"/"+u("GetSMSTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putSmsTemplate(t){return e.send({op:"PutSMSTemplate",method:"PUT",path:"/notify/templates/sms/"+u("PutSMSTemplate","slug",t.path.slug)+"/"+u("PutSMSTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteSmsTemplate(t){return e.send({op:"DeleteSMSTemplate",method:"DELETE",path:"/notify/templates/sms/"+u("DeleteSMSTemplate","slug",t.path.slug)+"/"+u("DeleteSMSTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async listWhatsAppTemplates(t){return e.send({op:"ListWhatsAppTemplates",method:"GET",path:"/notify/templates/whatsapp",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getWhatsAppTemplate(t){return e.send({op:"GetWhatsAppTemplate",method:"GET",path:"/notify/templates/whatsapp/"+u("GetWhatsAppTemplate","slug",t.path.slug)+"/"+u("GetWhatsAppTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putWhatsAppTemplate(t){return e.send({op:"PutWhatsAppTemplate",method:"PUT",path:"/notify/templates/whatsapp/"+u("PutWhatsAppTemplate","slug",t.path.slug)+"/"+u("PutWhatsAppTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteWhatsAppTemplate(t){return e.send({op:"DeleteWhatsAppTemplate",method:"DELETE",path:"/notify/templates/whatsapp/"+u("DeleteWhatsAppTemplate","slug",t.path.slug)+"/"+u("DeleteWhatsAppTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async listTestUserMessages(t){return e.send({op:"ListTestUserMessages",method:"GET",path:"/notify/test-users/"+u("ListTestUserMessages","user_id",t.path.user_id)+"/messages",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async listTopics(t){return e.send({op:"ListTopics",method:"GET",path:"/notify/topics",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async createTopic(t){return e.send({op:"CreateTopic",method:"POST",path:"/notify/topics",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteTopic(t){return e.send({op:"DeleteTopic",method:"DELETE",path:"/notify/topics/"+u("DeleteTopic","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async changeTopic(t){return e.send({op:"ChangeTopic",method:"PATCH",path:"/notify/topics/"+u("ChangeTopic","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async addTopicSubscribers(t){return e.send({op:"AddTopicSubscribers",method:"POST",path:"/notify/topics/"+u("AddTopicSubscribers","name",t.path.name)+"/subscribers",auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async removeTopicSubscriber(t){return e.send({op:"RemoveTopicSubscriber",method:"DELETE",path:"/notify/topics/"+u("RemoveTopicSubscriber","name",t.path.name)+"/subscribers/"+u("RemoveTopicSubscriber","user_id",t.path.user_id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async followTopic(t){return e.send({op:"FollowTopic",method:"POST",path:"/notify/topics/"+u("FollowTopic","name",t.path.name)+"/subscription",auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async unfollowTopic(t){return e.send({op:"UnfollowTopic",method:"DELETE",path:"/notify/topics/"+u("UnfollowTopic","name",t.path.name)+"/subscription",auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async listUserDevices(t){return e.send({op:"ListUserDevices",method:"GET",path:"/notify/users/"+u("ListUserDevices","user_id",t.path.user_id)+"/devices",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getUserPreferences(t){return e.send({op:"GetUserPreferences",method:"GET",path:"/notify/users/"+u("GetUserPreferences","user_id",t.path.user_id)+"/preferences",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async setUserPreferences(t){return e.send({op:"SetUserPreferences",method:"PUT",path:"/notify/users/"+u("SetUserPreferences","user_id",t.path.user_id)+"/preferences",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async startVerification(t){return e.send({op:"StartVerification",method:"POST",path:"/notify/verifications",auth:[["SecretKeyAuth"]],answers:{202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async checkVerification(t){return e.send({op:"CheckVerification",method:"POST",path:"/notify/verifications/check",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async receiveSendGridEvents(t){return e.send({op:"ReceiveSendGridEvents",method:"POST",path:"/notify/webhooks/email/sendgrid",auth:[],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async receiveTwilioStatus(t){return e.send({op:"ReceiveTwilioStatus",method:"POST",path:"/notify/webhooks/sms/twilio",auth:[],answers:{204:"empty"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async receiveTwilioText(t){return e.send({op:"ReceiveTwilioText",method:"POST",path:"/notify/webhooks/sms/twilio/inbound",auth:[],answers:{204:"empty"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async receiveVonageReceiptQuery(t){return e.send({op:"ReceiveVonageReceiptQuery",method:"GET",path:"/notify/webhooks/sms/vonage",auth:[],answers:{204:"empty"},query:t?.query,signal:t?.signal})},async receiveVonageReceipt(t){return e.send({op:"ReceiveVonageReceipt",method:"POST",path:"/notify/webhooks/sms/vonage",auth:[],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async subscribeMetaWebhook(t){return e.send({op:"SubscribeMetaWebhook",method:"GET",path:"/notify/webhooks/whatsapp/meta",auth:[],answers:{200:"raw"},query:t.query,signal:t.signal})},async receiveMetaNotification(t){return e.send({op:"ReceiveMetaNotification",method:"POST",path:"/notify/webhooks/whatsapp/meta",auth:[],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getWebPushStatus(t){return e.send({op:"GetWebPushStatus",method:"GET",path:"/notify/webpush",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getWebPushKey(t){return e.send({op:"GetWebPushKey",method:"GET",path:"/notify/webpush/key",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async sendWhatsApp(t){return e.send({op:"SendWhatsApp",method:"POST",path:"/notify/whatsapp",auth:[["SecretKeyAuth"]],answers:{202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listWhatsAppInbound(t){return e.send({op:"ListWhatsAppInbound",method:"GET",path:"/notify/whatsapp/inbound",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})}}}var wi={};Dt(wi,{client:()=>kk});function kk(e){return{async getAppleAccount(t){return e.send({op:"GetAppleAccount",method:"GET",path:"/purchases/apple",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async disconnectApple(t){return e.send({op:"DisconnectApple",method:"DELETE",path:"/purchases/apple",auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async getAppleAccountToken(t){return e.send({op:"GetAppleAccountToken",method:"POST",path:"/purchases/apple/account-token",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async getAppleConnectPage(t){return e.send({op:"GetAppleConnectPage",method:"GET",path:"/purchases/apple/connect",auth:[],answers:{200:"raw"},signal:t?.signal})},async connectAppleKey(t){return e.send({op:"ConnectAppleKey",method:"POST",path:"/purchases/apple/connect",auth:[],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async createAppleGrant(t){return e.send({op:"CreateAppleGrant",method:"POST",path:"/purchases/apple/grants",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async getAppleReadiness(t){return e.send({op:"GetAppleReadiness",method:"GET",path:"/purchases/apple/readiness",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async reportAppleTransactions(t){return e.send({op:"ReportAppleTransactions",method:"POST",path:"/purchases/apple/transactions",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getGoogleAccountId(t){return e.send({op:"GetGoogleAccountID",method:"POST",path:"/purchases/google/account-id",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async reportGooglePurchases(t){return e.send({op:"ReportGooglePurchases",method:"POST",path:"/purchases/google/purchases",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async setXcodeCertificate(t){return e.send({op:"SetXcodeCertificate",method:"PUT",path:"/purchases/apple/xcode-certificate",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async clearXcodeCertificate(t){return e.send({op:"ClearXcodeCertificate",method:"DELETE",path:"/purchases/apple/xcode-certificate",auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async getGoogleAccount(t){return e.send({op:"GetGoogleAccount",method:"GET",path:"/purchases/google",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async connectGoogle(t){return e.send({op:"ConnectGoogle",method:"POST",path:"/purchases/google",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async disconnectGoogle(t){return e.send({op:"DisconnectGoogle",method:"DELETE",path:"/purchases/google",auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async getCatalog(t){return e.send({op:"GetCatalog",method:"GET",path:"/purchases/catalog",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async saveCatalog(t){return e.send({op:"SaveCatalog",method:"PUT",path:"/purchases/catalog",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async planCatalog(t){return e.send({op:"PlanCatalog",method:"POST",path:"/purchases/catalog/plans",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async getCatalogPlan(t){return e.send({op:"GetCatalogPlan",method:"GET",path:"/purchases/catalog/plans/"+u("GetCatalogPlan","plan_id",t.path.plan_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async confirmCatalogPlan(t){return e.send({op:"ConfirmCatalogPlan",method:"POST",path:"/purchases/catalog/plans/"+u("ConfirmCatalogPlan","plan_id",t.path.plan_id)+"/confirm",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async declineCatalogPlan(t){return e.send({op:"DeclineCatalogPlan",method:"POST",path:"/purchases/catalog/plans/"+u("DeclineCatalogPlan","plan_id",t.path.plan_id)+"/decline",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async validateCatalog(t){return e.send({op:"ValidateCatalog",method:"POST",path:"/purchases/catalog/validate",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listCharts(t){return e.send({op:"ListCharts",method:"GET",path:"/purchases/charts",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getChartsOverview(t){return e.send({op:"GetChartsOverview",method:"GET",path:"/purchases/charts/overview",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getChart(t){return e.send({op:"GetChart",method:"GET",path:"/purchases/charts/"+u("GetChart","chart",t.path.chart),auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getStripeConnectPage(t){return e.send({op:"GetStripeConnectPage",method:"GET",path:"/purchases/connect",auth:[],answers:{200:"raw"},signal:t?.signal})},async connectStripeKey(t){return e.send({op:"ConnectStripeKey",method:"POST",path:"/purchases/connect",auth:[],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getStripeAppInstallPage(t){return e.send({op:"GetStripeAppInstallPage",method:"GET",path:"/purchases/stripe/app/install",auth:[],answers:{200:"raw"},signal:t?.signal})},async startStripeAppInstall(t){return e.send({op:"StartStripeAppInstall",method:"POST",path:"/purchases/stripe/app/install",auth:[],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async completeStripeAppInstall(t){return e.send({op:"CompleteStripeAppInstall",method:"GET",path:"/purchases/stripe/app/callback",auth:[],answers:{200:"raw"},query:t?.query,signal:t?.signal})},async getCustomer(t){return e.send({op:"GetCustomer",method:"GET",path:"/purchases/customers/"+u("GetCustomer","customer_id",t.path.customer_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async grantCredits(t){return e.send({op:"GrantCredits",method:"POST",path:"/purchases/customers/"+u("GrantCredits","customer_id",t.path.customer_id)+"/credits",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listCreditEntries(t){return e.send({op:"ListCreditEntries",method:"GET",path:"/purchases/customers/"+u("ListCreditEntries","customer_id",t.path.customer_id)+"/credits/entries",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async forgiveCredits(t){return e.send({op:"ForgiveCredits",method:"POST",path:"/purchases/customers/"+u("ForgiveCredits","customer_id",t.path.customer_id)+"/credits/forgive",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listCustomerGrants(t){return e.send({op:"ListCustomerGrants",method:"GET",path:"/purchases/customers/"+u("ListCustomerGrants","customer_id",t.path.customer_id)+"/grants",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async grantEntitlement(t){return e.send({op:"GrantEntitlement",method:"POST",path:"/purchases/customers/"+u("GrantEntitlement","customer_id",t.path.customer_id)+"/grants",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async revokeGrant(t){return e.send({op:"RevokeGrant",method:"DELETE",path:"/purchases/customers/"+u("RevokeGrant","customer_id",t.path.customer_id)+"/grants/"+u("RevokeGrant","grant_id",t.path.grant_id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async holdSpend(t){return e.send({op:"HoldSpend",method:"POST",path:"/purchases/customers/"+u("HoldSpend","customer_id",t.path.customer_id)+"/holds",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async setCustomerLimit(t){return e.send({op:"SetCustomerLimit",method:"PUT",path:"/purchases/customers/"+u("SetCustomerLimit","customer_id",t.path.customer_id)+"/limits/"+u("SetCustomerLimit","limit_key",t.path.limit_key),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async clearCustomerLimit(t){return e.send({op:"ClearCustomerLimit",method:"DELETE",path:"/purchases/customers/"+u("ClearCustomerLimit","customer_id",t.path.customer_id)+"/limits/"+u("ClearCustomerLimit","limit_key",t.path.limit_key),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async grantLimit(t){return e.send({op:"GrantLimit",method:"POST",path:"/purchases/customers/"+u("GrantLimit","customer_id",t.path.customer_id)+"/limits/"+u("GrantLimit","limit_key",t.path.limit_key)+"/grants",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async spend(t){return e.send({op:"Spend",method:"POST",path:"/purchases/customers/"+u("Spend","customer_id",t.path.customer_id)+"/spend",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async commitSpend(t){return e.send({op:"CommitSpend",method:"POST",path:"/purchases/customers/"+u("CommitSpend","customer_id",t.path.customer_id)+"/spends/"+u("CommitSpend","spend_id",t.path.spend_id)+"/commit",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async extendHold(t){return e.send({op:"ExtendHold",method:"POST",path:"/purchases/customers/"+u("ExtendHold","customer_id",t.path.customer_id)+"/spends/"+u("ExtendHold","spend_id",t.path.spend_id)+"/extend",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async releaseSpend(t){return e.send({op:"ReleaseSpend",method:"POST",path:"/purchases/customers/"+u("ReleaseSpend","customer_id",t.path.customer_id)+"/spends/"+u("ReleaseSpend","spend_id",t.path.spend_id)+"/release",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async reverseSpend(t){return e.send({op:"ReverseSpend",method:"POST",path:"/purchases/customers/"+u("ReverseSpend","customer_id",t.path.customer_id)+"/spends/"+u("ReverseSpend","spend_id",t.path.spend_id)+"/reverse",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listExperiments(t){return e.send({op:"ListExperiments",method:"GET",path:"/purchases/experiments",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async startExperiment(t){return e.send({op:"StartExperiment",method:"POST",path:"/purchases/experiments",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getExperiment(t){return e.send({op:"GetExperiment",method:"GET",path:"/purchases/experiments/"+u("GetExperiment","experiment_id",t.path.experiment_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getExperimentResults(t){return e.send({op:"GetExperimentResults",method:"GET",path:"/purchases/experiments/"+u("GetExperimentResults","experiment_id",t.path.experiment_id)+"/results",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async stopExperiment(t){return e.send({op:"StopExperiment",method:"POST",path:"/purchases/experiments/"+u("StopExperiment","experiment_id",t.path.experiment_id)+"/stop",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async declareExperimentWinner(t){return e.send({op:"DeclareExperimentWinner",method:"POST",path:"/purchases/experiments/"+u("DeclareExperimentWinner","experiment_id",t.path.experiment_id)+"/winner",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getMyCustomerInfo(t){return e.send({op:"GetMyCustomerInfo",method:"GET",path:"/purchases/me",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async mergeGuest(t){return e.send({op:"MergeGuest",method:"POST",path:"/purchases/me/merge",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async createMergeGrant(t){return e.send({op:"CreateMergeGrant",method:"POST",path:"/purchases/me/merge-grant",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},signal:t?.signal})},async getOfferings(t){return e.send({op:"GetOfferings",method:"GET",path:"/purchases/offerings",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async listPaywalls(t){return e.send({op:"ListPaywalls",method:"GET",path:"/purchases/paywalls",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async createPaywall(t){return e.send({op:"CreatePaywall",method:"POST",path:"/purchases/paywalls",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listPaywallAssets(t){return e.send({op:"ListPaywallAssets",method:"GET",path:"/purchases/paywalls/assets",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async registerPaywallAsset(t){return e.send({op:"RegisterPaywallAsset",method:"POST",path:"/purchases/paywalls/assets",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deletePaywallAsset(t){return e.send({op:"DeletePaywallAsset",method:"DELETE",path:"/purchases/paywalls/assets/"+u("DeletePaywallAsset","asset_id",t.path.asset_id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async listPaywallTemplates(t){return e.send({op:"ListPaywallTemplates",method:"GET",path:"/purchases/paywalls/templates",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getPaywallTemplateAsset(t){return e.send({op:"GetPaywallTemplateAsset",method:"GET",path:"/purchases/paywalls/templates/"+u("GetPaywallTemplateAsset","key",t.path.key)+"/assets/"+u("GetPaywallTemplateAsset","asset_id",t.path.asset_id),auth:[["SecretKeyAuth"]],answers:{200:"raw",304:"empty"},headers:t.headers,signal:t.signal})},async validatePaywall(t){return e.send({op:"ValidatePaywall",method:"POST",path:"/purchases/paywalls/validate",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getPaywall(t){return e.send({op:"GetPaywall",method:"GET",path:"/purchases/paywalls/"+u("GetPaywall","paywall_id",t.path.paywall_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async deletePaywall(t){return e.send({op:"DeletePaywall",method:"DELETE",path:"/purchases/paywalls/"+u("DeletePaywall","paywall_id",t.path.paywall_id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async savePaywallDraft(t){return e.send({op:"SavePaywallDraft",method:"PUT",path:"/purchases/paywalls/"+u("SavePaywallDraft","paywall_id",t.path.paywall_id)+"/draft",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async publishPaywall(t){return e.send({op:"PublishPaywall",method:"POST",path:"/purchases/paywalls/"+u("PublishPaywall","paywall_id",t.path.paywall_id)+"/publish",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async listPaywallVersions(t){return e.send({op:"ListPaywallVersions",method:"GET",path:"/purchases/paywalls/"+u("ListPaywallVersions","paywall_id",t.path.paywall_id)+"/versions",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getPaywallVersion(t){return e.send({op:"GetPaywallVersion",method:"GET",path:"/purchases/paywalls/"+u("GetPaywallVersion","paywall_id",t.path.paywall_id)+"/versions/"+u("GetPaywallVersion","version",t.path.version),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async listPlacements(t){return e.send({op:"ListPlacements",method:"GET",path:"/purchases/placements",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async listAttributeKeys(t){return e.send({op:"ListAttributeKeys",method:"GET",path:"/purchases/placements/attributes",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async setPlacement(t){return e.send({op:"SetPlacement",method:"PUT",path:"/purchases/placements/"+u("SetPlacement","placement",t.path.placement),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deletePlacement(t){return e.send({op:"DeletePlacement",method:"DELETE",path:"/purchases/placements/"+u("DeletePlacement","placement",t.path.placement),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async recordPaywallExposure(t){return e.send({op:"RecordPaywallExposure",method:"POST",path:"/purchases/placements/"+u("RecordPaywallExposure","placement",t.path.placement)+"/exposures",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{204:"empty"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getPlacementPaywall(t){return e.send({op:"GetPlacementPaywall",method:"GET",path:"/purchases/placements/"+u("GetPlacementPaywall","placement",t.path.placement)+"/paywall",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json",204:"empty",304:"empty"},query:t.query,headers:t.headers,signal:t.signal})},async previewPlacement(t){return e.send({op:"PreviewPlacement",method:"POST",path:"/purchases/placements/"+u("PreviewPlacement","placement",t.path.placement)+"/resolve-preview",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getPlacementResults(t){return e.send({op:"GetPlacementResults",method:"GET",path:"/purchases/placements/"+u("GetPlacementResults","placement",t.path.placement)+"/results",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getPlacementRules(t){return e.send({op:"GetPlacementRules",method:"GET",path:"/purchases/placements/"+u("GetPlacementRules","placement",t.path.placement)+"/rules",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async setPlacementRules(t){return e.send({op:"SetPlacementRules",method:"PUT",path:"/purchases/placements/"+u("SetPlacementRules","placement",t.path.placement)+"/rules",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getSettings(t){return e.send({op:"GetSettings",method:"GET",path:"/purchases/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async updateSettings(t){return e.send({op:"UpdateSettings",method:"PUT",path:"/purchases/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getStripeAccount(t){return e.send({op:"GetStripeAccount",method:"GET",path:"/purchases/stripe",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async disconnectStripe(t){return e.send({op:"DisconnectStripe",method:"DELETE",path:"/purchases/stripe",auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async checkStripeAccount(t){return e.send({op:"CheckStripeAccount",method:"POST",path:"/purchases/stripe/check",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async createCheckout(t){return e.send({op:"CreateCheckout",method:"POST",path:"/purchases/stripe/checkout",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async createCheckoutRedemption(t){return e.send({op:"CreateCheckoutRedemption",method:"POST",path:"/purchases/stripe/checkout/redemption",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async redeemPurchase(t){return e.send({op:"RedeemPurchase",method:"POST",path:"/purchases/redemptions/redeem",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getRedemptionPage(t){return e.send({op:"GetRedemptionPage",method:"GET",path:"/purchases/redeem",auth:[],answers:{200:"raw"},query:t.query,signal:t.signal})},async createStripeGrant(t){return e.send({op:"CreateStripeGrant",method:"POST",path:"/purchases/stripe/grants",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async createStripeAppInstall(t){return e.send({op:"CreateStripeAppInstall",method:"POST",path:"/purchases/stripe/app/grants",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async createPortalSession(t){return e.send({op:"CreatePortalSession",method:"POST",path:"/purchases/stripe/portal",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async receiveAppleNotification(t){return e.send({op:"ReceiveAppleNotification",method:"POST",path:"/purchases/webhooks/apple",auth:[],answers:{200:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async receiveGoogleNotification(t){return e.send({op:"ReceiveGoogleNotification",method:"POST",path:"/purchases/webhooks/google",auth:[],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async receiveStripeEvent(t){return e.send({op:"ReceiveStripeEvent",method:"POST",path:"/purchases/webhooks/stripe",auth:[],answers:{200:"empty"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async receiveStripeAppEvent(t){return e.send({op:"ReceiveStripeAppEvent",method:"POST",path:"/purchases/webhooks/stripe-app",auth:[],answers:{200:"empty"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listMyOffers(t){return e.send({op:"ListMyOffers",method:"GET",path:"/purchases/offers",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async recordOfferView(t){return e.send({op:"RecordOfferView",method:"POST",path:"/purchases/offers/"+u("RecordOfferView","offer_key",t.path.offer_key)+"/views",auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},signal:t.signal})},async signAppleOffer(t){return e.send({op:"SignAppleOffer",method:"POST",path:"/purchases/offers/"+u("SignAppleOffer","offer_key",t.path.offer_key)+"/apple-signature",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async claimOffer(t){return e.send({op:"ClaimOffer",method:"POST",path:"/purchases/offers/"+u("ClaimOffer","offer_key",t.path.offer_key)+"/claim",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},signal:t.signal})},async redeemCoupon(t){return e.send({op:"RedeemCoupon",method:"POST",path:"/purchases/coupons/redeem",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getOfferStats(t){return e.send({op:"GetOfferStats",method:"GET",path:"/purchases/offers/stats",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async listCoupons(t){return e.send({op:"ListCoupons",method:"GET",path:"/purchases/coupons",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async createCoupon(t){return e.send({op:"CreateCoupon",method:"POST",path:"/purchases/coupons",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getCoupon(t){return e.send({op:"GetCoupon",method:"GET",path:"/purchases/coupons/"+u("GetCoupon","coupon_key",t.path.coupon_key),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async revokeCoupon(t){return e.send({op:"RevokeCoupon",method:"DELETE",path:"/purchases/coupons/"+u("RevokeCoupon","coupon_key",t.path.coupon_key),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async listCouponCodes(t){return e.send({op:"ListCouponCodes",method:"GET",path:"/purchases/coupons/"+u("ListCouponCodes","coupon_key",t.path.coupon_key)+"/codes",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async setXcodeOfferKey(t){return e.send({op:"SetXcodeOfferKey",method:"PUT",path:"/purchases/apple/xcode-offer-key",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async searchCustomers(t){return e.send({op:"SearchCustomers",method:"GET",path:"/purchases/customers",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getCustomerHistory(t){return e.send({op:"GetCustomerHistory",method:"GET",path:"/purchases/customers/"+u("GetCustomerHistory","customer_id",t.path.customer_id)+"/history",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async listCatalogRevisions(t){return e.send({op:"ListCatalogRevisions",method:"GET",path:"/purchases/catalog/revisions",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getCatalogRevision(t){return e.send({op:"GetCatalogRevision",method:"GET",path:"/purchases/catalog/revisions/"+u("GetCatalogRevision","revision",t.path.revision),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async restoreCatalogRevision(t){return e.send({op:"RestoreCatalogRevision",method:"POST",path:"/purchases/catalog/revisions/"+u("RestoreCatalogRevision","revision",t.path.revision)+"/restore",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async extendSubscription(t){return e.send({op:"ExtendSubscription",method:"POST",path:"/purchases/customers/"+u("ExtendSubscription","customer_id",t.path.customer_id)+"/subscriptions/"+u("ExtendSubscription","subscription_id",t.path.subscription_id)+"/extend",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async refundSubscription(t){return e.send({op:"RefundSubscription",method:"POST",path:"/purchases/customers/"+u("RefundSubscription","customer_id",t.path.customer_id)+"/subscriptions/"+u("RefundSubscription","subscription_id",t.path.subscription_id)+"/refund",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async cancelSubscription(t){return e.send({op:"CancelSubscription",method:"POST",path:"/purchases/customers/"+u("CancelSubscription","customer_id",t.path.customer_id)+"/subscriptions/"+u("CancelSubscription","subscription_id",t.path.subscription_id)+"/cancel",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async setRefundDataConsent(t){return e.send({op:"SetRefundDataConsent",method:"PUT",path:"/purchases/me/refund-data-consent",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})}}}var vi={};Dt(vi,{client:()=>Sk});function Sk(e){return{async broadcast(t){return e.send({op:"Broadcast",method:"POST",path:"/realtime/broadcast",auth:[["SecretKeyAuth"]],answers:{202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getChannels(t){return e.send({op:"GetChannels",method:"GET",path:"/realtime/channels",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async putChannels(t){return e.send({op:"PutChannels",method:"PUT",path:"/realtime/channels",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getLimits(t){return e.send({op:"GetLimits",method:"GET",path:"/realtime/limits",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async putLimits(t){return e.send({op:"PutLimits",method:"PUT",path:"/realtime/limits",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async revalidate(t){return e.send({op:"Revalidate",method:"POST",path:"/realtime/revalidate",auth:[["SecretKeyAuth"]],answers:{202:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async writeState(t){return e.send({op:"WriteState",method:"POST",path:"/realtime/state",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getStats(t){return e.send({op:"GetStats",method:"GET",path:"/realtime/stats",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})}}}var _i={};Dt(_i,{client:()=>Ak});function Ak(e){return{async listSecretAudit(t){return e.send({op:"ListSecretAudit",method:"GET",path:"/secrets/audit",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async listFieldKeys(t){return e.send({op:"ListFieldKeys",method:"GET",path:"/secrets/fields",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getFieldKeys(t){return e.send({op:"GetFieldKeys",method:"GET",path:"/secrets/fields/keys",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async openFields(t){return e.send({op:"OpenFields",method:"POST",path:"/secrets/fields/open",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async sealPlaceholder(t){return e.send({op:"SealPlaceholder",method:"POST",path:"/secrets/fields/placeholder",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async rotateFieldKeys(t){return e.send({op:"RotateFieldKeys",method:"POST",path:"/secrets/fields/rotate",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async listTransitKeys(t){return e.send({op:"ListTransitKeys",method:"GET",path:"/secrets/transit",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getTransitKeys(t){return e.send({op:"GetTransitKeys",method:"GET",path:"/secrets/transit/keys",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getTransitPublicKeys(t){return e.send({op:"GetTransitPublicKeys",method:"GET",path:"/secrets/transit/public",auth:[["ApiKeyAuth"],["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async rotateTransitKeys(t){return e.send({op:"RotateTransitKeys",method:"POST",path:"/secrets/transit/rotate",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t?.headers,body:{kind:"json",contentType:"application/json",value:t?.body},signal:t?.signal})},async retireTransitKey(t){return e.send({op:"RetireTransitKey",method:"POST",path:"/secrets/transit/"+u("RetireTransitKey","kid",t.path.kid)+"/retire",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async listSecrets(t){return e.send({op:"ListSecrets",method:"GET",path:"/secrets/"+u("ListSecrets","environment",t.path.environment),auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getEnvironmentValues(t){return e.send({op:"GetEnvironmentValues",method:"GET",path:"/secrets/"+u("GetEnvironmentValues","environment",t.path.environment)+"/values",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getSecret(t){return e.send({op:"GetSecret",method:"GET",path:"/secrets/"+u("GetSecret","environment",t.path.environment)+"/"+u("GetSecret","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putSecret(t){return e.send({op:"PutSecret",method:"PUT",path:"/secrets/"+u("PutSecret","environment",t.path.environment)+"/"+u("PutSecret","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteSecret(t){return e.send({op:"DeleteSecret",method:"DELETE",path:"/secrets/"+u("DeleteSecret","environment",t.path.environment)+"/"+u("DeleteSecret","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async rollbackSecret(t){return e.send({op:"RollbackSecret",method:"POST",path:"/secrets/"+u("RollbackSecret","environment",t.path.environment)+"/"+u("RollbackSecret","name",t.path.name)+"/rollback",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listSecretVersions(t){return e.send({op:"ListSecretVersions",method:"GET",path:"/secrets/"+u("ListSecretVersions","environment",t.path.environment)+"/"+u("ListSecretVersions","name",t.path.name)+"/versions",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})}}}var $i={};Dt($i,{client:()=>Pk});function Pk(e){return{async listBuckets(t){return e.send({op:"ListBuckets",method:"GET",path:"/storage/buckets",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getBucket(t){return e.send({op:"GetBucket",method:"GET",path:"/storage/buckets/"+u("GetBucket","bucket",t.path.bucket),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putBucket(t){return e.send({op:"PutBucket",method:"PUT",path:"/storage/buckets/"+u("PutBucket","bucket",t.path.bucket),auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteBucket(t){return e.send({op:"DeleteBucket",method:"DELETE",path:"/storage/buckets/"+u("DeleteBucket","bucket",t.path.bucket),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async copyObject(t){return e.send({op:"CopyObject",method:"POST",path:"/storage/buckets/"+u("CopyObject","bucket",t.path.bucket)+"/copy",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async moveObject(t){return e.send({op:"MoveObject",method:"POST",path:"/storage/buckets/"+u("MoveObject","bucket",t.path.bucket)+"/move",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listObjects(t){return e.send({op:"ListObjects",method:"GET",path:"/storage/buckets/"+u("ListObjects","bucket",t.path.bucket)+"/objects",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getObject(t){return e.send({op:"GetObject",method:"GET",path:"/storage/buckets/"+u("GetObject","bucket",t.path.bucket)+"/objects/"+u("GetObject","path",t.path.path),auth:[["SecretKeyAuth"]],answers:{200:"raw",206:"raw",304:"empty"},query:t.query,headers:t.headers,signal:t.signal})},async putObject(t){return e.send({op:"PutObject",method:"PUT",path:"/storage/buckets/"+u("PutObject","bucket",t.path.bucket)+"/objects/"+u("PutObject","path",t.path.path),auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},query:t.query,headers:t.headers,body:{kind:"raw",contentType:t.contentType??"application/octet-stream",value:t.body},signal:t.signal})},async deleteObject(t){return e.send({op:"DeleteObject",method:"DELETE",path:"/storage/buckets/"+u("DeleteObject","bucket",t.path.bucket)+"/objects/"+u("DeleteObject","path",t.path.path),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async headObject(t){return e.send({op:"HeadObject",method:"HEAD",path:"/storage/buckets/"+u("HeadObject","bucket",t.path.bucket)+"/objects/"+u("HeadObject","path",t.path.path),auth:[["SecretKeyAuth"]],answers:{200:"empty",304:"empty"},query:t.query,headers:t.headers,signal:t.signal})},async createSignedUrl(t){return e.send({op:"CreateSignedUrl",method:"POST",path:"/storage/buckets/"+u("CreateSignedUrl","bucket",t.path.bucket)+"/signed-urls",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async createUploadUrl(t){return e.send({op:"CreateUploadUrl",method:"POST",path:"/storage/buckets/"+u("CreateUploadUrl","bucket",t.path.bucket)+"/upload-urls",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getPublicObject(t){return e.send({op:"GetPublicObject",method:"GET",path:"/storage/public/"+u("GetPublicObject","bucket",t.path.bucket)+"/"+u("GetPublicObject","path",t.path.path),auth:[],answers:{200:"raw",206:"raw",302:"redirect",304:"empty"},query:t.query,headers:t.headers,signal:t.signal})},async headPublicObject(t){return e.send({op:"HeadPublicObject",method:"HEAD",path:"/storage/public/"+u("HeadPublicObject","bucket",t.path.bucket)+"/"+u("HeadPublicObject","path",t.path.path),auth:[],answers:{200:"empty",302:"redirect",304:"empty"},query:t.query,headers:t.headers,signal:t.signal})},async getSignedObject(t){return e.send({op:"GetSignedObject",method:"GET",path:"/storage/signed/"+u("GetSignedObject","bucket",t.path.bucket)+"/"+u("GetSignedObject","path",t.path.path),auth:[],answers:{200:"raw",206:"raw",302:"redirect",304:"empty"},query:t.query,headers:t.headers,signal:t.signal})},async putSignedObject(t){return e.send({op:"PutSignedObject",method:"PUT",path:"/storage/signed/"+u("PutSignedObject","bucket",t.path.bucket)+"/"+u("PutSignedObject","path",t.path.path),auth:[],answers:{200:"json",201:"json"},query:t.query,headers:t.headers,body:{kind:"raw",contentType:t.contentType??"application/octet-stream",value:t.body},signal:t.signal})},async headSignedObject(t){return e.send({op:"HeadSignedObject",method:"HEAD",path:"/storage/signed/"+u("HeadSignedObject","bucket",t.path.bucket)+"/"+u("HeadSignedObject","path",t.path.path),auth:[],answers:{200:"empty",302:"redirect",304:"empty"},query:t.query,headers:t.headers,signal:t.signal})},async getStorageStats(t){return e.send({op:"GetStorageStats",method:"GET",path:"/storage/stats",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async upload(t){return e.send({op:"Upload",method:"POST",path:"/storage/upload/"+u("Upload","machine",t.path.machine)+"/"+u("Upload","route",t.path.route),auth:[["ApiKeyAuth","userJWT"],["ApiKeyAuth"]],answers:{},body:{kind:"raw",contentType:t.contentType??"multipart/form-data",value:t.body},signal:t.signal})}}}var ki={};Dt(ki,{client:()=>Rk});function Rk(e){return{async listActions(t){return e.send({op:"ListActions",method:"GET",path:"/stores/actions",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getAction(t){return e.send({op:"GetAction",method:"GET",path:"/stores/actions/"+u("GetAction","action_id",t.path.action_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async confirmAction(t){return e.send({op:"ConfirmAction",method:"POST",path:"/stores/actions/"+u("ConfirmAction","action_id",t.path.action_id)+"/confirm",auth:[["SecretKeyAuth"]],answers:{200:"json",202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async declineAction(t){return e.send({op:"DeclineAction",method:"POST",path:"/stores/actions/"+u("DeclineAction","action_id",t.path.action_id)+"/decline",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async getAppleAccount(t){return e.send({op:"GetAppleAccount",method:"GET",path:"/stores/apple",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async disconnectApple(t){return e.send({op:"DisconnectApple",method:"DELETE",path:"/stores/apple",auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async checkAppleAccount(t){return e.send({op:"CheckAppleAccount",method:"POST",path:"/stores/apple/check",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async createAppleGrant(t){return e.send({op:"CreateAppleGrant",method:"POST",path:"/stores/apple/grants",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async getSandboxReadiness(t){return e.send({op:"GetSandboxReadiness",method:"GET",path:"/stores/apple/readiness",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async listSandboxTesters(t){return e.send({op:"ListSandboxTesters",method:"GET",path:"/stores/apple/sandbox-testers",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async clearSandboxPurchaseHistory(t){return e.send({op:"ClearSandboxPurchaseHistory",method:"POST",path:"/stores/apple/sandbox-testers/clear-purchase-history",auth:[["SecretKeyAuth"]],answers:{202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async updateSandboxTester(t){return e.send({op:"UpdateSandboxTester",method:"PATCH",path:"/stores/apple/sandbox-testers/"+u("UpdateSandboxTester","tester_id",t.path.tester_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listApps(t){return e.send({op:"ListApps",method:"GET",path:"/stores/apps",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async listFeedback(t){return e.send({op:"ListFeedback",method:"GET",path:"/stores/apps/"+u("ListFeedback","app_id",t.path.app_id)+"/feedback",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getFeedback(t){return e.send({op:"GetFeedback",method:"GET",path:"/stores/apps/"+u("GetFeedback","app_id",t.path.app_id)+"/feedback/"+u("GetFeedback","kind",t.path.kind)+"/"+u("GetFeedback","feedback_id",t.path.feedback_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async listGroups(t){return e.send({op:"ListGroups",method:"GET",path:"/stores/apps/"+u("ListGroups","app_id",t.path.app_id)+"/groups",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async createGroup(t){return e.send({op:"CreateGroup",method:"POST",path:"/stores/apps/"+u("CreateGroup","app_id",t.path.app_id)+"/groups",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async linkApp(t){return e.send({op:"LinkApp",method:"POST",path:"/stores/apps/"+u("LinkApp","app_id",t.path.app_id)+"/link",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getListing(t){return e.send({op:"GetListing",method:"GET",path:"/stores/apps/"+u("GetListing","app_id",t.path.app_id)+"/listing",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async setListing(t){return e.send({op:"SetListing",method:"PUT",path:"/stores/apps/"+u("SetListing","app_id",t.path.app_id)+"/listing",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async planListing(t){return e.send({op:"PlanListing",method:"POST",path:"/stores/apps/"+u("PlanListing","app_id",t.path.app_id)+"/listing/plan",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async createPackage(t){return e.send({op:"CreatePackage",method:"POST",path:"/stores/apps/"+u("CreatePackage","app_id",t.path.app_id)+"/packages",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async uploadScreenshot(t){return e.send({op:"UploadScreenshot",method:"PUT",path:"/stores/apps/"+u("UploadScreenshot","app_id",t.path.app_id)+"/screenshots",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,query:t.query,headers:t.headers,body:{kind:"raw",contentType:t.contentType??"image/png",value:t.body},signal:t.signal})},async getReviewInfo(t){return e.send({op:"GetReviewInfo",method:"GET",path:"/stores/apps/"+u("GetReviewInfo","app_id",t.path.app_id)+"/testflight/review-info",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async setReviewInfo(t){return e.send({op:"SetReviewInfo",method:"PUT",path:"/stores/apps/"+u("SetReviewInfo","app_id",t.path.app_id)+"/testflight/review-info",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getUploadKey(t){return e.send({op:"GetUploadKey",method:"GET",path:"/stores/apps/"+u("GetUploadKey","app_id",t.path.app_id)+"/upload-key",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getAppStoreVersion(t){return e.send({op:"GetAppStoreVersion",method:"GET",path:"/stores/apps/"+u("GetAppStoreVersion","app_id",t.path.app_id)+"/version",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async prepareAppStoreVersion(t){return e.send({op:"PrepareAppStoreVersion",method:"PUT",path:"/stores/apps/"+u("PrepareAppStoreVersion","app_id",t.path.app_id)+"/version",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async planPhasedRelease(t){return e.send({op:"PlanPhasedRelease",method:"POST",path:"/stores/apps/"+u("PlanPhasedRelease","app_id",t.path.app_id)+"/version/phased-release",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async planReleaseVersion(t){return e.send({op:"PlanReleaseVersion",method:"POST",path:"/stores/apps/"+u("PlanReleaseVersion","app_id",t.path.app_id)+"/version/release",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async planSubmitReview(t){return e.send({op:"PlanSubmitReview",method:"POST",path:"/stores/apps/"+u("PlanSubmitReview","app_id",t.path.app_id)+"/version/submit",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async planWithdrawReview(t){return e.send({op:"PlanWithdrawReview",method:"POST",path:"/stores/apps/"+u("PlanWithdrawReview","app_id",t.path.app_id)+"/version/withdraw",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async getAppVitals(t){return e.send({op:"GetAppVitals",method:"GET",path:"/stores/apps/"+u("GetAppVitals","app_id",t.path.app_id)+"/vitals",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getAppWebhook(t){return e.send({op:"GetAppWebhook",method:"GET",path:"/stores/apps/"+u("GetAppWebhook","app_id",t.path.app_id)+"/webhook",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async makeAppWebhook(t){return e.send({op:"MakeAppWebhook",method:"POST",path:"/stores/apps/"+u("MakeAppWebhook","app_id",t.path.app_id)+"/webhook",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async pingAppWebhook(t){return e.send({op:"PingAppWebhook",method:"POST",path:"/stores/apps/"+u("PingAppWebhook","app_id",t.path.app_id)+"/webhook/ping",auth:[["SecretKeyAuth"]],answers:{202:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async downloadSignedBundle(t){return e.send({op:"DownloadSignedBundle",method:"GET",path:"/stores/bundles",auth:[],answers:{200:"raw"},query:t.query,signal:t.signal})},async getConnectPage(t){return e.send({op:"GetConnectPage",method:"GET",path:"/stores/connect",auth:[],answers:{200:"raw"},signal:t?.signal})},async connectAppleKey(t){return e.send({op:"ConnectAppleKey",method:"POST",path:"/stores/connect",auth:[],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getGoogleAccount(t){return e.send({op:"GetGoogleAccount",method:"GET",path:"/stores/google",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async connectGoogle(t){return e.send({op:"ConnectGoogle",method:"POST",path:"/stores/google",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async disconnectGoogle(t){return e.send({op:"DisconnectGoogle",method:"DELETE",path:"/stores/google",auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async checkGoogleAccount(t){return e.send({op:"CheckGoogleAccount",method:"POST",path:"/stores/google/check",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async deleteGroup(t){return e.send({op:"DeleteGroup",method:"DELETE",path:"/stores/groups/"+u("DeleteGroup","group_id",t.path.group_id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async renameGroup(t){return e.send({op:"RenameGroup",method:"PATCH",path:"/stores/groups/"+u("RenameGroup","group_id",t.path.group_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async addGroupBuild(t){return e.send({op:"AddGroupBuild",method:"POST",path:"/stores/groups/"+u("AddGroupBuild","group_id",t.path.group_id)+"/builds",auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listTesters(t){return e.send({op:"ListTesters",method:"GET",path:"/stores/groups/"+u("ListTesters","group_id",t.path.group_id)+"/testers",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async setTesters(t){return e.send({op:"SetTesters",method:"PUT",path:"/stores/groups/"+u("SetTesters","group_id",t.path.group_id)+"/testers",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listPackages(t){return e.send({op:"ListPackages",method:"GET",path:"/stores/packages",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getPackage(t){return e.send({op:"GetPackage",method:"GET",path:"/stores/packages/"+u("GetPackage","package_id",t.path.package_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async uploadArtifact(t){return e.send({op:"UploadArtifact",method:"PUT",path:"/stores/packages/"+u("UploadArtifact","package_id",t.path.package_id)+"/artifact",auth:[],answers:{200:"json"},headers:t.headers,body:{kind:"raw",contentType:t.contentType??"application/octet-stream",value:t.body},signal:t.signal})},async planBetaReview(t){return e.send({op:"PlanBetaReview",method:"POST",path:"/stores/packages/"+u("PlanBetaReview","package_id",t.path.package_id)+"/beta-review",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async listDeliveries(t){return e.send({op:"ListDeliveries",method:"GET",path:"/stores/packages/"+u("ListDeliveries","package_id",t.path.package_id)+"/deliveries",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async deliver(t){return e.send({op:"Deliver",method:"POST",path:"/stores/packages/"+u("Deliver","package_id",t.path.package_id)+"/deliveries",auth:[["SecretKeyAuth"]],answers:{200:"json",202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getSignedBundleLink(t){return e.send({op:"GetSignedBundleLink",method:"POST",path:"/stores/packages/"+u("GetSignedBundleLink","package_id",t.path.package_id)+"/deliveries/"+u("GetSignedBundleLink","channel",t.path.channel)+"/bundle-link",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async planExpire(t){return e.send({op:"PlanExpire",method:"POST",path:"/stores/packages/"+u("PlanExpire","package_id",t.path.package_id)+"/expire",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async planExportCompliance(t){return e.send({op:"PlanExportCompliance",method:"POST",path:"/stores/packages/"+u("PlanExportCompliance","package_id",t.path.package_id)+"/export-compliance",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async setWhatToTest(t){return e.send({op:"SetWhatToTest",method:"PUT",path:"/stores/packages/"+u("SetWhatToTest","package_id",t.path.package_id)+"/what-to-test",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async takeAppleWebhook(t){return e.send({op:"TakeAppleWebhook",method:"POST",path:"/stores/webhooks/apple/"+u("TakeAppleWebhook","app_id",t.path.app_id),auth:[],answers:{200:"empty"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getAppleSession(t){return e.send({op:"GetAppleSession",method:"GET",path:"/stores/apple/session",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async disconnectAppleSession(t){return e.send({op:"DisconnectAppleSession",method:"DELETE",path:"/stores/apple/session",auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async checkAppleSession(t){return e.send({op:"CheckAppleSession",method:"POST",path:"/stores/apple/session/check",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async createAppleIdGrant(t){return e.send({op:"CreateAppleIDGrant",method:"POST",path:"/stores/apple/session/grants",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async getAppleIdPage(t){return e.send({op:"GetAppleIDPage",method:"GET",path:"/stores/connect/apple-id",auth:[],answers:{200:"raw"},signal:t?.signal})},async signInAppleId(t){return e.send({op:"SignInAppleID",method:"POST",path:"/stores/connect/apple-id",auth:[],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async submitAppleIdCode(t){return e.send({op:"SubmitAppleIDCode",method:"POST",path:"/stores/connect/apple-id/code",auth:[],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async chooseAppleIdTeam(t){return e.send({op:"ChooseAppleIDTeam",method:"POST",path:"/stores/connect/apple-id/team",auth:[],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getAppReview(t){return e.send({op:"GetAppReview",method:"GET",path:"/stores/apps/"+u("GetAppReview","app_id",t.path.app_id)+"/review",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getReviewAttachment(t){return e.send({op:"GetReviewAttachment",method:"GET",path:"/stores/apps/"+u("GetReviewAttachment","app_id",t.path.app_id)+"/review/threads/"+u("GetReviewAttachment","thread_id",t.path.thread_id)+"/attachments/"+u("GetReviewAttachment","attachment_id",t.path.attachment_id),auth:[["SecretKeyAuth"]],answers:{200:"raw"},signal:t.signal})},async setReviewDraft(t){return e.send({op:"SetReviewDraft",method:"PUT",path:"/stores/apps/"+u("SetReviewDraft","app_id",t.path.app_id)+"/review/threads/"+u("SetReviewDraft","thread_id",t.path.thread_id)+"/draft",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async sendReviewDraft(t){return e.send({op:"SendReviewDraft",method:"POST",path:"/stores/apps/"+u("SendReviewDraft","app_id",t.path.app_id)+"/review/threads/"+u("SendReviewDraft","thread_id",t.path.thread_id)+"/draft/send",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async getAppPrivacy(t){return e.send({op:"GetAppPrivacy",method:"GET",path:"/stores/apps/"+u("GetAppPrivacy","app_id",t.path.app_id)+"/privacy",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async setAppPrivacy(t){return e.send({op:"SetAppPrivacy",method:"PUT",path:"/stores/apps/"+u("SetAppPrivacy","app_id",t.path.app_id)+"/privacy",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async makeAppRecord(t){return e.send({op:"MakeAppRecord",method:"POST",path:"/stores/apps/"+u("MakeAppRecord","app_id",t.path.app_id)+"/record",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async removeAppRecord(t){return e.send({op:"RemoveAppRecord",method:"DELETE",path:"/stores/apps/"+u("RemoveAppRecord","app_id",t.path.app_id)+"/record",auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async listMadeAppleKeys(t){return e.send({op:"ListMadeAppleKeys",method:"GET",path:"/stores/apple/keys",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async makeAppleKey(t){return e.send({op:"MakeAppleKey",method:"POST",path:"/stores/apple/keys",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async revokeMadeAppleKey(t){return e.send({op:"RevokeMadeAppleKey",method:"DELETE",path:"/stores/apple/keys/"+u("RevokeMadeAppleKey","key_id",t.path.key_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async shareAppleSession(t){return e.send({op:"ShareAppleSession",method:"PUT",path:"/stores/apple/session/shares/"+u("ShareAppleSession","environment",t.path.environment),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async unshareAppleSession(t){return e.send({op:"UnshareAppleSession",method:"DELETE",path:"/stores/apple/session/shares/"+u("UnshareAppleSession","environment",t.path.environment),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async getInstallPage(t){return e.send({op:"GetInstallPage",method:"GET",path:"/stores/install",auth:[],answers:{200:"raw"},query:t.query,signal:t.signal})},async getInstallStatus(t){return e.send({op:"GetInstallStatus",method:"GET",path:"/stores/install/status",auth:[],answers:{200:"json"},query:t.query,signal:t.signal})},async retryInstall(t){return e.send({op:"RetryInstall",method:"POST",path:"/stores/install/retry",auth:[],answers:{204:"empty"},query:t.query,signal:t.signal})},async getInstallEnrollment(t){return e.send({op:"GetInstallEnrollment",method:"GET",path:"/stores/install/enroll",auth:[],answers:{200:"raw",303:"redirect"},query:t.query,signal:t.signal})},async registerInstallDevice(t){return e.send({op:"RegisterInstallDevice",method:"POST",path:"/stores/install/device",auth:[],answers:{200:"raw",301:"redirect"},query:t.query,body:{kind:"raw",contentType:t.contentType??"application/pkcs7-signature",value:t.body},signal:t.signal})},async getInstallManifest(t){return e.send({op:"GetInstallManifest",method:"GET",path:"/stores/install/manifest",auth:[],answers:{200:"raw"},query:t.query,signal:t.signal})},async getInstallBuild(t){return e.send({op:"GetInstallBuild",method:"GET",path:"/stores/install/app",auth:[],answers:{200:"raw"},query:t.query,signal:t.signal})},async headInstallBuild(t){return e.send({op:"HeadInstallBuild",method:"HEAD",path:"/stores/install/app",auth:[],answers:{200:"empty"},query:t.query,signal:t.signal})},async getInstallIcon(t){return e.send({op:"GetInstallIcon",method:"GET",path:"/stores/install/icon",auth:[],answers:{200:"raw"},query:t?.query,signal:t?.signal})},async listInvitations(t){return e.send({op:"ListInvitations",method:"GET",path:"/stores/packages/"+u("ListInvitations","package_id",t.path.package_id)+"/invitations",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async invitePerson(t){return e.send({op:"InvitePerson",method:"POST",path:"/stores/packages/"+u("InvitePerson","package_id",t.path.package_id)+"/invitations",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async revokeInvitation(t){return e.send({op:"RevokeInvitation",method:"DELETE",path:"/stores/invitations/"+u("RevokeInvitation","invitation_id",t.path.invitation_id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async listDevices(t){return e.send({op:"ListDevices",method:"GET",path:"/stores/devices",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})}}}var Kr={attempts:3,maxWaitSeconds:30},Ek=new Set([429,502,503,504]);function Bl(e,t=Kr){let n=t.sleep??jk;return{async send(s){let a=Tk(s),i=a.body,r=!i||i.kind!=="raw"||wa(i.value),o=(a.method==="GET"||a.method==="HEAD"||a.idempotent===!0)&&r;for(let l=1;;l++)try{return await e.send(a)}catch(d){if(!o||l>=t.attempts||!(d instanceof W)||a.signal?.aborted)throw d;let p=Ck(d,l,t.maxWaitSeconds);if(p===void 0)throw d;await n(p*1e3,a.signal)}}}}function Tk(e){return e.idempotent?Object.entries(e.headers??{}).some(([n,s])=>n.toLowerCase()==="idempotency-key"&&s!==void 0&&s!==null&&s!=="")?e:{...e,headers:{...e.headers,"Idempotency-Key":Ok()}}:e}function Ck(e,t,n){return Ek.has(e.status)||e.code==="network_error"?e.retryAfter!==void 0?e.retryAfter<=n?e.retryAfter:void 0:Math.min(.5*2**(t-1),n)*(.8+Math.random()*.4):void 0}function jk(e,t){return new Promise((n,s)=>{if(t?.aborted)return s(t.reason);let a=()=>{clearTimeout(i),s(t?.reason)},i=setTimeout(()=>{t?.removeEventListener("abort",a),n()},e);t?.addEventListener("abort",a,{once:!0})})}function Ok(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(n=>n.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}import{hostname as Nk}from"node:os";var Ik=new Set(["apikey","authorization",Ul]);function Lk(e){let t={accept:"application/json"};for(let[n,s]of Object.entries(e??{}))s!=null&&!Ik.has(n.toLowerCase())&&(t[n.toLowerCase()]=String(s));return t}function Dk(e,t,n){let s=null;try{s=n.startsWith("/")?new URL(n,e):null}catch{s=null}if(!s||s.origin!==new URL(e).origin)throw new W({op:t,status:0,code:"invalid_path",message:`${t}: a module's path stays at its environment's address`});return s.href}async function Mk(e){let t=e.status===204||e.status===304?"":await e.text();if(t!=="")try{return JSON.parse(t)}catch{return t}}function xk(e,t,n){let s=n??{},a=Number(t.headers.get("retry-after")??"");return new W({op:e,status:t.status,code:typeof s.error=="string"?s.error:`http_${t.status}`,message:Fr(n,t.status),requestId:typeof s.request_id=="string"?s.request_id:t.headers.get("x-request-id")??void 0,retryAfter:Number.isFinite(a)&&a>0?a:typeof s.retry_after=="number"?s.retry_after:void 0,body:n})}var Fn=class{bytes;contentType;constructor(t,n){this.bytes=t,this.contentType=n}};function Gk(e){return e instanceof Fn?{headers:{"content-type":e.contentType,"content-length":String(e.bytes.size)},body:e.bytes}:e===void 0?{headers:{}}:{headers:{"content-type":"application/json"},body:JSON.stringify(e)}}async function Ve(e,t,n,s,a,i){let r=`${n} ${s}`,o=Gk(a),l=await e.module(Dk(Wt(e.cloud,t),r,s),{method:n,headers:{...Lk(i),...o.headers},body:o.body}),d=await Mk(l);if(l.status>=200&&l.status<300)return{status:l.status,body:Tr(d),etag:l.headers.get("etag")??void 0};throw xk(r,l,d)}var qk=10080*60*1e3;async function Wl(e,t,n=!1){let s=await e.state.personalKey(t);if(!n&&s&&Date.parse(s.expires_at)-e.io.now()>qk)return s;let a=await e.post(`/environments/${ee("the environment's ref",t)}/personal-key`,{host:Nk().slice(0,100)||"computer"});return await e.state.keepPersonalKey(t,a),a}function Fr(e,t){let n=e??{},s=typeof n.error_description=="string"?n.error_description:`the module answered ${t}`,a=Array.isArray(n.field_errors)?n.field_errors.flatMap(i=>{let{pointer:r,message:o}=i??{};return typeof o=="string"?[`${typeof r=="string"&&r!==""?`${r}: `:""}${o}`]:[]}):[];return a.length>0?`${s}: ${a.join("; ")}`:s}import{relative as Uk}from"node:path";async function _a(e,t){let n=await e.run("git",["rev-parse","--show-toplevel"],{cwd:t});if(n.code!==0)return null;let s=n.stdout.trim(),a=await e.run("git",["remote","get-url","origin"],{cwd:t}),i=await e.run("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:t}),r=i.code===0?i.stdout.trim():"";return{root:s,repository:a.code===0?Kk(a.stdout.trim()):void 0,branch:r!==""&&r!=="HEAD"?r:void 0,path:Uk(s,t).split("\\").join("/")}}function Kk(e){let t=/^(?:https?:\/\/(?:[^@/]+@)?github\.com\/|git@github\.com:|ssh:\/\/git@github\.com\/)([A-Za-z0-9-]+)\/([A-Za-z0-9._-]+?)(?:\.git)?\/?$/.exec(e);return t?`${t[1]}/${t[2]}`:void 0}async function $a(e,t){let n=await nt(e);return new Map(n.filter(s=>s.project_id===t.project_id).map(s=>[s.ref,s.slug]))}function Bn(e,t){return t?e.get(t.ref)??t.ref:""}var Et="main";async function nt(e){let[t,n]=await Promise.all([e.get("/environments"),e.get("/orgs")]),s=new Map(n.organizations.map(a=>[a.id,a.name]));return t.environments.map(a=>({...a,org_name:s.get(a.organization_id)??a.organization_id}))}function Oe(e){return{org_id:e.organization_id,org_name:e.org_name,project_id:e.project_id,project_name:e.project_name,env_ref:e.ref,env_slug:e.slug,env_name:e.name}}function se(e){return`${e.org_name} \u203A ${e.project_name} \u203A ${e.env_name}${e.env_name!==e.env_slug?` (${e.env_slug})`:""}`}function Wn(e){return(e.env.PALBASE_TOKEN??"").startsWith("pbe_")}async function Si(e){let[t]=await nt(e.studio);if(!t)throw new y("token_refused","Studio names no environment for PALBASE_TOKEN",{hint:"mint another: palbase env:tokens:create"});let n=Oe(t),s=r=>new y("token_environment",`PALBASE_TOKEN is ${se(n)}'s environment token: it acts there alone, not in ${r}`,{hint:"mint one there: palbase env:tokens:create -P <project> -E <env>"}),{project:a,env:i}=e.global;if(a!==void 0&&t.project_id!==a&&!Hl(t.project_name,a.slice(a.indexOf("/")+1)))throw s(a);if(i!==void 0&&i!==t.slug&&i!==t.ref)throw s(i);if(a===void 0&&i===void 0){let r=await e.state.targetFor(e.io.cwd);if(r&&r.target.env_ref!==t.ref)throw s(`${se(r.target)}, chosen for ${r.dir}`)}return t}async function w(e){if(Wn(e.io))return Oe(await Si(e));let{project:t,env:n}=e.global;if(t!==void 0||n!==void 0){let r=await nt(e.studio),o;if(t!==void 0)o=ms(r,t);else{let l=await e.state.targetFor(e.io.cwd);if(!l)throw Jl("-E names an environment of the project chosen here, and none is chosen: add -P <project>");o=r.filter(d=>d.project_id===l.target.project_id)}if(n!==void 0){let l=o.find(d=>d.slug===n||d.ref===n);if(!l)throw new y("no_such_environment",`the project has no environment ${JSON.stringify(n)}`,{hint:`its environments: ${o.map(d=>d.slug).join(", ")}`});return Oe(l)}return o.length===1?Oe(o[0]):Oe(await zl(e,o,"Which environment?"))}let s=await e.state.targetFor(e.io.cwd);if(s)return s.target;if(!e.interactive)throw Jl("no environment is chosen for this directory");let a=await nt(e.studio);if(a.length===0)throw new y("no_environments","your account reaches no environment yet",{hint:"make one: palbase projects:create <name>"});let i=Oe(await zl(e,a,"Which environment?"));return e.out.note(`Acting on ${se(i)}. palbase use remembers it for this directory.`),i}async function Ds(e){return(await cs(e)).t}async function cs(e){if(Wn(e.io))return{t:Oe(await Si(e)),by:"token"};let t=await e.state.targetFor(e.io.cwd);if(e.global.project===void 0&&e.global.env===void 0&&t)return{t:t.target,by:"here"};let n=await Du(e,t?.target);if(e.global.env!==void 0)return{t:Oe(Vl(n,e.global.env)),by:"env"};let s=n.find(a=>a.ref===t?.target.env_ref);return s?{t:Oe(s),by:"here"}:{t:Oe(n.find(a=>a.slug===Et)??n[0]),by:"fallback"}}function Br(e,t){return e.by==="fallback"?t:`${t}${t.includes("?")?"&":"?"}environment=${encodeURIComponent(e.t.env_ref)}`}var Lu=1e3;async function us(e){let t=[],n=new Set,s;for(;;){let a=await e(s);if(t.push(...a.items),!a.next)return t;if(n.has(a.next)||n.size>=Lu)throw new y("list_unending",`the platform's list did not end: ${n.has(a.next)?`it gave the cursor ${JSON.stringify(a.next)} twice`:`it ran past ${Lu} pages`}`);n.add(a.next),s=a.next}}async function Ms(e,t,n,s,a){if(t.by==="env"||t.by==="token"||t.by==="here"&&(n.environment?.ref??t.t.env_ref)===t.t.env_ref)return;let i=(await s()).filter(o=>o.name===n.name);if(i.length<2)return;let r=await $a(e.studio,t.t);throw new y("ambiguous_name",`${a} is held by more than one of ${t.t.project_name}'s environments: ${i.map(o=>Bn(r,o.environment)).join(", ")}`,{hint:"name the environment: -E <env>"})}async function xs(e){if(Wn(e.io))return Oe(await Si(e));let t=await e.state.targetFor(e.io.cwd);if(e.global.project===void 0&&e.global.env===void 0&&t)return t.target;let n=await Du(e,t?.target);if(e.global.env!==void 0)return Oe(Vl(n,e.global.env));let s=n.find(i=>i.ref===t?.target.env_ref);if(s)return Oe(s);let a=n[0].project_name;if(!e.interactive)throw g(`which environment of ${a} is it bound to? name it with -E <env>`,`its environments: ${n.map(i=>i.slug).join(", ")}`);return Oe(await zl(e,n,re(`Which environment of ${a} does it belong to?`)))}async function Gs(e,t,n,s){if(!n||n.ref===t.env_ref)return t;let a=(await nt(e.studio)).find(i=>i.ref===n.ref);if(e.global.env!==void 0){let i=a?.slug??n.name??n.ref;throw new y("bound_elsewhere",`${s} is bound to ${t.project_name}'s environment ${i}, not ${t.env_slug}`,{hint:`leave -E out: the command acts where it is bound${a?` (or name it, -E ${a.slug})`:""}`})}if(!a)throw new y("environment_out_of_reach",`${s} is bound to ${t.project_name}'s environment ${n.name||n.ref}, which your account does not reach`,{hint:"an admin of the project's organization adds you to that environment"});return Oe(a)}function Wr(e,t,n){return e.global.env===void 0?n:`${n}${n.includes("?")?"&":"?"}environment=${encodeURIComponent(t.env_ref)}`}async function Ai(e,t,n){let s=(await nt(e.studio)).filter(a=>a.project_id===t.project_id);return Vl(s,n)}function Ae(e){return`The ${e} is the project's: the command acts in the environment it is bound to. -E picks it where two environments hold its name, and is refused when it names another.`}var qs="It is bound to the environment -E names, or to the one chosen for this directory: a person at the terminal is asked which, anyone else names it with -E.";async function Du(e,t){let n=await nt(e.studio);if(e.global.project!==void 0)return ms(n,e.global.project);if(t){let a=n.filter(i=>i.project_id===t.project_id);if(a.length===0)throw new y("no_such_project",`the project chosen here (${t.project_name}) is not among yours any more`,{hint:"palbase use another"});return a}if(!e.interactive)throw new y("no_target","which project? none is chosen for this directory",{hint:"pass -P <project>, or choose one here with palbase use"});if(n.length===0)throw new y("no_environments","your account reaches no environment yet",{hint:"make one: palbase projects:create <name>"});let s=[...new Map(n.map(a=>[a.project_id,a])).values()];for(s.forEach((a,i)=>e.out.note(` ${String(i+1).padStart(2)}) ${a.org_name} \u203A ${a.project_name}`));;){let a=Number((await e.io.prompt(`Which project? [1-${s.length}] `)).trim());if(Number.isInteger(a)&&a>=1&&a<=s.length){let i=s[a-1];return e.out.note(`Acting on ${i.org_name} \u203A ${i.project_name}. palbase use remembers one for this directory.`),n.filter(r=>r.project_id===i.project_id)}e.out.note(`answer with a number from 1 to ${s.length}`)}}function Vl(e,t){let n=e.find(s=>s.slug===t||s.ref===t);if(!n)throw new y("no_such_environment",`the project has no environment ${JSON.stringify(t)}`,{hint:`its environments: ${e.map(s=>s.slug).join(", ")}`});return n}function ms(e,t){let n=e.filter(l=>l.project_id===t);if(n.length>0)return n;let s=t.indexOf("/"),[a,i]=s>=0?[t.slice(0,s),t.slice(s+1)]:[void 0,t],r=e.filter(l=>Hl(l.project_name,i)&&(a===void 0||Hl(l.org_name,a)||l.organization_id===a)),o=new Set(r.map(l=>l.project_id));if(o.size===0)throw new y("no_such_project",`no project ${JSON.stringify(t)} among yours`,{hint:"palbase projects:list shows them"});if(o.size>1){let l=[...new Set(r.map(d=>`${d.org_name}/${d.project_name}`))].join(", ");throw new y("ambiguous_project",`${JSON.stringify(t)} is a project in more than one organization: ${l}`,{hint:"name it as org/project"})}return r}async function k(e,t,n,s){e.out.note(`${se(t)}: ${n}${e.global.yes?" (confirmed with -y)":""}`);let a=t.env_slug===Et;if(!a&&s===void 0||e.global.yes)return;if(!e.interactive){let r=Wn(e.io)?"confirm with -y: with PALBASE_TOKEN, -y is the go-ahead (the CLI asks no one else, and a person's yes elsewhere is not one)":"confirm with -y";throw new y("confirmation_needed",a?`${t.project_name} \u203A ${t.env_name} is the project's production environment`:s,{hint:r})}let i=(await e.io.prompt(re(`${a?`This is ${t.project_name}'s production environment`:s}. Go ahead? [y/N] `))).trim().toLowerCase();if(i!=="y"&&i!=="yes")throw new y("cancelled","nothing was changed")}async function zl(e,t,n){if(!e.interactive)throw Jl(`${n.replace(/\?$/,"")}: ${t.map(s=>`${s.project_name}/${s.slug}`).join(", ")}`);for(t.forEach((s,a)=>e.out.note(` ${String(a+1).padStart(2)}) ${se(Oe(s))}`));;){let s=(await e.io.prompt(`${n} [1-${t.length}] `)).trim(),a=Number(s);if(Number.isInteger(a)&&a>=1&&a<=t.length)return t[a-1];e.out.note(`answer with a number from 1 to ${t.length}`)}}function Jl(e){return new y("no_target",e,{hint:"choose one here with palbase use, or pass -P <project> -E <env>"})}function Hl(e,t){return e.localeCompare(t,void 0,{sensitivity:"accent"})===0}import{randomUUID as Fk}from"node:crypto";import{readFile as Bk}from"node:fs/promises";import{resolve as Wk}from"node:path";var zk=6,Xl=0,Mu=[];async function Jk(e){Xl<zk?Xl++:await new Promise(t=>Mu.push(t));try{return await e()}finally{let t=Mu.shift();t?t():Xl--}}async function wt(e,t,n,s,a,i){return Jk(()=>Ve(e.studio,t.env_ref,n,s,a,i))}async function h(e,t,n,s,a,i){return(await wt(e,t,n,s,a,i)).body}async function vt(e,t,n){let s=await wt(e,t,"GET",n);return{body:s.body,etag:s.etag}}function pt(e){return e?{"if-match":e}:void 0}function J(){return{"idempotency-key":Fk()}}function T(e){return encodeURIComponent(e)}function hs(e){return e.map(t=>{let n=t.indexOf("=");if(n<=0)throw g(`a setting is key=value, not ${JSON.stringify(t)}`);let s=t.slice(0,n).split(".");if(s.some(a=>a===""||a==="__proto__"||a==="constructor"||a==="prototype"))throw g(`${JSON.stringify(t.slice(0,n))} is not a key`);return{path:s,value:An(t.slice(n+1))}})}function An(e){try{return JSON.parse(e)}catch{return e}}function gs(e,t){let n=structuredClone(e);for(let{path:s,value:a}of t){let i=n;for(let r of s.slice(0,-1)){let o=i[r];(typeof o!="object"||o===null)&&(i[r]={}),i=i[r]}i[s[s.length-1]]=a}return n}function zn(e,t){return[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>!Tt(e[n],t[n])).sort()}function xu(e){return JSON.stringify(e,(t,n)=>n!==null&&typeof n=="object"&&!Array.isArray(n)?Object.fromEntries(Object.entries(n).sort(([s],[a])=>s<a?-1:s>a?1:0)):n)}function Tt(e,t){return xu(e)===xu(t)}function ct(e){return e===void 0?"(not set)":typeof e=="string"&&e!==""?e:JSON.stringify(e)}function ka(e,t){let n=Object.keys(t).sort(),s=Math.max(0,...n.map(a=>a.length));for(let a of n)e.out.line(`${a.padEnd(s)} ${ct(t[a])}`)}function Ct(e,t,n){e.out.result({settings:n,changed:[]},()=>e.out.line(`Nothing to change: ${t} already ${t.endsWith("s")?"are":"is"} so.`))}async function Xe(e,t,n){let s;if(t!==void 0&&t!=="-")try{s=await Bk(Wk(e.io.cwd,t),"utf8")}catch(a){throw new y("unreadable_file",`${t} could not be read: ${a instanceof Error?a.message:String(a)}`)}else e.io.interactive&&e.out.note(`Reading ${n} from stdin; end it with Ctrl-D.`),s=await e.io.readStdin();if(s.trim()==="")throw g(`no ${n} was given`,t===void 0?"pass --file <path>, or pipe it in":void 0);return s}function Fe(e,t){try{return JSON.parse(e)}catch(n){throw g(`${t} is not JSON: ${n instanceof Error?n.message:String(n)}`)}}async function ut(e,t){e.io.interactive&&e.out.note(`Paste ${t}, then Ctrl-D (it is read from stdin, never from the command line):`);let n=(await e.io.readStdin()).trim();if(n==="")throw g(`no ${t} was piped in`,"pipe it in: palbase \u2026 < file");return n}function Sa(e){if(e.flags.enable===!0&&e.flags.disable===!0)throw g("--enable and --disable are one or the other");if(e.flags.enable===!0)return!0;if(e.flags.disable===!0)return!1}function fs(e,t){if(e!==void 0){if(e==="yes"||e==="true")return!0;if(e==="no"||e==="false")return!1;throw g(`--${t} is yes or no`)}}function Ie(e){return e===void 0?void 0:(Array.isArray(e)?e:[e]).flatMap(n=>String(n).split(",")).map(n=>n.trim()).filter(n=>n!=="")}function Te(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<0)throw g(`--${t} is a whole number`);return n}var Pi={enable:{type:"boolean",description:"turn it on"},disable:{type:"boolean",description:"turn it off"}};async function Se(e,t,n){try{await n(),e.done(t)}catch(s){if(!(s instanceof W))throw s;e.left(`${t}: refused \u2014 ${s.message}`)}}function We(e,t){return e.filter(n=>n.key.startsWith(t)).map(n=>({...n,name:n.key.slice(t.length)}))}function Yl(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>!(t==null||t===""||Array.isArray(t)&&t.length===0)))}import{writeFile as Hk}from"node:fs/promises";var Vk=/^[A-Z][A-Z0-9_]{0,127}$/,Aa={dev:{type:"boolean",description:"the development set (what a backend on a developer's computer reads, and a machine started with it), not production \u2014 whatever the environment is named"}};function Pa(e){return e.flags.dev===!0?"development":"production"}function Ri(e){let t=e.args[0];if(!Vk.test(t))throw g(`${JSON.stringify(t)} is not a secret's name: capital letters, digits and _, a letter first`);return t}async function Zl(e,t,n){try{let s=await us(async a=>{let i=await h(e,t,"GET",`/machines?limit=100&environment=${encodeURIComponent(t.env_ref)}${a?`&cursor=${encodeURIComponent(a)}`:""}`);return{items:i.machines,next:i.next_cursor}});return{using:s.filter(a=>a.secrets===n).map(a=>a.name).sort(),others:s.filter(a=>a.secrets!==n)}}catch(s){return{unread:s instanceof Error?s.message:String(s)}}}function Ql(e,t,n,s){if("unread"in s){e.out.note(`which machines start with the ${n} set could not be read (${s.unread}): palbase machines:list -E ${t.env_slug} says each one's`);return}if(s.using.length>0){let o=s.using.join(", ");e.out.line(`${o} ${s.using.length===1?"starts":"start"} with the ${n} set: rolling out with the new value \u2014 palbase machines:list -E ${t.env_slug} shows it until every copy runs it.`);return}let a=n==="production"?"development":"production",i=n==="development"?" Only a backend run on a computer (palbase run, env:pull) reads it.":"";if(s.others.length===0){n==="production"&&e.out.note(`${se(t)} has no machine yet: one started with the ${n} set reads it.`);return}let r=s.others.map(o=>`${o.name} starts with ${o.secrets?`the ${o.secrets} set`:"no set"}`).join(", ");e.out.warn(`no machine of ${se(t)} starts with the ${n} set (${r}): this value reaches none of them.${i} palbase machines:update <name> --secrets ${n} starts a machine with it; ${n==="production"?"--dev writes":"leaving --dev out writes"} the ${a} set.`)}async function Ra(e,t,n){let s=[],a;do{let i=await h(e,t,"GET",`/secrets/${n}?limit=1000${a?`&cursor=${encodeURIComponent(a)}`:""}`);s.push(...i.secrets),a=i.next_cursor}while(a);return s}var Xk={name:"secrets:list",summary:"the environment's secrets by name, with their version \u2014 never their values",usage:"[--dev]",flags:Aa,scope:"environment",async run(e){let t=await w(e),n=Pa(e),s=await Ra(e,t,n);e.out.result({set:n,secrets:s},()=>{s.length===0&&e.out.line(`No ${n} secrets.`);for(let a of s)e.out.line(`${a.name} v${a.version} ${a.updated_at}`)})}},Yk={name:"secrets:set",summary:"set a secret: its value is read from stdin, never from the command line",usage:"<NAME> [--dev] < value",details:["An environment has two sets, production and development, whatever the environment is named: Development's machines may start with its production set. A machine starts with the set it names (machines:update --secrets), and a change of that set rolls it out with the new value; a backend run with palbase run or env:pull reads development.","It says which of the environment's machines start with the set, and warns when none does."],args:{min:1,max:1},flags:Aa,scope:"environment",async run(e){let t=await w(e),n=Ri(e),s=Pa(e),a=await ut(e,`the value of ${n}`);await k(e,t,`set the ${s} secret ${n}`);let i=await h(e,t,"PUT",`/secrets/${s}/${n}`,{value:a}),r=await Zl(e,t,s);e.out.result({set:s,name:n,version:i.version,environment:t.env_slug,machines:"using"in r?r.using:null},()=>{e.out.line(`Set ${n} v${i.version} in the ${s} set of ${se(t)}.`),Ql(e,t,s,r)})}},Zk={name:"secrets:unset",summary:"take a secret away",usage:"<NAME> [--dev]",args:{min:1,max:1},flags:Aa,scope:"environment",async run(e){let t=await w(e),n=Ri(e),s=Pa(e);await k(e,t,`take away the ${s} secret ${n}`),await h(e,t,"DELETE",`/secrets/${s}/${n}`);let a=await Zl(e,t,s);e.out.result({set:s,name:n,deleted:!0,environment:t.env_slug,machines:"using"in a?a.using:null},()=>{e.out.line(`Took ${n} away from the ${s} set of ${se(t)}.`),Ql(e,t,s,a)})}},Qk={name:"secrets:get",summary:"print one development secret's value (an admin's): a production secret's is never read back",usage:"<NAME> --dev",details:["A production secret's value is never read back, by anyone: only the machines that start with it are given it, and it is changed by setting it again (secrets:set). The development set is what a backend on your computer reads (palbase run, env:pull): secrets:get NAME --dev prints one."],args:{min:1,max:1},flags:Aa,scope:"environment",async run(e){let t=await w(e),n=Ri(e),s=await h(e,t,"GET",`/secrets/${Pa(e)}/${n}`);e.out.result({name:n,version:s.version,value:s.value},()=>e.out.line(s.value))}},eS={name:"secrets:versions",summary:"a secret's versions, newest first \u2014 never their values",usage:"<NAME> [--dev]",args:{min:1,max:1},flags:Aa,scope:"environment",async run(e){let t=await w(e),n=Ri(e),s=await h(e,t,"GET",`/secrets/${Pa(e)}/${n}/versions`);e.out.result(s,()=>{for(let a of s.versions)e.out.line(`v${a.version} ${a.created_at}${a.current?" (current)":""}`)})}},tS={name:"secrets:rollback",summary:"put a secret back to one of its versions (a new version with that value)",usage:"<NAME> --version <n> [--dev]",args:{min:1,max:1},flags:{...Aa,version:{type:"string",value:"n",description:"the version to go back to"}},scope:"environment",async run(e){let t=await w(e),n=Ri(e),s=Number(e.flags.version);if(!Number.isInteger(s)||s<1)throw g("--version is a version number (secrets:versions lists them)");let a=Pa(e);await k(e,t,`put the ${a} secret ${n} back to v${s}`);let i=await h(e,t,"POST",`/secrets/${a}/${n}/rollback`,{version:s}),r=await Zl(e,t,a);e.out.result({set:a,name:n,version:i.version,environment:t.env_slug,machines:"using"in r?r.using:null},()=>{e.out.line(`${n} in the ${a} set of ${se(t)} is v${s}'s value again, as v${i.version}.`),Ql(e,t,a,r)})}},nS={name:"secrets:audit",summary:"every read and write of the environment's secrets, newest first: which secret, which key did it, when \u2014 never a value",usage:"[--name <NAME>] [--dev | --prod] [--limit <n>]",details:["A backend that reads the secrets at boot (palbase run, a machine) shows here as a read, with the key it read with: palbase keys:list names the key.","An encrypted column's values opened through Palbase (Studio's table, a secret key) are recorded under the column's address: --name patients.tc lists who opened them, and when."],flags:{name:{type:"string",value:"NAME",description:"only this secret's, or an encrypted field's opens (table.column)"},dev:{type:"boolean",description:"only the development secrets"},prod:{type:"boolean",description:"only the production secrets"},limit:{type:"string",value:"n",description:"how many (default 30)"}},scope:"environment",async run(e){let t=await w(e);if(e.flags.dev===!0&&e.flags.prod===!0)throw g("--dev or --prod, not both");let n=Number(e.flags.limit??30);if(!Number.isInteger(n)||n<1||n>500)throw g("--limit is a whole number from 1 to 500");let s=new URLSearchParams({limit:String(n),...e.flags.name?{name:e.flags.name}:{},...e.flags.dev===!0?{environment:"development"}:e.flags.prod===!0?{environment:"production"}:{}}),a=await h(e,t,"GET",`/secrets/audit?${s}`);e.out.result(a,()=>{a.entries.length===0?e.out.line("No read or write of a secret yet."):e.out.table(a.entries,[{header:"when",value:i=>i.at.slice(0,19).replace("T"," ")},{header:"what",value:i=>i.action},{header:"set",value:i=>i.environment??""},{header:"secret",value:i=>i.name?`${i.name}${i.version?` v${i.version}`:""}`:"every one"},{header:"key",value:i=>i.key_id}])})}};function Gu(e,t){e.out.table(t.keys,[{header:"key",value:n=>`${n.id}${n.id===t.current?" (in force)":""}`},{header:"in force from",value:n=>n.activates_at.slice(0,19).replace("T"," ")},{header:"made by",value:n=>n.created_by}])}var sS={name:"fields:list",summary:"the keys the environment's encrypted database fields are sealed with \u2014 never the keys themselves",scope:"environment",async run(e){let t=await w(e),n=await h(e,t,"GET","/secrets/fields");e.out.result(n,()=>Gu(e,n))}},aS={name:"fields:rotate",summary:"make a new key for the environment's encrypted fields (an owner's or an admin's)",details:["It comes into force in five minutes: by then every running backend has fetched it. New values are sealed with it from then on; a palbase/backend app seals its older values again with it, in the background.","The older keys go on opening what they sealed."],scope:"environment",async run(e){let t=await w(e);await k(e,t,"rotate the encrypted fields' key");let n=await h(e,t,"POST","/secrets/fields/rotate"),s=n.keys[n.keys.length-1];e.out.result(n,()=>{e.out.line(`Made ${s.id} in ${se(t)}: in force from ${s.activates_at.slice(0,19).replace("T"," ")} UTC.`),Gu(e,n)})}},iS={name:"fields:keys",summary:"download the environment's field keys into a file (its owner's): what opens a dump of its database elsewhere",usage:"--out <file>",details:["The file opens every encrypted field of the environment: keep it as you would the database's password. It is the shape palbase/server's Fields reads: new Fields({ fetch: async () => JSON.parse(readFileSync(file, 'utf8')) }).","The download is in the secrets audit trail (secrets:audit)."],flags:{out:{type:"string",value:"file",description:"where the keys go (made readable by you alone); never the screen"}},scope:"environment",async run(e){let t=e.flags.out;if(!t)throw g("fields:keys writes the keys into a file: --out <file> (never onto the screen, which keeps them)");let n=await w(e),s=await h(e,n,"GET","/secrets/fields/keys");await Hk(t,`${JSON.stringify(s,null,2)}
|
|
21
|
+
`}import{createHash as xG,randomBytes as GG,timingSafeEqual as qG}from"node:crypto";import{createServer as KG}from"node:http";var Fl="owner.json";var WG=300*1e3;function ee(e,t){try{return u("palbase",e,t)}catch(n){throw n instanceof W&&n.code==="invalid_path_parameter"?new y("unsafe_path",`${e} cannot be ${t===""?"empty":JSON.stringify(t)}: a request's path cannot carry it`):n}}var Cu={name:"login",summary:"sign in with your Studio account",details:["Shows a one-time code and opens Studio, where you approve it while signed in there.","The CLI then holds a session of yours: Studio lists it with your others, and ending it there signs the CLI out.","On a machine with no browser (a server, an agent), open the address it prints on any device."],flags:{"no-browser":{type:"boolean",description:"print the address instead of opening a browser"}},scope:"none",async run(e){if(e.io.env.PALBASE_TOKEN)throw new y("token_in_use","PALBASE_TOKEN is set: the CLI acts with that token, and a sign-in would not be used",{hint:"unset PALBASE_TOKEN to sign in as yourself"});let t=await yu(e.io,e.cloud),n=`${e.cloud.studioWeb}/device`;e.out.note(""),e.out.note(` Enter this code in your browser: ${t.user_code}`),e.out.note("");let s=e.flags["no-browser"]!==!0&&e.interactive&&await e.io.openBrowser(n);e.out.note(s?`Opened ${n} \u2014 sign in there if asked, then enter the code.`:`Open ${n} on any device, sign in, and enter the code.`),e.out.note("Waiting for the approval\u2026");let a=await bu(e.io,e.cloud,t);await e.state.writeSession(a),e.out.result({user:a.user},()=>e.out.line(`Signed in as ${a.user.email??a.user.id}.`))}},ju={name:"logout",summary:"sign out: the session is ended at Palbase and forgotten on this computer",scope:"none",async run(e){if(e.io.env.PALBASE_TOKEN)throw new y("token_in_use","PALBASE_TOKEN is set: logout ends your own sign-in, and the CLI acts with the token",{hint:"unset PALBASE_TOKEN to sign out"});let t=await e.state.readSession();if(!t){e.out.result({signed_out:!0},()=>e.out.line("You were not signed in."));return}for(let[n,s]of Object.entries(await e.state.personalKeys()))try{await e.studio.request("DELETE",`/environments/${ee("the environment's ref",n)}/personal-key/${ee("the personal key's id",s.id)}`)}catch(a){a instanceof Error&&"status"in a&&a.status===404||e.out.warn(`your key at ${n} (${s.label}) could not be revoked: ${a instanceof Error?a.message:String(a)} \u2014 revoke it in Studio, or it ends ${s.expires_at}`)}await e.state.forgetPersonalKeys(),await e.state.forget(Fl);try{await vu(e.io,e.cloud,t)}catch(n){e.out.warn(`${n instanceof Error?n.message:String(n)} \u2014 end the session in Studio (Account \u203A Sessions)`)}await e.state.clearSession(),e.out.result({signed_out:!0},()=>e.out.line(`Signed out ${t.user.email??t.user.id}.`))}},Ou={name:"whoami",summary:"the account the CLI acts as, and the environment chosen for this directory",scope:"account",async run(e){let t=e.io.env.PALBASE_TOKEN,n;if(t?.startsWith("pbu_")){let{organizations:a}=await e.studio.get("/orgs");n={id:`account token \u2026${t.slice(-4)}`,via:"token",organizations:a.length}}else if(t?.startsWith("pbo_")){let{organizations:a}=await e.studio.get("/orgs"),i=a[0];n={id:`token \u2026${t.slice(-4)}`,via:"token",...i&&{organization:{id:i.id,name:i.name,role:i.role}}}}else if(t){let a=Ir(t);n={id:String(a.sub??""),...typeof a.email=="string"?{email:a.email}:{},via:"token"}}else n={...(await e.studio.currentSession()).user,via:"session"};let s=await e.state.targetFor(e.io.cwd);e.out.result({user:n,target:s?.target??null,target_dir:s?.dir??null},()=>{e.out.line(n.organization?`an access token of ${re(n.organization.name)} (${n.organization.role}), ${n.id} (PALBASE_TOKEN)`:n.organizations!==void 0?`an ${n.id} (PALBASE_TOKEN): an admin of the ${n.organizations} organization${n.organizations===1?"":"s"} it opened`:`${n.email??n.id}${n.via==="token"?" (PALBASE_TOKEN)":""}`),s&&e.out.line(`${s.target.org_name} \u203A ${s.target.project_name} \u203A ${s.target.env_name} (${s.target.env_slug}) \u2014 chosen for ${s.dir}`)})}};var pk={name:"account:tokens:list",summary:"your account tokens (for a program that opens organizations): name, how many organizations they reach, when they end and were last used \u2014 never their values",scope:"account",async run(e){let{tokens:t}=await e.studio.get("/account/tokens");e.out.result({tokens:t},()=>{t.length===0?e.out.line("You have no account token yet: palbase account:tokens:create <name> makes one."):e.out.table(t,[{header:"name",value:n=>re(n.name)},{header:"token",value:n=>`pbu_\u2026${n.hint}`},{header:"organizations",value:n=>String(n.organizations)},{header:"ends",value:n=>n.expires_at.slice(0,10)},{header:"last used",value:n=>n.last_used_at?.slice(0,16).replace("T"," ")??"never"},{header:"id",value:n=>n.id}])})}},ck={name:"account:tokens:create",summary:"make an account token for a program that opens organizations; its value is shown this once",usage:"<name> [--days <n>]",details:["Give it to the program as its secret (PALBASE_TOKEN, or palbase/cloud's token): it opens organizations \u2014 you their owner, the token their admin \u2014 and builds projects and environments there.","It reaches only the organizations it opened, never your others; it makes no token or key and changes no one's place. It ends after --days (default 90, at most 365), when it is revoked, and, in an organization, when you leave it."],args:{min:1,max:1},flags:{days:{type:"string",value:"n",description:"how many days it is good for (default 90)"}},scope:"account",async run(e){let t=e.flags.days===void 0?90:Number(e.flags.days);if(!Number.isInteger(t)||t<1||t>365)throw g("--days is a whole number from 1 to 365");let n=await e.studio.post("/account/tokens",{name:e.args[0],expires_in_days:t});e.out.result(n,()=>{e.out.line(`Made the account token ${re(n.name)} (until ${n.expires_at.slice(0,10)}).`),e.out.line(`token (shown this once \u2014 keep it as the program's secret PALBASE_TOKEN): ${n.token}`)})}},uk={name:"account:tokens:revoke",summary:"revoke one of your account tokens (by its name or id): refused from its next request on; the organizations it opened stay yours",usage:"<name|id>",args:{min:1,max:1},scope:"account",async run(e){let{tokens:t}=await e.studio.get("/account/tokens"),n=t.filter(s=>s.id===e.args[0]||s.name===e.args[0]);if(n.length===0)throw new y("no_such_token",`you have no account token ${JSON.stringify(e.args[0])}`,{hint:"palbase account:tokens:list shows them"});if(n.length>1)throw new y("ambiguous_token",`${JSON.stringify(e.args[0])} names more than one token`,{hint:"pass its id"});await e.studio.request("DELETE",`/account/tokens/${ee("the token's id",n[0].id)}`),e.out.result({revoked:n[0].id},()=>e.out.line(`Revoked the account token ${re(n[0].name)}.`))}},Nu=[pk,ck,uk];var xr={};Dt(xr,{client:()=>mk});function mk(e){return{async draftAgent(t){return e.send({op:"DraftAgent",method:"POST",path:"/ai/agent-drafts",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listAgents(t){return e.send({op:"ListAgents",method:"GET",path:"/ai/agents",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getAgent(t){return e.send({op:"GetAgent",method:"GET",path:"/ai/agents/"+u("GetAgent","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putAgent(t){return e.send({op:"PutAgent",method:"PUT",path:"/ai/agents/"+u("PutAgent","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteAgent(t){return e.send({op:"DeleteAgent",method:"DELETE",path:"/ai/agents/"+u("DeleteAgent","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async publishAgent(t){return e.send({op:"PublishAgent",method:"POST",path:"/ai/agents/"+u("PublishAgent","name",t.path.name)+"/publish",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async rollbackAgent(t){return e.send({op:"RollbackAgent",method:"POST",path:"/ai/agents/"+u("RollbackAgent","name",t.path.name)+"/rollback",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listAgentVersions(t){return e.send({op:"ListAgentVersions",method:"GET",path:"/ai/agents/"+u("ListAgentVersions","name",t.path.name)+"/versions",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async listChats(t){return e.send({op:"ListChats",method:"GET",path:"/ai/chats",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async createChat(t){return e.send({op:"CreateChat",method:"POST",path:"/ai/chats",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getChat(t){return e.send({op:"GetChat",method:"GET",path:"/ai/chats/"+u("GetChat","chat_id",t.path.chat_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async deleteChat(t){return e.send({op:"DeleteChat",method:"DELETE",path:"/ai/chats/"+u("DeleteChat","chat_id",t.path.chat_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async decideChatApproval(t){return e.send({op:"DecideChatApproval",method:"POST",path:"/ai/chats/"+u("DecideChatApproval","chat_id",t.path.chat_id)+"/approvals/"+u("DecideChatApproval","approval_id",t.path.approval_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async forkChat(t){return e.send({op:"ForkChat",method:"POST",path:"/ai/chats/"+u("ForkChat","chat_id",t.path.chat_id)+"/fork",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getChatGoal(t){return e.send({op:"GetChatGoal",method:"GET",path:"/ai/chats/"+u("GetChatGoal","chat_id",t.path.chat_id)+"/goal",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async setChatGoal(t){return e.send({op:"SetChatGoal",method:"PUT",path:"/ai/chats/"+u("SetChatGoal","chat_id",t.path.chat_id)+"/goal",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async clearChatGoal(t){return e.send({op:"ClearChatGoal",method:"DELETE",path:"/ai/chats/"+u("ClearChatGoal","chat_id",t.path.chat_id)+"/goal",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{204:"empty"},query:t.query,signal:t.signal})},async updateChatGoal(t){return e.send({op:"UpdateChatGoal",method:"PATCH",path:"/ai/chats/"+u("UpdateChatGoal","chat_id",t.path.chat_id)+"/goal",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async putChatMember(t){return e.send({op:"PutChatMember",method:"PUT",path:"/ai/chats/"+u("PutChatMember","chat_id",t.path.chat_id)+"/members/"+u("PutChatMember","user_id",t.path.user_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteChatMember(t){return e.send({op:"DeleteChatMember",method:"DELETE",path:"/ai/chats/"+u("DeleteChatMember","chat_id",t.path.chat_id)+"/members/"+u("DeleteChatMember","user_id",t.path.user_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async listChatMessages(t){return e.send({op:"ListChatMessages",method:"GET",path:"/ai/chats/"+u("ListChatMessages","chat_id",t.path.chat_id)+"/messages",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async sendChatMessage(t){return e.send({op:"SendChatMessage",method:"POST",path:"/ai/chats/"+u("SendChatMessage","chat_id",t.path.chat_id)+"/messages",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json",202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getChatMessageAttachment(t){return e.send({op:"GetChatMessageAttachment",method:"GET",path:"/ai/chats/"+u("GetChatMessageAttachment","chat_id",t.path.chat_id)+"/messages/"+u("GetChatMessageAttachment","message_id",t.path.message_id)+"/attachments/"+u("GetChatMessageAttachment","position",t.path.position),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"raw"},signal:t.signal})},async listChatParts(t){return e.send({op:"ListChatParts",method:"GET",path:"/ai/chats/"+u("ListChatParts","chat_id",t.path.chat_id)+"/parts",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async putChatPipe(t){return e.send({op:"PutChatPipe",method:"PUT",path:"/ai/chats/"+u("PutChatPipe","chat_id",t.path.chat_id)+"/pipe",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteChatPipe(t){return e.send({op:"DeleteChatPipe",method:"DELETE",path:"/ai/chats/"+u("DeleteChatPipe","chat_id",t.path.chat_id)+"/pipe",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async sendSubagentMessage(t){return e.send({op:"SendSubagentMessage",method:"POST",path:"/ai/chats/"+u("SendSubagentMessage","chat_id",t.path.chat_id)+"/runs/"+u("SendSubagentMessage","run_id",t.path.run_id)+"/messages",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async stopSubagent(t){return e.send({op:"StopSubagent",method:"POST",path:"/ai/chats/"+u("StopSubagent","chat_id",t.path.chat_id)+"/runs/"+u("StopSubagent","run_id",t.path.run_id)+"/stop",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async stopChat(t){return e.send({op:"StopChat",method:"POST",path:"/ai/chats/"+u("StopChat","chat_id",t.path.chat_id)+"/stop",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listTurnToolCalls(t){return e.send({op:"ListTurnToolCalls",method:"GET",path:"/ai/chats/"+u("ListTurnToolCalls","chat_id",t.path.chat_id)+"/tool-calls",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getChatToolCall(t){return e.send({op:"GetChatToolCall",method:"GET",path:"/ai/chats/"+u("GetChatToolCall","chat_id",t.path.chat_id)+"/tool-calls/"+u("GetChatToolCall","call_id",t.path.call_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async answerChatToolCall(t){return e.send({op:"AnswerChatToolCall",method:"POST",path:"/ai/chats/"+u("AnswerChatToolCall","chat_id",t.path.chat_id)+"/tool-outputs/"+u("AnswerChatToolCall","call_id",t.path.call_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listChatTurnArtifacts(t){return e.send({op:"ListChatTurnArtifacts",method:"GET",path:"/ai/chats/"+u("ListChatTurnArtifacts","chat_id",t.path.chat_id)+"/turns/"+u("ListChatTurnArtifacts","response_id",t.path.response_id)+"/artifacts",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getChatTurnArtifact(t){return e.send({op:"GetChatTurnArtifact",method:"GET",path:"/ai/chats/"+u("GetChatTurnArtifact","chat_id",t.path.chat_id)+"/turns/"+u("GetChatTurnArtifact","response_id",t.path.response_id)+"/artifacts/"+u("GetChatTurnArtifact","artifact_id",t.path.artifact_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"raw"},signal:t.signal})},async getChatTurnCost(t){return e.send({op:"GetChatTurnCost",method:"GET",path:"/ai/chats/"+u("GetChatTurnCost","chat_id",t.path.chat_id)+"/turns/"+u("GetChatTurnCost","response_id",t.path.response_id)+"/cost",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async startChatVoice(t){return e.send({op:"StartChatVoice",method:"POST",path:"/ai/chats/"+u("StartChatVoice","chat_id",t.path.chat_id)+"/voice",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getChatVoice(t){return e.send({op:"GetChatVoice",method:"GET",path:"/ai/chats/"+u("GetChatVoice","chat_id",t.path.chat_id)+"/voice/"+u("GetChatVoice","voice_id",t.path.voice_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async closeChatVoice(t){return e.send({op:"CloseChatVoice",method:"DELETE",path:"/ai/chats/"+u("CloseChatVoice","chat_id",t.path.chat_id)+"/voice/"+u("CloseChatVoice","voice_id",t.path.voice_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async commandChatVoice(t){return e.send({op:"CommandChatVoice",method:"POST",path:"/ai/chats/"+u("CommandChatVoice","chat_id",t.path.chat_id)+"/voice/"+u("CommandChatVoice","voice_id",t.path.voice_id)+"/commands",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getChatWorkspaceFile(t){return e.send({op:"GetChatWorkspaceFile",method:"GET",path:"/ai/chats/"+u("GetChatWorkspaceFile","chat_id",t.path.chat_id)+"/workspace/files",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"raw"},query:t.query,signal:t.signal})},async putChatWorkspaceFile(t){return e.send({op:"PutChatWorkspaceFile",method:"PUT",path:"/ai/chats/"+u("PutChatWorkspaceFile","chat_id",t.path.chat_id)+"/workspace/files",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t.query,body:{kind:"raw",contentType:t.contentType??"application/octet-stream",value:t.body},signal:t.signal})},async deleteChatWorkspaceFile(t){return e.send({op:"DeleteChatWorkspaceFile",method:"DELETE",path:"/ai/chats/"+u("DeleteChatWorkspaceFile","chat_id",t.path.chat_id)+"/workspace/files",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async addChatWorkspaceRepo(t){return e.send({op:"AddChatWorkspaceRepo",method:"POST",path:"/ai/chats/"+u("AddChatWorkspaceRepo","chat_id",t.path.chat_id)+"/workspace/repos",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listChatWorkspaceTokens(t){return e.send({op:"ListChatWorkspaceTokens",method:"GET",path:"/ai/chats/"+u("ListChatWorkspaceTokens","chat_id",t.path.chat_id)+"/workspace/tokens",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async createChatWorkspaceToken(t){return e.send({op:"CreateChatWorkspaceToken",method:"POST",path:"/ai/chats/"+u("CreateChatWorkspaceToken","chat_id",t.path.chat_id)+"/workspace/tokens",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async revokeChatWorkspaceToken(t){return e.send({op:"RevokeChatWorkspaceToken",method:"DELETE",path:"/ai/chats/"+u("RevokeChatWorkspaceToken","chat_id",t.path.chat_id)+"/workspace/tokens/"+u("RevokeChatWorkspaceToken","token",t.path.token),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async createEmbeddings(t){return e.send({op:"CreateEmbeddings",method:"POST",path:"/ai/embeddings",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listEndpoints(t){return e.send({op:"ListEndpoints",method:"GET",path:"/ai/endpoints",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async putEndpoint(t){return e.send({op:"PutEndpoint",method:"PUT",path:"/ai/endpoints/"+u("PutEndpoint","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteEndpoint(t){return e.send({op:"DeleteEndpoint",method:"DELETE",path:"/ai/endpoints/"+u("DeleteEndpoint","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async listEnv(t){return e.send({op:"ListEnv",method:"GET",path:"/ai/env",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async putEnv(t){return e.send({op:"PutEnv",method:"PUT",path:"/ai/env/"+u("PutEnv","key",t.path.key),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteEnv(t){return e.send({op:"DeleteEnv",method:"DELETE",path:"/ai/env/"+u("DeleteEnv","key",t.path.key),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async createImage(t){return e.send({op:"CreateImage",method:"POST",path:"/ai/images",auth:[["SecretKeyAuth"]],answers:{202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getImage(t){return e.send({op:"GetImage",method:"GET",path:"/ai/images/"+u("GetImage","image_id",t.path.image_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getImageFile(t){return e.send({op:"GetImageFile",method:"GET",path:"/ai/images/"+u("GetImageFile","image_id",t.path.image_id)+"/files/"+u("GetImageFile","position",t.path.position),auth:[["SecretKeyAuth"]],answers:{200:"raw"},signal:t.signal})},async deleteMachine(t){return e.send({op:"DeleteMachine",method:"DELETE",path:"/ai/machines/"+u("DeleteMachine","machine",t.path.machine),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async cordonMachine(t){return e.send({op:"CordonMachine",method:"POST",path:"/ai/machines/"+u("CordonMachine","machine",t.path.machine)+"/cordon",auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async resumeMachine(t){return e.send({op:"ResumeMachine",method:"POST",path:"/ai/machines/"+u("ResumeMachine","machine",t.path.machine)+"/resume",auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async listModels(t){return e.send({op:"ListModels",method:"GET",path:"/ai/models",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async revokePoolKey(t){return e.send({op:"RevokePoolKey",method:"POST",path:"/ai/pool-keys/"+u("RevokePoolKey","key",t.path.key)+"/revoke",auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async listPools(t){return e.send({op:"ListPools",method:"GET",path:"/ai/pools",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async createPool(t){return e.send({op:"CreatePool",method:"POST",path:"/ai/pools",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deletePool(t){return e.send({op:"DeletePool",method:"DELETE",path:"/ai/pools/"+u("DeletePool","pool",t.path.pool),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async listPoolKeys(t){return e.send({op:"ListPoolKeys",method:"GET",path:"/ai/pools/"+u("ListPoolKeys","pool",t.path.pool)+"/keys",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async createPoolKey(t){return e.send({op:"CreatePoolKey",method:"POST",path:"/ai/pools/"+u("CreatePoolKey","pool",t.path.pool)+"/keys",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getPoolState(t){return e.send({op:"GetPoolState",method:"GET",path:"/ai/pools/"+u("GetPoolState","pool",t.path.pool)+"/state",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async listProviders(t){return e.send({op:"ListProviders",method:"GET",path:"/ai/providers",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async connectProvider(t){return e.send({op:"ConnectProvider",method:"PUT",path:"/ai/providers/"+u("ConnectProvider","provider",t.path.provider),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async disconnectProvider(t){return e.send({op:"DisconnectProvider",method:"DELETE",path:"/ai/providers/"+u("DisconnectProvider","provider",t.path.provider),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async listRepos(t){return e.send({op:"ListRepos",method:"GET",path:"/ai/repos",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async putRepo(t){return e.send({op:"PutRepo",method:"PUT",path:"/ai/repos/"+u("PutRepo","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteRepo(t){return e.send({op:"DeleteRepo",method:"DELETE",path:"/ai/repos/"+u("DeleteRepo","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async createResponse(t){return e.send({op:"CreateResponse",method:"POST",path:"/ai/responses",auth:[["SecretKeyAuth"]],answers:{200:"raw",202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getResponse(t){return e.send({op:"GetResponse",method:"GET",path:"/ai/responses/"+u("GetResponse","response_id",t.path.response_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async cancelResponse(t){return e.send({op:"CancelResponse",method:"POST",path:"/ai/responses/"+u("CancelResponse","response_id",t.path.response_id)+"/cancel",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async followResponse(t){return e.send({op:"FollowResponse",method:"GET",path:"/ai/responses/"+u("FollowResponse","response_id",t.path.response_id)+"/live",auth:[["SecretKeyAuth"]],answers:{200:"raw"},query:t.query,signal:t.signal})},async getSettings(t){return e.send({op:"GetSettings",method:"GET",path:"/ai/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async putSettings(t){return e.send({op:"PutSettings",method:"PUT",path:"/ai/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getSpend(t){return e.send({op:"GetSpend",method:"GET",path:"/ai/spend",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async askSupport(t){return e.send({op:"AskSupport",method:"POST",path:"/ai/support-questions",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listTools(t){return e.send({op:"ListTools",method:"GET",path:"/ai/tools",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async listUsage(t){return e.send({op:"ListUsage",method:"GET",path:"/ai/usage",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getWorkspaceSyncChanges(t){return e.send({op:"GetWorkspaceSyncChanges",method:"GET",path:"/ai/workspace-sync/changes",auth:[["WorkspaceTokenAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async createWorkspaceSyncChangeSet(t){return e.send({op:"CreateWorkspaceSyncChangeSet",method:"POST",path:"/ai/workspace-sync/changesets",auth:[["WorkspaceTokenAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getWorkspaceSyncConflict(t){return e.send({op:"GetWorkspaceSyncConflict",method:"GET",path:"/ai/workspace-sync/conflicts/"+u("GetWorkspaceSyncConflict","conflict_id",t.path.conflict_id),auth:[["WorkspaceTokenAuth"]],answers:{200:"json"},signal:t.signal})},async getWorkspaceSyncEvents(t){return e.send({op:"GetWorkspaceSyncEvents",method:"GET",path:"/ai/workspace-sync/events",auth:[["WorkspaceTokenAuth"]],answers:{200:"raw"},signal:t?.signal})},async createWorkspaceSyncGrants(t){return e.send({op:"CreateWorkspaceSyncGrants",method:"POST",path:"/ai/workspace-sync/grants",auth:[["WorkspaceTokenAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getWorkspaceSyncHead(t){return e.send({op:"GetWorkspaceSyncHead",method:"GET",path:"/ai/workspace-sync/head",auth:[["WorkspaceTokenAuth"]],answers:{200:"json"},signal:t?.signal})}}}var hi={};Dt(hi,{client:()=>hk});function hk(e){return{async listAudiences(t){return e.send({op:"ListAudiences",method:"GET",path:"/analytics/audiences",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async createAudience(t){return e.send({op:"CreateAudience",method:"POST",path:"/analytics/audiences",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async previewAudience(t){return e.send({op:"PreviewAudience",method:"POST",path:"/analytics/audiences/preview",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getAudience(t){return e.send({op:"GetAudience",method:"GET",path:"/analytics/audiences/"+u("GetAudience","id",t.path.id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async deleteAudience(t){return e.send({op:"DeleteAudience",method:"DELETE",path:"/analytics/audiences/"+u("DeleteAudience","id",t.path.id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async updateAudience(t){return e.send({op:"UpdateAudience",method:"PATCH",path:"/analytics/audiences/"+u("UpdateAudience","id",t.path.id),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listAudienceMembers(t){return e.send({op:"ListAudienceMembers",method:"GET",path:"/analytics/audiences/"+u("ListAudienceMembers","id",t.path.id)+"/members",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async alias(t){return e.send({op:"Alias",method:"POST",path:"/analytics/alias",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"empty"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async batch(t){return e.send({op:"Batch",method:"POST",path:"/analytics/batch",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"json",207:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getEventBreakdown(t){return e.send({op:"GetEventBreakdown",method:"GET",path:"/analytics/breakdown",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async capture(t){return e.send({op:"Capture",method:"POST",path:"/analytics/capture",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"empty"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async sendConsoleHistory(t){return e.send({op:"SendConsoleHistory",method:"POST",path:"/analytics/console-breadcrumbs",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getConsoleConfig(t){return e.send({op:"GetConsoleConfig",method:"GET",path:"/analytics/console-breadcrumbs/config",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async listConsoleRecords(t){return e.send({op:"ListConsoleRecords",method:"GET",path:"/analytics/console-records",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async listEventNames(t){return e.send({op:"ListEventNames",method:"GET",path:"/analytics/event-names",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async listEvents(t){return e.send({op:"ListEvents",method:"GET",path:"/analytics/events",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getEventTimeline(t){return e.send({op:"GetEventTimeline",method:"GET",path:"/analytics/events/timeline",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async runFunnel(t){return e.send({op:"RunFunnel",method:"POST",path:"/analytics/funnel",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async identify(t){return e.send({op:"Identify",method:"POST",path:"/analytics/identify",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"empty"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async page(t){return e.send({op:"Page",method:"POST",path:"/analytics/page",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"empty"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async sendPerf(t){return e.send({op:"SendPerf",method:"POST",path:"/analytics/perf",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listPerfGroups(t){return e.send({op:"ListPerfGroups",method:"GET",path:"/analytics/perf/client",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getPerfConfig(t){return e.send({op:"GetPerfConfig",method:"GET",path:"/analytics/perf/config",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json",304:"empty"},headers:t?.headers,signal:t?.signal})},async getPerfTimeline(t){return e.send({op:"GetPerfTimeline",method:"GET",path:"/analytics/perf/timeline",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async listRequestLines(t){return e.send({op:"ListRequestLines",method:"GET",path:"/analytics/requests",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getMachineTraffic(t){return e.send({op:"GetMachineTraffic",method:"GET",path:"/analytics/machines/"+u("GetMachineTraffic","name",t.path.name)+"/traffic",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async runRetention(t){return e.send({op:"RunRetention",method:"POST",path:"/analytics/retention",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async screen(t){return e.send({op:"Screen",method:"POST",path:"/analytics/screen",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"empty"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getSettings(t){return e.send({op:"GetSettings",method:"GET",path:"/analytics/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async putSettings(t){return e.send({op:"PutSettings",method:"PUT",path:"/analytics/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getSummary(t){return e.send({op:"GetSummary",method:"GET",path:"/analytics/summary",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async listTraces(t){return e.send({op:"ListTraces",method:"GET",path:"/analytics/traces",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async sendTrace(t){return e.send({op:"SendTrace",method:"POST",path:"/analytics/traces",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"empty"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async sendTraceBatch(t){return e.send({op:"SendTraceBatch",method:"POST",path:"/analytics/traces/batch",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"json",207:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getTraceHops(t){return e.send({op:"GetTraceHops",method:"GET",path:"/analytics/traces/by-trace",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async listSessionTraces(t){return e.send({op:"ListSessionTraces",method:"GET",path:"/analytics/traces/session",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getTraceSummary(t){return e.send({op:"GetTraceSummary",method:"GET",path:"/analytics/traces/summary",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getTraceTimeline(t){return e.send({op:"GetTraceTimeline",method:"GET",path:"/analytics/traces/timeline",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async searchPeople(t){return e.send({op:"SearchPeople",method:"GET",path:"/analytics/people",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async setPersonProperties(t){return e.send({op:"SetPersonProperties",method:"POST",path:"/analytics/people",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{202:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getPerson(t){return e.send({op:"GetPerson",method:"GET",path:"/analytics/people/"+u("GetPerson","person_id",t.path.person_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async listPersonEvents(t){return e.send({op:"ListPersonEvents",method:"GET",path:"/analytics/people/"+u("ListPersonEvents","person_id",t.path.person_id)+"/events",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getEventCatalog(t){return e.send({op:"GetEventCatalog",method:"GET",path:"/analytics/catalog",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async defineEvent(t){return e.send({op:"DefineEvent",method:"PUT",path:"/analytics/catalog/"+u("DefineEvent","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})}}}var gi={};Dt(gi,{client:()=>gk});function gk(e){return{async getAppleAppSiteAssociation(t){return e.send({op:"GetAppleAppSiteAssociation",method:"GET",path:"/.well-known/apple-app-site-association",auth:[],answers:{200:"json"},signal:t?.signal})},async getAssetLinks(t){return e.send({op:"GetAssetLinks",method:"GET",path:"/.well-known/assetlinks.json",auth:[],answers:{200:"json"},signal:t?.signal})},async getJwks(t){return e.send({op:"GetJWKS",method:"GET",path:"/.well-known/jwks.json",auth:[],answers:{200:"json"},signal:t?.signal})},async getOidcDiscovery(t){return e.send({op:"GetOIDCDiscovery",method:"GET",path:"/.well-known/openid-configuration",auth:[],answers:{200:"json"},signal:t?.signal})},async getWebAuthnRelatedOrigins(t){return e.send({op:"GetWebAuthnRelatedOrigins",method:"GET",path:"/.well-known/webauthn",auth:[],answers:{200:"json"},signal:t?.signal})},async adminVerifyDeviceAssertion(t){return e.send({op:"AdminVerifyDeviceAssertion",method:"POST",path:"/admin/attest/devices/assert",auth:[["AdminAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminGetAttestPolicy(t){return e.send({op:"AdminGetAttestPolicy",method:"GET",path:"/admin/attest/devices/attest-policy",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminGetAttestObservations(t){return e.send({op:"AdminGetAttestObservations",method:"GET",path:"/admin/attest/devices/observations",auth:[["AdminAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async adminRecordAttestObservations(t){return e.send({op:"AdminRecordAttestObservations",method:"POST",path:"/admin/attest/devices/observations",auth:[["AdminAuth"]],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminListAuditEvents(t){return e.send({op:"AdminListAuditEvents",method:"GET",path:"/admin/audit",auth:[["AdminAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async adminExportAuditEvents(t){return e.send({op:"AdminExportAuditEvents",method:"GET",path:"/admin/audit/export",auth:[["AdminAuth"]],answers:{200:"raw"},query:t?.query,signal:t?.signal})},async adminVerifyAuditTrail(t){return e.send({op:"AdminVerifyAuditTrail",method:"GET",path:"/admin/audit/verify",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminGetAuthSettings(t){return e.send({op:"AdminGetAuthSettings",method:"GET",path:"/admin/auth-settings",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminUpdateAuthSettings(t){return e.send({op:"AdminUpdateAuthSettings",method:"PUT",path:"/admin/auth-settings",auth:[["AdminAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminGetBreachWatch(t){return e.send({op:"AdminGetBreachWatch",method:"GET",path:"/admin/breach-watch",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminListHooks(t){return e.send({op:"AdminListHooks",method:"GET",path:"/admin/hooks",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminCreateHook(t){return e.send({op:"AdminCreateHook",method:"POST",path:"/admin/hooks",auth:[["AdminAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminUpdateHook(t){return e.send({op:"AdminUpdateHook",method:"PUT",path:"/admin/hooks/"+u("AdminUpdateHook","id",t.path.id),auth:[["AdminAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminDeleteHook(t){return e.send({op:"AdminDeleteHook",method:"DELETE",path:"/admin/hooks/"+u("AdminDeleteHook","id",t.path.id),auth:[["AdminAuth"]],answers:{204:"empty"},signal:t.signal})},async adminListHookExecutions(t){return e.send({op:"AdminListHookExecutions",method:"GET",path:"/admin/hooks/"+u("AdminListHookExecutions","id",t.path.id)+"/executions",auth:[["AdminAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async adminListIntegrations(t){return e.send({op:"AdminListIntegrations",method:"GET",path:"/admin/integrations",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminPutIntegration(t){return e.send({op:"AdminPutIntegration",method:"PUT",path:"/admin/integrations/"+u("AdminPutIntegration","name",t.path.name),auth:[["AdminAuth"]],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminDeleteIntegration(t){return e.send({op:"AdminDeleteIntegration",method:"DELETE",path:"/admin/integrations/"+u("AdminDeleteIntegration","name",t.path.name),auth:[["AdminAuth"]],answers:{204:"empty"},signal:t.signal})},async adminListOAuthClients(t){return e.send({op:"AdminListOAuthClients",method:"GET",path:"/admin/oauth-clients",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminCreateOAuthClient(t){return e.send({op:"AdminCreateOAuthClient",method:"POST",path:"/admin/oauth-clients",auth:[["AdminAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminGetOAuthClient(t){return e.send({op:"AdminGetOAuthClient",method:"GET",path:"/admin/oauth-clients/"+u("AdminGetOAuthClient","id",t.path.id),auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminDeleteOAuthClient(t){return e.send({op:"AdminDeleteOAuthClient",method:"DELETE",path:"/admin/oauth-clients/"+u("AdminDeleteOAuthClient","id",t.path.id),auth:[["AdminAuth"]],answers:{204:"empty"},signal:t.signal})},async adminUpdateOAuthClient(t){return e.send({op:"AdminUpdateOAuthClient",method:"PATCH",path:"/admin/oauth-clients/"+u("AdminUpdateOAuthClient","id",t.path.id),auth:[["AdminAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminListProviders(t){return e.send({op:"AdminListProviders",method:"GET",path:"/admin/providers",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminGetPhoneSettings(t){return e.send({op:"AdminGetPhoneSettings",method:"GET",path:"/admin/providers/phone/settings",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminUpdatePhoneSettings(t){return e.send({op:"AdminUpdatePhoneSettings",method:"PUT",path:"/admin/providers/phone/settings",auth:[["AdminAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminToggleProvider(t){return e.send({op:"AdminToggleProvider",method:"POST",path:"/admin/providers/"+u("AdminToggleProvider","name",t.path.name),auth:[["AdminAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminListRoles(t){return e.send({op:"AdminListRoles",method:"GET",path:"/admin/roles",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminUpsertRole(t){return e.send({op:"AdminUpsertRole",method:"PUT",path:"/admin/roles/"+u("AdminUpsertRole","name",t.path.name),auth:[["AdminAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminDeleteRole(t){return e.send({op:"AdminDeleteRole",method:"DELETE",path:"/admin/roles/"+u("AdminDeleteRole","name",t.path.name),auth:[["AdminAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async adminListServiceAccounts(t){return e.send({op:"AdminListServiceAccounts",method:"GET",path:"/admin/service-accounts",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminCreateServiceAccount(t){return e.send({op:"AdminCreateServiceAccount",method:"POST",path:"/admin/service-accounts",auth:[["AdminAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminGetServiceAccount(t){return e.send({op:"AdminGetServiceAccount",method:"GET",path:"/admin/service-accounts/"+u("AdminGetServiceAccount","id",t.path.id),auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminRevokeServiceAccount(t){return e.send({op:"AdminRevokeServiceAccount",method:"DELETE",path:"/admin/service-accounts/"+u("AdminRevokeServiceAccount","id",t.path.id),auth:[["AdminAuth"]],answers:{204:"empty"},signal:t.signal})},async adminRotateServiceAccount(t){return e.send({op:"AdminRotateServiceAccount",method:"POST",path:"/admin/service-accounts/"+u("AdminRotateServiceAccount","id",t.path.id)+"/rotate",auth:[["AdminAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async adminListSessions(t){return e.send({op:"AdminListSessions",method:"GET",path:"/admin/sessions",auth:[["AdminAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async adminRevokeSession(t){return e.send({op:"AdminRevokeSession",method:"DELETE",path:"/admin/sessions/"+u("AdminRevokeSession","id",t.path.id),auth:[["AdminAuth"]],answers:{204:"empty"},signal:t.signal})},async adminListSigningKeys(t){return e.send({op:"AdminListSigningKeys",method:"GET",path:"/admin/signing-keys",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminRotateSigningKey(t){return e.send({op:"AdminRotateSigningKey",method:"POST",path:"/admin/signing-keys/rotate",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async socialAdminConfig(t){return e.send({op:"SocialAdminConfig",method:"GET",path:"/admin/social-auth",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async socialCredentialPut(t){return e.send({op:"SocialCredentialPut",method:"PUT",path:"/admin/social-auth/credentials/"+u("SocialCredentialPut","key",t.path.key),auth:[["AdminAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async socialCredentialDelete(t){return e.send({op:"SocialCredentialDelete",method:"DELETE",path:"/admin/social-auth/credentials/"+u("SocialCredentialDelete","key",t.path.key),auth:[["AdminAuth"]],answers:{204:"empty"},headers:t.headers,signal:t.signal})},async socialProviderPatch(t){return e.send({op:"SocialProviderPatch",method:"PATCH",path:"/admin/social-auth/providers/"+u("SocialProviderPatch","provider",t.path.provider),auth:[["AdminAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminGetStats(t){return e.send({op:"AdminGetStats",method:"GET",path:"/admin/stats",auth:[["AdminAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async adminSendTestTemplate(t){return e.send({op:"AdminSendTestTemplate",method:"POST",path:"/admin/templates/"+u("AdminSendTestTemplate","key",t.path.key)+"/send-test",auth:[["AdminAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminListTestUsers(t){return e.send({op:"AdminListTestUsers",method:"GET",path:"/admin/test-users",auth:[["AdminAuth"]],answers:{200:"json"},signal:t?.signal})},async adminCreateTestUsers(t){return e.send({op:"AdminCreateTestUsers",method:"POST",path:"/admin/test-users",auth:[["AdminAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminSetTestUserPhone(t){return e.send({op:"AdminSetTestUserPhone",method:"PUT",path:"/admin/test-users/phone",auth:[["AdminAuth"]],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminCreateTestSignupAddress(t){return e.send({op:"AdminCreateTestSignupAddress",method:"POST",path:"/admin/test-users/addresses",auth:[["AdminAuth"]],answers:{201:"json"},signal:t?.signal})},async adminDeleteTestUser(t){return e.send({op:"AdminDeleteTestUser",method:"DELETE",path:"/admin/test-users/"+u("AdminDeleteTestUser","uid",t.path.uid),auth:[["AdminAuth"]],answers:{204:"empty"},signal:t.signal})},async adminCreateCustomToken(t){return e.send({op:"AdminCreateCustomToken",method:"POST",path:"/admin/token/custom",auth:[["AdminAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminListUsers(t){return e.send({op:"AdminListUsers",method:"GET",path:"/admin/users",auth:[["AdminAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async adminCreateUser(t){return e.send({op:"AdminCreateUser",method:"POST",path:"/admin/users",auth:[["AdminAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminImportUsers(t){return e.send({op:"AdminImportUsers",method:"POST",path:"/admin/users/import",auth:[["AdminAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminGetUser(t){return e.send({op:"AdminGetUser",method:"GET",path:"/admin/users/"+u("AdminGetUser","uid",t.path.uid),auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminDeleteUser(t){return e.send({op:"AdminDeleteUser",method:"DELETE",path:"/admin/users/"+u("AdminDeleteUser","uid",t.path.uid),auth:[["AdminAuth"]],answers:{204:"empty"},signal:t.signal})},async adminUpdateUser(t){return e.send({op:"AdminUpdateUser",method:"PATCH",path:"/admin/users/"+u("AdminUpdateUser","uid",t.path.uid),auth:[["AdminAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminBanUser(t){return e.send({op:"AdminBanUser",method:"POST",path:"/admin/users/"+u("AdminBanUser","uid",t.path.uid)+"/ban",auth:[["AdminAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminGetUserConsents(t){return e.send({op:"AdminGetUserConsents",method:"GET",path:"/admin/users/"+u("AdminGetUserConsents","uid",t.path.uid)+"/consents",auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminRevokeUserCredentials(t){return e.send({op:"AdminRevokeUserCredentials",method:"POST",path:"/admin/users/"+u("AdminRevokeUserCredentials","uid",t.path.uid)+"/credentials/revoke-all",auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminExportUser(t){return e.send({op:"AdminExportUser",method:"GET",path:"/admin/users/"+u("AdminExportUser","uid",t.path.uid)+"/export",auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminListUserMfaFactors(t){return e.send({op:"AdminListUserMFAFactors",method:"GET",path:"/admin/users/"+u("AdminListUserMFAFactors","uid",t.path.uid)+"/mfa",auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminResetUserMfa(t){return e.send({op:"AdminResetUserMFA",method:"DELETE",path:"/admin/users/"+u("AdminResetUserMFA","uid",t.path.uid)+"/mfa",auth:[["AdminAuth"]],answers:{204:"empty"},signal:t.signal})},async adminResetUserPassword(t){return e.send({op:"AdminResetUserPassword",method:"POST",path:"/admin/users/"+u("AdminResetUserPassword","uid",t.path.uid)+"/reset-password",auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminListUserRoles(t){return e.send({op:"AdminListUserRoles",method:"GET",path:"/admin/users/"+u("AdminListUserRoles","uid",t.path.uid)+"/roles",auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminAssignUserRole(t){return e.send({op:"AdminAssignUserRole",method:"PUT",path:"/admin/users/"+u("AdminAssignUserRole","uid",t.path.uid)+"/roles/"+u("AdminAssignUserRole","role",t.path.role),auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminRevokeUserRole(t){return e.send({op:"AdminRevokeUserRole",method:"DELETE",path:"/admin/users/"+u("AdminRevokeUserRole","uid",t.path.uid)+"/roles/"+u("AdminRevokeUserRole","role",t.path.role),auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminRevokeUserSessions(t){return e.send({op:"AdminRevokeUserSessions",method:"POST",path:"/admin/users/"+u("AdminRevokeUserSessions","uid",t.path.uid)+"/sessions/revoke-all",auth:[["AdminAuth"]],answers:{204:"empty"},signal:t.signal})},async adminUnbanUser(t){return e.send({op:"AdminUnbanUser",method:"POST",path:"/admin/users/"+u("AdminUnbanUser","uid",t.path.uid)+"/unban",auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async signInAnonymously(t){return e.send({op:"SignInAnonymously",method:"POST",path:"/auth/anonymous",auth:[["ApiKeyAuth"]],answers:{201:"json"},headers:t?.headers,body:{kind:"json",contentType:"application/json",value:t?.body},signal:t?.signal})},async convertAnonymousUser(t){return e.send({op:"ConvertAnonymousUser",method:"POST",path:"/auth/anonymous/convert",auth:[["ApiKeyAuth","userJWT"]],answers:{202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async verifyAnonymousConversion(t){return e.send({op:"VerifyAnonymousConversion",method:"POST",path:"/auth/anonymous/convert/verify",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async devicePendingRequest(t){return e.send({op:"DevicePendingRequest",method:"GET",path:"/auth/device/requests/"+u("DevicePendingRequest","user_code",t.path.user_code),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async deviceVerifyPage(t){return e.send({op:"DeviceVerifyPage",method:"GET",path:"/auth/device/verify",auth:[["ApiKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async deviceVerifySubmit(t){return e.send({op:"DeviceVerifySubmit",method:"POST",path:"/auth/device/verify",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async listDevices(t){return e.send({op:"ListDevices",method:"GET",path:"/auth/devices",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async attestAndroidDevice(t){return e.send({op:"AttestAndroidDevice",method:"POST",path:"/auth/devices/attest/android",auth:[["ApiKeyAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async attestIosDevice(t){return e.send({op:"AttestIOSDevice",method:"POST",path:"/auth/devices/attest/ios",auth:[["ApiKeyAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async bindDeviceKey(t){return e.send({op:"BindDeviceKey",method:"POST",path:"/auth/devices/bind",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async createDeviceChallenge(t){return e.send({op:"CreateDeviceChallenge",method:"POST",path:"/auth/devices/challenge",auth:[["ApiKeyAuth"]],answers:{200:"json"},headers:t?.headers,signal:t?.signal})},async verifyAndroidIntegrity(t){return e.send({op:"VerifyAndroidIntegrity",method:"POST",path:"/auth/devices/verify/android",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteDevice(t){return e.send({op:"DeleteDevice",method:"DELETE",path:"/auth/devices/"+u("DeleteDevice","id",t.path.id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async verifyDeviceSignature(t){return e.send({op:"VerifyDeviceSignature",method:"POST",path:"/auth/devices/"+u("VerifyDeviceSignature","id",t.path.id)+"/verify",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listIdentities(t){return e.send({op:"ListIdentities",method:"GET",path:"/auth/identities",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async unlinkIdentity(t){return e.send({op:"UnlinkIdentity",method:"DELETE",path:"/auth/identities/"+u("UnlinkIdentity","id",t.path.id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async createInstallation(t){return e.send({op:"CreateInstallation",method:"POST",path:"/auth/installations",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async bindInstallation(t){return e.send({op:"BindInstallation",method:"POST",path:"/auth/installations/"+u("BindInstallation","id",t.path.id)+"/bind",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async refreshInstallation(t){return e.send({op:"RefreshInstallation",method:"POST",path:"/auth/installations/"+u("RefreshInstallation","id",t.path.id)+"/refresh",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async revokeInstallation(t){return e.send({op:"RevokeInstallation",method:"POST",path:"/auth/installations/"+u("RevokeInstallation","id",t.path.id)+"/revoke",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async unbindInstallation(t){return e.send({op:"UnbindInstallation",method:"POST",path:"/auth/installations/"+u("UnbindInstallation","id",t.path.id)+"/unbind",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async login(t){return e.send({op:"Login",method:"POST",path:"/auth/login",auth:[["ApiKeyAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async logout(t){return e.send({op:"Logout",method:"POST",path:"/auth/logout",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async magicLinkRequest(t){return e.send({op:"MagicLinkRequest",method:"POST",path:"/auth/magic-link",auth:[["ApiKeyAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async magicLinkVerify(t){return e.send({op:"MagicLinkVerify",method:"POST",path:"/auth/magic-link/verify",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getMe(t){return e.send({op:"GetMe",method:"GET",path:"/auth/me",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async updateMe(t){return e.send({op:"UpdateMe",method:"PATCH",path:"/auth/me",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async mfaChallenge(t){return e.send({op:"MfaChallenge",method:"POST",path:"/auth/mfa/challenge",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async mfaEmailChallenge(t){return e.send({op:"MfaEmailChallenge",method:"POST",path:"/auth/mfa/email/challenge",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async mfaEmailEnroll(t){return e.send({op:"MfaEmailEnroll",method:"POST",path:"/auth/mfa/email/enroll",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async mfaEmailVerify(t){return e.send({op:"MfaEmailVerify",method:"POST",path:"/auth/mfa/email/verify",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async mfaEnroll(t){return e.send({op:"MfaEnroll",method:"POST",path:"/auth/mfa/enroll",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async mfaListFactors(t){return e.send({op:"MfaListFactors",method:"GET",path:"/auth/mfa/factors",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async mfaRemoveFactor(t){return e.send({op:"MfaRemoveFactor",method:"DELETE",path:"/auth/mfa/factors/"+u("MfaRemoveFactor","id",t.path.id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async mfaRecovery(t){return e.send({op:"MfaRecovery",method:"POST",path:"/auth/mfa/recovery",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async mfaRegenerateRecoveryCodes(t){return e.send({op:"MfaRegenerateRecoveryCodes",method:"POST",path:"/auth/mfa/recovery-codes/regenerate",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async mfaSmsChallenge(t){return e.send({op:"MfaSMSChallenge",method:"POST",path:"/auth/mfa/sms/challenge",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async mfaSmsEnroll(t){return e.send({op:"MfaSMSEnroll",method:"POST",path:"/auth/mfa/sms/enroll",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async mfaSmsVerifyEnrollment(t){return e.send({op:"MfaSMSVerifyEnrollment",method:"POST",path:"/auth/mfa/sms/verify",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async mfaVerifyEnrollment(t){return e.send({op:"MfaVerifyEnrollment",method:"POST",path:"/auth/mfa/verify",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async socialCallbackApple(t){return e.send({op:"SocialCallbackApple",method:"GET",path:"/auth/oauth/callback/apple",auth:[],answers:{},signal:t?.signal})},async socialCallbackApplePost(t){return e.send({op:"SocialCallbackApplePost",method:"POST",path:"/auth/oauth/callback/apple",auth:[],answers:{303:"redirect"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async socialCallbackGitHub(t){return e.send({op:"SocialCallbackGitHub",method:"GET",path:"/auth/oauth/callback/github",auth:[],answers:{303:"redirect"},query:t.query,signal:t.signal})},async socialCallbackGitHubPost(t){return e.send({op:"SocialCallbackGitHubPost",method:"POST",path:"/auth/oauth/callback/github",auth:[],answers:{},signal:t?.signal})},async socialCallbackGoogle(t){return e.send({op:"SocialCallbackGoogle",method:"GET",path:"/auth/oauth/callback/google",auth:[],answers:{303:"redirect"},query:t.query,signal:t.signal})},async socialCallbackGooglePost(t){return e.send({op:"SocialCallbackGooglePost",method:"POST",path:"/auth/oauth/callback/google",auth:[],answers:{},signal:t?.signal})},async socialCallbackMicrosoft(t){return e.send({op:"SocialCallbackMicrosoft",method:"GET",path:"/auth/oauth/callback/microsoft",auth:[],answers:{303:"redirect"},query:t.query,signal:t.signal})},async socialCallbackMicrosoftPost(t){return e.send({op:"SocialCallbackMicrosoftPost",method:"POST",path:"/auth/oauth/callback/microsoft",auth:[],answers:{},signal:t?.signal})},async socialConfig(t){return e.send({op:"SocialConfig",method:"GET",path:"/auth/oauth/config",auth:[["ApiKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async socialBegin(t){return e.send({op:"SocialBegin",method:"POST",path:"/auth/oauth/transactions",auth:[["ApiKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async socialCancel(t){return e.send({op:"SocialCancel",method:"POST",path:"/auth/oauth/transactions/"+u("SocialCancel","id",t.path.id)+"/cancel",auth:[["ApiKeyAuth"]],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async socialComplete(t){return e.send({op:"SocialComplete",method:"POST",path:"/auth/oauth/transactions/"+u("SocialComplete","id",t.path.id)+"/complete",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async requestPhoneOtp(t){return e.send({op:"RequestPhoneOTP",method:"POST",path:"/auth/otp",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async verifyPhoneOtp(t){return e.send({op:"VerifyPhoneOTP",method:"POST",path:"/auth/otp/verify",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async hostedRecoveryApprovalPage(t){return e.send({op:"HostedRecoveryApprovalPage",method:"GET",path:"/auth/pages/recovery-approval",auth:[],answers:{200:"raw"},query:t?.query,signal:t?.signal})},async hostedRecoveryApprovalSubmit(t){return e.send({op:"HostedRecoveryApprovalSubmit",method:"POST",path:"/auth/pages/recovery-approval",auth:[],answers:{200:"raw"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async hostedRecoveryContactPage(t){return e.send({op:"HostedRecoveryContactPage",method:"GET",path:"/auth/pages/recovery-contact",auth:[],answers:{200:"raw"},query:t?.query,signal:t?.signal})},async hostedRecoveryContactSubmit(t){return e.send({op:"HostedRecoveryContactSubmit",method:"POST",path:"/auth/pages/recovery-contact",auth:[],answers:{200:"raw"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async hostedResetPasswordPage(t){return e.send({op:"HostedResetPasswordPage",method:"GET",path:"/auth/pages/reset-password",auth:[],answers:{200:"raw"},query:t?.query,signal:t?.signal})},async hostedResetPasswordSubmit(t){return e.send({op:"HostedResetPasswordSubmit",method:"POST",path:"/auth/pages/reset-password",auth:[],answers:{200:"raw"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async hostedVerifyEmailPage(t){return e.send({op:"HostedVerifyEmailPage",method:"GET",path:"/auth/pages/verify-email",auth:[],answers:{200:"raw"},query:t?.query,signal:t?.signal})},async hostedVerifyEmailSubmit(t){return e.send({op:"HostedVerifyEmailSubmit",method:"POST",path:"/auth/pages/verify-email",auth:[],answers:{200:"raw"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async passwordChange(t){return e.send({op:"PasswordChange",method:"POST",path:"/auth/password/change",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async passwordResetRequest(t){return e.send({op:"PasswordResetRequest",method:"POST",path:"/auth/password/reset",auth:[["ApiKeyAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async passwordResetConfirm(t){return e.send({op:"PasswordResetConfirm",method:"POST",path:"/auth/password/reset/confirm",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async setPassword(t){return e.send({op:"SetPassword",method:"POST",path:"/auth/password/set",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async powChallenge(t){return e.send({op:"PowChallenge",method:"POST",path:"/auth/pow/challenge",auth:[["ApiKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async approveRecovery(t){return e.send({op:"ApproveRecovery",method:"POST",path:"/auth/recovery/approve",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listRecoveryContacts(t){return e.send({op:"ListRecoveryContacts",method:"GET",path:"/auth/recovery/contacts",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async addRecoveryContact(t){return e.send({op:"AddRecoveryContact",method:"POST",path:"/auth/recovery/contacts",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteRecoveryContact(t){return e.send({op:"DeleteRecoveryContact",method:"DELETE",path:"/auth/recovery/contacts/"+u("DeleteRecoveryContact","id",t.path.id),auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},signal:t.signal})},async verifyRecoveryContact(t){return e.send({op:"VerifyRecoveryContact",method:"POST",path:"/auth/recovery/contacts/"+u("VerifyRecoveryContact","id",t.path.id)+"/verify",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async denyRecovery(t){return e.send({op:"DenyRecovery",method:"POST",path:"/auth/recovery/deny",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async initiateRecovery(t){return e.send({op:"InitiateRecovery",method:"POST",path:"/auth/recovery/initiate",auth:[["ApiKeyAuth"]],answers:{200:"json",202:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getRecoveryStatus(t){return e.send({op:"GetRecoveryStatus",method:"GET",path:"/auth/recovery/status",auth:[["ApiKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async resendVerification(t){return e.send({op:"ResendVerification",method:"POST",path:"/auth/resend-verification",auth:[["ApiKeyAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listSessions(t){return e.send({op:"ListSessions",method:"GET",path:"/auth/sessions",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async revokeAllSessions(t){return e.send({op:"RevokeAllSessions",method:"DELETE",path:"/auth/sessions",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async revokeSession(t){return e.send({op:"RevokeSession",method:"DELETE",path:"/auth/sessions/"+u("RevokeSession","id",t.path.id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async signup(t){return e.send({op:"Signup",method:"POST",path:"/auth/signup",auth:[["ApiKeyAuth"]],answers:{201:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async stepUp(t){return e.send({op:"StepUp",method:"POST",path:"/auth/step-up",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async stepUpStatus(t){return e.send({op:"StepUpStatus",method:"GET",path:"/auth/step-up/status",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async stepUpWebAuthnBegin(t){return e.send({op:"StepUpWebAuthnBegin",method:"POST",path:"/auth/step-up/webauthn/begin",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async stepUpSmsSend(t){return e.send({op:"StepUpSMSSend",method:"POST",path:"/auth/step-up/sms/send",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async exchangeCustomToken(t){return e.send({op:"ExchangeCustomToken",method:"POST",path:"/auth/token/exchange",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async refreshToken(t){return e.send({op:"RefreshToken",method:"POST",path:"/auth/token/refresh",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async revokeRefreshToken(t){return e.send({op:"RevokeRefreshToken",method:"POST",path:"/auth/token/revoke",auth:[["ApiKeyAuth"]],answers:{200:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listTransactions(t){return e.send({op:"ListTransactions",method:"GET",path:"/auth/transactions",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async createTransaction(t){return e.send({op:"CreateTransaction",method:"POST",path:"/auth/transactions",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getTransaction(t){return e.send({op:"GetTransaction",method:"GET",path:"/auth/transactions/"+u("GetTransaction","id",t.path.id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async approveTransaction(t){return e.send({op:"ApproveTransaction",method:"POST",path:"/auth/transactions/"+u("ApproveTransaction","id",t.path.id)+"/approve",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async denyTransaction(t){return e.send({op:"DenyTransaction",method:"POST",path:"/auth/transactions/"+u("DenyTransaction","id",t.path.id)+"/deny",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listTrustedDevices(t){return e.send({op:"ListTrustedDevices",method:"GET",path:"/auth/trusted-devices",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async registerTrustedDevice(t){return e.send({op:"RegisterTrustedDevice",method:"POST",path:"/auth/trusted-devices",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async revokeTrustedDevice(t){return e.send({op:"RevokeTrustedDevice",method:"DELETE",path:"/auth/trusted-devices/"+u("RevokeTrustedDevice","id",t.path.id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async verifyTokenUser(t){return e.send({op:"VerifyTokenUser",method:"GET",path:"/auth/user",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async deleteAccount(t){return e.send({op:"DeleteAccount",method:"DELETE",path:"/auth/user",auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t?.body},signal:t?.signal})},async verifyEmail(t){return e.send({op:"VerifyEmail",method:"POST",path:"/auth/verify-email",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async webauthnListCredentials(t){return e.send({op:"WebauthnListCredentials",method:"GET",path:"/auth/webauthn/credentials",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async webauthnRenameCredential(t){return e.send({op:"WebauthnRenameCredential",method:"PUT",path:"/auth/webauthn/credentials/"+u("WebauthnRenameCredential","id",t.path.id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async webauthnDeleteCredential(t){return e.send({op:"WebauthnDeleteCredential",method:"DELETE",path:"/auth/webauthn/credentials/"+u("WebauthnDeleteCredential","id",t.path.id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async webauthnLoginBegin(t){return e.send({op:"WebauthnLoginBegin",method:"POST",path:"/auth/webauthn/login/begin",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t?.body},signal:t?.signal})},async webauthnLoginFinish(t){return e.send({op:"WebauthnLoginFinish",method:"POST",path:"/auth/webauthn/login/finish",auth:[["ApiKeyAuth"]],answers:{200:"json"},query:t.query,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async webauthnRecoveryBegin(t){return e.send({op:"WebauthnRecoveryBegin",method:"POST",path:"/auth/webauthn/recovery/begin",auth:[["ApiKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async webauthnRecoveryFinish(t){return e.send({op:"WebauthnRecoveryFinish",method:"POST",path:"/auth/webauthn/recovery/finish",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async webauthnRecoveryRegisterBegin(t){return e.send({op:"WebauthnRecoveryRegisterBegin",method:"POST",path:"/auth/webauthn/recovery/register/begin",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t?.body},signal:t?.signal})},async webauthnRecoveryRegisterFinish(t){return e.send({op:"WebauthnRecoveryRegisterFinish",method:"POST",path:"/auth/webauthn/recovery/register/finish",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async webauthnRegisterBegin(t){return e.send({op:"WebauthnRegisterBegin",method:"POST",path:"/auth/webauthn/register/begin",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t?.body},signal:t?.signal})},async webauthnRegisterFinish(t){return e.send({op:"WebauthnRegisterFinish",method:"POST",path:"/auth/webauthn/register/finish",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async webauthnSignupBegin(t){return e.send({op:"WebauthnSignupBegin",method:"POST",path:"/auth/webauthn/signup/begin",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async webauthnSignupFinish(t){return e.send({op:"WebauthnSignupFinish",method:"POST",path:"/auth/webauthn/signup/finish",auth:[["ApiKeyAuth"]],answers:{201:"json"},query:t.query,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async oauthAuthorize(t){return e.send({op:"OauthAuthorize",method:"GET",path:"/oauth/authorize",auth:[],answers:{302:"redirect",303:"redirect"},query:t?.query,signal:t?.signal})},async oauthAuthorizePost(t){return e.send({op:"OauthAuthorizePost",method:"POST",path:"/oauth/authorize",auth:[],answers:{302:"redirect",303:"redirect"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async oauthAuthorizeCallback(t){return e.send({op:"OauthAuthorizeCallback",method:"GET",path:"/oauth/authorize/callback",auth:[],answers:{303:"redirect"},query:t.query,signal:t.signal})},async oauthAuthorizeEmailLink(t){return e.send({op:"OauthAuthorizeEmailLink",method:"GET",path:"/oauth/authorize/email",auth:[],answers:{200:"raw",303:"redirect"},query:t.query,signal:t.signal})},async oauthDeviceAuthorize(t){return e.send({op:"OauthDeviceAuthorize",method:"POST",path:"/oauth/device",auth:[["OAuthClient"],[]],answers:{200:"json"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async oauthIntrospect(t){return e.send({op:"OauthIntrospect",method:"POST",path:"/oauth/introspect",auth:[["AdminAuth"],["OAuthClient"],[]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async oauthLogout(t){return e.send({op:"OauthLogout",method:"GET",path:"/oauth/logout",auth:[],answers:{302:"redirect"},query:t?.query,signal:t?.signal})},async oauthLogoutPost(t){return e.send({op:"OauthLogoutPost",method:"POST",path:"/oauth/logout",auth:[],answers:{302:"redirect"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t?.body},signal:t?.signal})},async oauthPar(t){return e.send({op:"OauthPAR",method:"POST",path:"/oauth/par",auth:[["OAuthClient"],[]],answers:{201:"json"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async oauthRevoke(t){return e.send({op:"OauthRevoke",method:"POST",path:"/oauth/revoke",auth:[["OAuthClient"],[]],answers:{200:"empty"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async oauthToken(t){return e.send({op:"OauthToken",method:"POST",path:"/oauth/token",auth:[["OAuthClient"],[]],answers:{200:"json"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async oauthUserinfo(t){return e.send({op:"OauthUserinfo",method:"GET",path:"/oauth/userinfo",auth:[["OAuthAccessToken"]],answers:{200:"json"},signal:t?.signal})},async oauthUserinfoPost(t){return e.send({op:"OauthUserinfoPost",method:"POST",path:"/oauth/userinfo",auth:[["OAuthAccessToken"]],answers:{200:"json"},signal:t?.signal})},async ownerCliCode(t){return e.send({op:"OwnerCLICode",method:"POST",path:"/auth/cli/owner-code",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listConsentKeys(t){return e.send({op:"ListConsentKeys",method:"GET",path:"/auth/consents/keys",auth:[["ApiKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getConsents(t){return e.send({op:"GetConsents",method:"GET",path:"/auth/consents",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t.query,headers:t.headers,signal:t.signal})},async chooseConsents(t){return e.send({op:"ChooseConsents",method:"PUT",path:"/auth/consents",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async linkConsents(t){return e.send({op:"LinkConsents",method:"POST",path:"/auth/consents/link",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminGetInstallationConsents(t){return e.send({op:"AdminGetInstallationConsents",method:"GET",path:"/admin/installations/"+u("AdminGetInstallationConsents","installation_id",t.path.installation_id)+"/consents",auth:[["AdminAuth"]],answers:{200:"json"},signal:t.signal})},async adminRefuseConsents(t){return e.send({op:"AdminRefuseConsents",method:"POST",path:"/admin/consents/refuse",auth:[["AdminAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminInviteUser(t){return e.send({op:"AdminInviteUser",method:"POST",path:"/admin/users/invite",auth:[["AdminAuth"]],answers:{200:"json",201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async acceptInvitation(t){return e.send({op:"AcceptInvitation",method:"POST",path:"/auth/invitations/accept",auth:[["ApiKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async hostedAcceptInvitationPage(t){return e.send({op:"HostedAcceptInvitationPage",method:"GET",path:"/auth/pages/accept-invitation",auth:[],answers:{200:"raw"},query:t?.query,signal:t?.signal})},async hostedAcceptInvitationSubmit(t){return e.send({op:"HostedAcceptInvitationSubmit",method:"POST",path:"/auth/pages/accept-invitation",auth:[],answers:{200:"raw"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async hostedNotMePage(t){return e.send({op:"HostedNotMePage",method:"GET",path:"/auth/pages/not-me",auth:[],answers:{200:"raw"},query:t?.query,signal:t?.signal})},async hostedNotMeSubmit(t){return e.send({op:"HostedNotMeSubmit",method:"POST",path:"/auth/pages/not-me",auth:[],answers:{200:"raw"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})}}}var Gr={};Dt(Gr,{client:()=>fk});function fk(e){return{async getCacheEntry(t){return e.send({op:"GetCacheEntry",method:"GET",path:"/cache/entry",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async putCacheEntry(t){return e.send({op:"PutCacheEntry",method:"PUT",path:"/cache/entry",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteCacheEntry(t){return e.send({op:"DeleteCacheEntry",method:"DELETE",path:"/cache/entry",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async incrementCacheEntry(t){return e.send({op:"IncrementCacheEntry",method:"POST",path:"/cache/entry/increment",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getCacheUsage(t){return e.send({op:"GetCacheUsage",method:"GET",path:"/cache/usage",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})}}}var qr={};Dt(qr,{client:()=>yk});function yk(e){return{async listCalls(t){return e.send({op:"ListCalls",method:"GET",path:"/calls",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async startCall(t){return e.send({op:"StartCall",method:"POST",path:"/calls",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json",201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminListCalls(t){return e.send({op:"AdminListCalls",method:"GET",path:"/calls/admin/calls",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async adminGetCall(t){return e.send({op:"AdminGetCall",method:"GET",path:"/calls/admin/calls/"+u("AdminGetCall","call_id",t.path.call_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async adminEndCall(t){return e.send({op:"AdminEndCall",method:"POST",path:"/calls/admin/calls/"+u("AdminEndCall","call_id",t.path.call_id)+"/end",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async createCallTicket(t){return e.send({op:"CreateCallTicket",method:"POST",path:"/calls/admin/calls/"+u("CreateCallTicket","call_id",t.path.call_id)+"/tickets",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getCallPlace(t){return e.send({op:"GetCallPlace",method:"GET",path:"/calls/places/"+u("GetCallPlace","place",t.path.place),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async watchCallPlace(t){return e.send({op:"WatchCallPlace",method:"POST",path:"/calls/places/"+u("WatchCallPlace","place",t.path.place)+"/watch",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async unwatchCallPlace(t){return e.send({op:"UnwatchCallPlace",method:"DELETE",path:"/calls/places/"+u("UnwatchCallPlace","place",t.path.place)+"/watch",auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},signal:t.signal})},async getCallSettings(t){return e.send({op:"GetCallSettings",method:"GET",path:"/calls/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async putCallSettings(t){return e.send({op:"PutCallSettings",method:"PUT",path:"/calls/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async rotateCallHookSecret(t){return e.send({op:"RotateCallHookSecret",method:"POST",path:"/calls/settings/hook-secret",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getCall(t){return e.send({op:"GetCall",method:"GET",path:"/calls/"+u("GetCall","call_id",t.path.call_id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async acceptCall(t){return e.send({op:"AcceptCall",method:"POST",path:"/calls/"+u("AcceptCall","call_id",t.path.call_id)+"/accept",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async declineCall(t){return e.send({op:"DeclineCall",method:"POST",path:"/calls/"+u("DeclineCall","call_id",t.path.call_id)+"/decline",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async callHeartbeat(t){return e.send({op:"CallHeartbeat",method:"POST",path:"/calls/"+u("CallHeartbeat","call_id",t.path.call_id)+"/heartbeat",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async joinCall(t){return e.send({op:"JoinCall",method:"POST",path:"/calls/"+u("JoinCall","call_id",t.path.call_id)+"/join",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async leaveCall(t){return e.send({op:"LeaveCall",method:"POST",path:"/calls/"+u("LeaveCall","call_id",t.path.call_id)+"/leave",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async getCallMedia(t){return e.send({op:"GetCallMedia",method:"POST",path:"/calls/"+u("GetCallMedia","call_id",t.path.call_id)+"/media",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async inviteToCall(t){return e.send({op:"InviteToCall",method:"POST",path:"/calls/"+u("InviteToCall","call_id",t.path.call_id)+"/participants",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})}}}var fi={};Dt(fi,{client:()=>bk});function bk(e){return{async getValues(t){return e.send({op:"GetValues",method:"GET",path:"/flags",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},headers:t?.headers,signal:t?.signal})},async batchUserValues(t){return e.send({op:"BatchUserValues",method:"POST",path:"/flags/batch",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getDelta(t){return e.send({op:"GetDelta",method:"GET",path:"/flags/delta",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json",304:"empty"},query:t?.query,headers:t?.headers,signal:t?.signal})},async getEvaluations(t){return e.send({op:"GetEvaluations",method:"GET",path:"/flags/evaluations",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async listExperiments(t){return e.send({op:"ListExperiments",method:"GET",path:"/flags/experiments",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async startExperiment(t){return e.send({op:"StartExperiment",method:"POST",path:"/flags/experiments",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getExperiment(t){return e.send({op:"GetExperiment",method:"GET",path:"/flags/experiments/"+u("GetExperiment","experiment_id",t.path.experiment_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getExperimentResults(t){return e.send({op:"GetExperimentResults",method:"GET",path:"/flags/experiments/"+u("GetExperimentResults","experiment_id",t.path.experiment_id)+"/results",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async stopExperiment(t){return e.send({op:"StopExperiment",method:"POST",path:"/flags/experiments/"+u("StopExperiment","experiment_id",t.path.experiment_id)+"/stop",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async declareExperimentWinner(t){return e.send({op:"DeclareExperimentWinner",method:"POST",path:"/flags/experiments/"+u("DeclareExperimentWinner","experiment_id",t.path.experiment_id)+"/winner",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getCurrentInstallations(t){return e.send({op:"GetCurrentInstallations",method:"GET",path:"/flags/installations/current",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getInstallationsDaily(t){return e.send({op:"GetInstallationsDaily",method:"GET",path:"/flags/installations/daily",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getSnapshot(t){return e.send({op:"GetSnapshot",method:"GET",path:"/flags/snapshot",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json",304:"empty"},headers:t?.headers,signal:t?.signal})},async listDefinitions(t){return e.send({op:"ListDefinitions",method:"GET",path:"/flags/system",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getDefinition(t){return e.send({op:"GetDefinition",method:"GET",path:"/flags/system/"+u("GetDefinition","key",t.path.key),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putDefinition(t){return e.send({op:"PutDefinition",method:"PUT",path:"/flags/system/"+u("PutDefinition","key",t.path.key),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteDefinition(t){return e.send({op:"DeleteDefinition",method:"DELETE",path:"/flags/system/"+u("DeleteDefinition","key",t.path.key),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async activateTemplates(t){return e.send({op:"ActivateTemplates",method:"POST",path:"/flags/templates/activation",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getActiveTemplate(t){return e.send({op:"GetActiveTemplate",method:"GET",path:"/flags/templates/active",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getTemplateCapabilities(t){return e.send({op:"GetTemplateCapabilities",method:"GET",path:"/flags/templates/capabilities",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getTemplateDraft(t){return e.send({op:"GetTemplateDraft",method:"GET",path:"/flags/templates/draft",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async createTemplateDraft(t){return e.send({op:"CreateTemplateDraft",method:"POST",path:"/flags/templates/draft",auth:[["SecretKeyAuth"]],answers:{201:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async discardTemplateDraft(t){return e.send({op:"DiscardTemplateDraft",method:"DELETE",path:"/flags/templates/draft",auth:[["SecretKeyAuth"]],answers:{204:"empty"},headers:t.headers,signal:t.signal})},async putTemplateParameter(t){return e.send({op:"PutTemplateParameter",method:"PUT",path:"/flags/templates/draft/parameters/"+u("PutTemplateParameter","key",t.path.key),auth:[["SecretKeyAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async removeTemplateParameter(t){return e.send({op:"RemoveTemplateParameter",method:"DELETE",path:"/flags/templates/draft/parameters/"+u("RemoveTemplateParameter","key",t.path.key),auth:[["SecretKeyAuth"]],answers:{200:"json"},headers:t.headers,signal:t.signal})},async reviewTemplateDraft(t){return e.send({op:"ReviewTemplateDraft",method:"GET",path:"/flags/templates/draft/review",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async publishTemplate(t){return e.send({op:"PublishTemplate",method:"POST",path:"/flags/templates/publish",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getPublishReceipt(t){return e.send({op:"GetPublishReceipt",method:"POST",path:"/flags/templates/publish/receipt",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async restoreTemplateVersion(t){return e.send({op:"RestoreTemplateVersion",method:"POST",path:"/flags/templates/restore/"+u("RestoreTemplateVersion","version",t.path.version),auth:[["SecretKeyAuth"]],answers:{201:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listTemplateVersions(t){return e.send({op:"ListTemplateVersions",method:"GET",path:"/flags/templates/versions",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getTemplateVersion(t){return e.send({op:"GetTemplateVersion",method:"GET",path:"/flags/templates/versions/"+u("GetTemplateVersion","version",t.path.version),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getUserValues(t){return e.send({op:"GetUserValues",method:"GET",path:"/flags/users/"+u("GetUserValues","user_id",t.path.user_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},headers:t.headers,signal:t.signal})},async putUserValues(t){return e.send({op:"PutUserValues",method:"PUT",path:"/flags/users/"+u("PutUserValues","user_id",t.path.user_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteUserValues(t){return e.send({op:"DeleteUserValues",method:"DELETE",path:"/flags/users/"+u("DeleteUserValues","user_id",t.path.user_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putUserValue(t){return e.send({op:"PutUserValue",method:"PUT",path:"/flags/users/"+u("PutUserValue","user_id",t.path.user_id)+"/"+u("PutUserValue","key",t.path.key),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteUserValue(t){return e.send({op:"DeleteUserValue",method:"DELETE",path:"/flags/users/"+u("DeleteUserValue","user_id",t.path.user_id)+"/"+u("DeleteUserValue","key",t.path.key),auth:[["SecretKeyAuth"]],answers:{200:"json"},headers:t.headers,signal:t.signal})}}}var yi={};Dt(yi,{client:()=>vk});function vk(e){return{async listMachines(t){return e.send({op:"ListMachines",method:"GET",path:"/machines",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async createMachine(t){return e.send({op:"CreateMachine",method:"POST",path:"/machines",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listMachineSizes(t){return e.send({op:"ListMachineSizes",method:"GET",path:"/machines/sizes",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getMachineNetwork(t){return e.send({op:"GetMachineNetwork",method:"GET",path:"/machines/network",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async connectGitHub(t){return e.send({op:"ConnectGitHub",method:"POST",path:"/machines/github/connect",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async listInstallations(t){return e.send({op:"ListInstallations",method:"GET",path:"/machines/github/installations",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async linkInstallation(t){return e.send({op:"LinkInstallation",method:"POST",path:"/machines/github/installations",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async shareInstallation(t){return e.send({op:"ShareInstallation",method:"POST",path:"/machines/github/installations/share",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async unlinkInstallation(t){return e.send({op:"UnlinkInstallation",method:"DELETE",path:"/machines/github/installations/"+u("UnlinkInstallation","installation",t.path.installation),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async listRepositories(t){return e.send({op:"ListRepositories",method:"GET",path:"/machines/github/repositories",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getMachine(t){return e.send({op:"GetMachine",method:"GET",path:"/machines/"+u("GetMachine","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async deleteMachine(t){return e.send({op:"DeleteMachine",method:"DELETE",path:"/machines/"+u("DeleteMachine","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async updateMachine(t){return e.send({op:"UpdateMachine",method:"PATCH",path:"/machines/"+u("UpdateMachine","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listBuilds(t){return e.send({op:"ListBuilds",method:"GET",path:"/machines/"+u("ListBuilds","name",t.path.name)+"/builds",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async deployMachine(t){return e.send({op:"DeployMachine",method:"POST",path:"/machines/"+u("DeployMachine","name",t.path.name)+"/builds",auth:[["SecretKeyAuth"]],answers:{202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listMachinePreviews(t){return e.send({op:"ListMachinePreviews",method:"GET",path:"/machines/"+u("ListMachinePreviews","name",t.path.name)+"/previews",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putMachinePreview(t){return e.send({op:"PutMachinePreview",method:"PUT",path:"/machines/"+u("PutMachinePreview","name",t.path.name)+"/previews/"+u("PutMachinePreview","pull_request",t.path.pull_request),auth:[["SecretKeyAuth"]],answers:{202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteMachinePreview(t){return e.send({op:"DeleteMachinePreview",method:"DELETE",path:"/machines/"+u("DeleteMachinePreview","name",t.path.name)+"/previews/"+u("DeleteMachinePreview","pull_request",t.path.pull_request),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async listMachineDomains(t){return e.send({op:"ListMachineDomains",method:"GET",path:"/machines/"+u("ListMachineDomains","name",t.path.name)+"/domains",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async addMachineDomain(t){return e.send({op:"AddMachineDomain",method:"POST",path:"/machines/"+u("AddMachineDomain","name",t.path.name)+"/domains",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteMachineDomain(t){return e.send({op:"DeleteMachineDomain",method:"DELETE",path:"/machines/"+u("DeleteMachineDomain","name",t.path.name)+"/domains/"+u("DeleteMachineDomain","host",t.path.host),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async updateMachineDomain(t){return e.send({op:"UpdateMachineDomain",method:"PATCH",path:"/machines/"+u("UpdateMachineDomain","name",t.path.name)+"/domains/"+u("UpdateMachineDomain","host",t.path.host),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getBuild(t){return e.send({op:"GetBuild",method:"GET",path:"/machines/"+u("GetBuild","name",t.path.name)+"/builds/"+u("GetBuild","build",t.path.build),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getBuildLog(t){return e.send({op:"GetBuildLog",method:"GET",path:"/machines/"+u("GetBuildLog","name",t.path.name)+"/builds/"+u("GetBuildLog","build",t.path.build)+"/log",auth:[["SecretKeyAuth"]],answers:{200:"raw"},signal:t.signal})},async rollbackMachine(t){return e.send({op:"RollbackMachine",method:"POST",path:"/machines/"+u("RollbackMachine","name",t.path.name)+"/rollback",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listDatabases(t){return e.send({op:"ListDatabases",method:"GET",path:"/databases",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async createDatabase(t){return e.send({op:"CreateDatabase",method:"POST",path:"/databases",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listDatabaseSizes(t){return e.send({op:"ListDatabaseSizes",method:"GET",path:"/databases/sizes",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getDatabase(t){return e.send({op:"GetDatabase",method:"GET",path:"/databases/"+u("GetDatabase","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async deleteDatabase(t){return e.send({op:"DeleteDatabase",method:"DELETE",path:"/databases/"+u("DeleteDatabase","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async updateDatabase(t){return e.send({op:"UpdateDatabase",method:"PATCH",path:"/databases/"+u("UpdateDatabase","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json",202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async undeleteDatabase(t){return e.send({op:"UndeleteDatabase",method:"POST",path:"/databases/"+u("UndeleteDatabase","name",t.path.name)+"/undelete",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async purgeDatabase(t){return e.send({op:"PurgeDatabase",method:"POST",path:"/databases/"+u("PurgeDatabase","name",t.path.name)+"/purge",auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async getDatabaseCredentials(t){return e.send({op:"GetDatabaseCredentials",method:"GET",path:"/databases/"+u("GetDatabaseCredentials","name",t.path.name)+"/credentials",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async changeDatabasePassword(t){return e.send({op:"ChangeDatabasePassword",method:"POST",path:"/databases/"+u("ChangeDatabasePassword","name",t.path.name)+"/password",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async readMachineLogs(t){return e.send({op:"ReadMachineLogs",method:"GET",path:"/machines/"+u("ReadMachineLogs","name",t.path.name)+"/logs",auth:[["SecretKeyAuth"]],answers:{200:"raw"},query:t.query,signal:t.signal})},async execInMachine(t){return e.send({op:"ExecInMachine",method:"POST",path:"/machines/"+u("ExecInMachine","name",t.path.name)+"/exec",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listMachineExecs(t){return e.send({op:"ListMachineExecs",method:"GET",path:"/machines/"+u("ListMachineExecs","name",t.path.name)+"/execs",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getMachineMetrics(t){return e.send({op:"GetMachineMetrics",method:"GET",path:"/machines/"+u("GetMachineMetrics","name",t.path.name)+"/metrics",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getMachineContract(t){return e.send({op:"GetMachineContract",method:"GET",path:"/machines/"+u("GetMachineContract","name",t.path.name)+"/openapi",auth:[["SecretKeyAuth"]],answers:{200:"json",304:"empty"},headers:t.headers,signal:t.signal})},async restoreDatabase(t){return e.send({op:"RestoreDatabase",method:"POST",path:"/databases/"+u("RestoreDatabase","name",t.path.name)+"/restore",auth:[["SecretKeyAuth"]],answers:{202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getDatabaseSchema(t){return e.send({op:"GetDatabaseSchema",method:"GET",path:"/databases/"+u("GetDatabaseSchema","name",t.path.name)+"/schema",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getDatabaseMetrics(t){return e.send({op:"GetDatabaseMetrics",method:"GET",path:"/databases/"+u("GetDatabaseMetrics","name",t.path.name)+"/metrics",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async queryDatabase(t){return e.send({op:"QueryDatabase",method:"POST",path:"/databases/"+u("QueryDatabase","name",t.path.name)+"/sql",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listCrons(t){return e.send({op:"ListCrons",method:"GET",path:"/machines/"+u("ListCrons","name",t.path.name)+"/crons",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async listCronRuns(t){return e.send({op:"ListCronRuns",method:"GET",path:"/machines/"+u("ListCronRuns","name",t.path.name)+"/crons/"+u("ListCronRuns","cron",t.path.cron)+"/runs",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async runCron(t){return e.send({op:"RunCron",method:"POST",path:"/machines/"+u("RunCron","name",t.path.name)+"/crons/"+u("RunCron","cron",t.path.cron)+"/run",auth:[["SecretKeyAuth"]],answers:{201:"json"},signal:t.signal})},async pauseCron(t){return e.send({op:"PauseCron",method:"POST",path:"/machines/"+u("PauseCron","name",t.path.name)+"/crons/"+u("PauseCron","cron",t.path.cron)+"/pause",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async resumeCron(t){return e.send({op:"ResumeCron",method:"POST",path:"/machines/"+u("ResumeCron","name",t.path.name)+"/crons/"+u("ResumeCron","cron",t.path.cron)+"/resume",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async listTasks(t){return e.send({op:"ListTasks",method:"GET",path:"/machines/"+u("ListTasks","name",t.path.name)+"/tasks",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async enqueueTask(t){return e.send({op:"EnqueueTask",method:"POST",path:"/machines/"+u("EnqueueTask","name",t.path.name)+"/tasks",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getTask(t){return e.send({op:"GetTask",method:"GET",path:"/machines/"+u("GetTask","name",t.path.name)+"/tasks/"+u("GetTask","task",t.path.task),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async cancelTask(t){return e.send({op:"CancelTask",method:"POST",path:"/machines/"+u("CancelTask","name",t.path.name)+"/tasks/"+u("CancelTask","task",t.path.task)+"/cancel",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async retryTask(t){return e.send({op:"RetryTask",method:"POST",path:"/machines/"+u("RetryTask","name",t.path.name)+"/tasks/"+u("RetryTask","task",t.path.task)+"/retry",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async listTaskTypes(t){return e.send({op:"ListTaskTypes",method:"GET",path:"/machines/"+u("ListTaskTypes","name",t.path.name)+"/task-types",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async makeTemplatedTestUsers(t){return e.send({op:"MakeTemplatedTestUsers",method:"POST",path:"/machines/"+u("MakeTemplatedTestUsers","name",t.path.name)+"/test-users",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async templateTestUser(t){return e.send({op:"TemplateTestUser",method:"POST",path:"/machines/"+u("TemplateTestUser","name",t.path.name)+"/test-users/"+u("TemplateTestUser","user",t.path.user)+"/templates/"+u("TemplateTestUser","template",t.path.template),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async deleteTemplatedTestUser(t){return e.send({op:"DeleteTemplatedTestUser",method:"DELETE",path:"/machines/"+u("DeleteTemplatedTestUser","name",t.path.name)+"/test-users/"+u("DeleteTemplatedTestUser","user",t.path.user),auth:[["SecretKeyAuth"]],answers:{200:"json",204:"empty"},headers:t.headers,signal:t.signal})},async listSites(t){return e.send({op:"ListSites",method:"GET",path:"/sites",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async createSite(t){return e.send({op:"CreateSite",method:"POST",path:"/sites",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getSite(t){return e.send({op:"GetSite",method:"GET",path:"/sites/"+u("GetSite","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async deleteSite(t){return e.send({op:"DeleteSite",method:"DELETE",path:"/sites/"+u("DeleteSite","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async updateSite(t){return e.send({op:"UpdateSite",method:"PATCH",path:"/sites/"+u("UpdateSite","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listSiteReleases(t){return e.send({op:"ListSiteReleases",method:"GET",path:"/sites/"+u("ListSiteReleases","name",t.path.name)+"/releases",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async createSiteRelease(t){return e.send({op:"CreateSiteRelease",method:"POST",path:"/sites/"+u("CreateSiteRelease","name",t.path.name)+"/releases",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async uploadSiteFile(t){return e.send({op:"UploadSiteFile",method:"PUT",path:"/sites/"+u("UploadSiteFile","name",t.path.name)+"/releases/"+u("UploadSiteFile","release",t.path.release)+"/files/"+u("UploadSiteFile","digest",t.path.digest),auth:[["SecretKeyAuth"]],answers:{204:"empty"},body:{kind:"raw",contentType:t.contentType??"application/octet-stream",value:t.body},signal:t.signal})},async finishSiteRelease(t){return e.send({op:"FinishSiteRelease",method:"POST",path:"/sites/"+u("FinishSiteRelease","name",t.path.name)+"/releases/"+u("FinishSiteRelease","release",t.path.release)+"/finish",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async rollbackSite(t){return e.send({op:"RollbackSite",method:"POST",path:"/sites/"+u("RollbackSite","name",t.path.name)+"/rollback",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listSiteBuilds(t){return e.send({op:"ListSiteBuilds",method:"GET",path:"/sites/"+u("ListSiteBuilds","name",t.path.name)+"/builds",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async deploySite(t){return e.send({op:"DeploySite",method:"POST",path:"/sites/"+u("DeploySite","name",t.path.name)+"/builds",auth:[["SecretKeyAuth"]],answers:{202:"json"},signal:t.signal})},async listSitePreviews(t){return e.send({op:"ListSitePreviews",method:"GET",path:"/sites/"+u("ListSitePreviews","name",t.path.name)+"/previews",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async listSiteDomains(t){return e.send({op:"ListSiteDomains",method:"GET",path:"/sites/"+u("ListSiteDomains","name",t.path.name)+"/domains",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async addSiteDomain(t){return e.send({op:"AddSiteDomain",method:"POST",path:"/sites/"+u("AddSiteDomain","name",t.path.name)+"/domains",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteSiteDomain(t){return e.send({op:"DeleteSiteDomain",method:"DELETE",path:"/sites/"+u("DeleteSiteDomain","name",t.path.name)+"/domains/"+u("DeleteSiteDomain","host",t.path.host),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async updateSiteDomain(t){return e.send({op:"UpdateSiteDomain",method:"PATCH",path:"/sites/"+u("UpdateSiteDomain","name",t.path.name)+"/domains/"+u("UpdateSiteDomain","host",t.path.host),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getSiteBuild(t){return e.send({op:"GetSiteBuild",method:"GET",path:"/sites/"+u("GetSiteBuild","name",t.path.name)+"/builds/"+u("GetSiteBuild","build",t.path.build),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async authorizeSitePreview(t){return e.send({op:"AuthorizeSitePreview",method:"POST",path:"/sites/"+u("AuthorizeSitePreview","name",t.path.name)+"/previews/"+u("AuthorizeSitePreview","pull_request",t.path.pull_request)+"/authorize",auth:[["SecretKeyAuth"]],answers:{202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async authorizeMachinePreview(t){return e.send({op:"AuthorizeMachinePreview",method:"POST",path:"/machines/"+u("AuthorizeMachinePreview","name",t.path.name)+"/previews/"+u("AuthorizeMachinePreview","pull_request",t.path.pull_request)+"/authorize",auth:[["SecretKeyAuth"]],answers:{202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async openMachinePreview(t){return e.send({op:"OpenMachinePreview",method:"POST",path:"/machines/"+u("OpenMachinePreview","name",t.path.name)+"/previews/"+u("OpenMachinePreview","pull_request",t.path.pull_request)+"/open",auth:[["SecretKeyAuth"]],answers:{202:"json"},signal:t.signal})},async moveMachine(t){return e.send({op:"MoveMachine",method:"POST",path:"/machines/"+u("MoveMachine","name",t.path.name)+"/move",auth:[["SecretKeyAuth"]],answers:{200:"json",202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async moveSite(t){return e.send({op:"MoveSite",method:"POST",path:"/sites/"+u("MoveSite","name",t.path.name)+"/move",auth:[["SecretKeyAuth"]],answers:{200:"json",202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async moveDatabase(t){return e.send({op:"MoveDatabase",method:"POST",path:"/databases/"+u("MoveDatabase","name",t.path.name)+"/move",auth:[["SecretKeyAuth"]],answers:{200:"json",202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async cancelSiteBuild(t){return e.send({op:"CancelSiteBuild",method:"POST",path:"/sites/"+u("CancelSiteBuild","name",t.path.name)+"/builds/"+u("CancelSiteBuild","build",t.path.build)+"/cancel",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async cancelBuild(t){return e.send({op:"CancelBuild",method:"POST",path:"/machines/"+u("CancelBuild","name",t.path.name)+"/builds/"+u("CancelBuild","build",t.path.build)+"/cancel",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async listSiteHooks(t){return e.send({op:"ListSiteHooks",method:"GET",path:"/sites/"+u("ListSiteHooks","name",t.path.name)+"/hooks",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async createSiteHook(t){return e.send({op:"CreateSiteHook",method:"POST",path:"/sites/"+u("CreateSiteHook","name",t.path.name)+"/hooks",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteSiteHook(t){return e.send({op:"DeleteSiteHook",method:"DELETE",path:"/sites/"+u("DeleteSiteHook","name",t.path.name)+"/hooks/"+u("DeleteSiteHook","hook",t.path.hook),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async listMachineHooks(t){return e.send({op:"ListMachineHooks",method:"GET",path:"/machines/"+u("ListMachineHooks","name",t.path.name)+"/hooks",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async createMachineHook(t){return e.send({op:"CreateMachineHook",method:"POST",path:"/machines/"+u("CreateMachineHook","name",t.path.name)+"/hooks",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteMachineHook(t){return e.send({op:"DeleteMachineHook",method:"DELETE",path:"/machines/"+u("DeleteMachineHook","name",t.path.name)+"/hooks/"+u("DeleteMachineHook","hook",t.path.hook),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async detectProject(t){return e.send({op:"DetectProject",method:"GET",path:"/machines/github/detect",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async createPreviewPass(t){return e.send({op:"CreatePreviewPass",method:"POST",path:"/sites/"+u("CreatePreviewPass","name",t.path.name)+"/previews/pass",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listPreviewLinks(t){return e.send({op:"ListPreviewLinks",method:"GET",path:"/sites/"+u("ListPreviewLinks","name",t.path.name)+"/previews/links",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async createPreviewLink(t){return e.send({op:"CreatePreviewLink",method:"POST",path:"/sites/"+u("CreatePreviewLink","name",t.path.name)+"/previews/links",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deletePreviewLink(t){return e.send({op:"DeletePreviewLink",method:"DELETE",path:"/sites/"+u("DeletePreviewLink","name",t.path.name)+"/previews/links/"+u("DeletePreviewLink","link",t.path.link),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async listEnvironmentDomains(t){return e.send({op:"ListEnvironmentDomains",method:"GET",path:"/domains",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async addEnvironmentDomain(t){return e.send({op:"AddEnvironmentDomain",method:"POST",path:"/domains",auth:[["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteEnvironmentDomain(t){return e.send({op:"DeleteEnvironmentDomain",method:"DELETE",path:"/domains/"+u("DeleteEnvironmentDomain","host",t.path.host),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async setEnvironmentSignInDomain(t){return e.send({op:"SetEnvironmentSignInDomain",method:"PATCH",path:"/domains/"+u("SetEnvironmentSignInDomain","host",t.path.host),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})}}}var Ur={};Dt(Ur,{client:()=>_k});function _k(e){return{async adminAccessLog(t){return e.send({op:"AdminAccessLog",method:"GET",path:"/messaging/admin/access-log",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async adminListConversations(t){return e.send({op:"AdminListConversations",method:"GET",path:"/messaging/admin/conversations",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async adminCreateConversation(t){return e.send({op:"AdminCreateConversation",method:"POST",path:"/messaging/admin/conversations",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminGetConversation(t){return e.send({op:"AdminGetConversation",method:"GET",path:"/messaging/admin/conversations/"+u("AdminGetConversation","conversation_id",t.path.conversation_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async adminDeleteConversation(t){return e.send({op:"AdminDeleteConversation",method:"DELETE",path:"/messaging/admin/conversations/"+u("AdminDeleteConversation","conversation_id",t.path.conversation_id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async adminUpdateConversation(t){return e.send({op:"AdminUpdateConversation",method:"PATCH",path:"/messaging/admin/conversations/"+u("AdminUpdateConversation","conversation_id",t.path.conversation_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminAddMembers(t){return e.send({op:"AdminAddMembers",method:"POST",path:"/messaging/admin/conversations/"+u("AdminAddMembers","conversation_id",t.path.conversation_id)+"/members",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminRemoveMember(t){return e.send({op:"AdminRemoveMember",method:"DELETE",path:"/messaging/admin/conversations/"+u("AdminRemoveMember","conversation_id",t.path.conversation_id)+"/members/"+u("AdminRemoveMember","user_id",t.path.user_id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async adminListMessages(t){return e.send({op:"AdminListMessages",method:"GET",path:"/messaging/admin/conversations/"+u("AdminListMessages","conversation_id",t.path.conversation_id)+"/messages",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async adminSendMessage(t){return e.send({op:"AdminSendMessage",method:"POST",path:"/messaging/admin/conversations/"+u("AdminSendMessage","conversation_id",t.path.conversation_id)+"/messages",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminDeleteMessage(t){return e.send({op:"AdminDeleteMessage",method:"DELETE",path:"/messaging/admin/conversations/"+u("AdminDeleteMessage","conversation_id",t.path.conversation_id)+"/messages/"+u("AdminDeleteMessage","message_id",t.path.message_id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async adminFileUrl(t){return e.send({op:"AdminFileURL",method:"GET",path:"/messaging/admin/conversations/"+u("AdminFileURL","conversation_id",t.path.conversation_id)+"/messages/"+u("AdminFileURL","message_id",t.path.message_id)+"/attachments/"+u("AdminFileURL","attachment_id",t.path.attachment_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async adminPutProfile(t){return e.send({op:"AdminPutProfile",method:"PUT",path:"/messaging/admin/profiles/"+u("AdminPutProfile","user_id",t.path.user_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async adminListReports(t){return e.send({op:"AdminListReports",method:"GET",path:"/messaging/admin/reports",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async adminGetReport(t){return e.send({op:"AdminGetReport",method:"GET",path:"/messaging/admin/reports/"+u("AdminGetReport","report_id",t.path.report_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async adminReportFileUrl(t){return e.send({op:"AdminReportFileURL",method:"GET",path:"/messaging/admin/reports/"+u("AdminReportFileURL","report_id",t.path.report_id)+"/attachments/"+u("AdminReportFileURL","attachment_id",t.path.attachment_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async adminResolveReport(t){return e.send({op:"AdminResolveReport",method:"POST",path:"/messaging/admin/reports/"+u("AdminResolveReport","report_id",t.path.report_id)+"/resolve",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listBlocks(t){return e.send({op:"ListBlocks",method:"GET",path:"/messaging/blocks",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async block(t){return e.send({op:"Block",method:"PUT",path:"/messaging/blocks/"+u("Block","user_id",t.path.user_id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async unblock(t){return e.send({op:"Unblock",method:"DELETE",path:"/messaging/blocks/"+u("Unblock","user_id",t.path.user_id),auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},signal:t.signal})},async listConversations(t){return e.send({op:"ListConversations",method:"GET",path:"/messaging/conversations",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async openDirectConversation(t){return e.send({op:"OpenDirectConversation",method:"POST",path:"/messaging/conversations/direct",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json",201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async createGroup(t){return e.send({op:"CreateGroup",method:"POST",path:"/messaging/conversations/group",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getConversation(t){return e.send({op:"GetConversation",method:"GET",path:"/messaging/conversations/"+u("GetConversation","conversation_id",t.path.conversation_id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async deleteConversation(t){return e.send({op:"DeleteConversation",method:"DELETE",path:"/messaging/conversations/"+u("DeleteConversation","conversation_id",t.path.conversation_id),auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},signal:t.signal})},async updateConversation(t){return e.send({op:"UpdateConversation",method:"PATCH",path:"/messaging/conversations/"+u("UpdateConversation","conversation_id",t.path.conversation_id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async clearConversation(t){return e.send({op:"ClearConversation",method:"POST",path:"/messaging/conversations/"+u("ClearConversation","conversation_id",t.path.conversation_id)+"/clear",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async closeConversation(t){return e.send({op:"CloseConversation",method:"POST",path:"/messaging/conversations/"+u("CloseConversation","conversation_id",t.path.conversation_id)+"/close",auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},signal:t.signal})},async joinGroup(t){return e.send({op:"JoinGroup",method:"POST",path:"/messaging/conversations/"+u("JoinGroup","conversation_id",t.path.conversation_id)+"/join",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async listMembers(t){return e.send({op:"ListMembers",method:"GET",path:"/messaging/conversations/"+u("ListMembers","conversation_id",t.path.conversation_id)+"/members",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t.query,signal:t.signal})},async addMembers(t){return e.send({op:"AddMembers",method:"POST",path:"/messaging/conversations/"+u("AddMembers","conversation_id",t.path.conversation_id)+"/members",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async removeMember(t){return e.send({op:"RemoveMember",method:"DELETE",path:"/messaging/conversations/"+u("RemoveMember","conversation_id",t.path.conversation_id)+"/members/"+u("RemoveMember","user_id",t.path.user_id),auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},signal:t.signal})},async updateMember(t){return e.send({op:"UpdateMember",method:"PATCH",path:"/messaging/conversations/"+u("UpdateMember","conversation_id",t.path.conversation_id)+"/members/"+u("UpdateMember","user_id",t.path.user_id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listMessages(t){return e.send({op:"ListMessages",method:"GET",path:"/messaging/conversations/"+u("ListMessages","conversation_id",t.path.conversation_id)+"/messages",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t.query,signal:t.signal})},async sendMessage(t){return e.send({op:"SendMessage",method:"POST",path:"/messaging/conversations/"+u("SendMessage","conversation_id",t.path.conversation_id)+"/messages",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json",201:"json",202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getMessage(t){return e.send({op:"GetMessage",method:"GET",path:"/messaging/conversations/"+u("GetMessage","conversation_id",t.path.conversation_id)+"/messages/"+u("GetMessage","message_id",t.path.message_id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async deleteMessage(t){return e.send({op:"DeleteMessage",method:"DELETE",path:"/messaging/conversations/"+u("DeleteMessage","conversation_id",t.path.conversation_id)+"/messages/"+u("DeleteMessage","message_id",t.path.message_id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json",204:"empty"},query:t.query,signal:t.signal})},async editMessage(t){return e.send({op:"EditMessage",method:"PATCH",path:"/messaging/conversations/"+u("EditMessage","conversation_id",t.path.conversation_id)+"/messages/"+u("EditMessage","message_id",t.path.message_id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async attachmentUrl(t){return e.send({op:"AttachmentURL",method:"GET",path:"/messaging/conversations/"+u("AttachmentURL","conversation_id",t.path.conversation_id)+"/messages/"+u("AttachmentURL","message_id",t.path.message_id)+"/attachments/"+u("AttachmentURL","attachment_id",t.path.attachment_id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async react(t){return e.send({op:"React",method:"PUT",path:"/messaging/conversations/"+u("React","conversation_id",t.path.conversation_id)+"/messages/"+u("React","message_id",t.path.message_id)+"/reactions/"+u("React","emoji",t.path.emoji),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async unreact(t){return e.send({op:"Unreact",method:"DELETE",path:"/messaging/conversations/"+u("Unreact","conversation_id",t.path.conversation_id)+"/messages/"+u("Unreact","message_id",t.path.message_id)+"/reactions/"+u("Unreact","emoji",t.path.emoji),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async messageReaders(t){return e.send({op:"MessageReaders",method:"GET",path:"/messaging/conversations/"+u("MessageReaders","conversation_id",t.path.conversation_id)+"/messages/"+u("MessageReaders","message_id",t.path.message_id)+"/readers",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async listReplies(t){return e.send({op:"ListReplies",method:"GET",path:"/messaging/conversations/"+u("ListReplies","conversation_id",t.path.conversation_id)+"/messages/"+u("ListReplies","message_id",t.path.message_id)+"/replies",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t.query,signal:t.signal})},async viewOnce(t){return e.send({op:"ViewOnce",method:"POST",path:"/messaging/conversations/"+u("ViewOnce","conversation_id",t.path.conversation_id)+"/messages/"+u("ViewOnce","message_id",t.path.message_id)+"/view",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t.signal})},async setConversationNotifications(t){return e.send({op:"SetConversationNotifications",method:"PUT",path:"/messaging/conversations/"+u("SetConversationNotifications","conversation_id",t.path.conversation_id)+"/notifications",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async reportScreenshot(t){return e.send({op:"ReportScreenshot",method:"POST",path:"/messaging/conversations/"+u("ReportScreenshot","conversation_id",t.path.conversation_id)+"/screenshot",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},signal:t.signal})},async typing(t){return e.send({op:"Typing",method:"POST",path:"/messaging/conversations/"+u("Typing","conversation_id",t.path.conversation_id)+"/typing",auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async createUpload(t){return e.send({op:"CreateUpload",method:"POST",path:"/messaging/conversations/"+u("CreateUpload","conversation_id",t.path.conversation_id)+"/uploads",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listOpenGroups(t){return e.send({op:"ListOpenGroups",method:"GET",path:"/messaging/groups/open",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getMyProfile(t){return e.send({op:"GetMyProfile",method:"GET",path:"/messaging/me",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async updateMyProfile(t){return e.send({op:"UpdateMyProfile",method:"PATCH",path:"/messaging/me",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async presence(t){return e.send({op:"Presence",method:"POST",path:"/messaging/me/presence",auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},signal:t?.signal})},async getProfiles(t){return e.send({op:"GetProfiles",method:"GET",path:"/messaging/profiles",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t.query,signal:t.signal})},async receipts(t){return e.send({op:"Receipts",method:"POST",path:"/messaging/receipts",auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async report(t){return e.send({op:"Report",method:"POST",path:"/messaging/reports",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listScheduled(t){return e.send({op:"ListScheduled",method:"GET",path:"/messaging/scheduled",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async cancelScheduled(t){return e.send({op:"CancelScheduled",method:"DELETE",path:"/messaging/scheduled/"+u("CancelScheduled","scheduled_id",t.path.scheduled_id),auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},signal:t.signal})},async updateScheduled(t){return e.send({op:"UpdateScheduled",method:"PATCH",path:"/messaging/scheduled/"+u("UpdateScheduled","scheduled_id",t.path.scheduled_id),auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async searchMessages(t){return e.send({op:"SearchMessages",method:"GET",path:"/messaging/search",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getSettings(t){return e.send({op:"GetSettings",method:"GET",path:"/messaging/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async putSettings(t){return e.send({op:"PutSettings",method:"PUT",path:"/messaging/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async rotateHookSecret(t){return e.send({op:"RotateHookSecret",method:"POST",path:"/messaging/settings/hook-secret",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async sync(t){return e.send({op:"Sync",method:"GET",path:"/messaging/sync",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async listThreads(t){return e.send({op:"ListThreads",method:"GET",path:"/messaging/threads",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t?.query,signal:t?.signal})}}}var bi={};Dt(bi,{client:()=>$k});function $k(e){return{async getDeliverability(t){return e.send({op:"GetDeliverability",method:"GET",path:"/notify/deliverability",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async listDevices(t){return e.send({op:"ListDevices",method:"GET",path:"/notify/devices",auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async registerDevice(t){return e.send({op:"RegisterDevice",method:"POST",path:"/notify/devices",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getDeviceStats(t){return e.send({op:"GetDeviceStats",method:"GET",path:"/notify/devices/stats",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async deleteMyDevice(t){return e.send({op:"DeleteMyDevice",method:"DELETE",path:"/notify/devices/"+u("DeleteMyDevice","device_id",t.path.device_id),auth:[["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async sendEmail(t){return e.send({op:"SendEmail",method:"POST",path:"/notify/email",auth:[["SecretKeyAuth"]],answers:{202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listInAppCampaigns(t){return e.send({op:"ListInAppCampaigns",method:"GET",path:"/notify/in-app/campaigns",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async createInAppCampaign(t){return e.send({op:"CreateInAppCampaign",method:"POST",path:"/notify/in-app/campaigns",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getInAppCampaign(t){return e.send({op:"GetInAppCampaign",method:"GET",path:"/notify/in-app/campaigns/"+u("GetInAppCampaign","id",t.path.id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putInAppCampaign(t){return e.send({op:"PutInAppCampaign",method:"PUT",path:"/notify/in-app/campaigns/"+u("PutInAppCampaign","id",t.path.id),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteInAppCampaign(t){return e.send({op:"DeleteInAppCampaign",method:"DELETE",path:"/notify/in-app/campaigns/"+u("DeleteInAppCampaign","id",t.path.id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async getInAppCampaignStats(t){return e.send({op:"GetInAppCampaignStats",method:"GET",path:"/notify/in-app/campaigns/"+u("GetInAppCampaignStats","id",t.path.id)+"/stats",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async showInAppMessage(t){return e.send({op:"ShowInAppMessage",method:"POST",path:"/notify/in-app/impressions",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async reportInAppEvent(t){return e.send({op:"ReportInAppEvent",method:"POST",path:"/notify/in-app/impressions/"+u("ReportInAppEvent","id",t.path.id)+"/events",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"]],answers:{204:"empty"},idempotent:!0,query:t.query,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listMyInAppMessages(t){return e.send({op:"ListMyInAppMessages",method:"GET",path:"/notify/in-app/messages",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t.query,signal:t.signal})},async listInAppTemplates(t){return e.send({op:"ListInAppTemplates",method:"GET",path:"/notify/in-app/templates",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async listMyInbox(t){return e.send({op:"ListMyInbox",method:"GET",path:"/notify/inbox",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async sendInbox(t){return e.send({op:"SendInbox",method:"POST",path:"/notify/inbox",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listInboxMessages(t){return e.send({op:"ListInboxMessages",method:"GET",path:"/notify/inbox/messages",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async readMyInbox(t){return e.send({op:"ReadMyInbox",method:"POST",path:"/notify/inbox/read",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteMyInboxMessage(t){return e.send({op:"DeleteMyInboxMessage",method:"DELETE",path:"/notify/inbox/"+u("DeleteMyInboxMessage","id",t.path.id),auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async listNotifyMessages(t){return e.send({op:"ListNotifyMessages",method:"GET",path:"/notify/messages",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getNotifyMessage(t){return e.send({op:"GetNotifyMessage",method:"GET",path:"/notify/messages/"+u("GetNotifyMessage","id",t.path.id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async cancelMessage(t){return e.send({op:"CancelMessage",method:"POST",path:"/notify/messages/"+u("CancelMessage","id",t.path.id)+"/cancel",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getMetricsSummary(t){return e.send({op:"GetMetricsSummary",method:"GET",path:"/notify/metrics/summary",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getMyPreferences(t){return e.send({op:"GetMyPreferences",method:"GET",path:"/notify/preferences",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async setMyPreferences(t){return e.send({op:"SetMyPreferences",method:"PUT",path:"/notify/preferences",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listNotifyProviders(t){return e.send({op:"ListNotifyProviders",method:"GET",path:"/notify/providers",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async putNotifyProvider(t){return e.send({op:"PutNotifyProvider",method:"PUT",path:"/notify/providers/"+u("PutNotifyProvider","channel",t.path.channel)+"/"+u("PutNotifyProvider","provider",t.path.provider),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteNotifyProvider(t){return e.send({op:"DeleteNotifyProvider",method:"DELETE",path:"/notify/providers/"+u("DeleteNotifyProvider","channel",t.path.channel)+"/"+u("DeleteNotifyProvider","provider",t.path.provider),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async sendPush(t){return e.send({op:"SendPush",method:"POST",path:"/notify/push",auth:[["SecretKeyAuth"]],answers:{202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async recordPushReceipts(t){return e.send({op:"RecordPushReceipts",method:"POST",path:"/notify/receipts",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getNotifySettings(t){return e.send({op:"GetNotifySettings",method:"GET",path:"/notify/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async putNotifySettings(t){return e.send({op:"PutNotifySettings",method:"PUT",path:"/notify/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async sendSms(t){return e.send({op:"SendSMS",method:"POST",path:"/notify/sms",auth:[["SecretKeyAuth"]],answers:{202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listEmailTemplates(t){return e.send({op:"ListEmailTemplates",method:"GET",path:"/notify/templates/email",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getEmailTemplate(t){return e.send({op:"GetEmailTemplate",method:"GET",path:"/notify/templates/email/"+u("GetEmailTemplate","slug",t.path.slug)+"/"+u("GetEmailTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putEmailTemplate(t){return e.send({op:"PutEmailTemplate",method:"PUT",path:"/notify/templates/email/"+u("PutEmailTemplate","slug",t.path.slug)+"/"+u("PutEmailTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteEmailTemplate(t){return e.send({op:"DeleteEmailTemplate",method:"DELETE",path:"/notify/templates/email/"+u("DeleteEmailTemplate","slug",t.path.slug)+"/"+u("DeleteEmailTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async listPushTemplates(t){return e.send({op:"ListPushTemplates",method:"GET",path:"/notify/templates/push",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getPushTemplate(t){return e.send({op:"GetPushTemplate",method:"GET",path:"/notify/templates/push/"+u("GetPushTemplate","slug",t.path.slug)+"/"+u("GetPushTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putPushTemplate(t){return e.send({op:"PutPushTemplate",method:"PUT",path:"/notify/templates/push/"+u("PutPushTemplate","slug",t.path.slug)+"/"+u("PutPushTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deletePushTemplate(t){return e.send({op:"DeletePushTemplate",method:"DELETE",path:"/notify/templates/push/"+u("DeletePushTemplate","slug",t.path.slug)+"/"+u("DeletePushTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async listSmsTemplates(t){return e.send({op:"ListSMSTemplates",method:"GET",path:"/notify/templates/sms",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getSmsTemplate(t){return e.send({op:"GetSMSTemplate",method:"GET",path:"/notify/templates/sms/"+u("GetSMSTemplate","slug",t.path.slug)+"/"+u("GetSMSTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putSmsTemplate(t){return e.send({op:"PutSMSTemplate",method:"PUT",path:"/notify/templates/sms/"+u("PutSMSTemplate","slug",t.path.slug)+"/"+u("PutSMSTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteSmsTemplate(t){return e.send({op:"DeleteSMSTemplate",method:"DELETE",path:"/notify/templates/sms/"+u("DeleteSMSTemplate","slug",t.path.slug)+"/"+u("DeleteSMSTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async listWhatsAppTemplates(t){return e.send({op:"ListWhatsAppTemplates",method:"GET",path:"/notify/templates/whatsapp",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getWhatsAppTemplate(t){return e.send({op:"GetWhatsAppTemplate",method:"GET",path:"/notify/templates/whatsapp/"+u("GetWhatsAppTemplate","slug",t.path.slug)+"/"+u("GetWhatsAppTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putWhatsAppTemplate(t){return e.send({op:"PutWhatsAppTemplate",method:"PUT",path:"/notify/templates/whatsapp/"+u("PutWhatsAppTemplate","slug",t.path.slug)+"/"+u("PutWhatsAppTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteWhatsAppTemplate(t){return e.send({op:"DeleteWhatsAppTemplate",method:"DELETE",path:"/notify/templates/whatsapp/"+u("DeleteWhatsAppTemplate","slug",t.path.slug)+"/"+u("DeleteWhatsAppTemplate","locale",t.path.locale),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async listTestUserMessages(t){return e.send({op:"ListTestUserMessages",method:"GET",path:"/notify/test-users/"+u("ListTestUserMessages","user_id",t.path.user_id)+"/messages",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async listTopics(t){return e.send({op:"ListTopics",method:"GET",path:"/notify/topics",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async createTopic(t){return e.send({op:"CreateTopic",method:"POST",path:"/notify/topics",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteTopic(t){return e.send({op:"DeleteTopic",method:"DELETE",path:"/notify/topics/"+u("DeleteTopic","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async changeTopic(t){return e.send({op:"ChangeTopic",method:"PATCH",path:"/notify/topics/"+u("ChangeTopic","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async addTopicSubscribers(t){return e.send({op:"AddTopicSubscribers",method:"POST",path:"/notify/topics/"+u("AddTopicSubscribers","name",t.path.name)+"/subscribers",auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async removeTopicSubscriber(t){return e.send({op:"RemoveTopicSubscriber",method:"DELETE",path:"/notify/topics/"+u("RemoveTopicSubscriber","name",t.path.name)+"/subscribers/"+u("RemoveTopicSubscriber","user_id",t.path.user_id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async followTopic(t){return e.send({op:"FollowTopic",method:"POST",path:"/notify/topics/"+u("FollowTopic","name",t.path.name)+"/subscription",auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async unfollowTopic(t){return e.send({op:"UnfollowTopic",method:"DELETE",path:"/notify/topics/"+u("UnfollowTopic","name",t.path.name)+"/subscription",auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async listUserDevices(t){return e.send({op:"ListUserDevices",method:"GET",path:"/notify/users/"+u("ListUserDevices","user_id",t.path.user_id)+"/devices",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getUserPreferences(t){return e.send({op:"GetUserPreferences",method:"GET",path:"/notify/users/"+u("GetUserPreferences","user_id",t.path.user_id)+"/preferences",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async setUserPreferences(t){return e.send({op:"SetUserPreferences",method:"PUT",path:"/notify/users/"+u("SetUserPreferences","user_id",t.path.user_id)+"/preferences",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async startVerification(t){return e.send({op:"StartVerification",method:"POST",path:"/notify/verifications",auth:[["SecretKeyAuth"]],answers:{202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async checkVerification(t){return e.send({op:"CheckVerification",method:"POST",path:"/notify/verifications/check",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async receiveSendGridEvents(t){return e.send({op:"ReceiveSendGridEvents",method:"POST",path:"/notify/webhooks/email/sendgrid",auth:[],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async receiveTwilioStatus(t){return e.send({op:"ReceiveTwilioStatus",method:"POST",path:"/notify/webhooks/sms/twilio",auth:[],answers:{204:"empty"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async receiveTwilioText(t){return e.send({op:"ReceiveTwilioText",method:"POST",path:"/notify/webhooks/sms/twilio/inbound",auth:[],answers:{204:"empty"},body:{kind:"form",contentType:"application/x-www-form-urlencoded",value:t.body},signal:t.signal})},async receiveVonageReceiptQuery(t){return e.send({op:"ReceiveVonageReceiptQuery",method:"GET",path:"/notify/webhooks/sms/vonage",auth:[],answers:{204:"empty"},query:t?.query,signal:t?.signal})},async receiveVonageReceipt(t){return e.send({op:"ReceiveVonageReceipt",method:"POST",path:"/notify/webhooks/sms/vonage",auth:[],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async subscribeMetaWebhook(t){return e.send({op:"SubscribeMetaWebhook",method:"GET",path:"/notify/webhooks/whatsapp/meta",auth:[],answers:{200:"raw"},query:t.query,signal:t.signal})},async receiveMetaNotification(t){return e.send({op:"ReceiveMetaNotification",method:"POST",path:"/notify/webhooks/whatsapp/meta",auth:[],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getWebPushStatus(t){return e.send({op:"GetWebPushStatus",method:"GET",path:"/notify/webpush",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getWebPushKey(t){return e.send({op:"GetWebPushKey",method:"GET",path:"/notify/webpush/key",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async sendWhatsApp(t){return e.send({op:"SendWhatsApp",method:"POST",path:"/notify/whatsapp",auth:[["SecretKeyAuth"]],answers:{202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listWhatsAppInbound(t){return e.send({op:"ListWhatsAppInbound",method:"GET",path:"/notify/whatsapp/inbound",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})}}}var wi={};Dt(wi,{client:()=>kk});function kk(e){return{async getAppleAccount(t){return e.send({op:"GetAppleAccount",method:"GET",path:"/purchases/apple",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async disconnectApple(t){return e.send({op:"DisconnectApple",method:"DELETE",path:"/purchases/apple",auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async getAppleAccountToken(t){return e.send({op:"GetAppleAccountToken",method:"POST",path:"/purchases/apple/account-token",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async getAppleConnectPage(t){return e.send({op:"GetAppleConnectPage",method:"GET",path:"/purchases/apple/connect",auth:[],answers:{200:"raw"},signal:t?.signal})},async connectAppleKey(t){return e.send({op:"ConnectAppleKey",method:"POST",path:"/purchases/apple/connect",auth:[],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async createAppleGrant(t){return e.send({op:"CreateAppleGrant",method:"POST",path:"/purchases/apple/grants",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async getAppleReadiness(t){return e.send({op:"GetAppleReadiness",method:"GET",path:"/purchases/apple/readiness",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async reportAppleTransactions(t){return e.send({op:"ReportAppleTransactions",method:"POST",path:"/purchases/apple/transactions",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getGoogleAccountId(t){return e.send({op:"GetGoogleAccountID",method:"POST",path:"/purchases/google/account-id",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async reportGooglePurchases(t){return e.send({op:"ReportGooglePurchases",method:"POST",path:"/purchases/google/purchases",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async setXcodeCertificate(t){return e.send({op:"SetXcodeCertificate",method:"PUT",path:"/purchases/apple/xcode-certificate",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async clearXcodeCertificate(t){return e.send({op:"ClearXcodeCertificate",method:"DELETE",path:"/purchases/apple/xcode-certificate",auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async getGoogleAccount(t){return e.send({op:"GetGoogleAccount",method:"GET",path:"/purchases/google",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async connectGoogle(t){return e.send({op:"ConnectGoogle",method:"POST",path:"/purchases/google",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async disconnectGoogle(t){return e.send({op:"DisconnectGoogle",method:"DELETE",path:"/purchases/google",auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async getCatalog(t){return e.send({op:"GetCatalog",method:"GET",path:"/purchases/catalog",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async saveCatalog(t){return e.send({op:"SaveCatalog",method:"PUT",path:"/purchases/catalog",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async planCatalog(t){return e.send({op:"PlanCatalog",method:"POST",path:"/purchases/catalog/plans",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async getCatalogPlan(t){return e.send({op:"GetCatalogPlan",method:"GET",path:"/purchases/catalog/plans/"+u("GetCatalogPlan","plan_id",t.path.plan_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async confirmCatalogPlan(t){return e.send({op:"ConfirmCatalogPlan",method:"POST",path:"/purchases/catalog/plans/"+u("ConfirmCatalogPlan","plan_id",t.path.plan_id)+"/confirm",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async declineCatalogPlan(t){return e.send({op:"DeclineCatalogPlan",method:"POST",path:"/purchases/catalog/plans/"+u("DeclineCatalogPlan","plan_id",t.path.plan_id)+"/decline",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async validateCatalog(t){return e.send({op:"ValidateCatalog",method:"POST",path:"/purchases/catalog/validate",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listCharts(t){return e.send({op:"ListCharts",method:"GET",path:"/purchases/charts",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getChartsOverview(t){return e.send({op:"GetChartsOverview",method:"GET",path:"/purchases/charts/overview",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getChart(t){return e.send({op:"GetChart",method:"GET",path:"/purchases/charts/"+u("GetChart","chart",t.path.chart),auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getStripeConnectPage(t){return e.send({op:"GetStripeConnectPage",method:"GET",path:"/purchases/connect",auth:[],answers:{200:"raw"},signal:t?.signal})},async connectStripeKey(t){return e.send({op:"ConnectStripeKey",method:"POST",path:"/purchases/connect",auth:[],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getStripeAppInstallPage(t){return e.send({op:"GetStripeAppInstallPage",method:"GET",path:"/purchases/stripe/app/install",auth:[],answers:{200:"raw"},signal:t?.signal})},async startStripeAppInstall(t){return e.send({op:"StartStripeAppInstall",method:"POST",path:"/purchases/stripe/app/install",auth:[],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async completeStripeAppInstall(t){return e.send({op:"CompleteStripeAppInstall",method:"GET",path:"/purchases/stripe/app/callback",auth:[],answers:{200:"raw"},query:t?.query,signal:t?.signal})},async getCustomer(t){return e.send({op:"GetCustomer",method:"GET",path:"/purchases/customers/"+u("GetCustomer","customer_id",t.path.customer_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async grantCredits(t){return e.send({op:"GrantCredits",method:"POST",path:"/purchases/customers/"+u("GrantCredits","customer_id",t.path.customer_id)+"/credits",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listCreditEntries(t){return e.send({op:"ListCreditEntries",method:"GET",path:"/purchases/customers/"+u("ListCreditEntries","customer_id",t.path.customer_id)+"/credits/entries",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async forgiveCredits(t){return e.send({op:"ForgiveCredits",method:"POST",path:"/purchases/customers/"+u("ForgiveCredits","customer_id",t.path.customer_id)+"/credits/forgive",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listCustomerGrants(t){return e.send({op:"ListCustomerGrants",method:"GET",path:"/purchases/customers/"+u("ListCustomerGrants","customer_id",t.path.customer_id)+"/grants",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async grantEntitlement(t){return e.send({op:"GrantEntitlement",method:"POST",path:"/purchases/customers/"+u("GrantEntitlement","customer_id",t.path.customer_id)+"/grants",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async revokeGrant(t){return e.send({op:"RevokeGrant",method:"DELETE",path:"/purchases/customers/"+u("RevokeGrant","customer_id",t.path.customer_id)+"/grants/"+u("RevokeGrant","grant_id",t.path.grant_id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async holdSpend(t){return e.send({op:"HoldSpend",method:"POST",path:"/purchases/customers/"+u("HoldSpend","customer_id",t.path.customer_id)+"/holds",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async setCustomerLimit(t){return e.send({op:"SetCustomerLimit",method:"PUT",path:"/purchases/customers/"+u("SetCustomerLimit","customer_id",t.path.customer_id)+"/limits/"+u("SetCustomerLimit","limit_key",t.path.limit_key),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async clearCustomerLimit(t){return e.send({op:"ClearCustomerLimit",method:"DELETE",path:"/purchases/customers/"+u("ClearCustomerLimit","customer_id",t.path.customer_id)+"/limits/"+u("ClearCustomerLimit","limit_key",t.path.limit_key),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async grantLimit(t){return e.send({op:"GrantLimit",method:"POST",path:"/purchases/customers/"+u("GrantLimit","customer_id",t.path.customer_id)+"/limits/"+u("GrantLimit","limit_key",t.path.limit_key)+"/grants",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async spend(t){return e.send({op:"Spend",method:"POST",path:"/purchases/customers/"+u("Spend","customer_id",t.path.customer_id)+"/spend",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async commitSpend(t){return e.send({op:"CommitSpend",method:"POST",path:"/purchases/customers/"+u("CommitSpend","customer_id",t.path.customer_id)+"/spends/"+u("CommitSpend","spend_id",t.path.spend_id)+"/commit",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async extendHold(t){return e.send({op:"ExtendHold",method:"POST",path:"/purchases/customers/"+u("ExtendHold","customer_id",t.path.customer_id)+"/spends/"+u("ExtendHold","spend_id",t.path.spend_id)+"/extend",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async releaseSpend(t){return e.send({op:"ReleaseSpend",method:"POST",path:"/purchases/customers/"+u("ReleaseSpend","customer_id",t.path.customer_id)+"/spends/"+u("ReleaseSpend","spend_id",t.path.spend_id)+"/release",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async reverseSpend(t){return e.send({op:"ReverseSpend",method:"POST",path:"/purchases/customers/"+u("ReverseSpend","customer_id",t.path.customer_id)+"/spends/"+u("ReverseSpend","spend_id",t.path.spend_id)+"/reverse",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listExperiments(t){return e.send({op:"ListExperiments",method:"GET",path:"/purchases/experiments",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async startExperiment(t){return e.send({op:"StartExperiment",method:"POST",path:"/purchases/experiments",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getExperiment(t){return e.send({op:"GetExperiment",method:"GET",path:"/purchases/experiments/"+u("GetExperiment","experiment_id",t.path.experiment_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getExperimentResults(t){return e.send({op:"GetExperimentResults",method:"GET",path:"/purchases/experiments/"+u("GetExperimentResults","experiment_id",t.path.experiment_id)+"/results",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async stopExperiment(t){return e.send({op:"StopExperiment",method:"POST",path:"/purchases/experiments/"+u("StopExperiment","experiment_id",t.path.experiment_id)+"/stop",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async declareExperimentWinner(t){return e.send({op:"DeclareExperimentWinner",method:"POST",path:"/purchases/experiments/"+u("DeclareExperimentWinner","experiment_id",t.path.experiment_id)+"/winner",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getMyCustomerInfo(t){return e.send({op:"GetMyCustomerInfo",method:"GET",path:"/purchases/me",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async mergeGuest(t){return e.send({op:"MergeGuest",method:"POST",path:"/purchases/me/merge",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async createMergeGrant(t){return e.send({op:"CreateMergeGrant",method:"POST",path:"/purchases/me/merge-grant",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},signal:t?.signal})},async getOfferings(t){return e.send({op:"GetOfferings",method:"GET",path:"/purchases/offerings",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async listPaywalls(t){return e.send({op:"ListPaywalls",method:"GET",path:"/purchases/paywalls",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async createPaywall(t){return e.send({op:"CreatePaywall",method:"POST",path:"/purchases/paywalls",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listPaywallAssets(t){return e.send({op:"ListPaywallAssets",method:"GET",path:"/purchases/paywalls/assets",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async registerPaywallAsset(t){return e.send({op:"RegisterPaywallAsset",method:"POST",path:"/purchases/paywalls/assets",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deletePaywallAsset(t){return e.send({op:"DeletePaywallAsset",method:"DELETE",path:"/purchases/paywalls/assets/"+u("DeletePaywallAsset","asset_id",t.path.asset_id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async listPaywallTemplates(t){return e.send({op:"ListPaywallTemplates",method:"GET",path:"/purchases/paywalls/templates",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getPaywallTemplateAsset(t){return e.send({op:"GetPaywallTemplateAsset",method:"GET",path:"/purchases/paywalls/templates/"+u("GetPaywallTemplateAsset","key",t.path.key)+"/assets/"+u("GetPaywallTemplateAsset","asset_id",t.path.asset_id),auth:[["SecretKeyAuth"]],answers:{200:"raw",304:"empty"},headers:t.headers,signal:t.signal})},async validatePaywall(t){return e.send({op:"ValidatePaywall",method:"POST",path:"/purchases/paywalls/validate",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getPaywall(t){return e.send({op:"GetPaywall",method:"GET",path:"/purchases/paywalls/"+u("GetPaywall","paywall_id",t.path.paywall_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async deletePaywall(t){return e.send({op:"DeletePaywall",method:"DELETE",path:"/purchases/paywalls/"+u("DeletePaywall","paywall_id",t.path.paywall_id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async savePaywallDraft(t){return e.send({op:"SavePaywallDraft",method:"PUT",path:"/purchases/paywalls/"+u("SavePaywallDraft","paywall_id",t.path.paywall_id)+"/draft",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async publishPaywall(t){return e.send({op:"PublishPaywall",method:"POST",path:"/purchases/paywalls/"+u("PublishPaywall","paywall_id",t.path.paywall_id)+"/publish",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async listPaywallVersions(t){return e.send({op:"ListPaywallVersions",method:"GET",path:"/purchases/paywalls/"+u("ListPaywallVersions","paywall_id",t.path.paywall_id)+"/versions",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getPaywallVersion(t){return e.send({op:"GetPaywallVersion",method:"GET",path:"/purchases/paywalls/"+u("GetPaywallVersion","paywall_id",t.path.paywall_id)+"/versions/"+u("GetPaywallVersion","version",t.path.version),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async listPlacements(t){return e.send({op:"ListPlacements",method:"GET",path:"/purchases/placements",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async listAttributeKeys(t){return e.send({op:"ListAttributeKeys",method:"GET",path:"/purchases/placements/attributes",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async setPlacement(t){return e.send({op:"SetPlacement",method:"PUT",path:"/purchases/placements/"+u("SetPlacement","placement",t.path.placement),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deletePlacement(t){return e.send({op:"DeletePlacement",method:"DELETE",path:"/purchases/placements/"+u("DeletePlacement","placement",t.path.placement),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async recordPaywallExposure(t){return e.send({op:"RecordPaywallExposure",method:"POST",path:"/purchases/placements/"+u("RecordPaywallExposure","placement",t.path.placement)+"/exposures",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{204:"empty"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getPlacementPaywall(t){return e.send({op:"GetPlacementPaywall",method:"GET",path:"/purchases/placements/"+u("GetPlacementPaywall","placement",t.path.placement)+"/paywall",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{200:"json",204:"empty",304:"empty"},query:t.query,headers:t.headers,signal:t.signal})},async previewPlacement(t){return e.send({op:"PreviewPlacement",method:"POST",path:"/purchases/placements/"+u("PreviewPlacement","placement",t.path.placement)+"/resolve-preview",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getPlacementResults(t){return e.send({op:"GetPlacementResults",method:"GET",path:"/purchases/placements/"+u("GetPlacementResults","placement",t.path.placement)+"/results",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getPlacementRules(t){return e.send({op:"GetPlacementRules",method:"GET",path:"/purchases/placements/"+u("GetPlacementRules","placement",t.path.placement)+"/rules",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async setPlacementRules(t){return e.send({op:"SetPlacementRules",method:"PUT",path:"/purchases/placements/"+u("SetPlacementRules","placement",t.path.placement)+"/rules",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getSettings(t){return e.send({op:"GetSettings",method:"GET",path:"/purchases/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async updateSettings(t){return e.send({op:"UpdateSettings",method:"PUT",path:"/purchases/settings",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getStripeAccount(t){return e.send({op:"GetStripeAccount",method:"GET",path:"/purchases/stripe",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async disconnectStripe(t){return e.send({op:"DisconnectStripe",method:"DELETE",path:"/purchases/stripe",auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async checkStripeAccount(t){return e.send({op:"CheckStripeAccount",method:"POST",path:"/purchases/stripe/check",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async createCheckout(t){return e.send({op:"CreateCheckout",method:"POST",path:"/purchases/stripe/checkout",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async createCheckoutRedemption(t){return e.send({op:"CreateCheckoutRedemption",method:"POST",path:"/purchases/stripe/checkout/redemption",auth:[["ApiKeyAuth"],["ApiKeyAuth","userJWT"],["SecretKeyAuth"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async redeemPurchase(t){return e.send({op:"RedeemPurchase",method:"POST",path:"/purchases/redemptions/redeem",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getRedemptionPage(t){return e.send({op:"GetRedemptionPage",method:"GET",path:"/purchases/redeem",auth:[],answers:{200:"raw"},query:t.query,signal:t.signal})},async createStripeGrant(t){return e.send({op:"CreateStripeGrant",method:"POST",path:"/purchases/stripe/grants",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async createStripeAppInstall(t){return e.send({op:"CreateStripeAppInstall",method:"POST",path:"/purchases/stripe/app/grants",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async createPortalSession(t){return e.send({op:"CreatePortalSession",method:"POST",path:"/purchases/stripe/portal",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async receiveAppleNotification(t){return e.send({op:"ReceiveAppleNotification",method:"POST",path:"/purchases/webhooks/apple",auth:[],answers:{200:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async receiveGoogleNotification(t){return e.send({op:"ReceiveGoogleNotification",method:"POST",path:"/purchases/webhooks/google",auth:[],answers:{204:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async receiveStripeEvent(t){return e.send({op:"ReceiveStripeEvent",method:"POST",path:"/purchases/webhooks/stripe",auth:[],answers:{200:"empty"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async receiveStripeAppEvent(t){return e.send({op:"ReceiveStripeAppEvent",method:"POST",path:"/purchases/webhooks/stripe-app",auth:[],answers:{200:"empty"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listMyOffers(t){return e.send({op:"ListMyOffers",method:"GET",path:"/purchases/offers",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},signal:t?.signal})},async recordOfferView(t){return e.send({op:"RecordOfferView",method:"POST",path:"/purchases/offers/"+u("RecordOfferView","offer_key",t.path.offer_key)+"/views",auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"},signal:t.signal})},async signAppleOffer(t){return e.send({op:"SignAppleOffer",method:"POST",path:"/purchases/offers/"+u("SignAppleOffer","offer_key",t.path.offer_key)+"/apple-signature",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async claimOffer(t){return e.send({op:"ClaimOffer",method:"POST",path:"/purchases/offers/"+u("ClaimOffer","offer_key",t.path.offer_key)+"/claim",auth:[["ApiKeyAuth","userJWT"]],answers:{201:"json"},signal:t.signal})},async redeemCoupon(t){return e.send({op:"RedeemCoupon",method:"POST",path:"/purchases/coupons/redeem",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getOfferStats(t){return e.send({op:"GetOfferStats",method:"GET",path:"/purchases/offers/stats",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async listCoupons(t){return e.send({op:"ListCoupons",method:"GET",path:"/purchases/coupons",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async createCoupon(t){return e.send({op:"CreateCoupon",method:"POST",path:"/purchases/coupons",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getCoupon(t){return e.send({op:"GetCoupon",method:"GET",path:"/purchases/coupons/"+u("GetCoupon","coupon_key",t.path.coupon_key),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async revokeCoupon(t){return e.send({op:"RevokeCoupon",method:"DELETE",path:"/purchases/coupons/"+u("RevokeCoupon","coupon_key",t.path.coupon_key),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async listCouponCodes(t){return e.send({op:"ListCouponCodes",method:"GET",path:"/purchases/coupons/"+u("ListCouponCodes","coupon_key",t.path.coupon_key)+"/codes",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async setXcodeOfferKey(t){return e.send({op:"SetXcodeOfferKey",method:"PUT",path:"/purchases/apple/xcode-offer-key",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async searchCustomers(t){return e.send({op:"SearchCustomers",method:"GET",path:"/purchases/customers",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getCustomerHistory(t){return e.send({op:"GetCustomerHistory",method:"GET",path:"/purchases/customers/"+u("GetCustomerHistory","customer_id",t.path.customer_id)+"/history",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async listCatalogRevisions(t){return e.send({op:"ListCatalogRevisions",method:"GET",path:"/purchases/catalog/revisions",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getCatalogRevision(t){return e.send({op:"GetCatalogRevision",method:"GET",path:"/purchases/catalog/revisions/"+u("GetCatalogRevision","revision",t.path.revision),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async restoreCatalogRevision(t){return e.send({op:"RestoreCatalogRevision",method:"POST",path:"/purchases/catalog/revisions/"+u("RestoreCatalogRevision","revision",t.path.revision)+"/restore",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async extendSubscription(t){return e.send({op:"ExtendSubscription",method:"POST",path:"/purchases/customers/"+u("ExtendSubscription","customer_id",t.path.customer_id)+"/subscriptions/"+u("ExtendSubscription","subscription_id",t.path.subscription_id)+"/extend",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async refundSubscription(t){return e.send({op:"RefundSubscription",method:"POST",path:"/purchases/customers/"+u("RefundSubscription","customer_id",t.path.customer_id)+"/subscriptions/"+u("RefundSubscription","subscription_id",t.path.subscription_id)+"/refund",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async cancelSubscription(t){return e.send({op:"CancelSubscription",method:"POST",path:"/purchases/customers/"+u("CancelSubscription","customer_id",t.path.customer_id)+"/subscriptions/"+u("CancelSubscription","subscription_id",t.path.subscription_id)+"/cancel",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async setRefundDataConsent(t){return e.send({op:"SetRefundDataConsent",method:"PUT",path:"/purchases/me/refund-data-consent",auth:[["ApiKeyAuth","userJWT"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})}}}var vi={};Dt(vi,{client:()=>Sk});function Sk(e){return{async broadcast(t){return e.send({op:"Broadcast",method:"POST",path:"/realtime/broadcast",auth:[["SecretKeyAuth"]],answers:{202:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getChannels(t){return e.send({op:"GetChannels",method:"GET",path:"/realtime/channels",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async putChannels(t){return e.send({op:"PutChannels",method:"PUT",path:"/realtime/channels",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getLimits(t){return e.send({op:"GetLimits",method:"GET",path:"/realtime/limits",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async putLimits(t){return e.send({op:"PutLimits",method:"PUT",path:"/realtime/limits",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async revalidate(t){return e.send({op:"Revalidate",method:"POST",path:"/realtime/revalidate",auth:[["SecretKeyAuth"]],answers:{202:"empty"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async writeState(t){return e.send({op:"WriteState",method:"POST",path:"/realtime/state",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getStats(t){return e.send({op:"GetStats",method:"GET",path:"/realtime/stats",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})}}}var _i={};Dt(_i,{client:()=>Ak});function Ak(e){return{async listSecretAudit(t){return e.send({op:"ListSecretAudit",method:"GET",path:"/secrets/audit",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async listFieldKeys(t){return e.send({op:"ListFieldKeys",method:"GET",path:"/secrets/fields",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getFieldKeys(t){return e.send({op:"GetFieldKeys",method:"GET",path:"/secrets/fields/keys",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async openFields(t){return e.send({op:"OpenFields",method:"POST",path:"/secrets/fields/open",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async sealPlaceholder(t){return e.send({op:"SealPlaceholder",method:"POST",path:"/secrets/fields/placeholder",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async rotateFieldKeys(t){return e.send({op:"RotateFieldKeys",method:"POST",path:"/secrets/fields/rotate",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async listTransitKeys(t){return e.send({op:"ListTransitKeys",method:"GET",path:"/secrets/transit",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getTransitKeys(t){return e.send({op:"GetTransitKeys",method:"GET",path:"/secrets/transit/keys",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getTransitPublicKeys(t){return e.send({op:"GetTransitPublicKeys",method:"GET",path:"/secrets/transit/public",auth:[["ApiKeyAuth"],["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async rotateTransitKeys(t){return e.send({op:"RotateTransitKeys",method:"POST",path:"/secrets/transit/rotate",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t?.headers,body:{kind:"json",contentType:"application/json",value:t?.body},signal:t?.signal})},async retireTransitKey(t){return e.send({op:"RetireTransitKey",method:"POST",path:"/secrets/transit/"+u("RetireTransitKey","kid",t.path.kid)+"/retire",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async listSecrets(t){return e.send({op:"ListSecrets",method:"GET",path:"/secrets/"+u("ListSecrets","environment",t.path.environment),auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getEnvironmentValues(t){return e.send({op:"GetEnvironmentValues",method:"GET",path:"/secrets/"+u("GetEnvironmentValues","environment",t.path.environment)+"/values",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getSecret(t){return e.send({op:"GetSecret",method:"GET",path:"/secrets/"+u("GetSecret","environment",t.path.environment)+"/"+u("GetSecret","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putSecret(t){return e.send({op:"PutSecret",method:"PUT",path:"/secrets/"+u("PutSecret","environment",t.path.environment)+"/"+u("PutSecret","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteSecret(t){return e.send({op:"DeleteSecret",method:"DELETE",path:"/secrets/"+u("DeleteSecret","environment",t.path.environment)+"/"+u("DeleteSecret","name",t.path.name),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async rollbackSecret(t){return e.send({op:"RollbackSecret",method:"POST",path:"/secrets/"+u("RollbackSecret","environment",t.path.environment)+"/"+u("RollbackSecret","name",t.path.name)+"/rollback",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listSecretVersions(t){return e.send({op:"ListSecretVersions",method:"GET",path:"/secrets/"+u("ListSecretVersions","environment",t.path.environment)+"/"+u("ListSecretVersions","name",t.path.name)+"/versions",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})}}}var $i={};Dt($i,{client:()=>Pk});function Pk(e){return{async listBuckets(t){return e.send({op:"ListBuckets",method:"GET",path:"/storage/buckets",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async getBucket(t){return e.send({op:"GetBucket",method:"GET",path:"/storage/buckets/"+u("GetBucket","bucket",t.path.bucket),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async putBucket(t){return e.send({op:"PutBucket",method:"PUT",path:"/storage/buckets/"+u("PutBucket","bucket",t.path.bucket),auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async deleteBucket(t){return e.send({op:"DeleteBucket",method:"DELETE",path:"/storage/buckets/"+u("DeleteBucket","bucket",t.path.bucket),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async copyObject(t){return e.send({op:"CopyObject",method:"POST",path:"/storage/buckets/"+u("CopyObject","bucket",t.path.bucket)+"/copy",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async moveObject(t){return e.send({op:"MoveObject",method:"POST",path:"/storage/buckets/"+u("MoveObject","bucket",t.path.bucket)+"/move",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listObjects(t){return e.send({op:"ListObjects",method:"GET",path:"/storage/buckets/"+u("ListObjects","bucket",t.path.bucket)+"/objects",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async getObject(t){return e.send({op:"GetObject",method:"GET",path:"/storage/buckets/"+u("GetObject","bucket",t.path.bucket)+"/objects/"+u("GetObject","path",t.path.path),auth:[["SecretKeyAuth"]],answers:{200:"raw",206:"raw",304:"empty"},query:t.query,headers:t.headers,signal:t.signal})},async putObject(t){return e.send({op:"PutObject",method:"PUT",path:"/storage/buckets/"+u("PutObject","bucket",t.path.bucket)+"/objects/"+u("PutObject","path",t.path.path),auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},query:t.query,headers:t.headers,body:{kind:"raw",contentType:t.contentType??"application/octet-stream",value:t.body},signal:t.signal})},async deleteObject(t){return e.send({op:"DeleteObject",method:"DELETE",path:"/storage/buckets/"+u("DeleteObject","bucket",t.path.bucket)+"/objects/"+u("DeleteObject","path",t.path.path),auth:[["SecretKeyAuth"]],answers:{204:"empty"},signal:t.signal})},async headObject(t){return e.send({op:"HeadObject",method:"HEAD",path:"/storage/buckets/"+u("HeadObject","bucket",t.path.bucket)+"/objects/"+u("HeadObject","path",t.path.path),auth:[["SecretKeyAuth"]],answers:{200:"empty",304:"empty"},query:t.query,headers:t.headers,signal:t.signal})},async createSignedUrl(t){return e.send({op:"CreateSignedUrl",method:"POST",path:"/storage/buckets/"+u("CreateSignedUrl","bucket",t.path.bucket)+"/signed-urls",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async createUploadUrl(t){return e.send({op:"CreateUploadUrl",method:"POST",path:"/storage/buckets/"+u("CreateUploadUrl","bucket",t.path.bucket)+"/upload-urls",auth:[["SecretKeyAuth"]],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getPublicObject(t){return e.send({op:"GetPublicObject",method:"GET",path:"/storage/public/"+u("GetPublicObject","bucket",t.path.bucket)+"/"+u("GetPublicObject","path",t.path.path),auth:[],answers:{200:"raw",206:"raw",302:"redirect",304:"empty"},query:t.query,headers:t.headers,signal:t.signal})},async headPublicObject(t){return e.send({op:"HeadPublicObject",method:"HEAD",path:"/storage/public/"+u("HeadPublicObject","bucket",t.path.bucket)+"/"+u("HeadPublicObject","path",t.path.path),auth:[],answers:{200:"empty",302:"redirect",304:"empty"},query:t.query,headers:t.headers,signal:t.signal})},async getSignedObject(t){return e.send({op:"GetSignedObject",method:"GET",path:"/storage/signed/"+u("GetSignedObject","bucket",t.path.bucket)+"/"+u("GetSignedObject","path",t.path.path),auth:[],answers:{200:"raw",206:"raw",302:"redirect",304:"empty"},query:t.query,headers:t.headers,signal:t.signal})},async putSignedObject(t){return e.send({op:"PutSignedObject",method:"PUT",path:"/storage/signed/"+u("PutSignedObject","bucket",t.path.bucket)+"/"+u("PutSignedObject","path",t.path.path),auth:[],answers:{200:"json",201:"json"},query:t.query,headers:t.headers,body:{kind:"raw",contentType:t.contentType??"application/octet-stream",value:t.body},signal:t.signal})},async headSignedObject(t){return e.send({op:"HeadSignedObject",method:"HEAD",path:"/storage/signed/"+u("HeadSignedObject","bucket",t.path.bucket)+"/"+u("HeadSignedObject","path",t.path.path),auth:[],answers:{200:"empty",302:"redirect",304:"empty"},query:t.query,headers:t.headers,signal:t.signal})},async getStorageStats(t){return e.send({op:"GetStorageStats",method:"GET",path:"/storage/stats",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async upload(t){return e.send({op:"Upload",method:"POST",path:"/storage/upload/"+u("Upload","machine",t.path.machine)+"/"+u("Upload","route",t.path.route),auth:[["ApiKeyAuth","userJWT"],["ApiKeyAuth"]],answers:{},body:{kind:"raw",contentType:t.contentType??"multipart/form-data",value:t.body},signal:t.signal})}}}var ki={};Dt(ki,{client:()=>Rk});function Rk(e){return{async listActions(t){return e.send({op:"ListActions",method:"GET",path:"/stores/actions",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getAction(t){return e.send({op:"GetAction",method:"GET",path:"/stores/actions/"+u("GetAction","action_id",t.path.action_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async confirmAction(t){return e.send({op:"ConfirmAction",method:"POST",path:"/stores/actions/"+u("ConfirmAction","action_id",t.path.action_id)+"/confirm",auth:[["SecretKeyAuth"]],answers:{200:"json",202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async declineAction(t){return e.send({op:"DeclineAction",method:"POST",path:"/stores/actions/"+u("DeclineAction","action_id",t.path.action_id)+"/decline",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async getAppleAccount(t){return e.send({op:"GetAppleAccount",method:"GET",path:"/stores/apple",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async disconnectApple(t){return e.send({op:"DisconnectApple",method:"DELETE",path:"/stores/apple",auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async checkAppleAccount(t){return e.send({op:"CheckAppleAccount",method:"POST",path:"/stores/apple/check",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async createAppleGrant(t){return e.send({op:"CreateAppleGrant",method:"POST",path:"/stores/apple/grants",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async getSandboxReadiness(t){return e.send({op:"GetSandboxReadiness",method:"GET",path:"/stores/apple/readiness",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async listSandboxTesters(t){return e.send({op:"ListSandboxTesters",method:"GET",path:"/stores/apple/sandbox-testers",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async clearSandboxPurchaseHistory(t){return e.send({op:"ClearSandboxPurchaseHistory",method:"POST",path:"/stores/apple/sandbox-testers/clear-purchase-history",auth:[["SecretKeyAuth"]],answers:{202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async updateSandboxTester(t){return e.send({op:"UpdateSandboxTester",method:"PATCH",path:"/stores/apple/sandbox-testers/"+u("UpdateSandboxTester","tester_id",t.path.tester_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listApps(t){return e.send({op:"ListApps",method:"GET",path:"/stores/apps",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async listFeedback(t){return e.send({op:"ListFeedback",method:"GET",path:"/stores/apps/"+u("ListFeedback","app_id",t.path.app_id)+"/feedback",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getFeedback(t){return e.send({op:"GetFeedback",method:"GET",path:"/stores/apps/"+u("GetFeedback","app_id",t.path.app_id)+"/feedback/"+u("GetFeedback","kind",t.path.kind)+"/"+u("GetFeedback","feedback_id",t.path.feedback_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async listGroups(t){return e.send({op:"ListGroups",method:"GET",path:"/stores/apps/"+u("ListGroups","app_id",t.path.app_id)+"/groups",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async createGroup(t){return e.send({op:"CreateGroup",method:"POST",path:"/stores/apps/"+u("CreateGroup","app_id",t.path.app_id)+"/groups",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async linkApp(t){return e.send({op:"LinkApp",method:"POST",path:"/stores/apps/"+u("LinkApp","app_id",t.path.app_id)+"/link",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getListing(t){return e.send({op:"GetListing",method:"GET",path:"/stores/apps/"+u("GetListing","app_id",t.path.app_id)+"/listing",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async setListing(t){return e.send({op:"SetListing",method:"PUT",path:"/stores/apps/"+u("SetListing","app_id",t.path.app_id)+"/listing",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async planListing(t){return e.send({op:"PlanListing",method:"POST",path:"/stores/apps/"+u("PlanListing","app_id",t.path.app_id)+"/listing/plan",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async createPackage(t){return e.send({op:"CreatePackage",method:"POST",path:"/stores/apps/"+u("CreatePackage","app_id",t.path.app_id)+"/packages",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async uploadScreenshot(t){return e.send({op:"UploadScreenshot",method:"PUT",path:"/stores/apps/"+u("UploadScreenshot","app_id",t.path.app_id)+"/screenshots",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,query:t.query,headers:t.headers,body:{kind:"raw",contentType:t.contentType??"image/png",value:t.body},signal:t.signal})},async getReviewInfo(t){return e.send({op:"GetReviewInfo",method:"GET",path:"/stores/apps/"+u("GetReviewInfo","app_id",t.path.app_id)+"/testflight/review-info",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t.query,signal:t.signal})},async setReviewInfo(t){return e.send({op:"SetReviewInfo",method:"PUT",path:"/stores/apps/"+u("SetReviewInfo","app_id",t.path.app_id)+"/testflight/review-info",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getUploadKey(t){return e.send({op:"GetUploadKey",method:"GET",path:"/stores/apps/"+u("GetUploadKey","app_id",t.path.app_id)+"/upload-key",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getAppStoreVersion(t){return e.send({op:"GetAppStoreVersion",method:"GET",path:"/stores/apps/"+u("GetAppStoreVersion","app_id",t.path.app_id)+"/version",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async prepareAppStoreVersion(t){return e.send({op:"PrepareAppStoreVersion",method:"PUT",path:"/stores/apps/"+u("PrepareAppStoreVersion","app_id",t.path.app_id)+"/version",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async planPhasedRelease(t){return e.send({op:"PlanPhasedRelease",method:"POST",path:"/stores/apps/"+u("PlanPhasedRelease","app_id",t.path.app_id)+"/version/phased-release",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async planReleaseVersion(t){return e.send({op:"PlanReleaseVersion",method:"POST",path:"/stores/apps/"+u("PlanReleaseVersion","app_id",t.path.app_id)+"/version/release",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async planSubmitReview(t){return e.send({op:"PlanSubmitReview",method:"POST",path:"/stores/apps/"+u("PlanSubmitReview","app_id",t.path.app_id)+"/version/submit",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async planWithdrawReview(t){return e.send({op:"PlanWithdrawReview",method:"POST",path:"/stores/apps/"+u("PlanWithdrawReview","app_id",t.path.app_id)+"/version/withdraw",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async getAppVitals(t){return e.send({op:"GetAppVitals",method:"GET",path:"/stores/apps/"+u("GetAppVitals","app_id",t.path.app_id)+"/vitals",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getAppWebhook(t){return e.send({op:"GetAppWebhook",method:"GET",path:"/stores/apps/"+u("GetAppWebhook","app_id",t.path.app_id)+"/webhook",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async makeAppWebhook(t){return e.send({op:"MakeAppWebhook",method:"POST",path:"/stores/apps/"+u("MakeAppWebhook","app_id",t.path.app_id)+"/webhook",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async pingAppWebhook(t){return e.send({op:"PingAppWebhook",method:"POST",path:"/stores/apps/"+u("PingAppWebhook","app_id",t.path.app_id)+"/webhook/ping",auth:[["SecretKeyAuth"]],answers:{202:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async downloadSignedBundle(t){return e.send({op:"DownloadSignedBundle",method:"GET",path:"/stores/bundles",auth:[],answers:{200:"raw"},query:t.query,signal:t.signal})},async getConnectPage(t){return e.send({op:"GetConnectPage",method:"GET",path:"/stores/connect",auth:[],answers:{200:"raw"},signal:t?.signal})},async connectAppleKey(t){return e.send({op:"ConnectAppleKey",method:"POST",path:"/stores/connect",auth:[],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getGoogleAccount(t){return e.send({op:"GetGoogleAccount",method:"GET",path:"/stores/google",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async connectGoogle(t){return e.send({op:"ConnectGoogle",method:"POST",path:"/stores/google",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async disconnectGoogle(t){return e.send({op:"DisconnectGoogle",method:"DELETE",path:"/stores/google",auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async checkGoogleAccount(t){return e.send({op:"CheckGoogleAccount",method:"POST",path:"/stores/google/check",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async deleteGroup(t){return e.send({op:"DeleteGroup",method:"DELETE",path:"/stores/groups/"+u("DeleteGroup","group_id",t.path.group_id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async renameGroup(t){return e.send({op:"RenameGroup",method:"PATCH",path:"/stores/groups/"+u("RenameGroup","group_id",t.path.group_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async addGroupBuild(t){return e.send({op:"AddGroupBuild",method:"POST",path:"/stores/groups/"+u("AddGroupBuild","group_id",t.path.group_id)+"/builds",auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listTesters(t){return e.send({op:"ListTesters",method:"GET",path:"/stores/groups/"+u("ListTesters","group_id",t.path.group_id)+"/testers",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async setTesters(t){return e.send({op:"SetTesters",method:"PUT",path:"/stores/groups/"+u("SetTesters","group_id",t.path.group_id)+"/testers",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async listPackages(t){return e.send({op:"ListPackages",method:"GET",path:"/stores/packages",auth:[["SecretKeyAuth"]],answers:{200:"json"},query:t?.query,signal:t?.signal})},async getPackage(t){return e.send({op:"GetPackage",method:"GET",path:"/stores/packages/"+u("GetPackage","package_id",t.path.package_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async uploadArtifact(t){return e.send({op:"UploadArtifact",method:"PUT",path:"/stores/packages/"+u("UploadArtifact","package_id",t.path.package_id)+"/artifact",auth:[],answers:{200:"json"},headers:t.headers,body:{kind:"raw",contentType:t.contentType??"application/octet-stream",value:t.body},signal:t.signal})},async planBetaReview(t){return e.send({op:"PlanBetaReview",method:"POST",path:"/stores/packages/"+u("PlanBetaReview","package_id",t.path.package_id)+"/beta-review",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async listDeliveries(t){return e.send({op:"ListDeliveries",method:"GET",path:"/stores/packages/"+u("ListDeliveries","package_id",t.path.package_id)+"/deliveries",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async deliver(t){return e.send({op:"Deliver",method:"POST",path:"/stores/packages/"+u("Deliver","package_id",t.path.package_id)+"/deliveries",auth:[["SecretKeyAuth"]],answers:{200:"json",202:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getSignedBundleLink(t){return e.send({op:"GetSignedBundleLink",method:"POST",path:"/stores/packages/"+u("GetSignedBundleLink","package_id",t.path.package_id)+"/deliveries/"+u("GetSignedBundleLink","channel",t.path.channel)+"/bundle-link",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async planExpire(t){return e.send({op:"PlanExpire",method:"POST",path:"/stores/packages/"+u("PlanExpire","package_id",t.path.package_id)+"/expire",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async planExportCompliance(t){return e.send({op:"PlanExportCompliance",method:"POST",path:"/stores/packages/"+u("PlanExportCompliance","package_id",t.path.package_id)+"/export-compliance",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async setWhatToTest(t){return e.send({op:"SetWhatToTest",method:"PUT",path:"/stores/packages/"+u("SetWhatToTest","package_id",t.path.package_id)+"/what-to-test",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async takeAppleWebhook(t){return e.send({op:"TakeAppleWebhook",method:"POST",path:"/stores/webhooks/apple/"+u("TakeAppleWebhook","app_id",t.path.app_id),auth:[],answers:{200:"empty"},headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getAppleSession(t){return e.send({op:"GetAppleSession",method:"GET",path:"/stores/apple/session",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async disconnectAppleSession(t){return e.send({op:"DisconnectAppleSession",method:"DELETE",path:"/stores/apple/session",auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async checkAppleSession(t){return e.send({op:"CheckAppleSession",method:"POST",path:"/stores/apple/session/check",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async createAppleIdGrant(t){return e.send({op:"CreateAppleIDGrant",method:"POST",path:"/stores/apple/session/grants",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t?.headers,signal:t?.signal})},async getAppleIdPage(t){return e.send({op:"GetAppleIDPage",method:"GET",path:"/stores/connect/apple-id",auth:[],answers:{200:"raw"},signal:t?.signal})},async signInAppleId(t){return e.send({op:"SignInAppleID",method:"POST",path:"/stores/connect/apple-id",auth:[],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async submitAppleIdCode(t){return e.send({op:"SubmitAppleIDCode",method:"POST",path:"/stores/connect/apple-id/code",auth:[],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async chooseAppleIdTeam(t){return e.send({op:"ChooseAppleIDTeam",method:"POST",path:"/stores/connect/apple-id/team",auth:[],answers:{200:"json"},body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async getAppReview(t){return e.send({op:"GetAppReview",method:"GET",path:"/stores/apps/"+u("GetAppReview","app_id",t.path.app_id)+"/review",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async getReviewAttachment(t){return e.send({op:"GetReviewAttachment",method:"GET",path:"/stores/apps/"+u("GetReviewAttachment","app_id",t.path.app_id)+"/review/threads/"+u("GetReviewAttachment","thread_id",t.path.thread_id)+"/attachments/"+u("GetReviewAttachment","attachment_id",t.path.attachment_id),auth:[["SecretKeyAuth"]],answers:{200:"raw"},signal:t.signal})},async setReviewDraft(t){return e.send({op:"SetReviewDraft",method:"PUT",path:"/stores/apps/"+u("SetReviewDraft","app_id",t.path.app_id)+"/review/threads/"+u("SetReviewDraft","thread_id",t.path.thread_id)+"/draft",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async sendReviewDraft(t){return e.send({op:"SendReviewDraft",method:"POST",path:"/stores/apps/"+u("SendReviewDraft","app_id",t.path.app_id)+"/review/threads/"+u("SendReviewDraft","thread_id",t.path.thread_id)+"/draft/send",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async getAppPrivacy(t){return e.send({op:"GetAppPrivacy",method:"GET",path:"/stores/apps/"+u("GetAppPrivacy","app_id",t.path.app_id)+"/privacy",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async setAppPrivacy(t){return e.send({op:"SetAppPrivacy",method:"PUT",path:"/stores/apps/"+u("SetAppPrivacy","app_id",t.path.app_id)+"/privacy",auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async makeAppRecord(t){return e.send({op:"MakeAppRecord",method:"POST",path:"/stores/apps/"+u("MakeAppRecord","app_id",t.path.app_id)+"/record",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async removeAppRecord(t){return e.send({op:"RemoveAppRecord",method:"DELETE",path:"/stores/apps/"+u("RemoveAppRecord","app_id",t.path.app_id)+"/record",auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async listMadeAppleKeys(t){return e.send({op:"ListMadeAppleKeys",method:"GET",path:"/stores/apple/keys",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})},async makeAppleKey(t){return e.send({op:"MakeAppleKey",method:"POST",path:"/stores/apple/keys",auth:[["SecretKeyAuth"]],answers:{201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async revokeMadeAppleKey(t){return e.send({op:"RevokeMadeAppleKey",method:"DELETE",path:"/stores/apple/keys/"+u("RevokeMadeAppleKey","key_id",t.path.key_id),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async shareAppleSession(t){return e.send({op:"ShareAppleSession",method:"PUT",path:"/stores/apple/session/shares/"+u("ShareAppleSession","environment",t.path.environment),auth:[["SecretKeyAuth"]],answers:{200:"json"},idempotent:!0,headers:t.headers,signal:t.signal})},async unshareAppleSession(t){return e.send({op:"UnshareAppleSession",method:"DELETE",path:"/stores/apple/session/shares/"+u("UnshareAppleSession","environment",t.path.environment),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async getInstallPage(t){return e.send({op:"GetInstallPage",method:"GET",path:"/stores/install",auth:[],answers:{200:"raw"},query:t.query,signal:t.signal})},async getInstallStatus(t){return e.send({op:"GetInstallStatus",method:"GET",path:"/stores/install/status",auth:[],answers:{200:"json"},query:t.query,signal:t.signal})},async retryInstall(t){return e.send({op:"RetryInstall",method:"POST",path:"/stores/install/retry",auth:[],answers:{204:"empty"},query:t.query,signal:t.signal})},async getInstallEnrollment(t){return e.send({op:"GetInstallEnrollment",method:"GET",path:"/stores/install/enroll",auth:[],answers:{200:"raw",303:"redirect"},query:t.query,signal:t.signal})},async registerInstallDevice(t){return e.send({op:"RegisterInstallDevice",method:"POST",path:"/stores/install/device",auth:[],answers:{200:"raw",301:"redirect"},query:t.query,body:{kind:"raw",contentType:t.contentType??"application/pkcs7-signature",value:t.body},signal:t.signal})},async getInstallManifest(t){return e.send({op:"GetInstallManifest",method:"GET",path:"/stores/install/manifest",auth:[],answers:{200:"raw"},query:t.query,signal:t.signal})},async getInstallBuild(t){return e.send({op:"GetInstallBuild",method:"GET",path:"/stores/install/app",auth:[],answers:{200:"raw"},query:t.query,signal:t.signal})},async headInstallBuild(t){return e.send({op:"HeadInstallBuild",method:"HEAD",path:"/stores/install/app",auth:[],answers:{200:"empty"},query:t.query,signal:t.signal})},async getInstallIcon(t){return e.send({op:"GetInstallIcon",method:"GET",path:"/stores/install/icon",auth:[],answers:{200:"raw"},query:t?.query,signal:t?.signal})},async listInvitations(t){return e.send({op:"ListInvitations",method:"GET",path:"/stores/packages/"+u("ListInvitations","package_id",t.path.package_id)+"/invitations",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t.signal})},async invitePerson(t){return e.send({op:"InvitePerson",method:"POST",path:"/stores/packages/"+u("InvitePerson","package_id",t.path.package_id)+"/invitations",auth:[["SecretKeyAuth"]],answers:{200:"json",201:"json"},idempotent:!0,headers:t.headers,body:{kind:"json",contentType:"application/json",value:t.body},signal:t.signal})},async revokeInvitation(t){return e.send({op:"RevokeInvitation",method:"DELETE",path:"/stores/invitations/"+u("RevokeInvitation","invitation_id",t.path.invitation_id),auth:[["SecretKeyAuth"]],answers:{204:"empty"},idempotent:!0,headers:t.headers,signal:t.signal})},async listDevices(t){return e.send({op:"ListDevices",method:"GET",path:"/stores/devices",auth:[["SecretKeyAuth"]],answers:{200:"json"},signal:t?.signal})}}}var Kr={attempts:3,maxWaitSeconds:30},Ek=new Set([429,502,503,504]);function Bl(e,t=Kr){let n=t.sleep??jk;return{async send(s){let a=Tk(s),i=a.body,r=!i||i.kind!=="raw"||wa(i.value),o=(a.method==="GET"||a.method==="HEAD"||a.idempotent===!0)&&r;for(let l=1;;l++)try{return await e.send(a)}catch(d){if(!o||l>=t.attempts||!(d instanceof W)||a.signal?.aborted)throw d;let p=Ck(d,l,t.maxWaitSeconds);if(p===void 0)throw d;await n(p*1e3,a.signal)}}}}function Tk(e){return e.idempotent?Object.entries(e.headers??{}).some(([n,s])=>n.toLowerCase()==="idempotency-key"&&s!==void 0&&s!==null&&s!=="")?e:{...e,headers:{...e.headers,"Idempotency-Key":Ok()}}:e}function Ck(e,t,n){return Ek.has(e.status)||e.code==="network_error"?e.retryAfter!==void 0?e.retryAfter<=n?e.retryAfter:void 0:Math.min(.5*2**(t-1),n)*(.8+Math.random()*.4):void 0}function jk(e,t){return new Promise((n,s)=>{if(t?.aborted)return s(t.reason);let a=()=>{clearTimeout(i),s(t?.reason)},i=setTimeout(()=>{t?.removeEventListener("abort",a),n()},e);t?.addEventListener("abort",a,{once:!0})})}function Ok(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(n=>n.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}import{hostname as Nk}from"node:os";var Ik=new Set(["apikey","authorization",Ul]);function Lk(e){let t={accept:"application/json"};for(let[n,s]of Object.entries(e??{}))s!=null&&!Ik.has(n.toLowerCase())&&(t[n.toLowerCase()]=String(s));return t}function Dk(e,t,n){let s=null;try{s=n.startsWith("/")?new URL(n,e):null}catch{s=null}if(!s||s.origin!==new URL(e).origin)throw new W({op:t,status:0,code:"invalid_path",message:`${t}: a module's path stays at its environment's address`});return s.href}async function Mk(e){let t=e.status===204||e.status===304?"":await e.text();if(t!=="")try{return JSON.parse(t)}catch{return t}}function xk(e,t,n){let s=n??{},a=Number(t.headers.get("retry-after")??"");return new W({op:e,status:t.status,code:typeof s.error=="string"?s.error:`http_${t.status}`,message:Fr(n,t.status),requestId:typeof s.request_id=="string"?s.request_id:t.headers.get("x-request-id")??void 0,retryAfter:Number.isFinite(a)&&a>0?a:typeof s.retry_after=="number"?s.retry_after:void 0,body:n})}var Fn=class{bytes;contentType;constructor(t,n){this.bytes=t,this.contentType=n}};function Gk(e){return e instanceof Fn?{headers:{"content-type":e.contentType,"content-length":String(e.bytes.size)},body:e.bytes}:e===void 0?{headers:{}}:{headers:{"content-type":"application/json"},body:JSON.stringify(e)}}async function Ve(e,t,n,s,a,i){let r=`${n} ${s}`,o=Gk(a),l=await e.module(Dk(Wt(e.cloud,t),r,s),{method:n,headers:{...Lk(i),...o.headers},body:o.body}),d=await Mk(l);if(l.status>=200&&l.status<300)return{status:l.status,body:Tr(d),etag:l.headers.get("etag")??void 0};throw xk(r,l,d)}var qk=10080*60*1e3;async function Wl(e,t,n=!1){let s=await e.state.personalKey(t);if(!n&&s&&Date.parse(s.expires_at)-e.io.now()>qk)return s;let a=await e.post(`/environments/${ee("the environment's ref",t)}/personal-key`,{host:Nk().slice(0,100)||"computer"});return await e.state.keepPersonalKey(t,a),a}function Fr(e,t){let n=e??{},s=typeof n.error_description=="string"?n.error_description:`the module answered ${t}`,a=Array.isArray(n.field_errors)?n.field_errors.flatMap(i=>{let{pointer:r,message:o}=i??{};return typeof o=="string"?[`${typeof r=="string"&&r!==""?`${r}: `:""}${o}`]:[]}):[];return a.length>0?`${s}: ${a.join("; ")}`:s}import{relative as Uk}from"node:path";async function _a(e,t){let n=await e.run("git",["rev-parse","--show-toplevel"],{cwd:t});if(n.code!==0)return null;let s=n.stdout.trim(),a=await e.run("git",["remote","get-url","origin"],{cwd:t}),i=await e.run("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:t}),r=i.code===0?i.stdout.trim():"";return{root:s,repository:a.code===0?Kk(a.stdout.trim()):void 0,branch:r!==""&&r!=="HEAD"?r:void 0,path:Uk(s,t).split("\\").join("/")}}function Kk(e){let t=/^(?:https?:\/\/(?:[^@/]+@)?github\.com\/|git@github\.com:|ssh:\/\/git@github\.com\/)([A-Za-z0-9-]+)\/([A-Za-z0-9._-]+?)(?:\.git)?\/?$/.exec(e);return t?`${t[1]}/${t[2]}`:void 0}async function $a(e,t){let n=await nt(e);return new Map(n.filter(s=>s.project_id===t.project_id).map(s=>[s.ref,s.slug]))}function Bn(e,t){return t?e.get(t.ref)??t.ref:""}var Et="main";async function nt(e){let[t,n]=await Promise.all([e.get("/environments"),e.get("/orgs")]),s=new Map(n.organizations.map(a=>[a.id,a.name]));return t.environments.map(a=>({...a,org_name:s.get(a.organization_id)??a.organization_id}))}function Oe(e){return{org_id:e.organization_id,org_name:e.org_name,project_id:e.project_id,project_name:e.project_name,env_ref:e.ref,env_slug:e.slug,env_name:e.name}}function se(e){return`${e.org_name} \u203A ${e.project_name} \u203A ${e.env_name}${e.env_name!==e.env_slug?` (${e.env_slug})`:""}`}function Wn(e){return(e.env.PALBASE_TOKEN??"").startsWith("pbe_")}async function Si(e){let[t]=await nt(e.studio);if(!t)throw new y("token_refused","Studio names no environment for PALBASE_TOKEN",{hint:"mint another: palbase env:tokens:create"});let n=Oe(t),s=r=>new y("token_environment",`PALBASE_TOKEN is ${se(n)}'s environment token: it acts there alone, not in ${r}`,{hint:"mint one there: palbase env:tokens:create -P <project> -E <env>"}),{project:a,env:i}=e.global;if(a!==void 0&&t.project_id!==a&&!Hl(t.project_name,a.slice(a.indexOf("/")+1)))throw s(a);if(i!==void 0&&i!==t.slug&&i!==t.ref)throw s(i);if(a===void 0&&i===void 0){let r=await e.state.targetFor(e.io.cwd);if(r&&r.target.env_ref!==t.ref)throw s(`${se(r.target)}, chosen for ${r.dir}`)}return t}async function w(e){if(Wn(e.io))return Oe(await Si(e));let{project:t,env:n}=e.global;if(t!==void 0||n!==void 0){let r=await nt(e.studio),o;if(t!==void 0)o=ms(r,t);else{let l=await e.state.targetFor(e.io.cwd);if(!l)throw Jl("-E names an environment of the project chosen here, and none is chosen: add -P <project>");o=r.filter(d=>d.project_id===l.target.project_id)}if(n!==void 0){let l=o.find(d=>d.slug===n||d.ref===n);if(!l)throw new y("no_such_environment",`the project has no environment ${JSON.stringify(n)}`,{hint:`its environments: ${o.map(d=>d.slug).join(", ")}`});return Oe(l)}return o.length===1?Oe(o[0]):Oe(await zl(e,o,"Which environment?"))}let s=await e.state.targetFor(e.io.cwd);if(s)return s.target;if(!e.interactive)throw Jl("no environment is chosen for this directory");let a=await nt(e.studio);if(a.length===0)throw new y("no_environments","your account reaches no environment yet",{hint:"make one: palbase projects:create <name>"});let i=Oe(await zl(e,a,"Which environment?"));return e.out.note(`Acting on ${se(i)}. palbase use remembers it for this directory.`),i}async function Ds(e){return(await cs(e)).t}async function cs(e){if(Wn(e.io))return{t:Oe(await Si(e)),by:"token"};let t=await e.state.targetFor(e.io.cwd);if(e.global.project===void 0&&e.global.env===void 0&&t)return{t:t.target,by:"here"};let n=await Du(e,t?.target);if(e.global.env!==void 0)return{t:Oe(Vl(n,e.global.env)),by:"env"};let s=n.find(a=>a.ref===t?.target.env_ref);return s?{t:Oe(s),by:"here"}:{t:Oe(n.find(a=>a.slug===Et)??n[0]),by:"fallback"}}function Br(e,t){return e.by==="fallback"?t:`${t}${t.includes("?")?"&":"?"}environment=${encodeURIComponent(e.t.env_ref)}`}var Lu=1e3;async function us(e){let t=[],n=new Set,s;for(;;){let a=await e(s);if(t.push(...a.items),!a.next)return t;if(n.has(a.next)||n.size>=Lu)throw new y("list_unending",`the platform's list did not end: ${n.has(a.next)?`it gave the cursor ${JSON.stringify(a.next)} twice`:`it ran past ${Lu} pages`}`);n.add(a.next),s=a.next}}async function Ms(e,t,n,s,a){if(t.by==="env"||t.by==="token"||t.by==="here"&&(n.environment?.ref??t.t.env_ref)===t.t.env_ref)return;let i=(await s()).filter(o=>o.name===n.name);if(i.length<2)return;let r=await $a(e.studio,t.t);throw new y("ambiguous_name",`${a} is held by more than one of ${t.t.project_name}'s environments: ${i.map(o=>Bn(r,o.environment)).join(", ")}`,{hint:"name the environment: -E <env>"})}async function xs(e){if(Wn(e.io))return Oe(await Si(e));let t=await e.state.targetFor(e.io.cwd);if(e.global.project===void 0&&e.global.env===void 0&&t)return t.target;let n=await Du(e,t?.target);if(e.global.env!==void 0)return Oe(Vl(n,e.global.env));let s=n.find(i=>i.ref===t?.target.env_ref);if(s)return Oe(s);let a=n[0].project_name;if(!e.interactive)throw g(`which environment of ${a} is it bound to? name it with -E <env>`,`its environments: ${n.map(i=>i.slug).join(", ")}`);return Oe(await zl(e,n,re(`Which environment of ${a} does it belong to?`)))}async function Gs(e,t,n,s){if(!n||n.ref===t.env_ref)return t;let a=(await nt(e.studio)).find(i=>i.ref===n.ref);if(e.global.env!==void 0){let i=a?.slug??n.name??n.ref;throw new y("bound_elsewhere",`${s} is bound to ${t.project_name}'s environment ${i}, not ${t.env_slug}`,{hint:`leave -E out: the command acts where it is bound${a?` (or name it, -E ${a.slug})`:""}`})}if(!a)throw new y("environment_out_of_reach",`${s} is bound to ${t.project_name}'s environment ${n.name||n.ref}, which your account does not reach`,{hint:"an admin of the project's organization adds you to that environment"});return Oe(a)}function Wr(e,t,n){return e.global.env===void 0?n:`${n}${n.includes("?")?"&":"?"}environment=${encodeURIComponent(t.env_ref)}`}async function Ai(e,t,n){let s=(await nt(e.studio)).filter(a=>a.project_id===t.project_id);return Vl(s,n)}function Ae(e){return`The ${e} is the project's: the command acts in the environment it is bound to. -E picks it where two environments hold its name, and is refused when it names another.`}var qs="It is bound to the environment -E names, or to the one chosen for this directory: a person at the terminal is asked which, anyone else names it with -E.";async function Du(e,t){let n=await nt(e.studio);if(e.global.project!==void 0)return ms(n,e.global.project);if(t){let a=n.filter(i=>i.project_id===t.project_id);if(a.length===0)throw new y("no_such_project",`the project chosen here (${t.project_name}) is not among yours any more`,{hint:"palbase use another"});return a}if(!e.interactive)throw new y("no_target","which project? none is chosen for this directory",{hint:"pass -P <project>, or choose one here with palbase use"});if(n.length===0)throw new y("no_environments","your account reaches no environment yet",{hint:"make one: palbase projects:create <name>"});let s=[...new Map(n.map(a=>[a.project_id,a])).values()];for(s.forEach((a,i)=>e.out.note(` ${String(i+1).padStart(2)}) ${a.org_name} \u203A ${a.project_name}`));;){let a=Number((await e.io.prompt(`Which project? [1-${s.length}] `)).trim());if(Number.isInteger(a)&&a>=1&&a<=s.length){let i=s[a-1];return e.out.note(`Acting on ${i.org_name} \u203A ${i.project_name}. palbase use remembers one for this directory.`),n.filter(r=>r.project_id===i.project_id)}e.out.note(`answer with a number from 1 to ${s.length}`)}}function Vl(e,t){let n=e.find(s=>s.slug===t||s.ref===t);if(!n)throw new y("no_such_environment",`the project has no environment ${JSON.stringify(t)}`,{hint:`its environments: ${e.map(s=>s.slug).join(", ")}`});return n}function ms(e,t){let n=e.filter(l=>l.project_id===t);if(n.length>0)return n;let s=t.indexOf("/"),[a,i]=s>=0?[t.slice(0,s),t.slice(s+1)]:[void 0,t],r=e.filter(l=>Hl(l.project_name,i)&&(a===void 0||Hl(l.org_name,a)||l.organization_id===a)),o=new Set(r.map(l=>l.project_id));if(o.size===0)throw new y("no_such_project",`no project ${JSON.stringify(t)} among yours`,{hint:"palbase projects:list shows them"});if(o.size>1){let l=[...new Set(r.map(d=>`${d.org_name}/${d.project_name}`))].join(", ");throw new y("ambiguous_project",`${JSON.stringify(t)} is a project in more than one organization: ${l}`,{hint:"name it as org/project"})}return r}async function k(e,t,n,s){e.out.note(`${se(t)}: ${n}${e.global.yes?" (confirmed with -y)":""}`);let a=t.env_slug===Et;if(!a&&s===void 0||e.global.yes)return;if(!e.interactive){let r=Wn(e.io)?"confirm with -y: with PALBASE_TOKEN, -y is the go-ahead (the CLI asks no one else, and a person's yes elsewhere is not one)":"confirm with -y";throw new y("confirmation_needed",a?`${t.project_name} \u203A ${t.env_name} is the project's production environment`:s,{hint:r})}let i=(await e.io.prompt(re(`${a?`This is ${t.project_name}'s production environment`:s}. Go ahead? [y/N] `))).trim().toLowerCase();if(i!=="y"&&i!=="yes")throw new y("cancelled","nothing was changed")}async function zl(e,t,n){if(!e.interactive)throw Jl(`${n.replace(/\?$/,"")}: ${t.map(s=>`${s.project_name}/${s.slug}`).join(", ")}`);for(t.forEach((s,a)=>e.out.note(` ${String(a+1).padStart(2)}) ${se(Oe(s))}`));;){let s=(await e.io.prompt(`${n} [1-${t.length}] `)).trim(),a=Number(s);if(Number.isInteger(a)&&a>=1&&a<=t.length)return t[a-1];e.out.note(`answer with a number from 1 to ${t.length}`)}}function Jl(e){return new y("no_target",e,{hint:"choose one here with palbase use, or pass -P <project> -E <env>"})}function Hl(e,t){return e.localeCompare(t,void 0,{sensitivity:"accent"})===0}import{randomUUID as Fk}from"node:crypto";import{readFile as Bk}from"node:fs/promises";import{resolve as Wk}from"node:path";var zk=6,Xl=0,Mu=[];async function Jk(e){Xl<zk?Xl++:await new Promise(t=>Mu.push(t));try{return await e()}finally{let t=Mu.shift();t?t():Xl--}}async function wt(e,t,n,s,a,i){return Jk(()=>Ve(e.studio,t.env_ref,n,s,a,i))}async function h(e,t,n,s,a,i){return(await wt(e,t,n,s,a,i)).body}async function vt(e,t,n){let s=await wt(e,t,"GET",n);return{body:s.body,etag:s.etag}}function pt(e){return e?{"if-match":e}:void 0}function J(){return{"idempotency-key":Fk()}}function T(e){return encodeURIComponent(e)}function hs(e){return e.map(t=>{let n=t.indexOf("=");if(n<=0)throw g(`a setting is key=value, not ${JSON.stringify(t)}`);let s=t.slice(0,n).split(".");if(s.some(a=>a===""||a==="__proto__"||a==="constructor"||a==="prototype"))throw g(`${JSON.stringify(t.slice(0,n))} is not a key`);return{path:s,value:An(t.slice(n+1))}})}function An(e){try{return JSON.parse(e)}catch{return e}}function gs(e,t){let n=structuredClone(e);for(let{path:s,value:a}of t){let i=n;for(let r of s.slice(0,-1)){let o=i[r];(typeof o!="object"||o===null)&&(i[r]={}),i=i[r]}i[s[s.length-1]]=a}return n}function zn(e,t){return[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>!Tt(e[n],t[n])).sort()}function xu(e){return JSON.stringify(e,(t,n)=>n!==null&&typeof n=="object"&&!Array.isArray(n)?Object.fromEntries(Object.entries(n).sort(([s],[a])=>s<a?-1:s>a?1:0)):n)}function Tt(e,t){return xu(e)===xu(t)}function ct(e){return e===void 0?"(not set)":typeof e=="string"&&e!==""?e:JSON.stringify(e)}function ka(e,t){let n=Object.keys(t).sort(),s=Math.max(0,...n.map(a=>a.length));for(let a of n)e.out.line(`${a.padEnd(s)} ${ct(t[a])}`)}function Ct(e,t,n){e.out.result({settings:n,changed:[]},()=>e.out.line(`Nothing to change: ${t} already ${t.endsWith("s")?"are":"is"} so.`))}async function Xe(e,t,n){let s;if(t!==void 0&&t!=="-")try{s=await Bk(Wk(e.io.cwd,t),"utf8")}catch(a){throw new y("unreadable_file",`${t} could not be read: ${a instanceof Error?a.message:String(a)}`)}else e.io.interactive&&e.out.note(`Reading ${n} from stdin; end it with Ctrl-D.`),s=await e.io.readStdin();if(s.trim()==="")throw g(`no ${n} was given`,t===void 0?"pass --file <path>, or pipe it in":void 0);return s}function Fe(e,t){try{return JSON.parse(e)}catch(n){throw g(`${t} is not JSON: ${n instanceof Error?n.message:String(n)}`)}}async function ut(e,t){e.io.interactive&&e.out.note(`Paste ${t}, then Ctrl-D (it is read from stdin, never from the command line):`);let n=(await e.io.readStdin()).trim();if(n==="")throw g(`no ${t} was piped in`,"pipe it in: palbase \u2026 < file");return n}function Sa(e){if(e.flags.enable===!0&&e.flags.disable===!0)throw g("--enable and --disable are one or the other");if(e.flags.enable===!0)return!0;if(e.flags.disable===!0)return!1}function fs(e,t){if(e!==void 0){if(e==="yes"||e==="true")return!0;if(e==="no"||e==="false")return!1;throw g(`--${t} is yes or no`)}}function Ie(e){return e===void 0?void 0:(Array.isArray(e)?e:[e]).flatMap(n=>String(n).split(",")).map(n=>n.trim()).filter(n=>n!=="")}function Te(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<0)throw g(`--${t} is a whole number`);return n}var Pi={enable:{type:"boolean",description:"turn it on"},disable:{type:"boolean",description:"turn it off"}};async function Se(e,t,n){try{await n(),e.done(t)}catch(s){if(!(s instanceof W))throw s;e.left(`${t}: refused \u2014 ${s.message}`)}}function We(e,t){return e.filter(n=>n.key.startsWith(t)).map(n=>({...n,name:n.key.slice(t.length)}))}function Yl(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>!(t==null||t===""||Array.isArray(t)&&t.length===0)))}import{writeFile as Hk}from"node:fs/promises";var Vk=/^[A-Z][A-Z0-9_]{0,127}$/,Aa={dev:{type:"boolean",description:"the development set (what a backend on a developer's computer reads, and a machine started with it), not production \u2014 whatever the environment is named"}};function Pa(e){return e.flags.dev===!0?"development":"production"}function Ri(e){let t=e.args[0];if(!Vk.test(t))throw g(`${JSON.stringify(t)} is not a secret's name: capital letters, digits and _, a letter first`);return t}async function Zl(e,t,n){try{let s=await us(async a=>{let i=await h(e,t,"GET",`/machines?limit=100&environment=${encodeURIComponent(t.env_ref)}${a?`&cursor=${encodeURIComponent(a)}`:""}`);return{items:i.machines,next:i.next_cursor}});return{using:s.filter(a=>a.secrets===n).map(a=>a.name).sort(),others:s.filter(a=>a.secrets!==n)}}catch(s){return{unread:s instanceof Error?s.message:String(s)}}}function Ql(e,t,n,s){if("unread"in s){e.out.note(`which machines start with the ${n} set could not be read (${s.unread}): palbase machines:list -E ${t.env_slug} says each one's`);return}if(s.using.length>0){let o=s.using.join(", ");e.out.line(`${o} ${s.using.length===1?"starts":"start"} with the ${n} set: rolling out with the new value \u2014 palbase machines:list -E ${t.env_slug} shows it until every copy runs it.`);return}let a=n==="production"?"development":"production",i=n==="development"?" Only a backend run on a computer (palbase run, env:pull) reads it.":"";if(s.others.length===0){n==="production"&&e.out.note(`${se(t)} has no machine yet: one started with the ${n} set reads it.`);return}let r=s.others.map(o=>`${o.name} starts with ${o.secrets?`the ${o.secrets} set`:"no set"}`).join(", ");e.out.warn(`no machine of ${se(t)} starts with the ${n} set (${r}): this value reaches none of them.${i} palbase machines:update <name> --secrets ${n} starts a machine with it; ${n==="production"?"--dev writes":"leaving --dev out writes"} the ${a} set.`)}async function Ra(e,t,n){let s=[],a;do{let i=await h(e,t,"GET",`/secrets/${n}?limit=1000${a?`&cursor=${encodeURIComponent(a)}`:""}`);s.push(...i.secrets),a=i.next_cursor}while(a);return s}var Xk={name:"secrets:list",summary:"the environment's secrets by name, with their version \u2014 never their values",usage:"[--dev]",flags:Aa,scope:"environment",async run(e){let t=await w(e),n=Pa(e),s=await Ra(e,t,n);e.out.result({set:n,secrets:s},()=>{s.length===0&&e.out.line(`No ${n} secrets.`);for(let a of s)e.out.line(`${a.name} v${a.version} ${a.updated_at}`)})}},Yk={name:"secrets:set",summary:"set a secret: its value is read from stdin, never from the command line",usage:"<NAME> [--dev] < value",details:["An environment has two sets, production and development, whatever the environment is named: Development's machines may start with its production set. A machine starts with the set it names (machines:update --secrets), and a change of that set rolls it out with the new value; a backend run with palbase run or env:pull reads development.","It says which of the environment's machines start with the set, and warns when none does."],args:{min:1,max:1},flags:Aa,scope:"environment",async run(e){let t=await w(e),n=Ri(e),s=Pa(e),a=await ut(e,`the value of ${n}`);await k(e,t,`set the ${s} secret ${n}`);let i=await h(e,t,"PUT",`/secrets/${s}/${n}`,{value:a}),r=await Zl(e,t,s);e.out.result({set:s,name:n,version:i.version,environment:t.env_slug,machines:"using"in r?r.using:null},()=>{e.out.line(`Set ${n} v${i.version} in the ${s} set of ${se(t)}.`),Ql(e,t,s,r)})}},Zk={name:"secrets:unset",summary:"take a secret away",usage:"<NAME> [--dev]",args:{min:1,max:1},flags:Aa,scope:"environment",async run(e){let t=await w(e),n=Ri(e),s=Pa(e);await k(e,t,`take away the ${s} secret ${n}`),await h(e,t,"DELETE",`/secrets/${s}/${n}`);let a=await Zl(e,t,s);e.out.result({set:s,name:n,deleted:!0,environment:t.env_slug,machines:"using"in a?a.using:null},()=>{e.out.line(`Took ${n} away from the ${s} set of ${se(t)}.`),Ql(e,t,s,a)})}},Qk={name:"secrets:get",summary:"print one development secret's value (an admin's): a production secret's is never read back",usage:"<NAME> --dev",details:["A production secret's value is never read back, by anyone: only the machines that start with it are given it, and it is changed by setting it again (secrets:set). The development set is what a backend on your computer reads (palbase run, env:pull): secrets:get NAME --dev prints one."],args:{min:1,max:1},flags:Aa,scope:"environment",async run(e){let t=await w(e),n=Ri(e),s=await h(e,t,"GET",`/secrets/${Pa(e)}/${n}`);e.out.result({name:n,version:s.version,value:s.value},()=>e.out.line(s.value))}},eS={name:"secrets:versions",summary:"a secret's versions, newest first \u2014 never their values",usage:"<NAME> [--dev]",args:{min:1,max:1},flags:Aa,scope:"environment",async run(e){let t=await w(e),n=Ri(e),s=await h(e,t,"GET",`/secrets/${Pa(e)}/${n}/versions`);e.out.result(s,()=>{for(let a of s.versions)e.out.line(`v${a.version} ${a.created_at}${a.current?" (current)":""}`)})}},tS={name:"secrets:rollback",summary:"put a secret back to one of its versions (a new version with that value)",usage:"<NAME> --version <n> [--dev]",args:{min:1,max:1},flags:{...Aa,version:{type:"string",value:"n",description:"the version to go back to"}},scope:"environment",async run(e){let t=await w(e),n=Ri(e),s=Number(e.flags.version);if(!Number.isInteger(s)||s<1)throw g("--version is a version number (secrets:versions lists them)");let a=Pa(e);await k(e,t,`put the ${a} secret ${n} back to v${s}`);let i=await h(e,t,"POST",`/secrets/${a}/${n}/rollback`,{version:s}),r=await Zl(e,t,a);e.out.result({set:a,name:n,version:i.version,environment:t.env_slug,machines:"using"in r?r.using:null},()=>{e.out.line(`${n} in the ${a} set of ${se(t)} is v${s}'s value again, as v${i.version}.`),Ql(e,t,a,r)})}},nS={name:"secrets:audit",summary:"every read and write of the environment's secrets, newest first: which secret, which key did it, when \u2014 never a value",usage:"[--name <NAME>] [--dev | --prod] [--limit <n>]",details:["A backend that reads the secrets at boot (palbase run, a machine) shows here as a read, with the key it read with: palbase keys:list names the key.","An encrypted column's values opened through Palbase (Studio's table, a secret key) are recorded under the column's address: --name patients.tc lists who opened them, and when."],flags:{name:{type:"string",value:"NAME",description:"only this secret's, or an encrypted field's opens (table.column)"},dev:{type:"boolean",description:"only the development secrets"},prod:{type:"boolean",description:"only the production secrets"},limit:{type:"string",value:"n",description:"how many (default 30)"}},scope:"environment",async run(e){let t=await w(e);if(e.flags.dev===!0&&e.flags.prod===!0)throw g("--dev or --prod, not both");let n=Number(e.flags.limit??30);if(!Number.isInteger(n)||n<1||n>500)throw g("--limit is a whole number from 1 to 500");let s=new URLSearchParams({limit:String(n),...e.flags.name?{name:e.flags.name}:{},...e.flags.dev===!0?{environment:"development"}:e.flags.prod===!0?{environment:"production"}:{}}),a=await h(e,t,"GET",`/secrets/audit?${s}`);e.out.result(a,()=>{a.entries.length===0?e.out.line("No read or write of a secret yet."):e.out.table(a.entries,[{header:"when",value:i=>i.at.slice(0,19).replace("T"," ")},{header:"what",value:i=>i.action},{header:"set",value:i=>i.environment??""},{header:"secret",value:i=>i.name?`${i.name}${i.version?` v${i.version}`:""}`:"every one"},{header:"key",value:i=>i.key_id}])})}};function Gu(e,t){e.out.table(t.keys,[{header:"key",value:n=>`${n.id}${n.id===t.current?" (in force)":""}`},{header:"in force from",value:n=>n.activates_at.slice(0,19).replace("T"," ")},{header:"made by",value:n=>n.created_by}])}var sS={name:"fields:list",summary:"the keys the environment's encrypted database fields are sealed with \u2014 never the keys themselves",scope:"environment",async run(e){let t=await w(e),n=await h(e,t,"GET","/secrets/fields");e.out.result(n,()=>Gu(e,n))}},aS={name:"fields:rotate",summary:"make a new key for the environment's encrypted fields (an owner's or an admin's)",details:["It comes into force in five minutes: by then every running backend has fetched it. New values are sealed with it from then on; a palbase/backend app seals its older values again with it, in the background.","The older keys go on opening what they sealed."],scope:"environment",async run(e){let t=await w(e);await k(e,t,"rotate the encrypted fields' key");let n=await h(e,t,"POST","/secrets/fields/rotate"),s=n.keys[n.keys.length-1];e.out.result(n,()=>{e.out.line(`Made ${s.id} in ${se(t)}: in force from ${s.activates_at.slice(0,19).replace("T"," ")} UTC.`),Gu(e,n)})}},iS={name:"fields:keys",summary:"download the environment's field keys into a file (its owner's): what opens a dump of its database elsewhere",usage:"--out <file>",details:["The file opens every encrypted field of the environment: keep it as you would the database's password. It is the shape palbase/server's Fields reads: new Fields({ fetch: async () => JSON.parse(readFileSync(file, 'utf8')) }).","The download is in the secrets audit trail (secrets:audit)."],flags:{out:{type:"string",value:"file",description:"where the keys go (made readable by you alone); never the screen"}},scope:"environment",async run(e){let t=e.flags.out;if(!t)throw g("fields:keys writes the keys into a file: --out <file> (never onto the screen, which keeps them)");let n=await w(e),s=await h(e,n,"GET","/secrets/fields/keys");await Hk(t,`${JSON.stringify(s,null,2)}
|
|
22
22
|
`,{mode:384,flag:"wx"}),e.out.result({file:t,keys:s.keys.map(a=>a.id)},()=>e.out.line(`Wrote the keys of ${se(n)} (${s.keys.map(a=>a.id).join(", ")}) to ${t}.`))}};function ed(e,t){e.out.table(t.keys,[{header:"key",value:n=>`${n.id}${n.id===t.current?" (in use)":""}`},{header:"made",value:n=>n.created_at.slice(0,19).replace("T"," ")},{header:"made by",value:n=>n.created_by},{header:"retired",value:n=>n.retired_at?`${n.retired_at.slice(0,19).replace("T"," ")} by ${n.retired_by}`:""}])}var rS={name:"transit:list",summary:"the keys the encrypted fields of a request to the environment's backend are sealed to \u2014 their public halves alone",scope:"environment",async run(e){let t=await w(e),n=await h(e,t,"GET","/secrets/transit");e.out.result(n,()=>ed(e,n))}},oS={name:"transit:rotate",summary:"make a new key for the encrypted fields of requests to the backend (an owner's or an admin's)",usage:"[--retire-previous]",details:["Apps seal to it from their next fetch of the project's keys (within the hour), or at once with --retire-previous: every older key is retired with it \u2014 what to do when one may have been taken \u2014 and an app that seals to a retired one is told so, fetches the keys again and sends its call once more.","No app needs a new build: an app holds the project's signing key, not its keys."],flags:{"retire-previous":{type:"boolean",description:"retire every older key at once"}},scope:"environment",async run(e){let t=await w(e),n=e.flags["retire-previous"]===!0;await k(e,t,n?"rotate the transit keys, retiring every older one":"rotate the transit keys");let s=await h(e,t,"POST","/secrets/transit/rotate",{retire_previous:n});e.out.result(s,()=>{e.out.line(`Made ${s.current} in ${se(t)}: apps seal to it from now${n?"; every older key is retired":""}.`),ed(e,s)})}},lS={name:"transit:retire",summary:"retire a transit key that is not the one in use: no request sealed to it opens from then on",usage:"<key>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=e.args[0];if(!/^t[1-9][0-9]{0,5}$/.test(n))throw g(`${n} is not a transit key's id`,"palbase transit:list names them (t1, t2, \u2026)");await k(e,t,`retire the transit key ${n}`);let s=await h(e,t,"POST",`/secrets/transit/${n}/retire`);e.out.result(s,()=>{e.out.line(`Retired ${n} in ${se(t)}.`),ed(e,s)})}},qu=[Xk,Yk,Qk,Zk,eS,tS,nS,sS,aS,iS,rS,oS,lS];import{randomBytes as dm}from"node:crypto";import{chmod as jS,lstat as OS,readFile as am,rename as NS,writeFile as im}from"node:fs/promises";function Uu(){let e=globalThis;if(typeof e.document<"u"||e.navigator?.product==="ReactNative")return!0;let t=e.navigator?.userAgent;return typeof t=="string"&&t.startsWith("Mozilla/")}var Jn=class extends Error{code;constructor(t,n){super(n),this.name="FieldError",this.code=t}},zr="pbe1.",dS="pbl1.",pS=6e4,td="[A-Za-z_][A-Za-z0-9_$]{0,62}",cS=new RegExp(`^${td}\\.${td}(\\.${td})?$`);function uS(e){return cS.test(e)}var Ei=class{crypto;keys=new Map;lookupKey;timer;opts;now;constructor(t){this.opts=t,this.now=t.now??Date.now}get loaded(){return this.lookupKey!==void 0}async load(t){this.crypto??=await import("node:crypto"),this.take(await this.opts.fetch(t)),this.timer===void 0&&(this.timer=setInterval(()=>{this.opts.fetch().then(n=>this.take(n),()=>{})},pS),this.timer.unref?.())}close(){clearInterval(this.timer),this.timer=void 0}take(t){let n=new Map;for(let s of t.keys)n.set(s.id,{id:s.id,key:Buffer.from(s.key,"base64url"),activatesAt:Date.parse(s.activates_at)});this.keys=n,this.lookupKey=Buffer.from(t.lookup,"base64url")}ready(){if(this.crypto===void 0||this.lookupKey===void 0)throw new Jn("not_loaded","the project's field keys are not loaded: await palbase.fields.load() at startup");return this.crypto}currentKey(){this.ready();let t;for(let n of this.keys.values())n.activatesAt<=this.now()&&(t===void 0||n.activatesAt>=t.activatesAt)&&(t=n);if(t===void 0)throw new Jn("unknown_key","the project has no field key in force");return t.id}encrypt(t,n){let s=this.ready();nd(t);let a=this.currentKey(),i=s.randomBytes(12);return mS(s,this.keys.get(a).key,i,a,t,n)}decrypt(t,n){let s=this.ready();if(nd(t),!n.startsWith(zr))throw new Jn("not_encrypted",`${t} holds a value that is not encrypted`);let a=n.slice(zr.length),i=a.indexOf("."),r=i<0?a:a.slice(0,i),o=this.keys.get(r);if(o===void 0)throw new Jn("unknown_key",`${t} was sealed with field key ${r}, which this project does not hold`);let l=Buffer.from(a.slice(i+1),"base64url");if(i<0||l.length<28||l.toString("base64url")!==a.slice(i+1))throw new Jn("unopenable",`${t} holds a value that does not open here`);try{let d=s.createDecipheriv("aes-256-gcm",o.key,l.subarray(0,12));return d.setAAD(Ku(t)),d.setAuthTag(l.subarray(l.length-16)),Buffer.concat([d.update(l.subarray(12,l.length-16)),d.final()]).toString("utf8")}catch{throw new Jn("unopenable",`${t} holds a value that does not open here: tampered, or another column's`)}}isEncrypted(t){return t.startsWith(zr)}lookup(t,n){let s=this.ready();return nd(t),hS(s,this.lookupKey,t,n)}};function nd(e){if(!uS(e))throw new TypeError(`a field's address is table.column, or schema.table.column, not ${JSON.stringify(e)}`)}function Ku(e){return Buffer.from(`pbe1\0${e}`,"utf8")}function mS(e,t,n,s,a,i){let r=e.createCipheriv("aes-256-gcm",t,n);r.setAAD(Ku(a));let o=Buffer.concat([n,r.update(i,"utf8"),r.final(),r.getAuthTag()]);return`${zr}${s}.${o.toString("base64url")}`}function hS(e,t,n,s){let a=e.createHmac("sha256",t);return a.update(`pbl1\0${n}\0`,"utf8"),a.update(s,"utf8"),`${dS}${a.digest("base64url")}`}var ad="pbt1.",pn="Palbase-Encryption";var Vr="x-palbase-encrypted",st=class extends Error{code;constructor(t,n){super(n),this.name="TransitError",this.code=t}},ys=new TextEncoder,gS=new TextDecoder("utf-8",{fatal:!0}),cn=()=>{let e=globalThis.crypto?.subtle;if(!e)throw new Error("encrypted fields need WebCrypto (crypto.subtle): a secure context \u2014 https, or localhost");return e};function At(e){return new Uint8Array(new ArrayBuffer(e))}function un(...e){let t=At(e.reduce((s,a)=>s+a.length,0)),n=0;for(let s of e)t.set(s,n),n+=s.length;return t}function Pn(e){return un(e)}function Ci(e,t){let n=At(t);for(let s=t-1;s>=0;s--)n[s]=e&255,e>>>=8;return n}function ji(e){let t="";for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Rn(e){let t=e.replace(/=+$/,"");if(!/^[A-Za-z0-9_-]*$/.test(t)||t.length%4===1)throw new st("malformed","not base64url");let n=atob(t.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-t.length%4)%4)),s=At(n.length);for(let a=0;a<n.length;a++)s[a]=n.charCodeAt(a);return s}var Fu=un(ys.encode("KEM"),Ci(32,2)),Ti=un(ys.encode("HPKE"),Ci(32,2),Ci(1,2),Ci(1,2)),Bu=ys.encode("HPKE-v1"),fS=16,yS=12,bS=32,Wu=Uint8Array.from([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]);async function zu(e,t){let n=await cn().importKey("raw",e.length===0?At(32):Pn(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return new Uint8Array(await cn().sign("HMAC",n,Pn(t)))}async function Jr(e,t,n,s){return zu(t,un(Bu,e,ys.encode(n),s))}async function sd(e,t,n,s,a){let i=un(Ci(a,2),Bu,e,ys.encode(n),s),r=At(a),o=At(0);for(let l=1,d=0;d<a;l++)o=await zu(t,un(o,i,Uint8Array.of(l))),r.set(o.subarray(0,Math.min(o.length,a-d)),d),d+=o.length;return r}async function Ju(e){if(e.length!==32)throw new st("malformed","an X25519 private key is 32 bytes");return cn().importKey("pkcs8",un(Wu,e),{name:"X25519"},!1,["deriveBits"])}async function Hu(e){if(e.length!==32)throw new st("malformed","an X25519 public key is 32 bytes");return cn().importKey("raw",Pn(e),{name:"X25519"},!1,[])}async function Vu(e,t){return new Uint8Array(await cn().deriveBits({name:"X25519",public:t},e,256))}async function Xu(e,t,n){let s=await Jr(Fu,At(0),"eae_prk",e);return sd(Fu,s,"shared_secret",un(t,n),bS)}async function Yu(e,t){let n=await Jr(Ti,At(0),"psk_id_hash",At(0)),s=await Jr(Ti,At(0),"info_hash",t),a=un(Uint8Array.of(0),n,s),i=await Jr(Ti,e,"secret",At(0));return{key:await sd(Ti,i,"key",a,fS),nonce:await sd(Ti,i,"base_nonce",a,yS)}}async function Xr(e,t,n,s,a){let i=await cn().importKey("raw",Pn(t),"AES-GCM",!1,[e]);return new Uint8Array(await cn()[e]({name:"AES-GCM",iv:Pn(n),additionalData:Pn(s)},i,Pn(a)))}async function id(e,t,n,s=At(0),a){let i,r;if(a)i=await Ju(a.privateKey),r=Pn(a.publicKey);else{let p=await cn().generateKey({name:"X25519"},!0,["deriveBits"]);i=p.privateKey,r=new Uint8Array(await cn().exportKey("raw",p.publicKey))}let o=await Xu(await Vu(i,await Hu(e)),r,e),{key:l,nonce:d}=await Yu(o,t);return{enc:r,ct:await Xr("encrypt",l,d,s,n)}}async function wS(e,t,n,s,a,i=At(0)){if(n.length!==32)throw new st("malformed","an encapsulated X25519 key is 32 bytes");try{let r=await Xu(await Vu(await Ju(e),await Hu(n)),n,t),{key:o,nonce:l}=await Yu(r,s);return await Xr("decrypt",o,l,i,a)}catch{throw new st("unopenable","the request's key does not open with the project's key it names")}}async function Zu(e){let t=await cn().importKey("pkcs8",un(Wu,e),{name:"X25519"},!0,["deriveBits"]),n=await cn().exportKey("jwk",t);return Rn(n.x)}function Yr(e,t,n,s=[]){if(s.some(a=>a.includes("\0")))throw new st("malformed","a path's value holds no NUL");return ys.encode(["palbase-encryption","1",e,t.toUpperCase(),vS(n),...s].join("\0"))}function vS(e){return e.replace(/\{[^/{}]*\}/g,"{}")}async function Qu(e,t,n,s={}){let a=s.key?Pn(s.key):crypto.getRandomValues(At(32)),{enc:i,ct:r}=await id(t,n,a,At(0),s.ephemeral);return{kid:e,key:a,header:`1.${e}.${ji(i)}.${ji(r)}`}}function rd(e){let t=e.trim().split(".");if(t.length!==4||t[0]!=="1"||!/^t[1-9][0-9]{0,5}$/.test(t[1]))throw new st("malformed",`${pn} is 1.<key id>.<enc>.<ct>`);let n=Rn(t[2]),s=Rn(t[3]);if(n.length!==32||s.length!==48)throw new st("malformed",`${pn} carries a 32-byte encapsulated key and a sealed 32-byte key`);return{kid:t[1],enc:n,ct:s}}async function em(e,t,n,s){let{enc:a,ct:i}=rd(e),r=await wS(t,n,a,s,i);if(r.length!==32)throw new st("unopenable","the request's key is not 32 bytes");return r}function tm(e){return ys.encode(`pbt1\0${e}`)}async function Oi(e,t,n,s){let a=s?Pn(s):crypto.getRandomValues(At(12)),i=JSON.stringify(n);if(i===void 0)throw new st("malformed",`${t}: an encrypted field holds a JSON value`);let r=await Xr("encrypt",e,a,tm(t),ys.encode(i));return ad+ji(un(a,r))}function Ni(e){return typeof e=="string"&&e.startsWith(ad)}async function Zr(e,t,n){if(!Ni(n))throw new st("unopenable",`${t} is not an encrypted field`);let s;try{s=Rn(n.slice(ad.length))}catch{throw new st("unopenable",`${t} is not an encrypted field`)}if(s.length<28)throw new st("unopenable",`${t} is too short to be an encrypted field`);let a;try{a=await Xr("decrypt",e,s.subarray(0,12),tm(t),s.subarray(12))}catch{throw new st("unopenable",`${t} does not open: changed, moved from another field, or another request's`)}try{return JSON.parse(gS.decode(a))}catch{throw new st("unopenable",`${t} opens to no JSON value`)}}function Qr(e){return e.replace(/~/g,"~0").replace(/\//g,"~1").replace(/\*/g,"~2")}function _S(e){return e.replace(/~2/g,"*").replace(/~1/g,"/").replace(/~0/g,"~")}var nm=Symbol("items");function $S(e,t){if(!(e!==t&&!e.startsWith(t+"/")))return e===t?[]:e.slice(t.length+1).split("/").map(n=>n==="*"?nm:_S(n))}async function Ea(e,t,n,s){let a=e;for(let i of n){let r=$S(i,t);r!==void 0&&(a=await Hr(a,r,t,s))}return a}async function Hr(e,t,n,s){if(t.length===0)return e===void 0?void 0:s(n,e);let[a,...i]=t;if(a===nm){if(!Array.isArray(e))return e;let o=[];for(let[l,d]of e.entries())o.push(await Hr(d,i,`${n}/${l}`,s));return o}if(Array.isArray(e)){if(!/^(0|[1-9][0-9]*)$/.test(a)||Number(a)>=e.length)return e;let o=[...e];return o[Number(a)]=await Hr(o[Number(a)],i,`${n}/${a}`,s),o}if(typeof e!="object"||e===null||Array.isArray(e)||!Object.hasOwn(e,a))return e;let r={...e};return r[a]=await Hr(r[a],i,`${n}/${Qr(a)}`,s),r}var mn=class extends Error{status=400;code;data;constructor(t,n,s={}){super(n),this.name="TransitRefusal",this.code=t,this.data=s}},kS=6e4,SS=1e3;function od(e){return/^t[1-9][0-9]{0,5}$/.test(e)?Number(e.slice(1)):0}var Ii=class{keys=new Map;retired=new Set;order=[];project;timer;fetchedAt=0;heldFrom=0;fetching;opts;now;sleep;constructor(t){this.opts=t,this.now=t.now??Date.now,this.sleep=t.sleep??(n=>new Promise(s=>setTimeout(s,n)))}get loaded(){return this.project!==void 0}get projectId(){if(this.project===void 0)throw new Error("the project's transit keys are not loaded: await palbase.transit.load() at startup");return this.project}current(){return this.order[0]}async load(t){await this.refresh(t),this.timer===void 0&&(this.timer=setInterval(()=>{this.refresh().catch(()=>{})},kS),this.timer.unref?.())}close(){clearInterval(this.timer),this.timer=void 0}refresh(t){return this.fetching??=(async()=>{let n=this.now();try{let s=await this.opts.fetch(t),a=new Map;for(let i of s.keys){let r=Rn(i.key);a.set(i.id,{privateKey:r,publicKey:this.keys.get(i.id)?.publicKey??await Zu(r)})}this.keys=a,this.order=s.keys.map(i=>i.id),this.retired=new Set(s.retired),this.project=s.project,this.fetchedAt=this.now(),this.heldFrom=n}finally{this.fetching=void 0}})(),this.fetching}newest(){return Math.max(0,...this.order.map(od),...[...this.retired].map(od))}async key(t){let n=this.now();for(;od(t)>this.newest()&&this.heldFrom<n;){let i=this.fetchedAt+SS-this.now();if(i>0){await this.sleep(i);continue}await this.refresh()}let s=this.keys.get(t),a=this.current();if(this.retired.has(t))throw new mn("encryption_key_retired",`the request is sealed to ${t}, retired: fetch the project's keys again`,{current:a});if(s===void 0)throw new mn("encryption_key_unknown",`the request is sealed to ${t}, which the project has not made`,{current:a});return s}async request(t){if(t.header===void 0||t.header===null||t.header==="")throw new mn("encryption_required",`this route carries encrypted fields: the request names its key in ${pn}`,{field:pn,current:this.current()});let n;try{n=rd(t.header).kid}catch{throw new mn("encryption_unopenable",`${pn} is not one`,{field:pn})}let s=await this.key(n),a;try{a=Yr(this.projectId,t.method,t.path,t.params??[])}catch{throw new mn("encryption_unopenable","the request's path holds a value no key is sealed for",{field:pn})}try{return new eo(n,await em(t.header,s.privateKey,s.publicKey,a))}catch(i){throw i instanceof st?new mn("encryption_unopenable","the request's key does not open: sealed for another project, route or path, or changed",{field:pn}):i}}},eo=class{kid;key;constructor(t,n){this.kid=t,this.key=n}async open(t,n,s){return Ea(t,n,s,async(a,i)=>{if(!Ni(i))throw new mn("encryption_required",`${a} is an encrypted field: it came plain`,{field:a});try{return await Zr(this.key,a,i)}catch{throw new mn("encryption_unopenable",`${a} does not open: changed, moved from another field, or another request's`,{field:a})}})}async seal(t,n){return Ea(t,"/response",n,(s,a)=>Oi(this.key,s,a))}sealField(t,n){return Oi(this.key,t,n)}};var AS=/^pb_[a-z0-9]+_s/;function to(e){if(Uu())throw new TypeError("palbase/server runs on a server: its secret key never goes into a browser or a mobile app \u2014 apps use palbase/web (or the native SDKs) with the publishable key");if(typeof e.secretKey!="string"||!AS.test(e.secretKey))throw new TypeError("secretKey is the project secret key (pb_<ref>_s\u2026); a publishable key belongs in palbase/web");let t=Bl(Dl({baseUrl:e.url,credentials:{secretKey:e.secretKey},fetch:e.fetch,solveProofOfWork:e.solveProofOfWork??!1}),e.retry??Kr),n=_i.client(t);return{ai:xr.client(t),analytics:hi.client(t),auth:gi.client(t),cache:Gr.client(t),calls:qr.client(t),fields:new Ei({fetch:async s=>(await n.getFieldKeys({signal:s})).data}),flags:fi.client(t),machines:yi.client(t),messaging:Ur.client(t),notify:bi.client(t),purchases:wi.client(t),realtime:vi.client(t),secrets:n,storage:$i.client(t),stores:ki.client(t),transit:new Ii({fetch:async s=>(await n.getTransitKeys({signal:s})).data}),transport:t,url:new URL(e.url).origin}}var mU=1024*1024;var fU=8*1024;var $U=16*1024,kU=10*6e4;var ES=/^[A-Za-z_][A-Za-z0-9_]{0,127}$/,TS=/^(PALBASE_|NODE_|BUN_|NPM_|LD_|DYLD_|GIT_|SSH_)|^(PATH|HOME|SHELL|USER|TMPDIR|TMP|TEMP|PWD|IFS|ENV|BASH_ENV|SSL_CERT_FILE|SSL_CERT_DIR|CURL_CA_BUNDLE|REQUESTS_CA_BUNDLE|NO_PROXY|ALL_PROXY|HTTP_PROXY|HTTPS_PROXY|PG\w*)$/i;function ld(e){return!ES.test(e)||TS.test(e)||/_PROXY$/i.test(e)}var CS=/^(PORT|PALBASE_(URL|PROJECT_ID|MACHINE|REPLICAS|SECRET_KEY|WEBHOOK_SECRET|PLATFORM_SECRET|CONTRACT_OUT|SECRETS|DB_[A-Z0-9_]+))$/;function dd(e){return CS.test(e)}import"node:os";import{join as IS,resolve as LS}from"node:path";var dK=10080*60*1e3,sm="# >>> palbase (palbase env:pull writes this block; edit outside it)",pd="# <<< palbase";async function Li(e,t){let n=await Wl(e.studio,t.env_ref),{keys:s}=await e.studio.get(`/environments/${ee("the environment's ref",t.env_ref)}/keys`),a=s.find(i=>i.id===n.id);return a&&!a.revoked_at?n:Wl(e.studio,t.env_ref,!0)}async function no(e,t){return{...await ud(e,t),key:await Li(e,t)}}async function ud(e,t){let n=await e.studio.get(`/environments/${t.env_ref}`);return{url:Wt(e.cloud,t.env_ref),projectId:n.platform_id}}var so="development",rm={name:"env:pull",summary:"write what the backend needs to run here into .env.local: the environment's address and your own key \u2014 no secret's value",usage:"[--file <path>]",details:["The app reads the project's development secrets at boot (PALBASE_SECRETS=development); their names are listed as comments: set one in the file to override it. A production secret's value is never read back: only the machines that start with it are given it.","The key is yours (CLI \u2014 you (this computer)), good for 30 days, made again by env:pull and run; palbase logout revokes it.","Only the block between the palbase markers is written; the rest of the file stays as it is."],flags:{file:{type:"string",value:"path",description:"the file (default .env.local)"}},scope:"environment",async run(e){let t=await w(e),n=so;t.env_slug===Et&&await k(e,t,"write a key of the production environment into a file on this computer");let s=await no(e,t),a=await Ve(e.studio,t.env_ref,"GET",`/secrets/${n}`).then(f=>(f.body.secrets??f.body.items??[]).map(b=>b.name).filter(b=>typeof b=="string"&&!ld(b)).sort(),()=>[]),i=LS(e.io.cwd,e.flags.file??".env.local"),r=[sm,`# ${cd(se(t))} \u2014 ${new Date(e.io.now()).toISOString()}`,`# PALBASE_SECRET_KEY is your own: ${cd(s.key.label)}, good until ${cd(s.key.expires_at)}.`,`PALBASE_URL=${s.url}`,`PALBASE_PROJECT_ID=${s.projectId}`,`PALBASE_SECRET_KEY=${s.key.key}`,`PALBASE_SECRETS=${n}`,...a.length>0?[`# The ${n} secrets, read at boot \u2014 set one here to override it:`,...a.map(f=>`# ${f}=`)]:[],pd].join(`
|
|
23
23
|
`),o="";try{if((await OS(i)).isSymbolicLink())throw new y("symlink",`${i} is a link: env:pull writes the key into a file of its own`,{hint:"remove the link, or pass --file <path>"});o=await am(i,"utf8")}catch(f){if(f.code!=="ENOENT")throw f}let l=o.indexOf(sm),d=o.indexOf(pd),p=l>=0&&d>l?`${o.slice(0,l)}${r}${o.slice(d+pd.length)}`:`${o}${o===""||o.endsWith(`
|
|
24
24
|
`)?"":`
|
|
@@ -669,21 +669,21 @@ ${Object.entries(e).map(([i,r])=>`${a}${JSON.stringify(i)}: ${$p(r,a,n)}`).join(
|
|
|
669
669
|
${t}}`}var Zn=e=>["",e.toUpperCase(),"-".repeat(e.length)],e2=[{title:"One package and the button that buys it",note:`The least a paywall is: a title, a package that says its own price, the purchase button, and the links App Review expects. Colors are the theme's tokens; "{{price}}" is filled by the app from its store.`,definition:{schema:2,name:"Simple",default_locale:"en",theme:{colors:{light:{background:"#FFFFFF",surface:"#F2F2F7",text:"#111114",muted:"#6B6B70",accent:"#5B5BD6",on_accent:"#FFFFFF"},dark:{background:"#000000",surface:"#1C1C1E",text:"#F5F5F7",muted:"#9A9AA0",accent:"#8E8EF5",on_accent:"#000000"}}},root:{type:"stack",spacing:16,align:"stretch",style:{padding:24,background:"background"},children:[{type:"text",text:"Go Pro",size:28,weight:700},{type:"spacer"},{type:"package",product:"pro",plan:"monthly",selected:!0,style:{padding:16,corners:14,background:"surface"},children:[{type:"text",text:"{{product_name}} \u2014 {{price}} / {{period}}",weight:600}]},{type:"purchase_button",style:{height:52,corners:14,background:"accent"},content:{type:"text",text:"Continue",color:"on_accent",weight:600}},{type:"stack",axis:"horizontal",spacing:24,distribution:"center",children:[{type:"button",action:{type:"restore"},visible:{platform:["ios","android"]},content:{type:"text",text:"Restore",size:13,color:"muted"}},{type:"button",action:{type:"terms"},content:{type:"text",text:"Terms",size:13,color:"muted"}},{type:"button",action:{type:"privacy"},content:{type:"text",text:"Privacy",size:13,color:"muted"}}]}]}}},{title:"Two packages, two languages, a trial said only to who can take it",note:`Texts are keys of the language table ({"t": key}); the package selected is drawn in its "states.selected" style; a text with "visible.intro_eligible" shows only while the customer can still take the selected package's trial, and one naming "{{savings}}" is not drawn for a package that saves nothing.`,definition:{schema:2,name:"Two plans",default_locale:"en",locales:{en:{title:"Read without limits",yearly:"Yearly",monthly:"Monthly",per:"{{price}} / {{period}}",save:"Save {{savings}}",cta:"Continue",cta_trial:"Try {{trial}}",then:"Then {{price}} a {{period}}. Cancel anytime."},es:{title:"Lee sin l\xEDmites",yearly:"Anual",monthly:"Mensual",per:"{{price}} / {{period}}",save:"Ahorra {{savings}}",cta:"Continuar",cta_trial:"Prueba {{trial}}",then:"Despu\xE9s, {{price}} al {{period}}. Cancela cuando quieras."}},theme:{colors:{light:{background:"#FBFAF7",surface:"#FFFFFF",text:"#111111",muted:"#77736B",accent:"#111111",on_accent:"#FBFAF7",stroke:"#1111111F"},dark:{background:"#0D0D0C",surface:"#1A1A18",text:"#F2F0EA",muted:"#8E8A82",accent:"#F2F0EA",on_accent:"#0D0D0C",stroke:"#F2F0EA24"}},typography:{title:{size:30,weight:700,text_style:"title"},row:{size:17,weight:600,text_style:"body"},caption:{size:13,weight:400,text_style:"footnote"}},radii:{card:14},spacing:{sm:8,md:16,lg:24}},root:{type:"stack",spacing:"md",align:"stretch",style:{padding:"lg",background:"background"},children:[{type:"text",text:{t:"title"},size:"title",align:"start"},{type:"spacer"},...["yearly","monthly"].map(e=>({type:"package",product:"pro",plan:e,selected:e==="yearly",style:{padding:"md",corners:"card",background:"surface",border:{width:1,color:"stroke"}},states:{selected:{border:{width:2,color:"accent"}}},children:[{type:"stack",axis:"horizontal",align:"center",children:[{type:"text",text:{t:e},size:"row",align:"start"},{type:"spacer"},{type:"stack",align:"end",children:[{type:"text",text:{t:"per"},size:"row"},{type:"text",text:{t:"save"},size:"caption",color:"muted"}]}]}]}))]},footer:{type:"stack",spacing:"sm",align:"stretch",style:{padding:"lg",background:"background"},children:[{type:"purchase_button",style:{height:52,corners:"card",background:"accent"},visible:{intro_eligible:!0},content:{type:"text",text:{t:"cta_trial"},size:"row",color:"on_accent"}},{type:"purchase_button",style:{height:52,corners:"card",background:"accent"},visible:{intro_eligible:!1},content:{type:"text",text:{t:"cta"},size:"row",color:"on_accent"}},{type:"text",text:{t:"then"},size:"caption",color:"muted"}]}}},{title:"A photograph, a sheet a button opens, and what only one platform shows",note:`An image names a project asset (palbase purchases:paywalls:assets:upload answers its asset:<id> \u2014 the id below is a placeholder); a button's action opens a sheet by its id; "visible.platform" keeps the offer code button to iOS.`,definition:{schema:2,name:"With a sheet",default_locale:"en",theme:{colors:{light:{background:"#FFFFFF",surface:"#F2F2F7",text:"#111114",muted:"#6B6B70",accent:"#FF5A36",on_accent:"#FFFFFF"},dark:{background:"#0B0B0F",surface:"#1C1C1E",text:"#F5F5F7",muted:"#9A9AA0",accent:"#FF7A5C",on_accent:"#0B0B0F"}}},header:{type:"image",src:"asset:00000000-0000-4000-8000-000000000000",alt:"A traveller at sunrise",fit:"fill",style:{height:220}},root:{type:"stack",spacing:16,align:"stretch",style:{padding:24,background:"background"},children:[{type:"text",text:"Your next trip, planned in minutes",size:26,weight:700,align:"start"},{type:"package",product:"pro",plan:"yearly",selected:!0,style:{padding:16,corners:14,background:"surface"},children:[{type:"text",text:"{{price}} a {{period}}",weight:600}]},{type:"button",action:{type:"sheet",sheet:"details"},content:{type:"text",text:"What is included?",color:"accent"}},{type:"button",action:{type:"offer_code"},visible:{platform:["ios"]},content:{type:"text",text:"Redeem a code",size:13,color:"muted"}}]},footer:{type:"stack",align:"stretch",style:{padding:24,background:"background"},children:[{type:"purchase_button",style:{height:52,corners:26,background:"accent"},content:{type:"text",text:"Continue",color:"on_accent",weight:600}}]},sheets:{details:{title:"What is included",root:{type:"stack",spacing:12,align:"stretch",style:{padding:24},children:[{type:"features",items:[{icon:"globe",text:"Offline maps for 190 countries"},{icon:"sparkles",text:"Itineraries that adapt"},{icon:"bell",text:"Price alerts"}]},{type:"button",action:{type:"close"},content:{type:"text",text:"Close",color:"accent"}}]}}}}}];function Aw(e){let t=e.$defs,n=t[bw],s=t[ww].oneOf.map(l=>Yo(l)),a=s.map(l=>new Set(Object.keys(t[l].properties))).reduce((l,d)=>new Set([...l].filter(p=>d.has(p)))),i=l=>String(t[l].properties.type.enum[0]),r=[];r.push(`PAYWALL DEFINITIONS \u2014 writing one by hand (schema ${n.properties.schema?.description?.match(/: (\d+)\./)?.[1]??"2"})`),r.push("",...Ot(String(e.description??""),"")),r.push(...Zn("The flow")),r.push(" palbase purchases:paywalls the paywalls, their draft revisions, where each is shown"," palbase purchases:paywalls:templates the module's designs to start from"," palbase purchases:paywalls:new <name> --template <key> a template to a file, selling the catalog's packages"," palbase purchases:paywalls:get <name> writes palbase/paywalls/<name>.json and prints its revision"," (edit the file: its first line names palbase/paywalls/paywall.schema.json, which an editor checks it against)"," palbase purchases:paywalls:validate --file <file> every problem \u2014 path: code \u2014 sentence; exit 1 while one is left"," palbase purchases:paywalls:preview --file <file> a PNG to look at; --all: every platform, appearance and text size"," palbase purchases:paywalls:check --file <file> what is wrong on every screen: overflow, cut text, contrast \u2026; exit 1 while one is left, 4 when it could not be drawn"," palbase purchases:paywalls:put <name> --file <file> --revision <n> [--publish]"," palbase purchases:paywalls:publish <name> the draft becomes what the apps draw",' palbase purchases:placements:set <placement> --paywall <name> an app asks for a placement: pb.purchases.paywall("<placement>")',""," A new paywall: start from a template (new), or write the file (an example below is one); put it with --revision 0."," A problem's path is where it is in the file: root.children[2].content.text. Fix it there, validate again."," Look before saving: preview draws the file, not the saved draft. --package, --state tab=<id>,switch=on|off,sheet=<id>"," and --locale draw the states a customer puts it in."),r.push(...Zn("The definition")," (* is required; nothing the schema does not name is taken)"),r.push(...Ja(n,new Set(["$schema"]))),r.push("",...Ot("header and footer stay fixed; root scrolls between them. Each is one component \u2014 a stack, to hold more than one."," ")),r.push(...Zn("The theme")),r.push(...Ot(String(t.PaywallTheme?.description??"")," "),...Ja(t.PaywallTheme)),r.push(" colors:",...Ot(String(t.PaywallColors?.description??"")," "),...Ot(String(t.PaywallPalette?.description??"")," ")),r.push(" a typography token:",...Ja(t.PaywallTypography).map(l=>` ${l}`)),r.push(...Ot("Wherever a field takes a color, points or a size, it takes a token of the theme (by its name) or the value itself."," ")),r.push(...Zn("Texts and variables")),r.push(...Ot(String(t.PaywallString?.description??"")," "),...Ot(String(t.PaywallLocales?.description??"")," "),...Ot(String(t.PaywallTexts?.description??"")," ")),r.push(...Zn("Every component takes"));for(let l of[...a].filter(d=>d!=="type").sort()){let d=t[s[0]].properties[l],p=Yo(d),c=Sw(l,d)||(p?String(t[p]?.description??""):"");r.push(` ${l}: ${Ha(d)}`),c!==""&&r.push(...Ot(c," ")),p&&t[p]?.properties&&r.push(...Ja(t[p]).map(m=>` ${m}`))}r.push(...Zn("Components"),' ("type" names one; its own fields follow, beside what every component takes)');for(let l of s)r.push("",` ${i(l)}`),r.push(...Ot(String(t[l].description??"")," ")),r.push(...Ja(t[l],a).map(d=>` ${d}`));let o=new Set([bw,ww,...s,"PaywallTheme","PaywallColors","PaywallPalette","PaywallTypography","PaywallTypeScale","PaywallScale","PaywallLocales","PaywallTexts","PaywallString","PaywallLiteral",...Object.keys(_w)]);for(let l of a){let d=Yo(t[s[0]].properties[l]);d&&o.add(d)}r.push(...Zn("Parts")," (what the fields above take, by the name they are given there)");for(let[l,d]of Object.entries(t))o.has(l)||(r.push("",` ${$w(l)}${d.properties?"":`: ${Ha(d)}${kw(d)}`}`),typeof d.description=="string"&&r.push(...Ot(d.description," ")),d.properties&&r.push(...Ja(d).map(p=>` ${p}`)));return r.push(...Zn("Assets")),r.push(...Ot(`An image, a video, a font or an HTML block is a file of the project: palbase purchases:paywalls:assets:upload <file> uploads and registers it and answers the asset:<id> a field takes (an image's or a video's "src", a typography's or a text's "font", a custom_html's "src"). palbase purchases:paywalls:assets lists them. An image or a video may name an https address instead: every app downloads it from there.`," ")),r.push(...Zn("Examples")),e2.forEach((l,d)=>{r.push("",` ${d+1}. ${l.title}`,...Ot(l.note," "),""),r.push(...$p(l.definition).split(`
|
|
670
670
|
`).map(p=>` ${p}`))}),`${r.join(`
|
|
671
671
|
`)}
|
|
672
|
-
`}var Zo={$schema:"https://json-schema.org/draft/2020-12/schema",title:"Palbase paywall definition",description:"A paywall: a design system (the theme's colors, type scale, radii and spacing) and a free layout of components that name it \u2014 a fixed header and footer around the part that scrolls, and sheets it opens. Every component takes a style, a condition to be shown, a style for when it is selected, and an entrance animation. Prices are never in it: an app fills `{{price}}` and the other variables from its store. Its assets (asset:<id>) are the project's, given as https addresses in the app's answer and listed for the app to download before it shows the paywall. The server refuses what it does not know and holds a definition to bounds: 128 KiB of JSON, 400 components, 16 deep, 500 characters a text, 40 languages, 8 stops a gradient, 2 seconds an animation, 10 carousel pages, 5 tabs, 5 sheets.",$ref:"#/$defs/PaywallDefinition",$defs:{PaywallAction:{additionalProperties:!1,description:"What a button does.",properties:{package:{description:"Package.",pattern:"^([a-z][a-z0-9_]{0,39})\\.([a-z][a-z0-9_]{0,39})$",type:"string"},sheet:{description:"Sheet.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},type:{description:"Type.",enum:["close","restore","open_url","terms","privacy","offer_code","sheet","select_package"],type:"string"},url:{description:"Url.",maxLength:2048,pattern:"^https://.+$",type:"string"}},required:["type"],type:"object"},PaywallAnimation:{additionalProperties:!1,description:"How the component appears; a renderer skips it when the system asks to reduce motion.",properties:{delay_ms:{default:0,description:"Delay ms.",maximum:2e3,minimum:0,type:"integer"},duration_ms:{default:300,description:"Duration ms.",maximum:2e3,minimum:50,type:"integer"},easing:{default:"ease_out",description:"Easing.",enum:["ease_out","ease_in_out","spring"],type:"string"},type:{description:"Type.",enum:["fade","slide_up","slide_down","slide_leading","slide_trailing","scale"],type:"string"}},required:["type"],type:"object"},PaywallBorder:{additionalProperties:!1,description:"A border.",properties:{color:{description:"Color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},width:{description:"Width.",maximum:16,minimum:.5,type:"number"}},required:["color","width"],type:"object"},PaywallButton:{additionalProperties:!1,description:"A button that does an action: closes the paywall, restores purchases, opens an address, the terms or the privacy policy, the store's offer code sheet, one of the paywall's sheets, or selects a package.",properties:{action:{$ref:"#/$defs/PaywallAction"},animation:{$ref:"#/$defs/PaywallAnimation"},content:{$ref:"#/$defs/PaywallComponent"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["button"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["action","content","type"],type:"object"},PaywallCarousel:{additionalProperties:!1,description:"Pages the customer swipes through, the next peeking in, advancing on their own, with an indicator.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},auto_advance_ms:{description:"Auto advance ms.",maximum:3e4,minimum:1e3,type:"integer"},height:{description:"Height.",oneOf:[{$ref:"#/$defs/PaywallSizeKeyword"},{$ref:"#/$defs/PaywallLength"}]},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},indicator:{$ref:"#/$defs/PaywallIndicator"},loop:{default:!1,description:"Loop.",type:"boolean"},pages:{description:"Pages.",items:{$ref:"#/$defs/PaywallComponent"},maxItems:10,minItems:1,type:"array"},peek:{default:0,description:"Peek.",maximum:64,minimum:0,type:"integer"},spacing:{default:8,description:"Spacing.",maximum:64,minimum:0,type:"integer"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["carousel"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["pages","type"],type:"object"},PaywallColorValue:{description:"A color: a token of the theme's colors (the light or the dark value, as the app appears), or #RRGGBB / #RRGGBBAA.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},PaywallColors:{additionalProperties:!1,description:"The theme's colors by name, for each appearance; both name the same colors, at least background, surface, text, muted, accent and on_accent.",properties:{dark:{$ref:"#/$defs/PaywallPalette"},light:{$ref:"#/$defs/PaywallPalette"}},required:["dark","light"],type:"object"},PaywallComponent:{description:"A component, by its type. A newer schema adds components; an app never draws a definition with one it does not know.",oneOf:[{$ref:"#/$defs/PaywallButton"},{$ref:"#/$defs/PaywallCarousel"},{$ref:"#/$defs/PaywallCountdown"},{$ref:"#/$defs/PaywallCustomHtml"},{$ref:"#/$defs/PaywallDivider"},{$ref:"#/$defs/PaywallFeatures"},{$ref:"#/$defs/PaywallIcon"},{$ref:"#/$defs/PaywallImage"},{$ref:"#/$defs/PaywallPackage"},{$ref:"#/$defs/PaywallPurchaseButton"},{$ref:"#/$defs/PaywallSpacer"},{$ref:"#/$defs/PaywallStack"},{$ref:"#/$defs/PaywallSwitch"},{$ref:"#/$defs/PaywallTabs"},{$ref:"#/$defs/PaywallText"},{$ref:"#/$defs/PaywallTimeline"},{$ref:"#/$defs/PaywallVideo"}]},PaywallCondition:{additionalProperties:!1,description:"When the component is shown: every field named holds at once.",properties:{appearance:{description:"Appearance.",enum:["light","dark"],type:"string"},intro_eligible:{description:"Intro eligible.",type:"boolean"},locale:{description:"Locale.",items:{pattern:"^[a-z]{2,3}(-[A-Z][A-Za-z]{1,3})?$",type:"string"},maxItems:40,minItems:1,type:"array",uniqueItems:!0},offer_open:{description:"Holds while the package's offer (its package component's offer) is the customer's to take: the package the component is in, else the selected one.",type:"boolean"},platform:{description:"Platform.",items:{enum:["ios","android","web"],type:"string"},maxItems:3,minItems:1,type:"array",uniqueItems:!0},selected_package:{description:"Selected package.",items:{pattern:"^([a-z][a-z0-9_]{0,39})\\.([a-z][a-z0-9_]{0,39})$",type:"string"},maxItems:6,minItems:1,type:"array"},tab:{description:"Tab.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"}},type:"object"},PaywallCorners:{additionalProperties:!1,description:"Each corner its own, in points or a token of the theme's radii.",properties:{bottom_leading:{default:0,description:"Bottom leading.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]},bottom_trailing:{default:0,description:"Bottom trailing.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]},top_leading:{default:0,description:"Top leading.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]},top_trailing:{default:0,description:"Top trailing.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]}},type:"object"},PaywallCountdown:{additionalProperties:!1,description:"A countdown to an instant, or for a time from the moment the paywall opened: one content while it counts \u2014 its texts name {{countdown}}, {{days}}, {{hours}}, {{minutes}}, {{seconds}} \u2014, another once it ended.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},counting:{$ref:"#/$defs/PaywallComponent"},ended:{$ref:"#/$defs/PaywallComponent"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},target:{$ref:"#/$defs/PaywallTarget"},type:{description:"The component.",enum:["countdown"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["counting","target","type"],type:"object"},PaywallCustomHtml:{additionalProperties:!1,description:"A decorative HTML block from an archive the project uploaded (an animation, a Lottie or Rive scene): drawn in a sandbox of an origin of its own: it reaches neither the page around it, nor the app, nor the purchase, and loads only what came in its archive (a content security policy) \u2014 it may still navigate its own frame away and open a WebRTC connection (a content security policy does not cover WebRTC). It is told the selected package, the language and the appearance, and is hidden from screen readers. It cannot buy anything.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},height:{description:"Height.",oneOf:[{$ref:"#/$defs/PaywallSizeKeyword"},{$ref:"#/$defs/PaywallLength"}]},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},src:{description:"Src.",maxLength:2048,pattern:"^asset:([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$",type:"string"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["custom_html"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["height","src","type"],type:"object"},PaywallDefinition:{additionalProperties:!1,description:"A paywall: a design system (the theme's colors, type scale, radii and spacing) and a free layout of components that name it \u2014 a fixed header and footer around the part that scrolls, and sheets it opens. Every component takes a style, a condition to be shown, a style for when it is selected, and an entrance animation. Prices are never in it: an app fills `{{price}}` and the other variables from its store. Its assets (asset:<id>) are the project's, given as https addresses in the app's answer and listed for the app to download before it shows the paywall. The server refuses what it does not know and holds a definition to bounds: 128 KiB of JSON, 400 components, 16 deep, 500 characters a text, 40 languages, 8 stops a gradient, 2 seconds an animation, 10 carousel pages, 5 tabs, 5 sheets.",properties:{$schema:{type:"string",description:"The JSON Schema an editor checks this file against. The CLI takes it out before the definition is sent."},default_locale:{description:"The language a text falls back to: a tag such as en or pt-BR.",pattern:"^[a-z]{2,3}(-[A-Z][A-Za-z]{1,3})?$",type:"string"},footer:{$ref:"#/$defs/PaywallComponent"},header:{$ref:"#/$defs/PaywallComponent"},locales:{$ref:"#/$defs/PaywallLocales"},name:{description:"The paywall's name, for the people who edit it (1 to 100 characters).",maxLength:100,minLength:1,type:"string"},root:{$ref:"#/$defs/PaywallComponent"},schema:{description:"The schema the definition is written in: 2. An app says the newest schema it draws (X-Palbase-Paywall-Schema) and is given the newest version written in it or an older one; an app that draws no schema this server takes is told to update (426).",maximum:2,minimum:2,type:"integer"},sheets:{$ref:"#/$defs/PaywallSheets"},theme:{$ref:"#/$defs/PaywallTheme"}},required:["schema","name","default_locale","theme","root"],type:"object"},PaywallDivider:{additionalProperties:!1,description:"A thin line across its stack.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},color:{default:"muted",description:"Color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},thickness:{default:1,description:"Thickness.",maximum:8,minimum:.5,type:"number"},type:{description:"The component.",enum:["divider"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["type"],type:"object"},PaywallEdges:{additionalProperties:!1,description:"Each edge its own, in points or a token of the theme's spacing.",properties:{bottom:{default:0,description:"Bottom.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]},leading:{default:0,description:"Leading.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]},top:{default:0,description:"Top.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]},trailing:{default:0,description:"Trailing.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]}},type:"object"},PaywallFeature:{additionalProperties:!1,description:"A feature.",properties:{icon:{$ref:"#/$defs/PaywallIconName"},text:{$ref:"#/$defs/PaywallString"}},required:["icon","text"],type:"object"},PaywallFeatures:{additionalProperties:!1,description:"What the purchase gives, each with an icon.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},color:{default:"text",description:"Color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},icon_color:{default:"accent",description:"Icon color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},items:{description:"Items.",items:{$ref:"#/$defs/PaywallFeature"},maxItems:12,minItems:1,type:"array"},spacing:{default:12,description:"Spacing.",maximum:64,minimum:0,type:"integer"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["features"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["items","type"],type:"object"},PaywallFontSize:{description:"A size in points, scaled with the platform's body style.",maximum:120,minimum:6,type:"number"},PaywallIcon:{additionalProperties:!1,description:"An icon every renderer draws.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},color:{default:"accent",description:"Color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},name:{$ref:"#/$defs/PaywallIconName"},size:{default:24,description:"Size.",maximum:128,minimum:8,type:"integer"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["icon"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["name","type"],type:"object"},PaywallIconName:{description:"An icon every renderer draws (SF Symbols on iOS).",enum:["ad_free","arrow_right","bell","bolt","book","calendar","chart","chat","check","check_circle","clock","close","cloud","crown","download","gift","globe","heart","infinity","lock","lock_open","music","people","person","photo","play","quote","shield","sparkles","star","trophy","video"],type:"string"},PaywallImage:{additionalProperties:!1,description:"An image the app downloads before it shows the paywall: an https address, or an image the project uploaded.",properties:{alt:{$ref:"#/$defs/PaywallString"},animation:{$ref:"#/$defs/PaywallAnimation"},aspect:{description:"Aspect.",maximum:10,minimum:.1,type:"number"},decorative:{default:!1,description:"Decorative.",type:"boolean"},fit:{default:"fit",description:"Fit.",enum:["fit","fill"],type:"string"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},mask:{$ref:"#/$defs/PaywallMask"},overlay:{description:"Overlay.",oneOf:[{$ref:"#/$defs/PaywallLinear"},{$ref:"#/$defs/PaywallRadial"}]},src:{description:"Src.",maxLength:2048,pattern:"^(https://.+|asset:([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}))$",type:"string"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["image"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["src","type"],type:"object"},PaywallImageFill:{additionalProperties:!1,description:"An image behind the component.",properties:{fit:{default:"fill",description:"Fit.",enum:["fit","fill"],type:"string"},src:{description:"Src.",maxLength:2048,pattern:"^(https://.+|asset:([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}))$",type:"string"},type:{description:"Type.",enum:["image"],type:"string"}},required:["src","type"],type:"object"},PaywallIndicator:{additionalProperties:!1,description:"A carousel's page indicator.",properties:{active_color:{default:"accent",description:"Active color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},color:{default:"muted",description:"Color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},size:{default:8,description:"Size.",maximum:16,minimum:2,type:"integer"},spacing:{default:6,description:"Spacing.",maximum:32,minimum:0,type:"integer"},style:{default:"dots",description:"Its style.",enum:["dots","bars","none"],type:"string"}},type:"object"},PaywallLength:{description:"A length in points.",maximum:4e3,minimum:0,type:"number"},PaywallLinear:{additionalProperties:!1,description:"A linear gradient: its angle (0 up, clockwise, 180 down) and 2 to 8 stops.",properties:{angle:{default:180,description:"Angle.",maximum:360,minimum:0,type:"number"},stops:{description:"Stops.",items:{$ref:"#/$defs/PaywallStop"},maxItems:8,minItems:2,type:"array"},type:{description:"Type.",enum:["linear"],type:"string"}},required:["stops","type"],type:"object"},PaywallLiteral:{description:"The text itself, in every language.",maxLength:500,type:"string"},PaywallLocales:{additionalProperties:{$ref:"#/$defs/PaywallTexts"},description:"The texts in each language (at most 40), by language tag: a component's `{\"t\": key}` is the app's language's, or the default locale's when it lacks the key.",type:"object"},PaywallMask:{additionalProperties:!1,description:"The image's shape: a rectangle with corners, a circle, or a rectangle whose bottom edge curves in (concave) or out (convex).",properties:{depth:{default:16,description:"Depth.",maximum:64,minimum:0,type:"number"},radius:{default:0,description:"Radius.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]},shape:{description:"Shape.",enum:["rect","circle","concave","convex"],type:"string"}},required:["shape"],type:"object"},PaywallPackage:{additionalProperties:!1,description:"A package on sale, laid out as the project likes: tapping it selects it; its content's styles for when it is selected apply while it is.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},children:{description:"The components.",items:{$ref:"#/$defs/PaywallComponent"},maxItems:50,type:"array"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},offer:{description:"One of the catalog's offers on the package: bought with it, and its texts' {{offer_price}} its price, while the customer may take it (GET /purchases/offers lists it).",pattern:"^[a-z][a-z0-9_]{0,39}$",type:"string"},plan:{description:"Plan.",pattern:"^[a-z][a-z0-9_]{0,39}$",type:"string"},product:{description:"Product.",pattern:"^[a-z][a-z0-9_]{0,39}$",type:"string"},selected:{default:!1,description:"Selected when the paywall opens (at most one).",type:"boolean"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["package"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["plan","product","type"],type:"object"},PaywallPalette:{additionalProperties:{pattern:"^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$",type:"string"},description:"Colors by token (lowercase letters, digits and _, at most 32), each #RRGGBB or #RRGGBBAA.",maxProperties:40,type:"object"},PaywallPoints:{description:"Points.",maximum:200,minimum:0,type:"number"},PaywallPurchaseButton:{additionalProperties:!1,description:"The button that buys the selected package \u2014 or its own package \u2014: the store's sheet (StoreKit) or checkout (Stripe) opens.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},content:{$ref:"#/$defs/PaywallComponent"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},package:{description:"Package.",pattern:"^([a-z][a-z0-9_]{0,39})\\.([a-z][a-z0-9_]{0,39})$",type:"string"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["purchase_button"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["content","type"],type:"object"},PaywallRadial:{additionalProperties:!1,description:"A radial gradient: its center and radius as shares of the component, and 2 to 8 stops.",properties:{center_x:{default:.5,description:"Center x.",maximum:1,minimum:0,type:"number"},center_y:{default:.5,description:"Center y.",maximum:1,minimum:0,type:"number"},radius:{default:.5,description:"Radius.",maximum:2,minimum:.01,type:"number"},stops:{description:"Stops.",items:{$ref:"#/$defs/PaywallStop"},maxItems:8,minItems:2,type:"array"},type:{description:"Type.",enum:["radial"],type:"string"}},required:["stops","type"],type:"object"},PaywallScale:{additionalProperties:{maximum:200,minimum:0,type:"number"},description:"Points by token (lowercase letters, digits and _, at most 32).",maxProperties:16,type:"object"},PaywallShadow:{additionalProperties:!1,description:"A shadow.",properties:{color:{description:"Color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},radius:{default:0,description:"Radius.",maximum:64,minimum:0,type:"number"},x:{default:0,description:"X.",maximum:64,minimum:-64,type:"number"},y:{default:0,description:"Y.",maximum:64,minimum:-64,type:"number"}},required:["color"],type:"object"},PaywallSheet:{additionalProperties:!1,description:"A second page a button opens over the paywall.",properties:{root:{$ref:"#/$defs/PaywallComponent"},title:{$ref:"#/$defs/PaywallString"}},required:["root"],type:"object"},PaywallSheets:{additionalProperties:{$ref:"#/$defs/PaywallSheet"},description:"The sheets by id (lowercase letters, digits, _ and -, starting with a letter).",maxProperties:5,type:"object"},PaywallSizeKeyword:{description:`fit: the content's size; fill: all the parent gives; a share of the parent ("50%").`,pattern:"^(fit|fill|([1-9][0-9]?|100)%)$",type:"string"},PaywallSpacer:{additionalProperties:!1,description:"Space: a fixed size, or all that is left along its stack when absent.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},size:{description:"Size.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["spacer"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["type"],type:"object"},PaywallSpan:{additionalProperties:!1,description:"A part of a text: bold, italic, underlined, struck through, colored, a link.",properties:{bold:{default:!1,description:"Bold.",type:"boolean"},color:{description:"Color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},italic:{default:!1,description:"Italic.",type:"boolean"},link:{description:"Link.",maxLength:2048,pattern:"^(terms|privacy|https://.+)$",type:"string"},strikethrough:{default:!1,description:"Strikethrough.",type:"boolean"},text:{$ref:"#/$defs/PaywallString"},underline:{default:!1,description:"Underline.",type:"boolean"}},required:["text"],type:"object"},PaywallStack:{additionalProperties:!1,description:"Components laid out one after another \u2014 down, across \u2014 or over each other (z). The root, the header and the footer are each one; the root scrolls between the fixed header and footer.",properties:{align:{default:"center",description:"Align.",enum:["start","center","end","stretch"],type:"string"},animation:{$ref:"#/$defs/PaywallAnimation"},axis:{default:"vertical",description:"Axis.",enum:["vertical","horizontal","z"],type:"string"},children:{description:"The components.",items:{$ref:"#/$defs/PaywallComponent"},maxItems:50,type:"array"},distribution:{default:"start",description:"Distribution.",enum:["start","center","end","space_between","space_around","space_evenly"],type:"string"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},scroll:{default:!1,description:"Scroll.",type:"boolean"},spacing:{default:0,description:"Spacing.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["stack"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["type"],type:"object"},PaywallStates:{additionalProperties:!1,description:"The component's style while what it is in is selected: the package it is in (or is), the tab whose label it is.",properties:{selected:{$ref:"#/$defs/PaywallStyle"}},type:"object"},PaywallStop:{additionalProperties:!1,description:"A gradient's color at a point along it (0 to 1).",properties:{at:{description:"At.",maximum:1,minimum:0,type:"number"},color:{description:"Color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"}},required:["at","color"],type:"object"},PaywallString:{description:'A text: the string itself, or `{"t": key}` of the language table. Either may hold variables the app fills from its store \u2014 `{{price}}`, `{{price_per_month}}`, `{{period}}`, `{{trial}}`, `{{savings}}`, `{{product_name}}`, `{{offer_price}}` (the price of the package\'s offer while the customer may take it, its price otherwise) \u2014 of the package an item is, or of the selected package anywhere else. A text that names a variable its package has no value for (no trial, no savings) is not drawn.',oneOf:[{$ref:"#/$defs/PaywallLiteral"},{$ref:"#/$defs/PaywallTextKey"}]},PaywallStyle:{additionalProperties:!1,description:"What every component takes: padding and margin by edge, a size, a fill, a border, corners each their own, a shadow, an opacity. Points and colors name the theme's tokens or are given as they are.",properties:{background:{description:"Background.",oneOf:[{$ref:"#/$defs/PaywallColorValue"},{$ref:"#/$defs/PaywallLinear"},{$ref:"#/$defs/PaywallRadial"},{$ref:"#/$defs/PaywallImageFill"},{$ref:"#/$defs/PaywallVideoFill"}]},border:{$ref:"#/$defs/PaywallBorder"},corners:{description:"Corners.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"},{$ref:"#/$defs/PaywallCorners"}]},height:{description:"Height.",oneOf:[{$ref:"#/$defs/PaywallSizeKeyword"},{$ref:"#/$defs/PaywallLength"}]},margin:{description:"Margin.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"},{$ref:"#/$defs/PaywallEdges"}]},max_width:{description:"Max width.",maximum:4e3,minimum:1,type:"integer"},opacity:{default:1,description:"Opacity.",maximum:1,minimum:0,type:"number"},padding:{description:"Padding.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"},{$ref:"#/$defs/PaywallEdges"}]},shadow:{$ref:"#/$defs/PaywallShadow"},width:{description:"Width.",oneOf:[{$ref:"#/$defs/PaywallSizeKeyword"},{$ref:"#/$defs/PaywallLength"}]}},type:"object"},PaywallSwitch:{additionalProperties:!1,description:"A switch between two contents \u2014 a yearly and a monthly offer \u2014, each selecting its own package when it is shown.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},default:{default:!1,description:"Default.",type:"boolean"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},label:{$ref:"#/$defs/PaywallString"},off:{$ref:"#/$defs/PaywallComponent"},off_package:{description:"Off package.",pattern:"^([a-z][a-z0-9_]{0,39})\\.([a-z][a-z0-9_]{0,39})$",type:"string"},on:{$ref:"#/$defs/PaywallComponent"},on_package:{description:"On package.",pattern:"^([a-z][a-z0-9_]{0,39})\\.([a-z][a-z0-9_]{0,39})$",type:"string"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},tint:{default:"accent",description:"Tint.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},type:{description:"The component.",enum:["switch"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["off","on","type"],type:"object"},PaywallTab:{additionalProperties:!1,description:"A tab: its label, its content, and the package it selects when it is shown.",properties:{content:{$ref:"#/$defs/PaywallComponent"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},label:{$ref:"#/$defs/PaywallComponent"},package:{description:"Package.",pattern:"^([a-z][a-z0-9_]{0,39})\\.([a-z][a-z0-9_]{0,39})$",type:"string"}},required:["content","id","label"],type:"object"},PaywallTabs:{additionalProperties:!1,description:"Tabs, each its own content and default package; the labels, in a bar, are components whose style when selected is the shown tab's.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},bar:{$ref:"#/$defs/PaywallStyle"},default:{description:"Default.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},tabs:{description:"Tabs.",items:{$ref:"#/$defs/PaywallTab"},maxItems:5,minItems:2,type:"array"},type:{description:"The component.",enum:["tabs"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["tabs","type"],type:"object"},PaywallTarget:{additionalProperties:!1,description:"What a countdown counts to: an instant (at), or a time from the moment the paywall opened (after_open_seconds) \u2014 one of them.",properties:{after_open_seconds:{description:"After open seconds.",maximum:604800,minimum:1,type:"integer"},at:{description:"At.",format:"date-time",type:"string"}},type:"object"},PaywallText:{additionalProperties:!1,description:"A text: one string, or spans \u2014 bold, italic, colored parts and links \u2014, in a type style of the theme or its own.",properties:{align:{default:"center",description:"Align.",enum:["start","center","end"],type:"string"},animation:{$ref:"#/$defs/PaywallAnimation"},color:{default:"text",description:"Color.",oneOf:[{$ref:"#/$defs/PaywallColorValue"},{$ref:"#/$defs/PaywallLinear"},{$ref:"#/$defs/PaywallRadial"}]},font:{description:"Font.",pattern:"^(system|rounded|serif|mono|asset:([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}))$",type:"string"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},letter_spacing:{description:"Letter spacing.",maximum:20,minimum:-5,type:"number"},line_height:{description:"Line height.",maximum:3,minimum:.5,type:"number"},max_lines:{description:"Max lines.",maximum:20,minimum:1,type:"integer"},size:{description:"Size.",oneOf:[{$ref:"#/$defs/PaywallFontSize"},{$ref:"#/$defs/PaywallToken"}]},spans:{description:"Spans.",items:{$ref:"#/$defs/PaywallSpan"},maxItems:20,minItems:1,type:"array"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},text:{$ref:"#/$defs/PaywallString"},type:{description:"The component.",enum:["text"],type:"string"},uppercase:{default:!1,description:"Uppercase.",type:"boolean"},visible:{$ref:"#/$defs/PaywallCondition"},weight:{description:"Weight.",enum:[100,200,300,400,500,600,700,800,900],type:"integer"}},required:["type"],type:"object"},PaywallTextKey:{additionalProperties:!1,description:"A text of the language table.",properties:{t:{description:"The text's key.",type:"string"}},required:["t"],type:"object"},PaywallTexts:{additionalProperties:{maxLength:500,type:"string"},description:"One language's texts, by key (lowercase letters, digits, `_` `.` `-`, at most 64): each at most 500 characters, with variables.",type:"object"},PaywallTheme:{additionalProperties:!1,description:"The paywall's design system: colors for light and dark, a type scale, radii and spacing; the components name them.",properties:{colors:{$ref:"#/$defs/PaywallColors"},radii:{$ref:"#/$defs/PaywallScale"},spacing:{$ref:"#/$defs/PaywallScale"},typography:{$ref:"#/$defs/PaywallTypeScale"}},required:["colors"],type:"object"},PaywallTimeline:{additionalProperties:!1,description:"Steps in time \u2014 a trial's today, its reminder, its first charge \u2014, each with an icon, joined by a line.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},color:{default:"text",description:"Color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},icon_color:{default:"on_accent",description:"Icon color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},items:{description:"Items.",items:{$ref:"#/$defs/PaywallTimelineItem"},maxItems:8,minItems:2,type:"array"},line_color:{default:"accent",description:"Line color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},line_width:{default:2,description:"Line width.",maximum:8,minimum:1,type:"integer"},spacing:{default:16,description:"Spacing.",maximum:64,minimum:0,type:"integer"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["timeline"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["items","type"],type:"object"},PaywallTimelineItem:{additionalProperties:!1,description:"A step of a timeline.",properties:{color:{description:"Color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},icon:{$ref:"#/$defs/PaywallIconName"},text:{$ref:"#/$defs/PaywallString"},title:{$ref:"#/$defs/PaywallString"}},required:["icon","title"],type:"object"},PaywallToken:{description:"A token of the theme's scale.",pattern:"^[a-z][a-z0-9_]{0,31}$",type:"string"},PaywallTypeScale:{additionalProperties:{$ref:"#/$defs/PaywallTypography"},description:"Type styles by token (lowercase letters, digits and _, at most 32).",maxProperties:16,type:"object"},PaywallTypography:{additionalProperties:!1,description:"A type style of the theme: what a text whose size names it is drawn in. It scales with its text style (Dynamic Type on iOS, the root font size on the web).",properties:{font:{default:"system",description:"Font.",pattern:"^(system|rounded|serif|mono|asset:([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}))$",type:"string"},letter_spacing:{default:0,description:"Letter spacing.",maximum:20,minimum:-5,type:"number"},line_height:{description:"Line height.",maximum:3,minimum:.5,type:"number"},size:{description:"Size.",maximum:120,minimum:6,type:"number"},text_style:{default:"body",description:"Text style.",enum:["large_title","title","title2","title3","headline","body","callout","subheadline","footnote","caption"],type:"string"},weight:{default:400,description:"Weight.",enum:[100,200,300,400,500,600,700,800,900],type:"integer"}},required:["size"],type:"object"},PaywallVideo:{additionalProperties:!1,description:"A video the app downloads before it shows the paywall; muted and looping unless it says otherwise.",properties:{alt:{$ref:"#/$defs/PaywallString"},animation:{$ref:"#/$defs/PaywallAnimation"},aspect:{description:"Aspect.",maximum:10,minimum:.1,type:"number"},autoplay:{default:!0,description:"Autoplay.",type:"boolean"},controls:{default:!1,description:"Controls.",type:"boolean"},fit:{default:"fill",description:"Fit.",enum:["fit","fill"],type:"string"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},loop:{default:!0,description:"Loop.",type:"boolean"},mute:{default:!0,description:"Mute.",type:"boolean"},poster:{description:"Poster.",maxLength:2048,pattern:"^(https://.+|asset:([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}))$",type:"string"},src:{description:"Src.",maxLength:2048,pattern:"^(https://.+|asset:([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}))$",type:"string"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["video"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["src","type"],type:"object"},PaywallVideoFill:{additionalProperties:!1,description:"A muted video behind the component.",properties:{loop:{default:!0,description:"Loop.",type:"boolean"},poster:{description:"Poster.",maxLength:2048,pattern:"^(https://.+|asset:([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}))$",type:"string"},src:{description:"Src.",maxLength:2048,pattern:"^(https://.+|asset:([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}))$",type:"string"},type:{description:"Type.",enum:["video"],type:"string"}},required:["src","type"],type:"object"}}};var mt=`${me}/paywalls`,Va=`${mt}/paywall.schema.json`,As="paywall-assets",Sp=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,nl=e=>`"${e}"`;function Xa(e,t,n){let s=e.args[t];if(s===void 0||s.trim()==="")throw g(`${n} is required`);return s}async function Qn(e,t){return(await h(e,t,"GET","/purchases/paywalls")).paywalls}function sl(e,t){if(Sp.test(t))return e.find(a=>a.id===t.toLowerCase());let n=e.filter(a=>a.name===t),s=n.length>0?n:e.filter(a=>a.name.toLocaleLowerCase()===t.toLocaleLowerCase());if(s.length>1)throw new y("ambiguous_paywall",`${s.length} paywalls are named ${JSON.stringify(t)}`,{hint:`name one by its id: ${s.map(a=>a.id).join(", ")}`});return s[0]}async function aa(e,t,n){let s=await Qn(e,t),a=sl(s,n);if(!a)throw new y("paywall_not_found",`no paywall ${JSON.stringify(n)}`,{hint:s.length>0?`the project's: ${s.map(i=>i.name).join(", ")}`:"the project has none yet: palbase purchases:paywalls:put <name> --file <file> --revision 0 makes one"});return a}function Zi(e){let t=e.normalize("NFKD").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60);return t===""?"paywall":t}function Nt(e,t,n,s,a=`${mt}/<name>${s}`){let i=o2(e.io.cwd,Tw(e.io.cwd,n)).split(l2).join("/");if(!i.startsWith(`${me}/`)||i.split("/").includes(".."))throw g(`--${t} ${n}: the file goes under ${me}/, as the CLI writes nothing else in the checkout`,`--${t} ${a}`);if(!i.endsWith(s))throw g(`--${t} ${n}: the file's name ends in ${s}`);return i}async function el(e,t,n){let s=await Be(e.io.cwd,t);await s2(r2(s),{recursive:!0}),await Be(e.io.cwd,t),await i2(s,n)}var Cw=`${JSON.stringify(Zo,null,2)}
|
|
672
|
+
`}var Zo={$schema:"https://json-schema.org/draft/2020-12/schema",title:"Palbase paywall definition",description:"A paywall: a design system (the theme's colors, type scale, radii and spacing) and a free layout of components that name it \u2014 a fixed header and footer around the part that scrolls, and sheets it opens. Every component takes a style, a condition to be shown, a style for when it is selected, and an entrance animation. Prices are never in it: an app fills `{{price}}` and the other variables from its store. Its assets (asset:<id>) are the project's, given as https addresses in the app's answer and listed for the app to download before it shows the paywall. The server refuses what it does not know and holds a definition to bounds: 128 KiB of JSON, 400 components, 16 deep, 500 characters a text, 40 languages, 8 stops a gradient, 2 seconds an animation, 10 carousel pages, 5 tabs, 5 sheets.",$ref:"#/$defs/PaywallDefinition",$defs:{PaywallAction:{additionalProperties:!1,description:"What a button does.",properties:{package:{description:"Package.",pattern:"^([a-z][a-z0-9_]{0,39})\\.([a-z][a-z0-9_]{0,39})$",type:"string"},sheet:{description:"Sheet.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},type:{description:"Type.",enum:["close","restore","open_url","terms","privacy","offer_code","sheet","select_package"],type:"string"},url:{description:"Url.",maxLength:2048,pattern:"^https://.+$",type:"string"}},required:["type"],type:"object"},PaywallAnimation:{additionalProperties:!1,description:"How the component appears; a renderer skips it when the system asks to reduce motion.",properties:{delay_ms:{default:0,description:"Delay ms.",maximum:2e3,minimum:0,type:"integer"},duration_ms:{default:300,description:"Duration ms.",maximum:2e3,minimum:50,type:"integer"},easing:{default:"ease_out",description:"Easing.",enum:["ease_out","ease_in_out","spring"],type:"string"},type:{description:"Type.",enum:["fade","slide_up","slide_down","slide_leading","slide_trailing","scale"],type:"string"}},required:["type"],type:"object"},PaywallBorder:{additionalProperties:!1,description:"A border.",properties:{color:{description:"Color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},width:{description:"Width.",maximum:16,minimum:.5,type:"number"}},required:["color","width"],type:"object"},PaywallButton:{additionalProperties:!1,description:"A button that does an action: closes the paywall, restores purchases, opens an address, the terms or the privacy policy, the store's offer code sheet, one of the paywall's sheets, or selects a package.",properties:{action:{$ref:"#/$defs/PaywallAction"},animation:{$ref:"#/$defs/PaywallAnimation"},content:{$ref:"#/$defs/PaywallComponent"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["button"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["action","content","type"],type:"object"},PaywallCarousel:{additionalProperties:!1,description:"Pages the customer swipes through, the next peeking in, advancing on their own, with an indicator.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},auto_advance_ms:{description:"Auto advance ms.",maximum:3e4,minimum:1e3,type:"integer"},height:{description:"Height.",oneOf:[{$ref:"#/$defs/PaywallSizeKeyword"},{$ref:"#/$defs/PaywallLength"}]},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},indicator:{$ref:"#/$defs/PaywallIndicator"},loop:{default:!1,description:"Loop.",type:"boolean"},pages:{description:"Pages.",items:{$ref:"#/$defs/PaywallComponent"},maxItems:10,minItems:1,type:"array"},peek:{default:0,description:"Peek.",maximum:64,minimum:0,type:"integer"},spacing:{default:8,description:"Spacing.",maximum:64,minimum:0,type:"integer"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["carousel"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["pages","type"],type:"object"},PaywallColorValue:{description:"A color: a token of the theme's colors (the light or the dark value, as the app appears), or #RRGGBB / #RRGGBBAA.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},PaywallColors:{additionalProperties:!1,description:"The theme's colors by name, for each appearance; both name the same colors, at least background, surface, text, muted, accent and on_accent.",properties:{dark:{$ref:"#/$defs/PaywallPalette"},light:{$ref:"#/$defs/PaywallPalette"}},required:["dark","light"],type:"object"},PaywallComponent:{description:"A component, by its type. A newer schema adds components; an app never draws a definition with one it does not know.",oneOf:[{$ref:"#/$defs/PaywallButton"},{$ref:"#/$defs/PaywallCarousel"},{$ref:"#/$defs/PaywallCountdown"},{$ref:"#/$defs/PaywallCustomHtml"},{$ref:"#/$defs/PaywallDivider"},{$ref:"#/$defs/PaywallFeatures"},{$ref:"#/$defs/PaywallIcon"},{$ref:"#/$defs/PaywallImage"},{$ref:"#/$defs/PaywallPackage"},{$ref:"#/$defs/PaywallPurchaseButton"},{$ref:"#/$defs/PaywallSpacer"},{$ref:"#/$defs/PaywallStack"},{$ref:"#/$defs/PaywallSwitch"},{$ref:"#/$defs/PaywallTabs"},{$ref:"#/$defs/PaywallText"},{$ref:"#/$defs/PaywallTimeline"},{$ref:"#/$defs/PaywallVideo"}]},PaywallCondition:{additionalProperties:!1,description:"When the component is shown: every field named holds at once.",properties:{appearance:{description:"Appearance.",enum:["light","dark"],type:"string"},intro_eligible:{description:"Intro eligible.",type:"boolean"},locale:{description:"Locale.",items:{pattern:"^[a-z]{2,3}(-[A-Z][A-Za-z]{1,3})?$",type:"string"},maxItems:40,minItems:1,type:"array",uniqueItems:!0},offer_open:{description:"Holds while the package's offer (its package component's offer) is the customer's to take: the package the component is in, else the selected one.",type:"boolean"},platform:{description:"Platform.",items:{enum:["ios","android","web","macos"],type:"string"},maxItems:4,minItems:1,type:"array",uniqueItems:!0},selected_package:{description:"Selected package.",items:{pattern:"^([a-z][a-z0-9_]{0,39})\\.([a-z][a-z0-9_]{0,39})$",type:"string"},maxItems:6,minItems:1,type:"array"},tab:{description:"Tab.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"}},type:"object"},PaywallCorners:{additionalProperties:!1,description:"Each corner its own, in points or a token of the theme's radii.",properties:{bottom_leading:{default:0,description:"Bottom leading.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]},bottom_trailing:{default:0,description:"Bottom trailing.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]},top_leading:{default:0,description:"Top leading.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]},top_trailing:{default:0,description:"Top trailing.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]}},type:"object"},PaywallCountdown:{additionalProperties:!1,description:"A countdown to an instant, or for a time from the moment the paywall opened: one content while it counts \u2014 its texts name {{countdown}}, {{days}}, {{hours}}, {{minutes}}, {{seconds}} \u2014, another once it ended.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},counting:{$ref:"#/$defs/PaywallComponent"},ended:{$ref:"#/$defs/PaywallComponent"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},target:{$ref:"#/$defs/PaywallTarget"},type:{description:"The component.",enum:["countdown"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["counting","target","type"],type:"object"},PaywallCustomHtml:{additionalProperties:!1,description:"A decorative HTML block from an archive the project uploaded (an animation, a Lottie or Rive scene): drawn in a sandbox of an origin of its own: it reaches neither the page around it, nor the app, nor the purchase, and loads only what came in its archive (a content security policy) \u2014 it may still navigate its own frame away and open a WebRTC connection (a content security policy does not cover WebRTC). It is told the selected package, the language and the appearance, and is hidden from screen readers. It cannot buy anything.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},height:{description:"Height.",oneOf:[{$ref:"#/$defs/PaywallSizeKeyword"},{$ref:"#/$defs/PaywallLength"}]},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},src:{description:"Src.",maxLength:2048,pattern:"^asset:([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$",type:"string"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["custom_html"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["height","src","type"],type:"object"},PaywallDefinition:{additionalProperties:!1,description:"A paywall: a design system (the theme's colors, type scale, radii and spacing) and a free layout of components that name it \u2014 a fixed header and footer around the part that scrolls, and sheets it opens. Every component takes a style, a condition to be shown, a style for when it is selected, and an entrance animation. Prices are never in it: an app fills `{{price}}` and the other variables from its store. Its assets (asset:<id>) are the project's, given as https addresses in the app's answer and listed for the app to download before it shows the paywall. The server refuses what it does not know and holds a definition to bounds: 128 KiB of JSON, 400 components, 16 deep, 500 characters a text, 40 languages, 8 stops a gradient, 2 seconds an animation, 10 carousel pages, 5 tabs, 5 sheets.",properties:{$schema:{type:"string",description:"The JSON Schema an editor checks this file against. The CLI takes it out before the definition is sent."},default_locale:{description:"The language a text falls back to: a tag such as en or pt-BR.",pattern:"^[a-z]{2,3}(-[A-Z][A-Za-z]{1,3})?$",type:"string"},footer:{$ref:"#/$defs/PaywallComponent"},header:{$ref:"#/$defs/PaywallComponent"},locales:{$ref:"#/$defs/PaywallLocales"},name:{description:"The paywall's name, for the people who edit it (1 to 100 characters).",maxLength:100,minLength:1,type:"string"},root:{$ref:"#/$defs/PaywallComponent"},schema:{description:"The schema the definition is written in: 2. An app says the newest schema it draws (X-Palbase-Paywall-Schema) and is given the newest version written in it or an older one; an app that draws no schema this server takes is told to update (426).",maximum:2,minimum:2,type:"integer"},sheets:{$ref:"#/$defs/PaywallSheets"},theme:{$ref:"#/$defs/PaywallTheme"}},required:["schema","name","default_locale","theme","root"],type:"object"},PaywallDivider:{additionalProperties:!1,description:"A thin line across its stack.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},color:{default:"muted",description:"Color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},thickness:{default:1,description:"Thickness.",maximum:8,minimum:.5,type:"number"},type:{description:"The component.",enum:["divider"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["type"],type:"object"},PaywallEdges:{additionalProperties:!1,description:"Each edge its own, in points or a token of the theme's spacing.",properties:{bottom:{default:0,description:"Bottom.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]},leading:{default:0,description:"Leading.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]},top:{default:0,description:"Top.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]},trailing:{default:0,description:"Trailing.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]}},type:"object"},PaywallFeature:{additionalProperties:!1,description:"A feature.",properties:{icon:{$ref:"#/$defs/PaywallIconName"},text:{$ref:"#/$defs/PaywallString"}},required:["icon","text"],type:"object"},PaywallFeatures:{additionalProperties:!1,description:"What the purchase gives, each with an icon.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},color:{default:"text",description:"Color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},icon_color:{default:"accent",description:"Icon color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},items:{description:"Items.",items:{$ref:"#/$defs/PaywallFeature"},maxItems:12,minItems:1,type:"array"},spacing:{default:12,description:"Spacing.",maximum:64,minimum:0,type:"integer"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["features"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["items","type"],type:"object"},PaywallFontSize:{description:"A size in points, scaled with the platform's body style.",maximum:120,minimum:6,type:"number"},PaywallIcon:{additionalProperties:!1,description:"An icon every renderer draws.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},color:{default:"accent",description:"Color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},name:{$ref:"#/$defs/PaywallIconName"},size:{default:24,description:"Size.",maximum:128,minimum:8,type:"integer"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["icon"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["name","type"],type:"object"},PaywallIconName:{description:"An icon every renderer draws (SF Symbols on iOS).",enum:["ad_free","arrow_right","bell","bolt","book","calendar","chart","chat","check","check_circle","clock","close","cloud","crown","download","gift","globe","heart","infinity","lock","lock_open","music","people","person","photo","play","quote","shield","sparkles","star","trophy","video"],type:"string"},PaywallImage:{additionalProperties:!1,description:"An image the app downloads before it shows the paywall: an https address, or an image the project uploaded.",properties:{alt:{$ref:"#/$defs/PaywallString"},animation:{$ref:"#/$defs/PaywallAnimation"},aspect:{description:"Aspect.",maximum:10,minimum:.1,type:"number"},decorative:{default:!1,description:"Decorative.",type:"boolean"},fit:{default:"fit",description:"Fit.",enum:["fit","fill"],type:"string"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},mask:{$ref:"#/$defs/PaywallMask"},overlay:{description:"Overlay.",oneOf:[{$ref:"#/$defs/PaywallLinear"},{$ref:"#/$defs/PaywallRadial"}]},src:{description:"Src.",maxLength:2048,pattern:"^(https://.+|asset:([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}))$",type:"string"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["image"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["src","type"],type:"object"},PaywallImageFill:{additionalProperties:!1,description:"An image behind the component.",properties:{fit:{default:"fill",description:"Fit.",enum:["fit","fill"],type:"string"},src:{description:"Src.",maxLength:2048,pattern:"^(https://.+|asset:([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}))$",type:"string"},type:{description:"Type.",enum:["image"],type:"string"}},required:["src","type"],type:"object"},PaywallIndicator:{additionalProperties:!1,description:"A carousel's page indicator.",properties:{active_color:{default:"accent",description:"Active color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},color:{default:"muted",description:"Color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},size:{default:8,description:"Size.",maximum:16,minimum:2,type:"integer"},spacing:{default:6,description:"Spacing.",maximum:32,minimum:0,type:"integer"},style:{default:"dots",description:"Its style.",enum:["dots","bars","none"],type:"string"}},type:"object"},PaywallLength:{description:"A length in points.",maximum:4e3,minimum:0,type:"number"},PaywallLinear:{additionalProperties:!1,description:"A linear gradient: its angle (0 up, clockwise, 180 down) and 2 to 8 stops.",properties:{angle:{default:180,description:"Angle.",maximum:360,minimum:0,type:"number"},stops:{description:"Stops.",items:{$ref:"#/$defs/PaywallStop"},maxItems:8,minItems:2,type:"array"},type:{description:"Type.",enum:["linear"],type:"string"}},required:["stops","type"],type:"object"},PaywallLiteral:{description:"The text itself, in every language.",maxLength:500,type:"string"},PaywallLocales:{additionalProperties:{$ref:"#/$defs/PaywallTexts"},description:"The texts in each language (at most 40), by language tag: a component's `{\"t\": key}` is the app's language's, or the default locale's when it lacks the key.",type:"object"},PaywallMask:{additionalProperties:!1,description:"The image's shape: a rectangle with corners, a circle, or a rectangle whose bottom edge curves in (concave) or out (convex).",properties:{depth:{default:16,description:"Depth.",maximum:64,minimum:0,type:"number"},radius:{default:0,description:"Radius.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]},shape:{description:"Shape.",enum:["rect","circle","concave","convex"],type:"string"}},required:["shape"],type:"object"},PaywallPackage:{additionalProperties:!1,description:"A package on sale, laid out as the project likes: tapping it selects it; its content's styles for when it is selected apply while it is.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},children:{description:"The components.",items:{$ref:"#/$defs/PaywallComponent"},maxItems:50,type:"array"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},offer:{description:"One of the catalog's offers on the package: bought with it, and its texts' {{offer_price}} its price, while the customer may take it (GET /purchases/offers lists it).",pattern:"^[a-z][a-z0-9_]{0,39}$",type:"string"},plan:{description:"Plan.",pattern:"^[a-z][a-z0-9_]{0,39}$",type:"string"},product:{description:"Product.",pattern:"^[a-z][a-z0-9_]{0,39}$",type:"string"},selected:{default:!1,description:"Selected when the paywall opens (at most one).",type:"boolean"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["package"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["plan","product","type"],type:"object"},PaywallPalette:{additionalProperties:{pattern:"^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$",type:"string"},description:"Colors by token (lowercase letters, digits and _, at most 32), each #RRGGBB or #RRGGBBAA.",maxProperties:40,type:"object"},PaywallPoints:{description:"Points.",maximum:200,minimum:0,type:"number"},PaywallPurchaseButton:{additionalProperties:!1,description:"The button that buys the selected package \u2014 or its own package \u2014: the store's sheet (StoreKit) or checkout (Stripe) opens.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},content:{$ref:"#/$defs/PaywallComponent"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},package:{description:"Package.",pattern:"^([a-z][a-z0-9_]{0,39})\\.([a-z][a-z0-9_]{0,39})$",type:"string"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["purchase_button"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["content","type"],type:"object"},PaywallRadial:{additionalProperties:!1,description:"A radial gradient: its center and radius as shares of the component, and 2 to 8 stops.",properties:{center_x:{default:.5,description:"Center x.",maximum:1,minimum:0,type:"number"},center_y:{default:.5,description:"Center y.",maximum:1,minimum:0,type:"number"},radius:{default:.5,description:"Radius.",maximum:2,minimum:.01,type:"number"},stops:{description:"Stops.",items:{$ref:"#/$defs/PaywallStop"},maxItems:8,minItems:2,type:"array"},type:{description:"Type.",enum:["radial"],type:"string"}},required:["stops","type"],type:"object"},PaywallScale:{additionalProperties:{maximum:200,minimum:0,type:"number"},description:"Points by token (lowercase letters, digits and _, at most 32).",maxProperties:16,type:"object"},PaywallShadow:{additionalProperties:!1,description:"A shadow.",properties:{color:{description:"Color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},radius:{default:0,description:"Radius.",maximum:64,minimum:0,type:"number"},x:{default:0,description:"X.",maximum:64,minimum:-64,type:"number"},y:{default:0,description:"Y.",maximum:64,minimum:-64,type:"number"}},required:["color"],type:"object"},PaywallSheet:{additionalProperties:!1,description:"A second page a button opens over the paywall.",properties:{root:{$ref:"#/$defs/PaywallComponent"},title:{$ref:"#/$defs/PaywallString"}},required:["root"],type:"object"},PaywallSheets:{additionalProperties:{$ref:"#/$defs/PaywallSheet"},description:"The sheets by id (lowercase letters, digits, _ and -, starting with a letter).",maxProperties:5,type:"object"},PaywallSizeKeyword:{description:`fit: the content's size; fill: all the parent gives; a share of the parent ("50%").`,pattern:"^(fit|fill|([1-9][0-9]?|100)%)$",type:"string"},PaywallSpacer:{additionalProperties:!1,description:"Space: a fixed size, or all that is left along its stack when absent.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},size:{description:"Size.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["spacer"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["type"],type:"object"},PaywallSpan:{additionalProperties:!1,description:"A part of a text: bold, italic, underlined, struck through, colored, a link.",properties:{bold:{default:!1,description:"Bold.",type:"boolean"},color:{description:"Color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},italic:{default:!1,description:"Italic.",type:"boolean"},link:{description:"Link.",maxLength:2048,pattern:"^(terms|privacy|https://.+)$",type:"string"},strikethrough:{default:!1,description:"Strikethrough.",type:"boolean"},text:{$ref:"#/$defs/PaywallString"},underline:{default:!1,description:"Underline.",type:"boolean"}},required:["text"],type:"object"},PaywallStack:{additionalProperties:!1,description:"Components laid out one after another \u2014 down, across \u2014 or over each other (z). The root, the header and the footer are each one; the root scrolls between the fixed header and footer.",properties:{align:{default:"center",description:"Align.",enum:["start","center","end","stretch"],type:"string"},animation:{$ref:"#/$defs/PaywallAnimation"},axis:{default:"vertical",description:"Axis.",enum:["vertical","horizontal","z"],type:"string"},children:{description:"The components.",items:{$ref:"#/$defs/PaywallComponent"},maxItems:50,type:"array"},distribution:{default:"start",description:"Distribution.",enum:["start","center","end","space_between","space_around","space_evenly"],type:"string"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},scroll:{default:!1,description:"Scroll.",type:"boolean"},spacing:{default:0,description:"Spacing.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"}]},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["stack"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["type"],type:"object"},PaywallStates:{additionalProperties:!1,description:"The component's style while what it is in is selected: the package it is in (or is), the tab whose label it is.",properties:{selected:{$ref:"#/$defs/PaywallStyle"}},type:"object"},PaywallStop:{additionalProperties:!1,description:"A gradient's color at a point along it (0 to 1).",properties:{at:{description:"At.",maximum:1,minimum:0,type:"number"},color:{description:"Color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"}},required:["at","color"],type:"object"},PaywallString:{description:'A text: the string itself, or `{"t": key}` of the language table. Either may hold variables the app fills from its store \u2014 `{{price}}`, `{{price_per_month}}`, `{{period}}`, `{{trial}}`, `{{savings}}`, `{{product_name}}`, `{{offer_price}}` (the price of the package\'s offer while the customer may take it, its price otherwise) \u2014 of the package an item is, or of the selected package anywhere else. A text that names a variable its package has no value for (no trial, no savings) is not drawn.',oneOf:[{$ref:"#/$defs/PaywallLiteral"},{$ref:"#/$defs/PaywallTextKey"}]},PaywallStyle:{additionalProperties:!1,description:"What every component takes: padding and margin by edge, a size, a fill, a border, corners each their own, a shadow, an opacity. Points and colors name the theme's tokens or are given as they are.",properties:{background:{description:"Background.",oneOf:[{$ref:"#/$defs/PaywallColorValue"},{$ref:"#/$defs/PaywallLinear"},{$ref:"#/$defs/PaywallRadial"},{$ref:"#/$defs/PaywallImageFill"},{$ref:"#/$defs/PaywallVideoFill"}]},border:{$ref:"#/$defs/PaywallBorder"},corners:{description:"Corners.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"},{$ref:"#/$defs/PaywallCorners"}]},height:{description:"Height.",oneOf:[{$ref:"#/$defs/PaywallSizeKeyword"},{$ref:"#/$defs/PaywallLength"}]},margin:{description:"Margin.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"},{$ref:"#/$defs/PaywallEdges"}]},max_width:{description:"Max width.",maximum:4e3,minimum:1,type:"integer"},opacity:{default:1,description:"Opacity.",maximum:1,minimum:0,type:"number"},padding:{description:"Padding.",oneOf:[{$ref:"#/$defs/PaywallPoints"},{$ref:"#/$defs/PaywallToken"},{$ref:"#/$defs/PaywallEdges"}]},shadow:{$ref:"#/$defs/PaywallShadow"},width:{description:"Width.",oneOf:[{$ref:"#/$defs/PaywallSizeKeyword"},{$ref:"#/$defs/PaywallLength"}]}},type:"object"},PaywallSwitch:{additionalProperties:!1,description:"A switch between two contents \u2014 a yearly and a monthly offer \u2014, each selecting its own package when it is shown.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},default:{default:!1,description:"Default.",type:"boolean"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},label:{$ref:"#/$defs/PaywallString"},off:{$ref:"#/$defs/PaywallComponent"},off_package:{description:"Off package.",pattern:"^([a-z][a-z0-9_]{0,39})\\.([a-z][a-z0-9_]{0,39})$",type:"string"},on:{$ref:"#/$defs/PaywallComponent"},on_package:{description:"On package.",pattern:"^([a-z][a-z0-9_]{0,39})\\.([a-z][a-z0-9_]{0,39})$",type:"string"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},tint:{default:"accent",description:"Tint.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},type:{description:"The component.",enum:["switch"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["off","on","type"],type:"object"},PaywallTab:{additionalProperties:!1,description:"A tab: its label, its content, and the package it selects when it is shown.",properties:{content:{$ref:"#/$defs/PaywallComponent"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},label:{$ref:"#/$defs/PaywallComponent"},package:{description:"Package.",pattern:"^([a-z][a-z0-9_]{0,39})\\.([a-z][a-z0-9_]{0,39})$",type:"string"}},required:["content","id","label"],type:"object"},PaywallTabs:{additionalProperties:!1,description:"Tabs, each its own content and default package; the labels, in a bar, are components whose style when selected is the shown tab's.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},bar:{$ref:"#/$defs/PaywallStyle"},default:{description:"Default.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},tabs:{description:"Tabs.",items:{$ref:"#/$defs/PaywallTab"},maxItems:5,minItems:2,type:"array"},type:{description:"The component.",enum:["tabs"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["tabs","type"],type:"object"},PaywallTarget:{additionalProperties:!1,description:"What a countdown counts to: an instant (at), or a time from the moment the paywall opened (after_open_seconds) \u2014 one of them.",properties:{after_open_seconds:{description:"After open seconds.",maximum:604800,minimum:1,type:"integer"},at:{description:"At.",format:"date-time",type:"string"}},type:"object"},PaywallText:{additionalProperties:!1,description:"A text: one string, or spans \u2014 bold, italic, colored parts and links \u2014, in a type style of the theme or its own.",properties:{align:{default:"center",description:"Align.",enum:["start","center","end"],type:"string"},animation:{$ref:"#/$defs/PaywallAnimation"},color:{default:"text",description:"Color.",oneOf:[{$ref:"#/$defs/PaywallColorValue"},{$ref:"#/$defs/PaywallLinear"},{$ref:"#/$defs/PaywallRadial"}]},font:{description:"Font.",pattern:"^(system|rounded|serif|mono|asset:([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}))$",type:"string"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},letter_spacing:{description:"Letter spacing.",maximum:20,minimum:-5,type:"number"},line_height:{description:"Line height.",maximum:3,minimum:.5,type:"number"},max_lines:{description:"Max lines.",maximum:20,minimum:1,type:"integer"},size:{description:"Size.",oneOf:[{$ref:"#/$defs/PaywallFontSize"},{$ref:"#/$defs/PaywallToken"}]},spans:{description:"Spans.",items:{$ref:"#/$defs/PaywallSpan"},maxItems:20,minItems:1,type:"array"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},text:{$ref:"#/$defs/PaywallString"},type:{description:"The component.",enum:["text"],type:"string"},uppercase:{default:!1,description:"Uppercase.",type:"boolean"},visible:{$ref:"#/$defs/PaywallCondition"},weight:{description:"Weight.",enum:[100,200,300,400,500,600,700,800,900],type:"integer"}},required:["type"],type:"object"},PaywallTextKey:{additionalProperties:!1,description:"A text of the language table.",properties:{t:{description:"The text's key.",type:"string"}},required:["t"],type:"object"},PaywallTexts:{additionalProperties:{maxLength:500,type:"string"},description:"One language's texts, by key (lowercase letters, digits, `_` `.` `-`, at most 64): each at most 500 characters, with variables.",type:"object"},PaywallTheme:{additionalProperties:!1,description:"The paywall's design system: colors for light and dark, a type scale, radii and spacing; the components name them.",properties:{colors:{$ref:"#/$defs/PaywallColors"},radii:{$ref:"#/$defs/PaywallScale"},spacing:{$ref:"#/$defs/PaywallScale"},typography:{$ref:"#/$defs/PaywallTypeScale"}},required:["colors"],type:"object"},PaywallTimeline:{additionalProperties:!1,description:"Steps in time \u2014 a trial's today, its reminder, its first charge \u2014, each with an icon, joined by a line.",properties:{animation:{$ref:"#/$defs/PaywallAnimation"},color:{default:"text",description:"Color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},icon_color:{default:"on_accent",description:"Icon color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},items:{description:"Items.",items:{$ref:"#/$defs/PaywallTimelineItem"},maxItems:8,minItems:2,type:"array"},line_color:{default:"accent",description:"Line color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},line_width:{default:2,description:"Line width.",maximum:8,minimum:1,type:"integer"},spacing:{default:16,description:"Spacing.",maximum:64,minimum:0,type:"integer"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["timeline"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["items","type"],type:"object"},PaywallTimelineItem:{additionalProperties:!1,description:"A step of a timeline.",properties:{color:{description:"Color.",pattern:"^(#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})|[a-z][a-z0-9_]{0,31})$",type:"string"},icon:{$ref:"#/$defs/PaywallIconName"},text:{$ref:"#/$defs/PaywallString"},title:{$ref:"#/$defs/PaywallString"}},required:["icon","title"],type:"object"},PaywallToken:{description:"A token of the theme's scale.",pattern:"^[a-z][a-z0-9_]{0,31}$",type:"string"},PaywallTypeScale:{additionalProperties:{$ref:"#/$defs/PaywallTypography"},description:"Type styles by token (lowercase letters, digits and _, at most 32).",maxProperties:16,type:"object"},PaywallTypography:{additionalProperties:!1,description:"A type style of the theme: what a text whose size names it is drawn in. It scales with its text style (Dynamic Type on iOS, the root font size on the web).",properties:{font:{default:"system",description:"Font.",pattern:"^(system|rounded|serif|mono|asset:([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}))$",type:"string"},letter_spacing:{default:0,description:"Letter spacing.",maximum:20,minimum:-5,type:"number"},line_height:{description:"Line height.",maximum:3,minimum:.5,type:"number"},size:{description:"Size.",maximum:120,minimum:6,type:"number"},text_style:{default:"body",description:"Text style.",enum:["large_title","title","title2","title3","headline","body","callout","subheadline","footnote","caption"],type:"string"},weight:{default:400,description:"Weight.",enum:[100,200,300,400,500,600,700,800,900],type:"integer"}},required:["size"],type:"object"},PaywallVideo:{additionalProperties:!1,description:"A video the app downloads before it shows the paywall; muted and looping unless it says otherwise.",properties:{alt:{$ref:"#/$defs/PaywallString"},animation:{$ref:"#/$defs/PaywallAnimation"},aspect:{description:"Aspect.",maximum:10,minimum:.1,type:"number"},autoplay:{default:!0,description:"Autoplay.",type:"boolean"},controls:{default:!1,description:"Controls.",type:"boolean"},fit:{default:"fill",description:"Fit.",enum:["fit","fill"],type:"string"},id:{description:"Names the component, unique in the paywall: an app's code can draw its own part in its place.",pattern:"^[a-z][a-z0-9_-]{0,39}$",type:"string"},loop:{default:!0,description:"Loop.",type:"boolean"},mute:{default:!0,description:"Mute.",type:"boolean"},poster:{description:"Poster.",maxLength:2048,pattern:"^(https://.+|asset:([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}))$",type:"string"},src:{description:"Src.",maxLength:2048,pattern:"^(https://.+|asset:([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}))$",type:"string"},states:{$ref:"#/$defs/PaywallStates"},style:{$ref:"#/$defs/PaywallStyle"},type:{description:"The component.",enum:["video"],type:"string"},visible:{$ref:"#/$defs/PaywallCondition"}},required:["src","type"],type:"object"},PaywallVideoFill:{additionalProperties:!1,description:"A muted video behind the component.",properties:{loop:{default:!0,description:"Loop.",type:"boolean"},poster:{description:"Poster.",maxLength:2048,pattern:"^(https://.+|asset:([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}))$",type:"string"},src:{description:"Src.",maxLength:2048,pattern:"^(https://.+|asset:([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}))$",type:"string"},type:{description:"Type.",enum:["video"],type:"string"}},required:["src","type"],type:"object"}}};var mt=`${me}/paywalls`,Va=`${mt}/paywall.schema.json`,As="paywall-assets",Sp=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,nl=e=>`"${e}"`;function Xa(e,t,n){let s=e.args[t];if(s===void 0||s.trim()==="")throw g(`${n} is required`);return s}async function Qn(e,t){return(await h(e,t,"GET","/purchases/paywalls")).paywalls}function sl(e,t){if(Sp.test(t))return e.find(a=>a.id===t.toLowerCase());let n=e.filter(a=>a.name===t),s=n.length>0?n:e.filter(a=>a.name.toLocaleLowerCase()===t.toLocaleLowerCase());if(s.length>1)throw new y("ambiguous_paywall",`${s.length} paywalls are named ${JSON.stringify(t)}`,{hint:`name one by its id: ${s.map(a=>a.id).join(", ")}`});return s[0]}async function aa(e,t,n){let s=await Qn(e,t),a=sl(s,n);if(!a)throw new y("paywall_not_found",`no paywall ${JSON.stringify(n)}`,{hint:s.length>0?`the project's: ${s.map(i=>i.name).join(", ")}`:"the project has none yet: palbase purchases:paywalls:put <name> --file <file> --revision 0 makes one"});return a}function Zi(e){let t=e.normalize("NFKD").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60);return t===""?"paywall":t}function Nt(e,t,n,s,a=`${mt}/<name>${s}`){let i=o2(e.io.cwd,Tw(e.io.cwd,n)).split(l2).join("/");if(!i.startsWith(`${me}/`)||i.split("/").includes(".."))throw g(`--${t} ${n}: the file goes under ${me}/, as the CLI writes nothing else in the checkout`,`--${t} ${a}`);if(!i.endsWith(s))throw g(`--${t} ${n}: the file's name ends in ${s}`);return i}async function el(e,t,n){let s=await Be(e.io.cwd,t);await s2(r2(s),{recursive:!0}),await Be(e.io.cwd,t),await i2(s,n)}var Cw=`${JSON.stringify(Zo,null,2)}
|
|
673
673
|
`;async function tl(e,t,n){await el(e,Va,Cw);let s=Pw.relative(Pw.dirname(t),Va);await el(e,t,`${JSON.stringify({$schema:s.startsWith(".")?s:`./${s}`,...n},null,2)}
|
|
674
674
|
`)}async function al(e,t){let n=Fe(await Xe(e,t,"the paywall"),"the paywall");if(typeof n!="object"||n===null||Array.isArray(n))throw g("a paywall is a JSON object: { schema, name, default_locale, theme, root, \u2026 }");if("draft"in n&&"draft_revision"in n)throw g('the file is a whole paywall (its draft, its revision, its problems): give its "draft" alone, as purchases:paywalls:get --out writes it');if("definition"in n&&!("root"in n))throw g('the file is a definition inside something else: give the "definition" alone, as purchases:paywalls:get --out writes it');let{$schema:s,...a}=n;return a}function il(e,t){for(let n of t)e.out.note(` ${n.path}: ${n.code} \u2014 ${n.message}${n.warning?" (warning)":""}`)}var jw=e=>e.filter(t=>!t.warning).length;function Ow(e){if(!(!(e instanceof W)||e.code!=="invalid_paywall"))return(e.body??{}).problems??[]}function Nw(e,t,n){let s=Ow(t);throw s!==void 0?(s.length>0&&(e.out.note(`The paywall breaks ${jw(s)} rule(s):`),il(e,s)),new y("invalid_paywall",`${n}: ${t.message}`,{hint:"fix each problem in the file (palbase purchases:paywalls:validate --file <file> checks it without saving)"})):t}function Iw(e,t,n){return new y("paywall_changed",`the draft of ${e} is no longer at revision ${t}: someone saved a newer one since it was read \u2014 nothing was ${n}`,{hint:`read it again (palbase purchases:paywalls:get ${JSON.stringify(e)}), make the edit on it, and save it with that revision`})}async function d2(e,t){let n=new Map,s=(o,l)=>{if(o===void 0)return;let d=n.get(o)??[];d.includes(l)||d.push(l),n.set(o,d)},{placements:a}=await h(e,t,"GET","/purchases/placements");for(let o of a)s(o.paywall_id,o.key);let i=a.filter(o=>o.rule_count>0);return(await Promise.all(i.map(o=>h(e,t,"GET",`/purchases/placements/${T(o.key)}/rules`)))).forEach((o,l)=>{for(let d of o.rules)s(d.target.paywall_id,`${i[l].key} (rule)`)}),n}var p2={name:"purchases:paywalls",summary:"the environment's paywalls: each one's draft revision, the version published, and the placements that show it",details:["A paywall is a JSON definition: purchases:paywalls:get writes one to a file, purchases:paywalls:put saves the edit as its draft, purchases:paywalls:publish makes the draft what the apps draw.","An app sees a paywall once it is published and a placement shows it.","How a definition is written \u2014 every component and field, and three to start from: palbase purchases:paywalls:guide"],scope:"environment",async run(e){let t=await w(e),[n,s]=await Promise.all([Qn(e,t),d2(e,t)]),a=n.map(i=>({...i,placements:s.get(i.id)??[]}));e.out.result({paywalls:a},()=>{if(a.length===0){e.out.line("No paywall yet."),e.out.line(`Write a definition and save it: palbase purchases:paywalls:put <name> --file ${mt}/<name>.json --revision 0`);return}e.out.table(a,[{header:"name",value:i=>i.name},{header:"id",value:i=>i.id},{header:"draft",value:i=>`revision ${i.draft_revision}`},{header:"published",value:i=>i.published_version===0?"never":`version ${i.published_version}, ${Y(i.published_at)}`},{header:"shown at",value:i=>i.placements.length===0?"\u2014":i.placements.join(", ")}])})}},c2={name:"purchases:paywalls:get",summary:"write a paywall's draft \u2014 or a version published \u2014 to a file to edit, with the revision it is at",usage:`<name|id> [--out <${mt}/name.json>] [--version <n>]`,details:[`The file is the definition alone, as purchases:paywalls:put takes it, under ${mt}/. Its first line names its JSON Schema, written beside it (${Va}), so an editor checks the file as it is edited.`,"The revision printed is the one an edit is saved on: purchases:paywalls:put --revision."],args:{min:1,max:1},flags:{out:{type:"string",value:"file",description:`where under ${me}/ (default: ${mt}/<name>.json)`},version:{type:"string",value:"n",description:"a published version instead of the draft"}},scope:"environment",async run(e){let t=await w(e),n=Te(e.flags.version,"version");if(n===0)throw g("--version is 1 or more: the versions published");let s=await aa(e,t,Xa(e,0,"the paywall's name or id")),a=e.flags.out!==void 0?Nt(e,"out",e.flags.out,".json"):`${mt}/${Zi(s.name)}${n===void 0?"":`.v${n}`}.json`;if(n!==void 0){let r;try{r=await h(e,t,"GET",`/purchases/paywalls/${T(s.id)}/versions/${n}`)}catch(o){throw o instanceof W&&o.status===404?new y("version_not_found",`${s.name} has no version ${n}${s.published_version===0?": it was never published":`: its newest is ${s.published_version} (the newest 50 are kept)`}`):o}if(!r.definition)throw new y("unexpected_answer",`the module answered version ${n} of ${s.name} without its definition`);await tl(e,a,r.definition),e.out.result({file:a,paywall_id:s.id,name:s.name,version:r.version,published_at:r.published_at,draft_revision:s.draft_revision},()=>{e.out.line(`Wrote version ${r.version} of ${s.name} (published ${Y(r.published_at)}) to ${a}.`),e.out.line(`Saved as the draft, it goes on the draft's revision: palbase purchases:paywalls:put ${JSON.stringify(s.name)} --file ${a} --revision ${s.draft_revision}`)});return}let i=await h(e,t,"GET",`/purchases/paywalls/${T(s.id)}`);await tl(e,a,i.draft),e.out.result({file:a,paywall_id:i.id,name:i.name,revision:i.draft_revision,published_version:i.published_version,problems:i.problems},()=>{e.out.line(`Wrote draft revision ${i.draft_revision} of ${i.name} to ${a}${i.published_version===0?" (never published)":` (version ${i.published_version} is published)`}.`),i.problems.length>0&&(e.out.note("The module says of the draft:"),il(e,i.problems)),e.out.line(`Save an edit of it: palbase purchases:paywalls:put ${JSON.stringify(i.name)} --file ${a} --revision ${i.draft_revision}`)})}},u2={name:"purchases:paywalls:validate",summary:"check a paywall definition as publishing it would, without saving it: every problem, by its path",usage:"--file <paywall.json>",details:["Every rule of the schema is checked, and every package against the environment's catalog as it is. A warning (what App Review expects of a paywall, say) does not stop a save or a publish.","It exits 1 while a problem that is not a warning is left; --json prints { valid, problems } either way."],flags:{file:{type:"string",value:"paywall.json",description:"the definition ('-' or none: stdin)"}},scope:"environment",async run(e){let t=await w(e),n=await al(e,e.flags.file),s;try{s={valid:!0,problems:(await h(e,t,"POST","/purchases/paywalls/validate",n,J())).problems??[]}}catch(a){let i=Ow(a);if(i===void 0)throw a;s={valid:!1,problems:i}}return e.out.result(s,()=>{s.problems.length>0&&il(e,s.problems);let a=s.problems.filter(i=>i.warning).length;e.out.line(s.valid?`The paywall can be published${a>0?`, with ${a} warning(s)`:""}.`:`The paywall breaks ${jw(s.problems)} rule(s): it cannot be saved as it is.`)}),s.valid?void 0:1}};async function Lw(e,t,n,s){try{let a=await wt(e,t,"POST",`/purchases/paywalls/${T(n.id)}/publish`,void 0,{"if-match":nl(s),...J()});return{version:a.body,fresh:a.status===201}}catch(a){if(a instanceof W&&a.status===412)throw Iw(n.name,s,"published");Nw(e,a,`${n.name} was not published`)}}function Dw(e,t,n){e.out.line(n.fresh?`Published version ${n.version.version} of ${t}: the apps asking for a placement that shows it get it at once.`:`The draft of ${t} is what version ${n.version.version} already is: nothing new was published.`)}var m2={name:"purchases:paywalls:put",summary:"save a definition as a paywall's draft, on the revision it was edited from \u2014 or make the paywall, at revision 0; --publish publishes it too",usage:"<name|id> --file <paywall.json> --revision <n> [--publish]",details:["The module checks it first: a definition that breaks a rule is refused with every problem, and nothing is saved.","Of two people editing at once, the second is told \u2014 the draft moved past the revision they edited \u2014 never overwritten.","What the apps draw changes only when the draft is published (--publish, or purchases:paywalls:publish). A new paywall takes the name its definition gives.","How a definition is written: palbase purchases:paywalls:guide"],args:{min:1,max:1},flags:{file:{type:"string",value:"paywall.json",description:"the definition, as purchases:paywalls:get wrote it ('-' or none: stdin)"},revision:{type:"string",value:"n",description:"the draft revision it was edited from, as purchases:paywalls:get printed it (0 makes a new paywall)"},publish:{type:"boolean",description:"publish the saved draft as the next version"}},scope:"environment",async run(e){let t=await w(e),n=Xa(e,0,"the paywall's name or id"),s=Te(e.flags.revision,"revision");if(s===void 0)throw g("--revision is the draft revision the paywall was edited from (0 for a new one): of two edits at once, the second is told, not saved over the first");let a=await al(e,e.flags.file),i=sl(await Qn(e,t),n),r=e.flags.publish===!0?" and publish it":"",o;try{if(i){if(s===0)throw new y("paywall_exists",`${i.name} is there already, at draft revision ${i.draft_revision}: an edit of it is saved on the revision it was read at`,{hint:`palbase purchases:paywalls:get ${JSON.stringify(i.name)} writes it and prints the revision`});await k(e,t,`save the draft of ${i.name} over revision ${s}${r}`),o=await h(e,t,"PUT",`/purchases/paywalls/${T(i.id)}/draft`,{definition:a},{"if-match":nl(s),...J()})}else{if(Sp.test(n))throw new y("paywall_not_found",`no paywall ${n}`);if(s!==0)throw new y("paywall_not_found",`no paywall ${JSON.stringify(n)} to save revision ${s} over`,{hint:"--revision 0 makes it"});if(typeof a.name!="string"||a.name.toLocaleLowerCase()!==n.toLocaleLowerCase())throw g(`the file names the paywall ${JSON.stringify(a.name)}, not ${JSON.stringify(n)}: a new paywall takes the name its definition gives`,`set "name" to ${JSON.stringify(n)} in the file, or: palbase purchases:paywalls:put ${JSON.stringify(a.name??"")} \u2026`);await k(e,t,`make the paywall ${a.name}${r}`),o=await h(e,t,"POST","/purchases/paywalls",{definition:a},J())}}catch(d){if(d instanceof W&&d.status===412)throw Iw(i?.name??n,s,"saved");if(d instanceof W&&d.code==="too_many_paywalls")throw new y("too_many_paywalls","the project has 100 paywalls, the most it holds: nothing was made",{hint:"delete one no placement shows: palbase purchases:paywalls:delete <name>"});Nw(e,d,"the paywall was not saved")}let l=e.flags.publish===!0?await Lw(e,t,o,o.draft_revision):void 0;e.out.result({...o,...l?{published:l.version,published_new:l.fresh}:{}},()=>{e.out.line(`${i?"Saved":"Made"} ${o.name}: its draft is at revision ${o.draft_revision}.`),o.problems.length>0&&(e.out.note("The module says of the draft:"),il(e,o.problems)),l?Dw(e,o.name,l):e.out.line(`The apps draw it once it is published: palbase purchases:paywalls:publish ${JSON.stringify(o.name)}`)})}},h2={name:"purchases:paywalls:publish",summary:"publish a paywall's draft as its next version: what the apps asking for a placement that shows it draw from then on",usage:"<name|id> [--revision <n>]",details:["It is checked as the apps will get it: every package must be sold by the catalog, every asset still what was registered.","--revision names the draft revision that was looked at: a draft saved since is not published in its place. Without it, the draft as it is now is published.","A draft the same as the newest version publishes nothing new."],args:{min:1,max:1},flags:{revision:{type:"string",value:"n",description:"the draft revision looked at (default: the draft as it is now)"}},scope:"environment",async run(e){let t=await w(e),n=await aa(e,t,Xa(e,0,"the paywall's name or id")),s=Te(e.flags.revision,"revision")??n.draft_revision;await k(e,t,`publish draft revision ${s} of ${n.name}`);let a=await Lw(e,t,n,s);e.out.result({...a.version,published_new:a.fresh},()=>Dw(e,n.name,a))}},g2={name:"purchases:paywalls:delete",summary:"delete a paywall and its versions; one a placement or a running experiment shows is not deleted",usage:"<name|id>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=await aa(e,t,Xa(e,0,"the paywall's name or id"));await k(e,t,`delete the paywall ${n.name}: its draft and every version of it`);try{await h(e,t,"DELETE",`/purchases/paywalls/${T(n.id)}`,void 0,J())}catch(s){throw s instanceof W&&s.code==="paywall_in_use"?new y("paywall_in_use",`${n.name} is shown \u2014 a placement shows it, as its default or by a rule, or a running experiment does \u2014 so it was not deleted`,{hint:"palbase purchases:paywalls says where; give those placements another paywall, or stop the experiment, first"}):s}e.out.result({deleted:n.id,name:n.name},()=>e.out.line(`Deleted ${n.name}.`))}},f2={name:"purchases:paywalls:schema",summary:"the JSON Schema of a paywall definition: every component, its fields and their bounds, for an editor or an agent to check a file against",usage:`[--out <${Va}>]`,details:["It is the module's contract, as the CLI was built with it: a file that passes may still be refused for what only the module knows (the catalog's packages, the project's assets) \u2014 purchases:paywalls:validate asks it.",'purchases:paywalls:get writes it too, and names it on the first line of each file ("$schema").'],flags:{out:{type:"string",value:"file",description:`where under ${me}/ (default: ${Va}); --json prints it instead`}},scope:"none",async run(e){if(e.global.json){e.out.result(Zo,()=>{});return}let t=e.flags.out!==void 0?Nt(e,"out",e.flags.out,".json"):Va;await el(e,t,Cw),e.out.line(`Wrote the paywall definition's JSON Schema to ${t}.`)}},y2={name:"purchases:paywalls:guide",summary:"how a paywall definition is written by hand \u2014 for an agent or a person: the flow, every component and field in the contract's words, three definitions to start from",usage:`[--out <${mt}/GUIDE.txt>]`,details:["It is made from the definition's JSON Schema the CLI carries (purchases:paywalls:schema), so it says what this version of the CLI checks."],flags:{out:{type:"string",value:"file",description:`write it to a file under ${me}/ instead of printing it`}},scope:"none",async run(e){let t=Aw(Zo),n=e.flags.out;if(n===void 0){e.out.result({guide:t},()=>e.io.stdout(t));return}let s=Nt(e,"out",n,".txt");await el(e,s,t),e.out.result({file:s},()=>e.out.line(`Wrote the guide to ${s}.`))}},Rw=["image","video","font","html"];function kp(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(e<10*1024?1:0)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}async function Ya(e,t){return(await h(e,t,"GET","/purchases/paywalls/assets")).assets??[]}var Ew={unsupported_asset:"it is no file a paywall takes: an image (PNG, JPEG or WebP, never SVG), a video (MP4 or MOV), a font (TTF, OTF or WOFF2), or an HTML block as a zip",asset_too_large:"it is too large for a paywall: an image is at most 2 MiB, a video 50 MiB, a font or an HTML block's zip 5 MiB",asset_kind_mismatch:"its bytes are not the kind --kind names",invalid_archive:"the zip could not be opened: an HTML block is a zip with index.html at its root",archive_too_many_files:"the HTML block holds too many files: at most 200",archive_too_large:"the HTML block is too large opened: at most 20 MiB of files",unsafe_archive_path:"the HTML block has a file whose path leaves the zip: every file stays under its root",archive_link:"the HTML block holds a link: a zip of plain files is taken",archive_no_index:"the HTML block has no index.html at its root",asset_unreadable:"the purchases module could not read it at its public address; trying again in a moment is safe",too_many_assets:"the project has 500 assets, the most it holds: delete one no paywall names first (palbase purchases:paywalls:assets:delete <id>)"};async function Ap(e,t){let n;try{n=await h(e,t,"GET",`/storage/buckets/${As}`)}catch(s){if(!(s instanceof W)||s.status!==404)throw s}if(!n?.public){if(n)throw new y("asset_bucket_private",`the project's ${As} bucket is private: an app downloads a paywall's assets at their public address, and the CLI does not open a bucket the project closed`,{hint:`if everything in it may be read by anyone: palbase storage:buckets:set ${As} --public`});await h(e,t,"PUT",`/storage/buckets/${As}`,{public:!0,file_size_limit:null,allowed_mime_types:[],variants:[]}),e.out.note(`Made the public bucket ${As}: paywall assets are kept in the project's own storage.`)}}function b2(e){let t=Qo(e).normalize("NFKD").replace(/[^\w.-]+/g,"-").replace(/^-+|-+$/g,"").slice(-80).replace(/^\.+$/,"")||"file";return`paywalls/${n2()}/${t}`}async function Pp(e,t,n,s){let a=b2(n);await mp(e,t,n,As,a);try{return await h(e,t,"POST","/purchases/paywalls/assets",{path:a,...s?{kind:s}:{}},J())}catch(i){throw await h(e,t,"DELETE",`/storage/buckets/${As}/objects/${Bo(a)}`).catch(()=>{}),i instanceof W&&i.code!==void 0&&i.code in Ew?new y(i.code,`${Qo(n)} was not registered: ${Ew[i.code]}`):i}}var w2={name:"purchases:paywalls:assets",summary:"the project's paywall assets: the images, videos, fonts and HTML blocks a definition names asset:<id>",scope:"environment",async run(e){let t=await w(e),n=await Ya(e,t);e.out.result({assets:n},()=>{if(n.length===0){e.out.line("No paywall asset yet."),e.out.line("Upload one: palbase purchases:paywalls:assets:upload <file>");return}e.out.table(n,[{header:"ref",value:s=>s.ref},{header:"kind",value:s=>s.kind},{header:"size",value:s=>kp(s.bytes)},{header:"file",value:s=>s.path.split("/").pop()??s.path},{header:"registered",value:s=>Y(s.created_at)}])})}},v2={name:"purchases:paywalls:assets:upload",summary:"upload a file to the project's storage and register it for paywalls: it answers the asset:<id> a definition names",usage:"<file> [--kind image|video|font|html]",details:[`The file goes to the project's public bucket ${As} (made when there is none; a private one is left as it is, and refuses). The module then reads it there, says what it is by its bytes, and keeps their SHA-256: an app draws what it downloads only when it is that.`,"An image is PNG, JPEG or WebP, at most 2 MiB; a video MP4 or MOV, 50 MiB; a font TTF, OTF or WOFF2, 5 MiB; an HTML block a zip with index.html at its root, 5 MiB."],args:{min:1,max:1},flags:{kind:{type:"string",value:"kind",description:"what the file is meant to be: one whose bytes are another kind is refused"}},scope:"environment",async run(e){let t=await w(e),n=Tw(e.io.cwd,Xa(e,0,"the file")),s=e.flags.kind;if(s!==void 0&&!Rw.includes(s))throw g(`--kind is one of ${Rw.join(", ")}`);let a;try{let r=await a2(n);if(!r.isFile())throw new Error("it is not a file");a=r.size}catch(r){throw new y("unreadable_file",`${e.args[0]} could not be read: ${r instanceof Error?r.message:String(r)}`)}if(a===0)throw new y("empty_file",`${e.args[0]} is empty`);await k(e,t,`upload ${Qo(n)} (${kp(a)}) as a paywall asset`),await Ap(e,t);let i=await Pp(e,t,n,s);e.out.result(i,()=>{e.out.line(`Registered ${Qo(n)} as ${i.ref} (${i.kind}, ${kp(i.bytes)}).`),e.out.line(`A definition names it "${i.ref}" where it takes ${i.kind==="html"?"an HTML block":i.kind==="image"?"an image":`a ${i.kind}`}.`)})}},_2={name:"purchases:paywalls:assets:delete",summary:"forget a paywall asset no paywall names, and remove its file from the project's storage",usage:"<asset:id|id>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=Xa(e,0,"the asset's id").replace(/^asset:/,"").toLowerCase();if(!Sp.test(n))throw g(`${e.args[0]} is not an asset: asset:<id>, as purchases:paywalls:assets lists them`);let s=(await Ya(e,t)).find(i=>i.id===n);if(!s)throw new y("asset_not_found",`the project has no asset ${n}`,{hint:"palbase purchases:paywalls:assets lists them"});await k(e,t,`delete the paywall asset ${s.ref} (${s.path.split("/").pop()})`);try{await h(e,t,"DELETE",`/purchases/paywalls/assets/${T(n)}`,void 0,J())}catch(i){throw i instanceof W&&i.code==="asset_in_use"?new y("asset_in_use",`${s.ref} is named by a paywall \u2014 in its draft, or in a version kept \u2014 so it was not deleted`,{hint:"take it out of the paywall (its draft, then publish) first"}):i}let a=!0;await h(e,t,"DELETE",`/storage/buckets/${T(s.bucket)}/objects/${Bo(s.path)}`).catch(()=>{a=!1}),e.out.result({deleted:n,object_removed:a},()=>{e.out.line(`Deleted ${s.ref}.`),a||e.out.warn(`its file stays in the project's storage: palbase storage:rm ${s.bucket}:${s.path}`)})}},Mw=[p2,c2,u2,m2,h2,g2,f2,y2,w2,v2,_2];var Uw=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,j2=/^AuthKey_([A-Z0-9]{10})\.p8$/,O2=8192,Kw=["testflight","play_internal","development"],Fw=["testflight","development"],Rp=100,Bw=5,N2=5,tv=300,I2=5,rl=900,L2=["iphone_6_9","iphone_6_5","ipad_13"],Ww=/^[0-9a-f]{64}$/i,D2=10*1024*1024,zw=3,M2={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg"},es=`${me}/store/listing.json`,Es={beta_review:"Beta App Review",export_compliance:"the export compliance answer",expire_build:"expiring the build",apply_listing:"writing the App Store page",submit_review:"the App Review submission",withdraw_review:"the withdrawal from App Review",release_version:"the release",phased_release:"a phased release change"};function Za(e){return e.package_id?`package ${e.package_id}`:`app ${e.app_id??"?"}`}var Cp=e=>e.charAt(0).toUpperCase()+e.slice(1);function Y(e){return e?e.slice(0,19).replace("T"," "):"\u2014"}function fe(e,t,n){let s=e.args[t];if(s===void 0||s.trim()==="")throw g(`${n} is required`);return s}function ns(e,t,n,s){let a=Wt(e.cloud,t.env_ref),i;try{i=new URL(n).origin}catch{throw new y("unexpected_address",`${s} is not a URL: nothing was sent`)}if(i!==a)throw new y("unexpected_address",`${s} names ${i}, not the environment's address ${a}: nothing was sent`);return a}async function er(e,t,n,s){let a;try{a=await e.io.fetch(t,{...n,redirect:"manual"})}catch(l){throw new y("network_error",`${s}: ${t} could not be reached: ${l instanceof Error?l.message:String(l)}`)}let i=await a.text(),r;if(i!=="")try{r=JSON.parse(i)}catch{r=i}if(a.status>=200&&a.status<300)return r;let o=r??{};throw new W({op:s,status:a.status,code:typeof o.error=="string"?o.error:`http_${a.status}`,message:Fr(r,a.status),requestId:typeof o.request_id=="string"?o.request_id:a.headers.get("x-request-id")??void 0,retryAfter:x2(a.headers.get("retry-after"),o.retry_after,e.io.now()),body:r})}function x2(e,t,n){if(e!==null&&e.trim()!==""){let s=Number(e);if(Number.isFinite(s)&&s>=0)return s;let a=Date.parse(e);if(Number.isFinite(a))return Math.max(0,Math.ceil((a-n)/1e3))}return typeof t=="number"&&Number.isFinite(t)&&t>=0?t:void 0}function jp(e,t){if(!t.connected){e.out.line("No Apple account is connected."),e.out.line("Connect one: palbase stores:apple:connect --key-file AuthKey_<KEYID>.p8 --issuer-id <issuer id>");return}e.out.line(`Apple account: issuer ${t.issuer_id??"?"}, key ${t.key_id??"?"}`),e.out.line(`status: ${t.status??"not checked"}${t.checked_at?` (checked ${Y(t.checked_at)})`:""}`),t.capabilities&&e.out.line(`reaches: ${t.capabilities.length>0?t.capabilities.join(", "):"nothing"}`),t.connected_at&&e.out.line(`connected ${Y(t.connected_at)}${t.connected_by?` by ${t.connected_by}`:""}`),t.status==="agreement"?e.out.line(`Apple waits on the account holder: ${t.action??"accept the account's agreements in App Store Connect"}, then palbase stores:apple:check`):t.action&&e.out.line(`To do: ${t.action}`)}function Op(e,t){if(!t.connected){e.out.line("No Apple ID is signed in (App Review messages, App Privacy and app records need one)."),e.out.line("Sign one in: palbase stores:apple:connect --apple-id <you@example.com>");return}e.out.line(`Apple ID: ${t.apple_id??"?"}${t.team?` in ${t.team.name}`:""}${t.roles&&t.roles.length>0?` (${t.roles.join(", ")})`:""}`),e.out.line(`session: ${t.status??"?"}${t.checked_at?` (checked ${Y(t.checked_at)})`:""}`),t.connected_at&&e.out.line(`signed in ${Y(t.connected_at)}${t.connected_by?` by ${t.connected_by}`:""}`),t.shared_from&&e.out.line(`shared from ${t.shared_from.name||t.shared_from.ref||t.shared_from.project_id}, where it was signed in: used here too; signed out from either, it serves neither`),t.action&&e.out.line(`To do: ${t.action}`)}var G2={name:"stores:apple",summary:"the environment's Apple account and Apple ID: whether each is connected, what Apple last said of them, what the key reaches",scope:"environment",async run(e){let t=await w(e),n=await h(e,t,"GET","/stores/apple"),s=await h(e,t,"GET","/stores/apple/session").catch(a=>{if(!(a instanceof W&&a.status===404))throw a});e.out.result(s===void 0?n:{...n,apple_id_session:s},()=>{jp(e,n),s!==void 0&&(e.out.line(""),Op(e,s))})}};async function q2(e,t){let n=new Uint8Array([...new TextEncoder().encode("palbase/stores/apple-id/password/1"),0,...new TextEncoder().encode(e.grant)]),{enc:s,ct:a}=await id(Rn(e.seal_key),n,new TextEncoder().encode(t)),i=new Uint8Array(s.length+a.length);return i.set(s),i.set(a,s.length),ji(i)}async function U2(e,t,n){if(e.flags["key-file"]!==void 0)throw g("--apple-id or --key-file, not both");if(e.flags["print-link"]===!0){await k(e,t,"make a link that signs an Apple ID in");let p=await h(e,t,"POST","/stores/apple/session/grants",void 0,J());ns(e,t,p.connect_url,"the sign-in link"),e.out.result({connect_url:p.connect_url,expires_at:p.expires_at},()=>{e.out.line(p.connect_url),e.out.note(`Open it in a browser and sign in there; it works once, until ${Y(p.expires_at)}.`)});return}if(!e.io.interactive)throw g("signing an Apple ID in asks for Apple's code at the terminal","or --print-link for a link a browser opens");await k(e,t,`sign the Apple ID ${n} in`);let s=await ut(e,`the password of ${n}`),a=await h(e,t,"POST","/stores/apple/session/grants",void 0,J()),i=ns(e,t,a.connect_url,"the sign-in link"),r=await q2(a,s),o=(p,c)=>er(e,`${i}/stores/connect/apple-id${p}`,{method:"POST",headers:{"content-type":"application/json",accept:"application/json"},body:JSON.stringify({grant:a.grant,...c})},"signing the Apple ID in"),l=await o("",{apple_id:n,password_sealed:r});for(;l.step==="code";){let p=l.method==="phone"?`to ${l.destination??"your phone"}`:"to your trusted devices",c=(await e.io.prompt(`Apple sent a code ${p}. Code: `)).replace(/\s/g,"");try{l=await o("/code",{code:c})}catch(m){if(m instanceof W&&m.code==="apple_code_refused"){e.out.note("Apple did not accept this code.");continue}throw m}}if(l.step==="team"){let p=l.teams??[],c=e.flags.team,m=c===void 0?void 0:p.find(f=>f.id===c||f.name===c);if(c!==void 0&&m===void 0)throw new y("unknown_team",`${n} is not in the team ${c}: ${p.map(f=>f.name).join(", ")}`);for(;m===void 0;){p.forEach((b,v)=>e.out.note(` ${v+1}. ${b.name}`));let f=Number((await e.io.prompt(`${n} is in ${p.length} teams. The one this environment's apps are in [1-${p.length}]: `)).trim());m=p[f-1]}l=await o("/team",{team:m.id})}let d=l.session??{connected:!1};e.out.result(d,()=>{e.out.line(`Signed ${n} in to ${se(t)}.`),Op(e,d)})}var K2={name:"stores:apple:connect",summary:"connect an App Store Connect API key, or sign an Apple ID in: either goes from this computer straight to the environment, never through Studio",usage:"--key-file <AuthKey_KEYID.p8> --issuer-id <issuer id> [--key-id <KEYID>] | --apple-id <email> [--team <team>] | [--apple-id <email>] --print-link",details:["App Store Connect \u2192 Users and Access \u2192 Integrations \u2192 App Store Connect API makes the key and shows the Issuer ID; stores:apple then says what its role reaches.","Studio is asked for a one-time grant alone; the key is posted with it to the environment's own address. --print-link prints a link that takes the key in a browser instead.","--apple-id signs an Apple ID in, for what Apple's API does not do: App Review's messages and the answer to them, App Privacy, making an app record. Its password is read here and handed to Apple through the environment, never kept; then Apple's code, and the team when the Apple ID is in more than one. An owner's or an admin's."],flags:{"apple-id":{type:"string",value:"email",description:"sign this Apple ID in instead of connecting a key"},team:{type:"string",value:"team",description:"the Apple ID's team, by name or id, when it is in more than one"},"key-file":{type:"string",value:"AuthKey_KEYID.p8",description:"the .p8 file Apple gave when the key was made"},"key-id":{type:"string",value:"KEYID",description:"the key's id (default: from the file's name)"},"issuer-id":{type:"string",value:"issuer id",description:"the account's issuer id"},"print-link":{type:"boolean",description:"only print a link that takes the key in a browser (valid 30 minutes, once)"}},scope:"environment",async run(e){let t=await w(e),n=e.flags["apple-id"];if(n!==void 0){if(n.trim()==="")throw g("--apple-id is the Apple ID: an email address");await U2(e,t,n.trim());return}if(e.flags["print-link"]===!0){if(e.flags["key-file"]!==void 0)throw g("--print-link or --key-file, not both");await k(e,t,"make a link that connects an Apple account");let m=await h(e,t,"POST","/stores/apple/grants",void 0,J());ns(e,t,m.connect_url,"the connect link"),e.out.result({connect_url:m.connect_url,expires_at:m.expires_at},()=>{e.out.line(m.connect_url),e.out.note(`Open it in a browser and pick the .p8 file; it works once, until ${Y(m.expires_at)}.`)});return}let s=e.flags["key-file"],a=e.flags["issuer-id"];if(s===void 0)throw g("--key-file names the .p8 file","or --print-link for a link a browser opens");if(a===void 0||a.trim()==="")throw g("--issuer-id is the account's issuer id (App Store Connect \u2192 Users and Access \u2192 Integrations)");let i=P2(s),r=e.flags["key-id"]??j2.exec(i)?.[1];if(r===void 0)throw g(`--key-id is needed: ${i} is not named AuthKey_<KEYID>.p8`);let o;try{let m=ts(e.io.cwd,s);if((await Tp(m)).size>O2)throw new y("not_a_key",`${s} is larger than a .p8 key`);o=await k2(m,"utf8")}catch(m){throw m instanceof y?m:new y("unreadable_file",`${s} could not be read: ${m instanceof Error?m.message:String(m)}`)}if(!o.includes("-----BEGIN PRIVATE KEY-----"))throw new y("not_a_key",`${s} is not a .p8 key (no "BEGIN PRIVATE KEY")`);await k(e,t,`connect the Apple account of issuer ${a} with key ${r}`);let l=await h(e,t,"POST","/stores/apple/grants",void 0,J()),d=ns(e,t,l.connect_url,"the connect link"),p={grant:l.grant,issuer_id:a.trim(),key_id:r,private_key:o,file_name:i},c=await er(e,`${d}/stores/connect`,{method:"POST",headers:{"content-type":"application/json",accept:"application/json"},body:JSON.stringify(p)},"connecting the Apple key");e.out.result(c,()=>{e.out.line(`Connected key ${r} to ${se(t)}.`),jp(e,c)})}},F2={name:"stores:apple:check",summary:"ask Apple about the connected key again (after the account holder accepted its agreements, or its role changed), or with --apple-id about the Apple ID",flags:{"apple-id":{type:"boolean",description:"check the Apple ID's session instead: whether Apple still takes it, its team and roles"}},scope:"environment",async run(e){let t=await w(e);if(e.flags["apple-id"]===!0){let s=await h(e,t,"POST","/stores/apple/session/check",void 0,J());e.out.result(s,()=>Op(e,s));return}let n=await h(e,t,"POST","/stores/apple/check",void 0,J());e.out.result(n,()=>jp(e,n))}},B2={name:"stores:apple:disconnect",summary:"take the environment's Apple key away (Apple keeps its apps and builds), or with --apple-id sign its Apple ID out",flags:{"apple-id":{type:"boolean",description:"sign the Apple ID out, at Apple too, and forget its session; the key stays"}},scope:"environment",async run(e){let t=await w(e);if(e.flags["apple-id"]===!0){let n=await h(e,t,"GET","/stores/apple/session"),s=n.shared_from?` (signed in for ${n.shared_from.name||n.shared_from.ref||n.shared_from.project_id}: every environment that uses it loses it)`:"";await k(e,t,`sign the Apple ID out${s}`),await h(e,t,"DELETE","/stores/apple/session",void 0,J()),e.out.result({disconnected:!0},()=>e.out.line(`Signed the Apple ID out of ${se(t)}, at Apple too.`));return}await k(e,t,"disconnect the Apple account (a key Palbase made is revoked at Apple)"),await h(e,t,"DELETE","/stores/apple",void 0,J()),e.out.result({disconnected:!0},()=>e.out.line(`Disconnected the Apple account from ${se(t)}.`))}},ia={asc:"App Store Connect API key",apns:"APNs keys (one for production, one for the sandbox)",iap:"In-App Purchase key"},W2=2,z2=60;function Np(e,t){let n=t.kind==="apns"?`APNs key (${t.environment??"?"})`:ia[t.kind]??t.kind;e.out.line(` ${t.key_id} ${n}${t.module?` for ${t.module}`:""}: ${t.state}${t.bundles&&t.bundles.length>0?` \u2014 ${t.bundles.join(", ")}`:""}`),t.note&&e.out.line(` ${t.note}`)}async function nv(e,t,n){let s=o=>n.some(l=>l.kind===o&&l.state==="waiting"),a=await h(e,t,"GET","/stores/apple"),i=await h(e,t,"GET","/notify/providers"),r=await h(e,t,"GET","/purchases/apple");return{asc:!a.connected,apns:!i.providers.some(o=>o.channel==="push"&&o.provider==="apns")&&!s("apns"),iap:!r.connected&&!s("iap")}}var J2={name:"stores:apple:keys",summary:"the keys Palbase made at Apple for the environment with its Apple ID, where each stands, and which keys the environment lacks",details:["Palbase makes them with the Apple ID signed in for the environment (stores:apple:connect --apple-id): stores:apple:keys:make. No one downloads a .p8."],scope:"environment",async run(e){let t=await w(e),n=await h(e,t,"GET","/stores/apple/keys"),s=await nv(e,t,n.keys);e.out.result({...n,lacking:Object.keys(s).filter(a=>s[a])},()=>{n.keys.length===0?e.out.line("Palbase made no key at Apple for this environment."):(e.out.line("Keys Palbase made at Apple:"),n.keys.forEach(i=>Np(e,i)));let a=Object.keys(ia).filter(i=>s[i]);if(a.length===0){e.out.line("The environment lacks no key.");return}e.out.line(`The environment lacks: ${a.map(i=>ia[i]).join("; ")}.`),e.out.line("Make them at Apple: palbase stores:apple:keys:make")})}},H2={name:"stores:apple:keys:make",summary:"make at Apple, with the environment's Apple ID, the keys it lacks \u2014 App Store Connect API, APNs, In-App Purchase \u2014 and connect them: one confirmation",details:["With no flag, every key the environment lacks; a key it has is kept. The Apple ID is an Admin or the Account Holder of the team.","APNs: one key for production and one for the sandbox, scoped to the environment's iOS apps; notify takes them. In-App Purchase: for one iOS app (--bundle with more than one); purchases connects it."],flags:{asc:{type:"boolean",description:"the App Store Connect API key"},apns:{type:"boolean",description:"the APNs keys"},iap:{type:"boolean",description:"the In-App Purchase key"},bundle:{type:"string",description:"the iOS app the In-App Purchase key is for, when the environment has more than one"}},scope:"environment",async run(e){let t=await w(e),n=await h(e,t,"GET","/stores/apple/keys"),s=await nv(e,t,n.keys),a=Object.keys(ia).filter(p=>e.flags[p]===!0),i=a.length>0?a:Object.keys(ia);for(let p of i.filter(c=>!s[c]))e.out.note(`The environment has its ${ia[p]}: it is kept.`);let r=i.filter(p=>s[p]);if(r.length===0){e.out.result({keys:[]},()=>e.out.line("The environment lacks none of these keys: nothing to make."));return}await k(e,t,`make at Apple and connect: ${r.map(p=>ia[p]).join("; ")}`);let o=[];for(let p of r){let c={kind:p};p==="iap"&&typeof e.flags.bundle=="string"&&(c.bundle=e.flags.bundle);let m=await h(e,t,"POST","/stores/apple/keys",c,J());o.push(...m.keys)}let l=e.io.now()+z2*1e3,d=o;for(;d.some(p=>p.state==="waiting")&&e.io.now()<l;){await e.io.sleep(W2*1e3);let p=await h(e,t,"GET","/stores/apple/keys");d=o.map(c=>p.keys.find(m=>m.key_id===c.key_id)??c)}e.out.result({keys:d},()=>{e.out.line(`Made at Apple for ${se(t)}:`),d.forEach(p=>Np(e,p)),d.some(p=>p.state==="waiting")&&e.out.note("A module has not taken its key yet: palbase stores:apple:keys says when it has.")})}},V2={name:"stores:apple:keys:revoke",summary:"revoke at Apple an APNs or In-App Purchase key Palbase made for the environment (the App Store Connect key is revoked as stores:apple:disconnect takes it away)",usage:"<key-id>",args:{min:1,max:1},scope:"environment",async run(e){let t=fe(e,0,"the key id"),n=await w(e);await k(e,n,`revoke the key ${t} at Apple`);let s=await h(e,n,"DELETE",`/stores/apple/keys/${T(t)}`,void 0,J());e.out.result(s,()=>{e.out.line(`Revoked ${t} at Apple.`),Np(e,s)})}};async function sv(e,t,n){let s=(await nt(e.studio)).filter(i=>i.project_id===t.project_id),a=s.find(i=>i.slug===n||i.ref===n);if(!a)throw new y("no_such_environment",`${t.project_name} has no environment ${JSON.stringify(n)}`,{hint:`its environments: ${s.map(i=>i.slug).join(", ")}`});if(a.ref===t.env_ref)throw g("the environment uses its own session: name another environment of the project");return a}var X2={name:"stores:apple:share",summary:"share the environment's Apple ID session with another environment of the project, which uses it while it has none of its own",usage:"<environment>",details:["An environment of the same project alone: Palbase refuses another project's, of your organization or not (other_project).","You are an owner or an admin of both environments; a key or an environment token does not share.","Signed out, or signed in again, the session serves none it was shared with: share it again. stores:apple:unshare takes it back."],args:{min:1,max:1},scope:"environment",async run(e){let t=fe(e,0,"the environment to share with"),n=await w(e),s=await sv(e,n,t);await k(e,n,`share its Apple ID session with ${s.name} (${s.slug})`);let a=await h(e,n,"PUT",`/stores/apple/session/shares/${T(s.ref)}`,void 0,J());e.out.result(a,()=>{e.out.line(`Shared with ${s.name} (${s.ref}): it uses this environment's Apple ID while it has none of its own.`)})}},Y2={name:"stores:apple:unshare",summary:"take the environment's Apple ID session back from another environment of the project",usage:"<environment>",args:{min:1,max:1},scope:"environment",async run(e){let t=fe(e,0,"the environment to take it back from"),n=await w(e),s=await sv(e,n,t);await k(e,n,`take its Apple ID session back from ${s.name} (${s.slug})`),await h(e,n,"DELETE",`/stores/apple/session/shares/${T(s.ref)}`,void 0,J()),e.out.result({unshared:s.ref},()=>{e.out.line(`Taken back from ${s.name} (${s.ref}): it uses this environment's Apple ID no more.`)})}};function Ip(e,t){if(!t.connected){e.out.line("Google Play is not connected."),e.out.line("Connect it: palbase stores:google:connect");return}e.out.line(`Play connection: ${t.service_account??"?"}`),e.out.line(`status: ${t.status??"not checked"}${t.checked_at?` (checked ${Y(t.checked_at)})`:""}`),t.capabilities&&e.out.line(`reaches: ${t.capabilities.length>0?t.capabilities.join(", "):"nothing yet"}`);for(let n of t.apps??[])e.out.line(` ${n.package_name}: ${n.reached?`reached (${n.capabilities.join(", ")})`:`not reached \u2014 ${n.problem??"Play did not say why"}`}`);t.connected_at&&e.out.line(`connected ${Y(t.connected_at)}${t.connected_by?` by ${t.connected_by}`:""}`),t.action&&e.out.line(`To do: ${t.action}`)}var Z2={name:"stores:google",summary:"the environment's Play connection: the service account Play Console invites, what Play let it reach",scope:"environment",async run(e){let t=await w(e),n=await h(e,t,"GET","/stores/google");e.out.result(n,()=>Ip(e,n))}},Q2={name:"stores:google:connect",summary:"connect Google Play: Palbase makes a service account for the environment, which your Play Console invites",details:["No key changes hands: Palbase acts as the service account it made in its own Google Cloud project.","Then, in Play Console \u2192 Users and permissions, invite the service account with the app (Release to testing tracks; for purchases also View financial data and Manage orders and subscriptions), link the Android app (stores:apps:link) and check: stores:google:check."],scope:"environment",async run(e){let t=await w(e);await k(e,t,"connect Google Play (Palbase makes a service account for it)");let n=await h(e,t,"POST","/stores/google",void 0,J());e.out.result(n,()=>Ip(e,n))}},eO={name:"stores:google:check",summary:"ask Play what the environment's service account reaches of each Android app: after Play Console invited it",scope:"environment",async run(e){let t=await w(e),n=await h(e,t,"POST","/stores/google/check",void 0,J());e.out.result(n,()=>Ip(e,n))}},tO={name:"stores:google:disconnect",summary:"delete the environment's service account at Google: Play Console's invite of it reaches nothing any more",scope:"environment",async run(e){let t=await w(e);await k(e,t,"disconnect Google Play (its service account is deleted)"),await h(e,t,"DELETE","/stores/google",void 0,J()),e.out.result({disconnected:!0},()=>e.out.line(`Disconnected Google Play from ${se(t)}.`))}};function nO(e,t){t.asc_app_id===null&&e.out.line(`Apple has no App Store Connect record for ${t.bundle_id} yet: make it with palbase stores:apps:record ${t.app_id} --name <App Store name> (needs an Apple ID signed in), or on the website (App Store Connect \u2192 Apps \u2192 +), then link again.`)}var sO={name:"stores:apps",summary:"the environment's apps linked to their store",scope:"environment",async run(e){let t=await w(e),n=await h(e,t,"GET","/stores/apps");e.out.result(n,()=>{n.apps.length===0?e.out.line("No app is linked yet: palbase stores:apps:link <app id>"):e.out.table(n.apps,[{header:"app",value:s=>s.app_id},{header:"platform",value:s=>s.platform},{header:"name",value:s=>s.name},{header:"bundle id / package",value:s=>s.bundle_id},{header:"team",value:s=>s.team_id??""},{header:"app store connect",value:s=>s.platform==="ios"?s.asc_app_id??"no record yet":""}])})}},aO={name:"stores:apps:link",summary:"link an app of the project to its store: an iOS app to the App Store, an Android app to Google Play (with an upload key Palbase makes)",usage:"<app id> [--name <name in the store>]",args:{min:1,max:1},flags:{name:{type:"string",value:"name",description:"its name in the store (default: the bundle id or package)"}},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s=e.flags.name!==void 0?{name:e.flags.name}:{};await k(e,t,`link the app ${n} to its store`);let a=await h(e,t,"POST",`/stores/apps/${T(n)}/link`,s,J());e.out.result(a,()=>{if(a.platform==="android"){e.out.line(`Linked ${a.name} (${a.bundle_id}) to Google Play.`),a.upload_key&&e.out.line(`upload key: ${a.upload_key.fingerprint} (Palbase signs its builds with it)`),a.play?e.out.line(`Play: ${a.play.reached?`reached (${a.play.capabilities.join(", ")})`:`not reached \u2014 ${a.play.problem??"?"}`}`):e.out.line("Play was not asked \u2014 the project has no Play connection (stores:google:connect), or Google did not answer (a service account made just now answers after a minute): palbase stores:google:check asks it.");return}e.out.line(`Linked ${a.name} (${a.bundle_id}, team ${a.team_id}).`),nO(e,a)})}},iO={name:"stores:feedback",summary:"an app's TestFlight feedback: testers' screenshots and crashes",usage:"<app id>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s=await h(e,t,"GET",`/stores/apps/${T(n)}/feedback`);e.out.result(s,()=>{s.feedback.length===0?e.out.line("No feedback yet."):e.out.table(s.feedback,[{header:"when",value:a=>Y(a.created_at)},{header:"kind",value:a=>a.kind},{header:"tester",value:a=>a.email??""},{header:"comment",value:a=>a.comment??""},{header:"id",value:a=>a.id}]),s.feedback.length>0&&e.out.note(`Read one, with a crash's log: palbase stores:feedback:get ${n} <crash|screenshot> <id>`)})}},rO={name:"stores:feedback:get",summary:"one of an app's TestFlight feedback: the device, the build, and a crash's log",usage:"<app id> <crash|screenshot> <feedback id>",details:["A crash's log is cut at 32 KiB: the exception and the crashed thread come first. A screenshot's images are Apple's links, which expire."],args:{min:3,max:3},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s=e.args[1];if(s!=="crash"&&s!=="screenshot")throw g("the kind is crash or screenshot");let a=fe(e,2,"the feedback's id"),i=await h(e,t,"GET",`/stores/apps/${T(n)}/feedback/${s}/${T(a)}`);e.out.result(i,()=>{e.out.line(`${Cp(i.kind)} ${D(i.id)}, sent ${Y(i.created_at)}${i.email?` by ${D(i.email)}`:""}`);let r=[i.device_model,i.os_version?`iOS ${i.os_version}`:void 0,i.locale].filter(Boolean).join(", ");r&&e.out.line(`from: ${D(r)}`),i.asc_build_id&&e.out.line(`build: ${D(i.asc_build_id)} (App Store Connect's id)`),i.comment&&e.out.line(`comment: ${D(i.comment)}`);for(let o of i.screenshots??[])e.out.line(`screenshot ${o.width}x${o.height}, until ${Y(o.expires_at)}: ${D(o.url)}`);i.kind==="crash"&&(i.crash_log?(e.out.line(i.crash_log_cut?"crash log (cut at 32 KiB):":"crash log:"),e.out.line(i.crash_log)):e.out.line("Apple has no log of this crash."))})}};function Jw(e,t,n){let s={on:"on: App Store Connect tells Palbase each change the moment it happens",refused:"refused: the connected key's role may not make it",failed:"failed: Apple refused it",none:"not made yet"};e.out.line(`App Store Connect webhook: ${s[n.state]??n.state}`),n.error&&e.out.line(`why: ${D(n.error)}`),n.url&&e.out.line(`reports to: ${D(n.url)}`),n.event_types.length>0&&e.out.line(`tells: ${n.event_types.join(", ")}`),n.installed_at&&e.out.line(`made ${Y(n.installed_at)}${n.asc_webhook_id?` (App Store Connect's ${D(n.asc_webhook_id)})`:""}`),e.out.line(n.last_delivery_at?`last delivery: ${D(n.last_delivery_type??"?")}, ${Y(n.last_delivery_at)}`:"last delivery: none yet"),n.pinged_at&&e.out.line(`last ping: ${Y(n.pinged_at)}`),n.state!=="on"&&e.out.note(`Until it is on, Palbase reads Apple every few minutes. Make it again: palbase stores:webhook ${t} --make`)}var Hw=30,Vw=2,oO={name:"stores:webhook",summary:"an iOS app's App Store Connect webhook: whether Apple tells Palbase each change at once, and its last delivery",usage:"<app id> [--make] [--ping]",details:["Palbase makes the webhook when the app is linked (the key's role must be Admin or App Manager), and tries again every day while it is not on; meanwhile it reads Apple every few minutes.","--make points it at the environment again with a new secret; --ping asks Apple to send it a ping and waits for it to arrive."],args:{min:1,max:1},flags:{make:{type:"boolean",description:"make it again: a new secret, pointed at the environment"},ping:{type:"boolean",description:"ask Apple to send it a ping, and wait for it to arrive"}},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s=`/stores/apps/${T(n)}/webhook`,a;if(e.flags.make?(await k(e,t,`make the App Store Connect webhook of ${n} again`),a=await h(e,t,"POST",s,{})):a=await h(e,t,"GET",s),e.flags.ping){let i=a.last_delivery_at;await h(e,t,"POST",`${s}/ping`,{});for(let o=0;o<Hw&&(await e.io.sleep(Vw*1e3),a=await h(e,t,"GET",s),!(a.pinged_at&&a.last_delivery_at&&a.last_delivery_at!==i));o+=Vw);let r=!!(a.last_delivery_at&&a.last_delivery_at!==i);e.out.result({...a,ping_arrived:r},()=>{Jw(e,n,a),e.out.line(r?"The ping arrived.":`Apple did not deliver the ping within ${Hw} s: look again with palbase stores:webhook ${n}`)});return}e.out.result(a,()=>Jw(e,n,a))}},Qi=e=>e==null?"\u2014":`${(e*100).toFixed(2)}%`,lO={ok:"App Store crash counts: the App Crashes report, last 30 days",none_yet:"App Store crash counts: Apple's report has no day yet",requested:"App Store crash counts: asked of Apple now; its first days come in a day or two",not_requested:"App Store crash counts: Palbase asks Apple for the report with its next round",admin_key_needed:"App Store crash counts: only an Admin key may read the App Crashes report \u2014 the connected key is not one"},dO={name:"stores:vitals",summary:"an app's health as its store has it: crashes, terminations and hangs, crash and ANR rates by version",usage:"<app id>",details:["An iOS app: the crashes testers sent from TestFlight, what TestFlight counted of its newest builds (installs, sessions, crashes, feedback), its App Store versions' terminations, hangs and launches, and App Store crashes by day (the App Crashes report, an Admin key's).","An Android app: Play's Android vitals \u2014 each version code's crash and ANR rates over seven days, its errors, and what Play flagged.","A new day of it is the environment's stores.vitals.changed event."],args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s=await h(e,t,"GET",`/stores/apps/${T(n)}/vitals`);e.out.result(s,()=>{if(e.out.line(`${s.platform==="android"?"Google Play":"App Store"} health of ${n}, read ${Y(s.read_at)}`),e.out.line(s.through?`crash data through ${s.through}`:"no crash data yet"),s.apple){let a=s.apple;a.testflight_crashes.length===0?e.out.line("TestFlight crashes: none"):(e.out.line(`TestFlight crashes (palbase stores:feedback:get ${n} crash <id> reads one with its log):`),e.out.table(a.testflight_crashes,[{header:"when",value:i=>Y(i.created_at)},{header:"id",value:i=>i.id},{header:"comment",value:i=>i.comment??""}])),a.testflight_builds.length>0&&(e.out.line("TestFlight builds, as Apple counts them:"),e.out.table(a.testflight_builds,[{header:"build",value:i=>`${i.version} (${i.build_number})${i.expired?", expired":""}`},{header:"days",value:i=>i.from?`${i.from} \u2013 ${i.to??i.from}`:"\u2014"},{header:"installs",value:i=>String(i.installs)},{header:"sessions",value:i=>String(i.sessions)},{header:"crashes",value:i=>String(i.crashes)},{header:"feedback",value:i=>String(i.feedback)},{header:"invites",value:i=>String(i.invites)}])),e.out.line(lO[a.crash_counts]??a.crash_counts),a.crash_days.length>0&&e.out.table(a.crash_days,[{header:"day",value:i=>i.date},{header:"version",value:i=>i.version},{header:"crashes",value:i=>String(i.crashes)},{header:"devices",value:i=>String(i.devices)}]),a.metrics.length===0?e.out.line("terminations, hangs, launches: Apple publishes none yet (enough people who share their data must run an App Store version)"):e.out.table(a.metrics,[{header:"what",value:i=>i.category},{header:"metric",value:i=>i.identifier},{header:"version",value:i=>i.version},{header:"value",value:i=>`${i.value}${i.unit?` ${i.unit}`:""}`},{header:"devices",value:i=>i.device??""}])}if(s.play){let a=s.play;a.versions.length===0?e.out.line("crash and ANR rates: Play has none yet (too few users)"):e.out.table(a.versions,[{header:"version code",value:i=>String(i.version_code)},{header:"crashes",value:i=>Qi(i.crash_rate)},{header:"crashes in use",value:i=>Qi(i.user_perceived_crash_rate)},{header:"ANRs",value:i=>Qi(i.anr_rate)},{header:"ANRs in use",value:i=>Qi(i.user_perceived_anr_rate)},{header:"users",value:i=>String(i.users)}]),a.issues.length>0&&e.out.table(a.issues,[{header:"error",value:i=>i.type},{header:"cause",value:i=>i.cause},{header:"where",value:i=>i.location},{header:"reports",value:i=>String(i.reports)},{header:"users",value:i=>String(i.users)}]);for(let i of a.anomalies)e.out.line(`Play flagged ${D(i.metric)}${i.version_code?` of version code ${i.version_code}`:""}${i.value!==null?`: ${Qi(i.value)}`:""}${i.from?` (${i.from}${i.to?` \u2013 ${i.to}`:""})`:""}`)}})}};function pO(e,t){e.out.line(`Package ${t.id} of ${t.app_id}: build ${t.build_number}${t.version?`, version ${t.version}`:""} \u2014 ${t.status==="uploaded"?`uploaded ${Y(t.uploaded_at)}`:"waiting for its build"}`),t.size!==null&&e.out.line(`${t.format?`.${t.format}`:"build"}: ${t.size} bytes, sha256 ${t.sha256??"?"}`),t.bundles.length>0&&e.out.line(`bundles: ${t.bundles.map(n=>n.bundle_id+(n.path?` (${n.path})`:"")).join(", ")}`),t.notes&&e.out.line(`notes: ${t.notes}`),e.out.line(`made ${Y(t.created_at)} by ${t.created_by} (command ${t.command_id})`);for(let n of t.deliveries)e.out.line(`${n.channel}: ${av(n)}`)}function av(e){let t=[e.status];return e.processing_state&&t.push(`Apple: ${e.processing_state}`),e.play_version_code!==void 0&&t.push(`Play: version code ${e.play_version_code}${e.play_release_status?`, ${e.play_release_status}`:""}`),e.signed_devices!==void 0&&t.push(`signed for ${e.signed_devices} phone${e.signed_devices===1?"":"s"}`),e.groups.length>0&&t.push(`${e.groups.length} group${e.groups.length===1?"":"s"}`),e.error_code&&t.push(`${e.error_code}${e.error?` \u2014 ${e.error}`:""}`),t.join(", ")}var cO={name:"stores:packages",summary:"the packages handed to the stores, newest first",usage:"[--app <app id>] [--limit <n>]",flags:{app:{type:"string",value:"app id",description:"only this app's"},limit:{type:"string",value:"n",description:"how many (1\u2013200, default 20)"}},scope:"environment",async run(e){let t=await w(e),n=Te(e.flags.limit,"limit")??20;if(n<1||n>200)throw g("--limit is a whole number from 1 to 200");let s=new URLSearchParams({limit:String(n),...e.flags.app?{app_id:e.flags.app}:{}}),a=await h(e,t,"GET",`/stores/packages?${s}`);e.out.result(a,()=>{a.packages.length===0?e.out.line("No package yet."):e.out.table(a.packages,[{header:"package",value:i=>i.id},{header:"app",value:i=>i.app_id},{header:"build",value:i=>String(i.build_number)},{header:"version",value:i=>i.version??""},{header:"status",value:i=>i.status},{header:"testflight",value:i=>i.deliveries.find(r=>r.channel==="testflight")?.status??""},{header:"development",value:i=>i.deliveries.find(r=>r.channel==="development")?.status??""},{header:"made",value:i=>Y(i.created_at)}]),a.next_cursor&&e.out.note(`More than ${n}: raise --limit to see older ones.`)})}},uO={name:"stores:packages:get",summary:"one package: its build, its bundles and its deliveries",usage:"<package id>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=await h(e,t,"GET",`/stores/packages/${T(fe(e,0,"the package's id"))}`);e.out.result(n,()=>pO(e,n))}},mO={name:"stores:packages:create",summary:"make a package of an app: its build number, and the URL and token its build is uploaded with",usage:"<app id> --command-id <id> [--notes <text>] [--entitlements-file <json>]",details:["The build is made with the build number it answers (an iOS app's CFBundleVersion, an Android app's versionCode), then uploaded: palbase stores:packages:upload.","The same --command-id again answers the same package, with a new upload token while it waits for its build: a build machine sends its run's id."],args:{min:1,max:1},flags:{"command-id":{type:"string",value:"id",description:"names the request (a CI run id): sent again, the same package"},notes:{type:"string",value:"text",description:"notes kept with it (a commit, a branch)"},"entitlements-file":{type:"string",value:"json",description:'what each bundle asks for, by bundle id ({"com.acme.app": {"aps-environment": "production"}})'}},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s=e.flags["command-id"];if(s===void 0||s.trim()==="")throw g("--command-id names the request: sent again, it answers the same package");let a={command_id:s};if(e.flags.notes!==void 0&&(a.notes=e.flags.notes),e.flags["entitlements-file"]!==void 0){let o=Fe(await Xe(e,e.flags["entitlements-file"],"the entitlements"),"the entitlements"),l=d=>typeof d=="object"&&d!==null&&!Array.isArray(d);if(!l(o)||!Object.values(o).every(l))throw g("the entitlements are an object of bundle id \u2192 its entitlements object");a.entitlements=o}await k(e,t,`make a package of ${n}`);let i=await wt(e,t,"POST",`/stores/apps/${T(n)}/packages`,a,J()),r=i.body;e.out.result(r,()=>{if(e.out.line(`Package ${r.id} of ${r.app_id}: build number ${r.build_number}${i.status===200?" (made before by this command id)":""}.`),r.status==="uploaded"){e.out.line("Its build has arrived already.");return}e.out.line(`Build it with build number ${r.build_number} (CFBundleVersion; an Android app's versionCode), then upload it:`),r.upload&&(e.out.line(` palbase stores:packages:upload ${r.id} --file <app.ipa> --token ${r.upload.token}`),e.out.line(`url: ${r.upload.url}`),e.out.line(`token: ${r.upload.token} (shown this once; it works until ${Y(r.upload.expires_at)})`))})}},hO={name:"stores:packages:upload",summary:"hand a package its build: the .ipa, .aab or .apk goes straight to the environment's address with the upload token",usage:"<package id> --file <app.ipa|app.aab|app.apk> --token <upload token>",details:["An Android app's App Bundle (.aab) goes to Play; its APK is installed directly on testers' phones (stores:deliver --channel development), signed with the app's upload key whatever it came signed with. The file is told by what it holds, not by its name.","The token is the one stores:packages:create printed; PALBASE_UPLOAD_TOKEN stands in for --token, out of the process list.","The file goes with its Content-Length. While the module is busy with another upload it is sent again, after the wait the module names, five times at most; a package that has its build already (this token's upload arrived before) counts as uploaded."],args:{min:1,max:1},flags:{file:{type:"string",value:"app.ipa|app.aab|app.apk",description:"the unsigned .ipa, the Android App Bundle (unsigned, or signed with the app's upload key) or the Android APK the build machine made"},token:{type:"string",value:"upload token",description:"the package's upload token"}},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the package's id"),s=e.flags.file;if(s===void 0)throw g("--file names the .ipa, .aab or .apk");let a=e.flags.token??e.io.env.PALBASE_UPLOAD_TOKEN;if(a===void 0||a.trim()==="")throw g("--token is the package's upload token (stores:packages:create printed it)","or PALBASE_UPLOAD_TOKEN");let i=ts(e.io.cwd,s),r;try{let p=await Tp(i);if(!p.isFile())throw new Error("not a file");r=p.size}catch(p){throw new y("unreadable_file",`${s} could not be read: ${p instanceof Error?p.message:String(p)}`)}await k(e,t,`upload ${s} (${r} bytes) as the build of package ${n}`);let o=`${Wt(e.cloud,t.env_ref)}/stores/packages/${T(n)}/artifact`,l;try{l=await Zw(i)}catch(p){throw new y("unreadable_file",`${s} could not be read: ${p instanceof Error?p.message:String(p)}`)}let d=`${s} \u2192 package ${n}`;for(let p=1;;p++)try{let c=await er(e,o,{method:"PUT",headers:{"palbase-upload-token":a,"content-type":"application/octet-stream","content-length":String(l.size),accept:"application/json"},body:l},d);e.out.result(c,()=>{e.out.line(`Package ${c.id}: build ${c.build_number}${c.version?`, version ${c.version}`:""} arrived (${c.size??l.size} bytes, sha256 ${c.sha256??"?"}).`),e.out.line(c.format==="apk"?`Install it on testers' phones: palbase stores:deliver ${c.id} --channel development --groups <group>, or palbase stores:invite ${c.id} <email>`:`Send it to testers: palbase stores:deliver ${c.id}`)});return}catch(c){if(!(c instanceof W))throw c;if(c.status===409&&c.code==="package_uploaded"){e.out.result({id:n,uploaded:!0,already:!0},()=>{e.out.line(`Package ${n} has its build already: an upload with this token arrived before, and this one was not taken.`),e.out.line(`Send it to testers: palbase stores:deliver ${n}`)});return}let m=c.status===409&&c.code==="upload_in_progress"||c.status===503&&c.code==="stores_busy",f=Math.max(c.retryAfter??N2,1);if(!m||p>=Bw||f>tv)throw c;e.out.note(`${d}: ${c.message}; trying again in ${f} s (${p+1} of ${Bw})`),await e.io.sleep(f*1e3)}}},gO={name:"stores:apps:upload-key",summary:"an Android app's upload key: the certificate Palbase signs its builds with (never its private key)",usage:"<app id> [--out <file.pem>]",details:["Play Console shows an app's upload key by this fingerprint; asked to change an app's upload key to Palbase's, it takes this certificate (--out)."],args:{min:1,max:1},flags:{out:{type:"string",value:"file.pem",description:"write the certificate (PEM) to this file"}},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s=await h(e,t,"GET",`/stores/apps/${T(n)}/upload-key`),a=e.flags.out;if(a!==void 0){let i=await Qw(ts(e.io.cwd,a),Rs.O_WRONLY|Rs.O_CREAT|Rs.O_TRUNC|Rs.O_NOFOLLOW);try{await i.writeFile(s.certificate)}finally{await i.close()}}e.out.result(s,()=>{e.out.line(`upload key of ${n}: SHA-256 ${s.fingerprint} (made ${Y(s.created_at)})`),a!==void 0&&e.out.line(`certificate written to ${a}`)})}},fO={name:"stores:packages:bundle",summary:"download a package's bundle as Palbase signed it for Play: to upload it in Play Console by hand",usage:"<package id> --out <file.aab> [--channel play_internal]",details:["stores:deliver sends every build to Play, an app's first too; when Play wants a release made in Play Console instead (Testing \u2192 Internal testing \u2192 Create new release), upload this file there: it is signed with the app's upload key.","The bytes come from the environment's address on a link the module sealed for this bundle, valid 15 minutes; Studio is asked for the link alone."],args:{min:1,max:1},flags:{out:{type:"string",value:"file.aab",description:"where to write it"},channel:{type:"string",value:"channel",description:"the Play delivery (play_internal)"}},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the package's id"),s=e.flags.out;if(s===void 0)throw g("--out names the file to write");let a=e.flags.channel??"play_internal";if(a!=="play_internal")throw g("--channel is play_internal");let i=await h(e,t,"POST",`/stores/packages/${T(n)}/deliveries/${T(a)}/bundle-link`,void 0,J());ns(e,t,i.url,"the download link");let r;try{r=await e.io.fetch(i.url,{method:"GET",redirect:"manual"})}catch(m){throw new y("network_error",`the signed bundle could not be downloaded: ${m instanceof Error?m.message:String(m)}`)}if(r.status!==200||!r.body){let m=await r.text(),f=m;try{f=JSON.parse(m)}catch{}throw new y("download_failed",`the signed bundle: ${Fr(f,r.status)}`)}let o=ts(e.io.cwd,s),l=await Qw(o,Rs.O_WRONLY|Rs.O_CREAT|Rs.O_TRUNC|Rs.O_NOFOLLOW),d=0,p=T2.fromWeb(r.body).on("data",m=>{d+=m.length}),c=Number(r.headers.get("content-length")??NaN);try{if(await C2(p,l.createWriteStream()),Number.isFinite(c)&&d!==c)throw new Error(`${d} of its ${c} bytes arrived`)}catch(m){throw await S2(o,{force:!0}),new y("download_failed",`the signed bundle did not arrive whole: ${m instanceof Error?m.message:String(m)}; ask again`)}e.out.result({file:s,bytes:d},()=>{e.out.line(`Wrote ${s} (${d} bytes): package ${n}, signed with the app's upload key.`),e.out.line("Upload it in Play Console \u2192 Testing \u2192 Internal testing \u2192 Create new release, once; then send the next package with stores:deliver.")})}};async function yO(e,t,n,s){if(s.every(r=>Uw.test(r)))return s;let a=await h(e,t,"GET",`/stores/packages/${T(n)}`),i=(await h(e,t,"GET",`/stores/apps/${T(a.app_id)}/groups`)).groups;return s.map(r=>{if(Uw.test(r))return r;let o=i.filter(d=>d.name===r),l=o.length>0?o:i.filter(d=>d.name.toLowerCase()===r.toLowerCase());if(l.length!==1)throw new y(l.length===0?"no_such_group":"ambiguous_group",`${a.app_id} has ${l.length===0?"no group":"more than one group"} named ${JSON.stringify(r)}`,{hint:`palbase stores:groups ${a.app_id} lists them`});return l[0].id})}async function bO(e,t,n){let s=await h(e,t,"GET",`/stores/packages/${T(n)}`);return s.format==="apk"?"development":(await h(e,t,"GET","/stores/apps")).apps.find(i=>i.app_id===s.app_id)?.platform==="android"?"play_internal":"testflight"}var wO={name:"stores:deliver",summary:"send a package to a channel's testers: signed, handed to Apple or Play \u2014 or installed on their own phones directly",usage:"<package id> [--channel testflight|play_internal|development] [--groups <group,\u2026>] [--what-to-test <text>] [--locale <locale>]",details:["An iOS app goes to TestFlight: processed, then given to the groups; an export compliance question is answered with stores:export-compliance.","An Android app goes to Play's internal testing track, to the testers it lists in Play Console. An invite given in Play Console just now takes a while to reach Play's API: a delivery Play refuses then (google_not_allowed) is sent again later.","--channel development installs it directly, with no TestFlight: each person of the development groups named is mailed a link, their iPhone registers itself, and the package is signed for their phones \u2014 again, with no new build, when another phone comes. Sent again, it invites who joined the groups since. palbase stores:invitations <package id> shows where each person is.","An Android app's APK goes to development alone (its default), its bundle to Play alone: the APK is signed with the app's upload key and is ready for everyone invited at once \u2014 an Android phone registers nowhere.","palbase stores:deliveries <package id> follows it."],args:{min:1,max:1},flags:{channel:{type:"string",value:"channel",description:"where it goes: testflight, play_internal (default: the app's platform's), or development (direct install; an APK's default)"},groups:{type:"string",multiple:!0,value:"group,\u2026",description:"the groups it goes to, by id or name: the channel's own kind (TestFlight groups, or development groups)"},"what-to-test":{type:"string",value:"text",description:"the note testers read"},locale:{type:"string",value:"locale",description:"the note's locale (default: the app's primary one)"}},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the package's id"),s=e.flags.channel??await bO(e,t,n);if(!Kw.includes(s))throw g(`--channel is one of ${Kw.join(", ")}`);let a=e.flags["what-to-test"];if(e.flags.locale!==void 0&&a===void 0)throw g("--locale is the --what-to-test note's");let i={channel:s},r=Ie(e.flags.groups);r&&r.length>0&&(i.groups=await yO(e,t,n,r)),a!==void 0&&(i.what_to_test={text:a,...e.flags.locale!==void 0?{locale:e.flags.locale}:{}}),await k(e,t,`send package ${n} to ${s}${i.groups?` (${i.groups.length} group${i.groups.length===1?"":"s"})`:""}`);let o=await h(e,t,"POST",`/stores/packages/${T(n)}/deliveries`,i,J());e.out.result(o,()=>{e.out.line(`Package ${n} \u2192 ${o.channel}: ${av(o)}.`),o.status!=="ready"&&o.status!=="failed"&&e.out.line(`Follow it: palbase stores:deliveries ${n}`)})}},vO={name:"stores:deliveries",summary:"a package's deliveries: where each is now, and what to do when one failed",usage:"<package id>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the package's id"),s=await h(e,t,"GET",`/stores/packages/${T(n)}/deliveries`);e.out.result(s,()=>{s.deliveries.length===0?e.out.line(`Package ${n} has not been sent anywhere: palbase stores:deliver ${n}`):e.out.table(s.deliveries,[{header:"channel",value:a=>a.channel},{header:"status",value:a=>a.status},{header:"store",value:a=>a.processing_state??(a.play_version_code!==void 0?`version code ${a.play_version_code}${a.play_release_status?` ${a.play_release_status}`:""}`:a.signed_devices!==void 0?`${a.signed_devices} phone${a.signed_devices===1?"":"s"}`:"")},{header:"groups",value:a=>String(a.groups.length)},{header:"updated",value:a=>Y(a.updated_at)},{header:"error",value:a=>a.error_code?`${a.error_code}${a.error?`: ${a.error}`:""}`:""}])})}};function _O(e){return e.devices.length===0?"":e.devices.map(t=>`${t.product??"phone"} \u2026${t.udid.slice(-6)} ${t.signed?"signed":t.status}`).join(", ")}function iv(e){return e.mail==="failed"&&e.mail_error?`failed: ${e.mail_error}`:e.mail}var $O={name:"stores:invitations",summary:"the people invited to install a package directly: how far each got, their mail, their phones",usage:"<package id>",details:["invited \u2192 opened (the link) \u2192 enrolled (a phone of theirs registered) \u2192 downloaded (a phone took the build to install it); or revoked, or expired.","A phone is signed once the package's build installs on it; registering, processing (Apple holds a new device up to 72 hours) or refused before that. Links are not listed: palbase stores:invite <package id> <email> answers a person's."],args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the package's id"),s=await h(e,t,"GET",`/stores/packages/${T(n)}/invitations`);e.out.result(s,()=>{s.invitations.length===0?e.out.line(`Nobody is invited to package ${n}: palbase stores:deliver ${n} --channel development --groups <group>, or palbase stores:invite ${n} <email>`):e.out.table(s.invitations,[{header:"invitation",value:a=>a.id},{header:"email",value:a=>a.email},{header:"status",value:a=>a.status},{header:"mail",value:iv},{header:"phones",value:_O},{header:"expires",value:a=>Y(a.expires_at)}])})}},kO={name:"stores:invite",summary:"invite one person to install a package directly: mails their link, and prints it",usage:"<package id> <email> [--no-mail] [--locale <language>]",details:["A person invited already keeps their link \u2014 mailed again unless --no-mail \u2014; an expired or revoked invitation is made again, with a new link. The package gets its development delivery when it had none.","The link works for 14 days. A person registers two new iPhones at most in 30 days, through whatever links they hold; a phone already theirs registers again freely. With an environment token the link works no longer than the token."],args:{min:2,max:2},flags:{"no-mail":{type:"boolean",description:"only print the link: nothing is mailed"},locale:{type:"string",value:"language",description:"the mail's and the page's language (en, tr; default: the project's)"}},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the package's id"),s=e.args[1]??"";if(!/^[^\s@]+@[^\s@]+$/.test(s))throw g("the person's email address is the second argument");let a=e.flags["no-mail"]!==!0,i={email:s,...a?{}:{mail:!1},...e.flags.locale!==void 0?{locale:e.flags.locale}:{}};await k(e,t,`invite ${s} to install package ${n}${a?" (a mail goes to them)":""}`);let r=await h(e,t,"POST",`/stores/packages/${T(n)}/invitations`,i,J());e.out.result(r,()=>{e.out.line(`${r.email} is ${r.status} (${iv(r)}); the link works until ${Y(r.expires_at)}:`),e.out.line(r.url)})}},SO={name:"stores:invitations:revoke",summary:"revoke an invitation: its link, its build and its registration stop working",usage:"<invitation id>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the invitation's id");await k(e,t,`revoke the invitation ${n}`),await h(e,t,"DELETE",`/stores/invitations/${T(n)}`,void 0,J()),e.out.result({id:n,revoked:!0},()=>e.out.line(`Revoked the invitation ${n}.`))}},AO={name:"stores:devices",summary:"the phones registered for the project's development builds, and where each stands at Apple",usage:"",details:["registering (to be registered at Apple when a build is signed for it), enabled, processing (Apple holds a new membership's 11th to 100th device out of builds for 24 to 72 hours) or refused, in Apple's words.","An Apple account registers 100 iPhones a membership year, and a removed one keeps its place until the year ends."],scope:"environment",async run(e){let t=await w(e),n=await h(e,t,"GET","/stores/devices");e.out.result(n,()=>{n.devices.length===0?e.out.line("No phone is registered: a person invited to a package registers theirs from the link (palbase stores:invite)."):e.out.table(n.devices,[{header:"udid",value:s=>s.udid},{header:"model",value:s=>s.product??""},{header:"status",value:s=>s.status==="refused"?`refused${s.limit?" (yearly limit)":""}${s.refusal?`: ${s.refusal}`:""}`:s.status},{header:"people",value:s=>s.people.join(", ")},{header:"registered",value:s=>Y(s.created_at)}])})}},PO={name:"stores:what-to-test:set",summary:"change what testers read with a package's TestFlight build, once Apple holds the build",usage:"<package id> --text <text> [--locale <locale>]",details:["Apple's note on the build, and the delivery's own; before Apple holds the build the module says so (build_not_at_apple) \u2014 stores:deliver --what-to-test sets it with the delivery."],args:{min:1,max:1},flags:{text:{type:"string",value:"text",description:"the note testers read (4000 characters at most)"},locale:{type:"string",value:"locale",description:"its locale (default: the app's primary one)"}},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the package's id"),s=e.flags.text;if(s===void 0||s.trim()==="")throw g("--text is the note testers read");if(s.length>4e3)throw g(`the note is 4000 characters at most (${s.length} were given)`);let a={text:s,...e.flags.locale!==void 0?{locale:e.flags.locale}:{}};await k(e,t,`change what testers read with package ${n}${a.locale?` (${a.locale})`:""}`);let i=await h(e,t,"PUT",`/stores/packages/${T(n)}/what-to-test`,a,J());e.out.result(i,()=>e.out.line(`Testers of package ${n} read${a.locale?` (${a.locale})`:""}: ${i.what_to_test??s}`))}};function rv(e,t){let n=(e.args[t]??"").trim();if(n===""||n.length>40||/[\r\n]/.test(n))throw g("a group's name is 1 to 40 characters on one line");return n}var RO={name:"stores:groups",summary:"an app's groups of testers",usage:"<app id>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s=await h(e,t,"GET",`/stores/apps/${T(n)}/groups`);e.out.result(s,()=>{s.groups.length===0?e.out.line(`${n} has no group: palbase stores:groups:create ${n} <name>`):e.out.table(s.groups,[{header:"group",value:a=>a.id},{header:"name",value:a=>a.name},{header:"kind",value:a=>a.kind??"testflight"},{header:"testers",value:a=>String(a.testers)},{header:"updated",value:a=>Y(a.updated_at)}])})}},EO={name:"stores:groups:create",summary:"make a group of testers for an app: a TestFlight group, or a development group for direct install",usage:"<app id> <name> [--kind testflight|development]",details:["A TestFlight group (an iOS app's default) is an internal and an external group at Apple, whose people Apple mails TestFlight's invitations.","A development group (an Android app's default) is Palbase's own list of the people a package is installed for directly (stores:deliver --channel development): nothing at Apple, no TestFlight invitation."],args:{min:2,max:2},flags:{kind:{type:"string",value:"kind",description:"testflight or development (default: testflight for an iOS app, development for an Android app)"}},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s=rv(e,1),a=e.flags.kind;if(a!==void 0&&!Fw.includes(a))throw g(`--kind is one of ${Fw.join(", ")}`);await k(e,t,`make the ${a?`${a} `:""}group ${JSON.stringify(s)} of ${n}`);let i={name:s,...a?{kind:a}:{}},r=await h(e,t,"POST",`/stores/apps/${T(n)}/groups`,i,J());e.out.result(r,()=>e.out.line(`Made ${r.name} (${r.id}), a ${r.kind} group.`))}},TO={name:"stores:groups:rename",summary:"rename a group",usage:"<group id> <name>",args:{min:2,max:2},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the group's id"),s=rv(e,1);await k(e,t,`rename the group ${n} to ${JSON.stringify(s)}`);let a=await h(e,t,"PATCH",`/stores/groups/${T(n)}`,{name:s},J());e.out.result(a,()=>e.out.line(`${a.id} is ${a.name}.`))}},CO={name:"stores:groups:delete",summary:"delete a group: its testers lose the builds it gave them",usage:"<group id>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the group's id");await k(e,t,`delete the group ${n}`),await h(e,t,"DELETE",`/stores/groups/${T(n)}`,void 0,J()),e.out.result({id:n,deleted:!0},()=>e.out.line(`Deleted the group ${n}.`))}},jO={name:"stores:groups:testers",summary:"a group's testers",usage:"<group id>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the group's id"),s=await h(e,t,"GET",`/stores/groups/${T(n)}/testers`);e.out.result(s,()=>{s.testers.length===0?e.out.line("No tester in the group."):e.out.table(s.testers,[{header:"email",value:a=>a.email},{header:"name",value:a=>[a.first_name,a.last_name].filter(Boolean).join(" ")},{header:"side",value:a=>a.side},{header:"added",value:a=>Y(a.added_at)}])})}};function OO(e){let t=e.trim();if(t.startsWith("[")){let n=Fe(t,"the testers");if(!Array.isArray(n)||!n.every(s=>typeof s=="object"&&s!==null&&typeof s.email=="string"))throw g('the testers are a JSON array of { "email": \u2026, "first_name": \u2026, "last_name": \u2026 }');return n}return t.split(/\r?\n/).map(n=>n.trim()).filter(n=>n!==""&&!n.startsWith("#")).map(n=>{let[s,a,i]=n.split(",").map(r=>r.trim());return{email:s,...a?{first_name:a}:{},...i?{last_name:i}:{}}})}var NO={name:"stores:groups:testers:set",summary:"set who a group holds, whole: those not named leave it",usage:"<group id> (--emails <a@x,\u2026> | --file <testers.txt>)",details:[`A file names one tester a line \u2014 email, or email,First,Last \u2014 or is a JSON array; - reads it from stdin. ${Rp} at most.`],args:{min:1,max:1},flags:{emails:{type:"string",multiple:!0,value:"a@x,\u2026",description:"the testers' addresses"},file:{type:"string",value:"path",description:"the testers, one a line (- for stdin)"}},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the group's id"),s=Ie(e.flags.emails);if(s===void 0==(e.flags.file===void 0))throw g("the testers are named by --emails or --file, one of the two");let a=s?s.map(d=>({email:d})):OO(await Xe(e,e.flags.file,"the testers"));for(let d of a)if(!/^[^@\s]+@[^@\s]+$/.test(d.email))throw g(`${JSON.stringify(d.email)} is not an email address`);if(a.length>Rp)throw g(`a group holds ${Rp} testers at most (${a.length} were named)`);let i=(await h(e,t,"GET",`/stores/groups/${T(n)}/testers`)).testers,r=new Set(a.map(d=>d.email.toLowerCase())),o=i.filter(d=>!r.has(d.email.toLowerCase())).map(d=>d.email);await k(e,t,`set the testers of ${n} to ${a.length}${o.length>0?`; ${o.length} leave: ${o.join(", ")}`:""}`);let l=await h(e,t,"PUT",`/stores/groups/${T(n)}/testers`,{testers:a},J());e.out.result({...l,left:o},()=>{e.out.line(`${n} holds ${l.testers.length} tester${l.testers.length===1?"":"s"}${o.length>0?`; ${o.join(", ")} left it`:""}.`)})}},IO={name:"stores:groups:add-build",summary:"give a group a package that TestFlight has (external testers get it after Beta App Review)",usage:"<group id> <package id>",args:{min:2,max:2},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the group's id"),s=fe(e,1,"the package's id");await k(e,t,`give package ${s} to the group ${n}`),await h(e,t,"POST",`/stores/groups/${T(n)}/builds`,{package_id:s},J()),e.out.result({group_id:n,package_id:s},()=>e.out.line(`Gave package ${s} to ${n}.`))}},LO={description:"description","feedback-email":"feedback_email","contact-first-name":"contact_first_name","contact-last-name":"contact_last_name","contact-phone":"contact_phone","contact-email":"contact_email","demo-account-name":"demo_account_name",notes:"notes",locale:"locale"};function $n(e){return e===""?"(not set)":e}var DO={name:"stores:review-info",summary:"an app's TestFlight test information as Apple holds it, in one locale, and what Beta App Review still lacks \u2014 the demo password only as set or not",usage:"<app id> [--locale <locale>]",args:{min:1,max:1},flags:{locale:{type:"string",value:"locale",description:"the locale to read (default: the app's primary one)"}},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s=e.flags.locale!==void 0?`?${new URLSearchParams({locale:e.flags.locale})}`:"",a=await h(e,t,"GET",`/stores/apps/${T(n)}/testflight/review-info${s}`);e.out.result(a,()=>{let i=a.locales.filter(p=>p!==a.locale);e.out.line(`Test information of ${n} in ${a.locale}${i.length>0?` (also in ${i.join(", ")})`:""}:`);let r=[`${a.contact_first_name} ${a.contact_last_name}`.trim(),a.contact_phone,a.contact_email].filter(p=>p!=="").join(", "),o=a.demo_account_required?`required: ${$n(a.demo_account_name)}, password ${a.demo_account_password_set?"set":"not set"}`:"not required",l=[["what to test",$n(a.description)],["feedback email",$n(a.feedback_email)],["review contact",$n(r)],["demo account",o],["notes",$n(a.notes)]],d=Math.max(...l.map(([p])=>p.length));for(let[p,c]of l)e.out.line(` ${p.padEnd(d)} ${c}`);e.out.line(a.missing.length===0?"Beta App Review has what it needs.":`Beta App Review still lacks: ${a.missing.join(", ")} (palbase stores:review-info:set ${n} \u2026).`)})}},MO={name:"stores:review-info:set",summary:"what Beta App Review needs to know of an app: only the fields given are written; it answers what is still missing",usage:"<app id> [--description <text>] [--feedback-email <a@x>] [--contact-\u2026 <\u2026>] [--demo-account-name <name> --demo-password-stdin] [--notes <text>] [--locale <locale>]",args:{min:1,max:1},flags:{description:{type:"string",value:"text",description:"what testers should test"},"feedback-email":{type:"string",value:"a@x",description:"where testers send feedback"},"contact-first-name":{type:"string",value:"name",description:"whom Apple calls: first name"},"contact-last-name":{type:"string",value:"name",description:"last name"},"contact-phone":{type:"string",value:"phone",description:"phone"},"contact-email":{type:"string",value:"a@x",description:"email"},"demo-account-name":{type:"string",value:"name",description:"a sign-in for the reviewer, when the app needs one"},"demo-password-stdin":{type:"boolean",description:"read the demo account's password from stdin (never the command line)"},notes:{type:"string",value:"text",description:"notes to the reviewer"},locale:{type:"string",value:"locale",description:"the description's and feedback address's locale (default: the app's primary one)"}},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s={};for(let[i,r]of Object.entries(LO))e.flags[i]!==void 0&&(s[r]=e.flags[i]);if(e.flags["demo-password-stdin"]===!0&&(s.demo_account_password=await ut(e,"the demo account's password")),Object.keys(s).length===0)throw g("nothing to write: name at least one field","palbase help stores:review-info:set");await k(e,t,`write ${Object.keys(s).join(", ")} of ${n}'s Beta App Review information`);let a=await h(e,t,"PUT",`/stores/apps/${T(n)}/testflight/review-info`,s,J());e.out.result(a,()=>{e.out.line(a.missing.length===0?"Beta App Review has what it needs.":`Beta App Review still lacks: ${a.missing.join(", ")}.`)})}};async function Lp(e,t){let n=M2[R2(t).toLowerCase()];if(n===void 0)throw g(`${e}: a screenshot is a .png or .jpg file`);let s;try{let a=await Tp(t);if(!a.isFile())throw new Error("not a file");s=a.size}catch(a){throw new y("unreadable_file",`${e} could not be read: ${a instanceof Error?a.message:String(a)}`)}if(s===0||s>D2)throw g(`${e}: a screenshot is 1 byte to 10 MB, and it is ${s} bytes`);return{file:e,path:t,contentType:n}}async function xO(e,t,n){let s=ts(e.io.cwd,me),a=ts(t,n),i=Gw(s,a);if(i===""||i===".."||i.startsWith(`..${qw}`)||E2(i))throw g(`${n}: a screenshot the page names by its file is under ${me}/, and ${Gw(e.io.cwd,a)||a} is not`,`move it under ${me}/, or name it by the SHA-256 palbase stores:screenshots:upload printed`);let r,o;try{[o,r]=await Promise.all([xw(s),xw(a)])}catch(l){throw new y("unreadable_file",`${n} could not be read: ${l instanceof Error?l.message:String(l)}`)}if(!r.startsWith(o+qw))throw new y("outside_palbase",`${n} is a link out of ${me}/: palbase reads only what is under it`);return Lp(n,r)}async function Dp(e,t,n,s,a="page"){let i;try{i=await Zw(s.path,{type:s.contentType})}catch(r){throw new y("unreadable_file",`${s.file} could not be read: ${r instanceof Error?r.message:String(r)}`)}for(let r=1;;r++)try{let o=`/stores/apps/${T(n)}/screenshots${a==="review"?"?for=review":""}`;return await h(e,t,"PUT",o,new Fn(i,s.contentType))}catch(o){if(!(o instanceof W)||o.status!==503||o.code!=="stores_busy")throw o;let l=Math.max(o.retryAfter??60,1);if(r>=zw||l>tv)throw o;e.out.note(`${s.file}: ${o.message}; trying again in ${l} s (${r+1} of ${zw})`),await e.io.sleep(l*1e3)}}var Ps=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function GO(e){let t=Ps(e)&&"draft"in e&&"revision"in e?e.draft:e;if(!Ps(t)||!Ps(t.locales))throw g('a page is a JSON object that names its languages: { "primary_category": \u2026, "locales": { "en-US": { "name": \u2026, "screenshots": { "iphone_6_9": [ \u2026 ] } } } }',`as palbase stores:listing:get <app id> --out ${es} writes it`);for(let[n,s]of Object.entries(t.locales)){if(!Ps(s))throw g(`locales.${n} is an object: { "name": \u2026, \u2026 }`);if(s.screenshots!==void 0){if(!Ps(s.screenshots))throw g(`locales.${n}.screenshots is an object of display \u2192 its screenshots (${L2.join(", ")})`);for(let[a,i]of Object.entries(s.screenshots))if(!Array.isArray(i)||!i.every(r=>typeof r=="string"&&r.trim()!==""))throw g(`locales.${n}.screenshots.${a} is a list of screenshots, each a SHA-256 or a file under ${me}/`)}}return t}function qO(e,t){let n=structuredClone(e);for(let s of Object.values(n.locales))for(let[a,i]of Object.entries(s.screenshots??{}))s.screenshots[a]=i.map(t);return n}var Ln=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function ov(e,t,n,s,a){if(t instanceof W){if(t.code==="listing_moved")throw new y("listing_moved",`${n}'s draft page is no longer at revision ${a??"?"}: someone saved a newer one since it was read \u2014 ${s}`,{hint:`read it again (palbase stores:listing:get ${n} --out <file>), make the edit on it, and save with that revision`});if(t.code==="listing_invalid"){let i=t.message.split("; ").filter(r=>r!=="");e.out.note(`The page has ${Ln(i.length,"problem")}:`);for(let r of i)e.out.note(` ${r}`);throw new y("listing_invalid",`${s}: the page breaks ${Ln(i.length,"rule")} of the App Store's`,{hint:"fix each in the file, and save it again"})}if(t.code==="listing_empty")throw new y("listing_empty",`${n} has no draft App Store page yet: ${s}`,{hint:`write one: palbase stores:listing:get ${n} --out ${es}, edit it, then palbase stores:listing:put ${n} --file ${es} --revision 0`});if(t.code==="no_editable_version")throw new y("no_editable_version",`${n} has no App Store version whose page can change: ${s}`,{hint:`prepare the next one: palbase stores:version:prepare ${n} --version <x.y.z>`})}throw t}var UO={name:"stores:listing:get",summary:"an iOS app's draft App Store page \u2014 categories, age rating, each language's text and screenshots \u2014 and its revision",usage:`<app id> [--out <${es}>]`,details:["--out writes the draft to a file to edit, under palbase/; stores:listing:put saves the edit on the revision printed. A screenshot can be named there by its file under palbase/ (relative to the draft's file) instead of its SHA-256: listing:put uploads it first.","Nothing of the draft is at Apple: stores:listing:plan compares it with App Store Connect, and the plan, once confirmed, writes it."],args:{min:1,max:1},flags:{out:{type:"string",value:"file",description:"write the draft to this file, under palbase/"}},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s=e.flags.out,a=s!==void 0?Nt(e,"out",s,".json",es):void 0,i=await h(e,t,"GET",`/stores/apps/${T(n)}/listing`);if(a!==void 0){let r=await Be(e.io.cwd,a);await $2(ev(r),{recursive:!0}),await Be(e.io.cwd,a),await A2(r,`${JSON.stringify(i.draft,null,2)}
|
|
675
675
|
`),e.out.result({file:a,app_id:i.app_id,revision:i.revision},()=>{e.out.line(`Wrote revision ${i.revision} of ${n}'s draft App Store page to ${a}.`),e.out.line(`Save an edit of it: palbase stores:listing:put ${n} --file ${a} --revision ${i.revision}`)});return}e.out.result(i,()=>{if(i.revision===0){e.out.line(`${n} has no draft App Store page yet (revision 0).`),e.out.line(`Start one: palbase stores:listing:get ${n} --out ${es}, then palbase stores:listing:put ${n} --file ${es} --revision 0`);return}e.out.line(`${n}'s draft App Store page, revision ${i.revision}${i.updated_at?` (saved ${Y(i.updated_at)}${i.updated_by?` by ${i.updated_by}`:""})`:""}:`);for(let r of JSON.stringify(i.draft,null,2).split(`
|
|
676
676
|
`))e.out.line(r);e.out.line(`Edit it in a file: palbase stores:listing:get ${n} --out ${es}`)})}},KO={name:"stores:listing:put",summary:"save an iOS app's draft App Store page, whole, on the revision it was edited from \u2014 its screenshot files uploaded first",usage:`<app id> --file <${es}> --revision <n>`,details:["A screenshot is named by its SHA-256, or by a file \u2014 a path from the draft's own file, under palbase/ (nothing else is read): each file is uploaded first, and the draft is saved with its SHA-256 in its place. The file itself is left as it is.","Of two people editing at once, the second is told \u2014 the draft moved past the revision they edited \u2014 never saved over. Nothing goes to Apple: stores:listing:plan says what the draft changes there."],args:{min:1,max:1},flags:{file:{type:"string",value:"listing.json",description:"the draft, as stores:listing:get --out wrote it ('-' or none: stdin)"},revision:{type:"string",value:"n",description:"the revision it was edited from, as stores:listing:get printed it (0: the first)"}},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s=Te(e.flags.revision,"revision");if(s===void 0)throw g("--revision is the revision the draft was edited from, as stores:listing:get printed it (0 for the first): of two edits at once, the second is told, not saved over the first");let a=e.flags.file,i=GO(Fe(await Xe(e,a,"the page"),"the page")),r=a!==void 0&&a!=="-"?ev(ts(e.io.cwd,a)):e.io.cwd,o=new Map,l=new Map;for(let f of Object.values(i.locales))for(let b of Object.values(f.screenshots??{}).flat()){if(Ww.test(b)||l.has(b))continue;let v=await xO(e,r,b);l.set(b,v.path),o.has(v.path)||o.set(v.path,v)}await k(e,t,`save ${n}'s draft App Store page over revision ${s}${o.size>0?`, uploading ${Ln(o.size,"screenshot")} first`:""}`);let d=new Map,p=[];for(let f of o.values()){let b=await Dp(e,t,n,f);d.set(f.path,b.sha256),p.push({file:f.file,sha256:b.sha256,displays:b.displays}),e.out.note(`uploaded ${f.file}: ${b.sha256} (${b.width}x${b.height}, fits ${b.displays.join(", ")||"no display"})`)}let c=qO(i,f=>Ww.test(f)?f.toLowerCase():d.get(l.get(f))),m;try{m=await h(e,t,"PUT",`/stores/apps/${T(n)}/listing`,{revision:s,draft:c},J())}catch(f){ov(e,f,n,"nothing was saved",s)}e.out.result({...m,uploaded:p},()=>{let f=Object.keys(m.draft.locales),b=Object.values(m.draft.locales).flatMap(v=>Object.values(v.screenshots??{}).flat()).length;e.out.line(`Saved revision ${m.revision} of ${n}'s draft App Store page: ${Ln(f.length,"language")}${f.length>0?` (${f.join(", ")})`:""}, ${Ln(b,"screenshot")}.`),e.out.line(`Nothing is at Apple yet: palbase stores:listing:plan ${n} says what it changes there.`)})}},FO={name:"stores:screenshots:upload",summary:"upload screenshots for an iOS app's App Store page: each is kept by its SHA-256, which the draft names it by",usage:"<app id> <file.png|file.jpg>\u2026",details:['Each is a PNG or JPEG of 10 MB at most, of a size the App Store takes: iPhone 6.9" (1320x2868, 1290x2796, 1260x2736), iPhone 6.5" (1242x2688, 1284x2778) or iPad 13" (2064x2752, 2048x2732), or turned. The same image again is the one kept.',"stores:listing:put uploads the files a draft names itself; this is for the SHA-256 alone."],args:{min:2,max:101},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s=[];for(let i of e.args.slice(1))s.push(await Lp(i,ts(e.io.cwd,i)));await k(e,t,`upload ${Ln(s.length,"screenshot")} for ${n}'s App Store page`);let a=[];for(let i of s)a.push({file:i.file,...await Dp(e,t,n,i)});e.out.result({screenshots:a},()=>{e.out.table(a,[{header:"file",value:i=>i.file},{header:"sha256",value:i=>i.sha256},{header:"size",value:i=>`${i.width}x${i.height}`},{header:"fits",value:i=>i.displays.length>0?i.displays.join(", "):"no display"}]),e.out.note(`Name them in the draft page by their SHA-256 (locales.<code>.screenshots.<display>), then: palbase stores:listing:put ${n} --file <file> --revision <n>`)})}},BO={name:"stores:review-screenshot",summary:"upload the screenshot App Review is shown of an in-app purchase: kept by its SHA-256, which the catalog names it by",usage:"<app id> <file.png|file.jpg>",details:[`A PNG or JPEG of 10 MB at most, at an App Store screenshot size \u2014 iPhone 6.9" 1320x2868, 1290x2796 or 1260x2736; iPhone 6.5" 1242x2688 or 1284x2778; iPad 13" 2064x2752 or 2048x2732 (or turned): App Review takes an in-app purchase's screenshot at no other.`,'Name it in the catalog, channels.ios.review.screenshot = "sha256:<hex>"; the next plan (palbase purchases:catalog:plan) gives it to App Store Connect, and Apple then has what it needs of the product to review it.'],args:{min:2,max:2},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s=await Lp(e.args[1],ts(e.io.cwd,e.args[1]));await k(e,t,`upload ${s.file} as a review screenshot for ${n}`);let a=await Dp(e,t,n,s,"review");e.out.result(a,()=>{e.out.line(`Kept ${s.file} for App Review: sha256 ${a.sha256} (${a.width}x${a.height}).`),e.out.note(`Name it in the catalog: channels.ios.review.screenshot = "sha256:${a.sha256}", then palbase purchases:catalog:plan`)})}},WO={name:"stores:listing:plan",summary:"plan writing an iOS app's draft page to App Store Connect: what changes, language by language; it runs when confirmed",usage:"<app id>",details:["The draft is compared with the page of the app's version that can change; a field the draft leaves empty, and a language it has not, are left as they are."],args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id");await k(e,t,`plan writing ${n}'s App Store page`);let s;try{s=await h(e,t,"POST",`/stores/apps/${T(n)}/listing/plan`,void 0,J())}catch(a){ov(e,a,n,"nothing was planned")}e.out.result(s,()=>{if(!s.action){e.out.line(`Nothing to change: App Store Connect holds ${n}'s page of version ${s.version} as revision ${s.revision} of the draft has it.`);return}e.out.line(`Revision ${s.revision} of the draft, written to version ${s.version}'s page, changes:`),s.steps.forEach((a,i)=>e.out.line(` ${i+1}. ${a.says}`)),Mp(e,s.action,{summary:!1})})}},zO={USES_THIRD_PARTY_CONTENT:"it shows, contains or reaches third-party content",DOES_NOT_USE_THIRD_PARTY_CONTENT:"no third-party content"},JO={manual:"manual: a person releases it once approved",after_approval:"as soon as it is approved"},HO=["paused","active","complete"];function lv(e,t,n){let s=n.version;e.out.line(s?`${t}: version ${s.version_string} \u2014 ${s.state}${s.first_version?" (the app's first: it has no What's New)":""}`:`${t} has no App Store version that can change.`);let a=[];s&&(a.push(["build",s.build_number!==""?s.build_number:"(none yet)"]),a.push(["copyright",$n(s.copyright)]),a.push(["release",s.release==="scheduled"?`scheduled: not before ${Y(s.release_at)}`:JO[s.release]??$n(s.release)]));let i=n.phased;a.push(["phased",i?`over seven days \u2014 ${i.state}${i.state!=="INACTIVE"?`, day ${i.day} of 7`:""}${i.paused_days>0?`, paused ${Ln(i.paused_days,"day")}`:""}`:"no: everyone gets it at once"]),a.push(["price",n.priced?"set":"none yet (stores:version:prepare --free makes it free)"]),a.push(["content rights",zO[n.content_rights]??$n(n.content_rights)]);let r=n.review,o=[`${r.contact_first_name} ${r.contact_last_name}`.trim(),r.contact_phone,r.contact_email].filter(d=>d!=="").join(", ");a.push(["review contact",$n(o)]),a.push(["demo account",r.demo_account_required?`required: ${$n(r.demo_account_name)}, password ${r.has_demo_password?"set":"not set"}`:"not required"]),a.push(["review notes",$n(r.notes)]),n.watched&&a.push(["watched",`${n.watched.version_string} ${n.watched.state} since ${Y(n.watched.state_at)} (read ${Y(n.watched.checked_at)})`]);let l=Math.max(...a.map(([d])=>d.length));for(let[d,p]of a)e.out.line(` ${d.padEnd(l)} ${p}`);if(n.missing.length>0){e.out.line("App Review would refuse it for:");for(let d of n.missing)e.out.line(` - ${d}`)}else s&&e.out.line(`App Review has what it needs: palbase stores:version:submit ${t}`);s||e.out.line(`Prepare the next one: palbase stores:version:prepare ${t} --version <x.y.z>`)}var VO={name:"stores:version",summary:"an iOS app's App Store version as App Review will see it \u2014 its build, release, phased release, price, content rights, review contact \u2014 and what App Review would refuse it for",usage:"<app id>",details:["The demo account's password is never read out: only whether Apple holds one. watched is what the module last saw of the version sent to App Review (it reads it every few minutes)."],args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s=await h(e,t,"GET",`/stores/apps/${T(n)}/version`);e.out.result(s,()=>lv(e,n,s))}},Xw={contact_first_name:"string",contact_last_name:"string",contact_email:"string",contact_phone:"string",demo_account_required:"boolean",demo_account_name:"string",notes:"string"};function XO(e){let t=Ps(e)&&Ps(e.review)&&"app_id"in e?e.review:e;if(!Ps(t))throw g('the review file is a JSON object: { "contact_first_name": \u2026, "contact_email": \u2026, "demo_account_required": \u2026, "notes": \u2026 }');let{has_demo_password:n,...s}=t;for(let[a,i]of Object.entries(s)){if(a==="demo_account_password")throw g("the review file holds no password: the demo account's is read from stdin, never from a file","take it out of the file, and pipe it in: \u2026 --demo-password-stdin < password.txt");let r=Xw[a];if(r===void 0)throw g(`the review file's ${a} is not one of App Review's details: ${Object.keys(Xw).join(", ")}`);if(typeof i!==r)throw g(`the review file's ${a} is ${r==="string"?"text":"true or false"}`)}return s}function Yw(e,t){if(e.flags[t]===!0&&e.flags[`no-${t}`]===!0)throw g(`--${t} and --no-${t} are one or the other`);if(e.flags[t]===!0)return!0;if(e.flags[`no-${t}`]===!0)return!1}var YO={name:"stores:version:prepare",summary:"prepare an iOS app's App Store version: its number, build, copyright, release, phased release, content rights, a free price, App Review's details",usage:"<app id> [--version <x.y.z>] [--build <n>] [--copyright <text>] [--release manual|after_approval|scheduled] [--release-at <RFC 3339>] [--phased | --no-phased] [--third-party-content | --no-third-party-content] [--free] [--territories all] [--app-privacy published|unpublished] [--review-file <review.json>] [--demo-password-stdin]",details:["Only what is given is written; --version makes the next version when the app has none that can change. The build is a TestFlight build of that version, by its number.","--review-file holds App Review's details as stores:version --json shows them (its review): a field the file leaves out stays as it is. The demo account's password is read from stdin alone (--demo-password-stdin), never from the file or the command line; it goes to Apple, and is never printed or kept."],args:{min:1,max:1},flags:{version:{type:"string",value:"x.y.z",description:"the version's number: makes it when the app has none that can change"},build:{type:"string",value:"n",description:"the TestFlight build App Review gets, by its build number"},copyright:{type:"string",value:"text",description:"the copyright line (2026 Your Company)"},release:{type:"string",value:"how",description:"how it goes out once approved: manual, after_approval or scheduled"},"release-at":{type:"string",value:"RFC 3339",description:"a scheduled release, not before then (alone, it is scheduled)"},phased:{type:"boolean",description:"release it in phases over seven days"},"no-phased":{type:"boolean",description:"release it to everyone at once"},"third-party-content":{type:"boolean",description:"the content rights statement: the app shows, contains or reaches third-party content"},"no-third-party-content":{type:"boolean",description:"the content rights statement: it does not"},free:{type:"boolean",description:"make an app with no price free everywhere (a paid price is set in App Store Connect)"},territories:{type:"string",value:"all",description:"all: sell an app sold nowhere in every country and region (chosen ones are set in App Store Connect)"},"app-privacy":{type:"string",value:"published|unpublished",description:"say the app's privacy details were published in App Store Connect (Apple has no API for them): the missing list stops asking for them"},"review-file":{type:"string",value:"review.json",description:"App Review's details: contact, demo account, notes ('-': stdin)"},"demo-password-stdin":{type:"boolean",description:"read the demo account's password from stdin (never a file or the command line)"}},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s={},a=[],i=e.flags.version;if(i!==void 0){if(!/^\d+(\.\d+){0,2}$/.test(i)||i.length>18)throw g(`--version ${i}: one to three numbers with dots (1.2.3)`);s.version_string=i,a.push(`version ${i}`)}let r=Te(e.flags.build,"build");if(r!==void 0){if(r<1)throw g("--build is a TestFlight build's number");s.build_number=r,a.push(`build ${r}`)}let o=e.flags.copyright;if(o!==void 0){if(o.trim()===""||o.length>200)throw g("--copyright is 1 to 200 characters (2026 Your Company)");s.copyright=o,a.push("copyright")}let l=e.flags.release,d=e.flags["release-at"];if(l!==void 0&&!["manual","after_approval","scheduled"].includes(l))throw g("--release is manual, after_approval or scheduled");if(d!==void 0){if(l!==void 0&&l!=="scheduled")throw g(`--release-at is a scheduled release's: not ${l}`);let A=Date.parse(d);if(!Number.isFinite(A))throw g(`--release-at ${d}: a time, RFC 3339 (2026-11-02T09:00:00Z)`);if(A<=e.io.now())throw g(`--release-at ${d}: a scheduled release's time is in the future`);s.release="scheduled",s.release_at=new Date(A).toISOString()}else{if(l==="scheduled")throw g("--release scheduled needs --release-at: when it may go out");l!==void 0&&(s.release=l)}s.release&&a.push(`release ${s.release}${s.release_at?` at ${s.release_at}`:""}`);let p=Yw(e,"phased");p!==void 0&&(s.phased=p,a.push(p?"phased release":"release to everyone at once"));let c=Yw(e,"third-party-content");c!==void 0&&(s.uses_third_party_content=c,a.push(c?"uses third-party content":"no third-party content")),e.flags.free===!0&&(s.price="free",a.push("free"));let m=e.flags.territories;if(m!==void 0){if(m!=="all")throw g("--territories is all (chosen countries are set in App Store Connect)");s.territories="all",a.push("sold in every country and region")}let f=e.flags["app-privacy"];if(f!==void 0){if(f!=="published"&&f!=="unpublished")throw g("--app-privacy is published or unpublished");s.app_privacy=f,a.push(`App Privacy ${f}`)}let b=e.flags["review-file"],v=e.flags["demo-password-stdin"]===!0;if(v&&b==="-")throw g("stdin carries the demo password or the review file, not both","--review-file <review.json> --demo-password-stdin < password.txt");if(b!==void 0||v){let A=b!==void 0?XO(Fe(await Xe(e,b,"the review details"),"the review details")):{},C=v?await ut(e,"the demo account's password"):void 0;if(C!==void 0&&C.length>256)throw g("the demo account's password is 256 characters at most");let{has_demo_password:N,...j}=(await h(e,t,"GET",`/stores/apps/${T(n)}/version`)).review;s.review={...j,...A,...C!==void 0?{demo_account_password:C}:{}},b!==void 0&&a.push("App Review's details"),C!==void 0&&a.push("the demo account's password")}if(a.length===0)throw g("nothing to prepare: name at least one of the version, its build, copyright, release, phased release, content rights, price, countries, App Privacy or review details","palbase help stores:version:prepare");await k(e,t,`prepare ${n}'s App Store version: ${a.join(", ")}`);let R;try{R=await h(e,t,"PUT",`/stores/apps/${T(n)}/version`,s)}catch(A){throw A instanceof W&&A.code==="no_editable_version"?new y("no_editable_version",`${n} has no App Store version that can change`,{hint:`make the next one: palbase stores:version:prepare ${n} --version <x.y.z> \u2026`}):A}e.out.result(R,()=>{e.out.line(`Prepared ${n}'s App Store version.`),lv(e,n,R)})}};function ol(e,t,n,s,a={},i){return{name:e,summary:s,usage:"<app id>",args:{min:1,max:1},scope:"environment",...a,async run(r){let o=await w(r),l=fe(r,0,"the app's id"),d=i?.(r);await k(r,o,`plan ${Es[t]} of app ${l}`);let p;try{p=await h(r,o,"POST",`/stores/apps/${T(l)}/version/${n}`,d,J())}catch(c){if(c instanceof W&&c.code==="version_incomplete"){let m=c.message.slice(c.message.indexOf(": ")+2).split("; ").filter(f=>f!=="");r.out.note("App Review would refuse the version for:");for(let f of m)r.out.note(` - ${f}`);throw new y("version_incomplete",`nothing was planned: the version lacks ${Ln(m.length,"thing")} App Review needs`,{hint:`palbase stores:version ${l} says what is missing; palbase stores:version:prepare ${l} \u2026 writes what can be written from here`})}throw c instanceof W&&c.code==="no_editable_version"?new y("no_editable_version",`${l} has no App Store version to send`,{hint:`prepare one: palbase stores:version:prepare ${l} --version <x.y.z> --build <n> \u2026`}):c}r.out.result(p,()=>Mp(r,p))}}}var ZO=ol("stores:version:submit","submit_review","submit","plan sending an iOS app's prepared version to App Review \u2014 refused, with what is missing, until it has what App Review needs; it runs when confirmed",{usage:"<app id> [--with <product id>,\u2026]",details:["--with sends the app's in-app purchases and subscriptions with the version, by product id: a product's first review goes with an app version, as Apple requires, and each is READY_TO_SUBMIT at Apple (its text, price, availability and review screenshot complete) or nothing is planned."],flags:{with:{type:"string",value:"product id,\u2026",description:"in-app purchases sent to App Review with the version, by product id"}}},e=>{let t=e.flags.with;if(t===void 0)return;let n=t.split(",").map(s=>s.trim()).filter(s=>s!=="");if(n.length===0||n.length>50)throw g("--with names 1 to 50 product ids, comma-separated");return{in_app_purchases:n}}),QO=ol("stores:version:withdraw","withdraw_review","withdraw","plan taking the version out of App Review: it is edited again, and sent again from the start; it runs when confirmed"),eN=ol("stores:version:release","release_version","release","plan releasing an approved version that waits for its developer (a manual release) on the App Store, for good; it runs when confirmed"),tN=ol("stores:version:phased","phased_release","phased-release","plan pausing, resuming or completing the version's phased release (complete: everyone gets it now); it runs when confirmed",{usage:"<app id> <paused|active|complete>",args:{min:2,max:2}},e=>{let t=e.args[1];if(!HO.includes(t))throw g(`a phased release is paused, active (resumed) or complete (everyone gets it now), not ${JSON.stringify(t)}`);return{state:t}});function Mp(e,t,n={}){e.out.line(`Planned ${Es[t.kind]??t.kind} of ${Za(t)} (action ${t.id}):`),n.summary!==!1&&e.out.line(` ${t.summary}`),e.out.line(` hash: ${t.hash}`),e.out.line(`It runs only when confirmed, before ${Y(t.expires_at)}:`),e.out.line(` palbase stores:actions:confirm ${t.id} --hash ${t.hash}`)}function xp(e,t,n,s,a={},i){return{name:e,summary:s,usage:"<package id>",args:{min:1,max:1},scope:"environment",...a,async run(r){let o=await w(r),l=fe(r,0,"the package's id"),d=i?.(r);await k(r,o,`plan ${Es[t]} of package ${l}`);let p=await h(r,o,"POST",`/stores/packages/${T(l)}/${n}`,d,J());r.out.result(p,()=>Mp(r,p))}}}var nN=xp("stores:beta-review","beta_review","beta-review","plan sending a package to Beta App Review (external testers get it after Apple's review); it runs when confirmed"),sN=xp("stores:export-compliance","export_compliance","export-compliance","plan the export compliance answer of a package's build (the question TestFlight waits on); it runs when confirmed",{usage:"<package id> --uses-non-exempt-encryption yes|no",flags:{"uses-non-exempt-encryption":{type:"string",value:"yes|no",description:"whether the app uses encryption beyond HTTPS and what iOS provides"}}},e=>{let t=fs(e.flags["uses-non-exempt-encryption"],"uses-non-exempt-encryption");if(t===void 0)throw g("--uses-non-exempt-encryption is yes or no: whether the app uses encryption beyond HTTPS and what iOS provides");return{uses_non_exempt_encryption:t}}),aN=xp("stores:expire","expire_build","expire","plan expiring a package's build in TestFlight (testers can no longer install it); it runs when confirmed"),iN={name:"stores:actions",summary:"the actions planned at Apple, newest first: what each does, and whether it ran (running: a page still being written)",usage:"[--status planned|done|declined|failed] [--limit <n>]",flags:{status:{type:"string",value:"status",description:"only those planned, done, declined or failed"},limit:{type:"string",value:"n",description:"how many (1\u2013200, default 30)"}},scope:"environment",async run(e){let t=await w(e),n=e.flags.status;if(n!==void 0&&!["planned","done","declined","failed"].includes(n))throw g("--status is planned, done, declined or failed");let s=Te(e.flags.limit,"limit")??30;if(s<1||s>200)throw g("--limit is a whole number from 1 to 200");let a=new URLSearchParams({limit:String(s),...n?{status:n}:{}}),i=await h(e,t,"GET",`/stores/actions?${a}`);e.out.result(i,()=>{i.actions.length===0?e.out.line(n?`No ${n} action.`:"No action yet."):e.out.table(i.actions,[{header:"action",value:r=>r.id},{header:"kind",value:r=>r.kind},{header:"package / app",value:r=>r.package_id??r.app_id??""},{header:"status",value:r=>r.status},{header:"planned",value:r=>Y(r.created_at)},{header:"what",value:r=>r.summary}]),i.next_cursor&&e.out.note(`More than ${s}: raise --limit to see older ones.`)})}},rN={name:"stores:actions:confirm",summary:"run a planned action at Apple: it names the hash of the plan that was shown, and is asked about first",usage:"<action id> --hash <hash>",details:["What it does is shown, then asked about \u2014 in every environment, as it cannot be undone at Apple. -y confirms without asking.",`An App Store page's plan is written after the answer (its screenshots take minutes): the command waits for it to be done or failed, ${rl/60} minutes at most; stopping the wait does not stop the writing.`],args:{min:1,max:1},flags:{hash:{type:"string",value:"hash",description:"the plan's hash, as it was shown when it was planned"}},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the action's id"),s=e.flags.hash;if(s===void 0||s.trim()==="")throw g("--hash is the plan's hash, as stores:actions or the plan printed it: a confirmation names the plan it saw");let a=await h(e,t,"GET",`/stores/actions/${T(n)}`);if(a.status!=="planned")throw new y("action_not_planned",`the action ${n} is ${a.status}: only a planned one is confirmed`);await k(e,t,`run ${Es[a.kind]??a.kind} of ${Za(a)}: ${a.summary}`,"It is done at Apple and cannot be undone");let i=await h(e,t,"POST",`/stores/actions/${T(n)}/confirm`,{hash:s},J());return i.status==="running"&&(i=await lN(e,t,i)),e.out.result(i,()=>oN(e,i)),i.status==="failed"?1:0}};function oN(e,t){e.out.line(`${Cp(Es[t.kind]??t.kind)} of ${Za(t)}: ${t.status}.`);let n=t.result??{};if(typeof n.error=="string"&&n.error!==""&&e.out.line(` ${n.error}`),Array.isArray(n.missing))for(let s of n.missing)typeof s=="string"&&e.out.line(` - ${s}`);if(typeof n.steps_done=="number"&&(t.status==="done"?e.out.line(`${Ln(n.steps_done,"step")} written at App Store Connect.`):e.out.line(`${Ln(n.steps_done,"step")} written before it stopped${typeof n.failed_step=="string"?` at: ${n.failed_step}`:""}; planned again, what is left is written.`)),t.kind==="phased_release"&&t.status==="done"&&typeof n.state=="string"&&e.out.line(`The phased release is ${n.state}.`),n.in_app_purchases&&typeof n.in_app_purchases=="object")for(let[s,a]of Object.entries(n.in_app_purchases))typeof a=="string"&&e.out.line(`App Store Connect says of ${s}: ${a}.`);typeof n.version_state=="string"&&e.out.line(`App Store Connect says of the version: ${n.version_state}.`),n.withdrawing===!0&&e.out.line(`App Store Connect is taking the version out of App Review, which takes it a few seconds: palbase stores:version ${t.app_id??"<app id>"} shows it once it has.`)}async function lN(e,t,n){e.out.note(`${Cp(Es[n.kind]??n.kind)} of ${Za(n)} is under way at App Store Connect; waiting for it to end (${rl/60} minutes at most \u2014 stopping the wait does not stop it).`);let s=e.io.now()+rl*1e3,a=n;for(;a.status==="running";){if(e.io.now()>=s)throw new y("action_running",`${Es[n.kind]??n.kind} of ${Za(n)} is still running after ${rl/60} minutes (action ${n.id})`,{hint:"it goes on without this command: palbase stores:actions says when it is done or failed"});await e.io.sleep(I2*1e3),a=await h(e,t,"GET",`/stores/actions/${T(n.id)}`)}return a}var dN={name:"stores:actions:decline",summary:"decline a planned action: it never runs",usage:"<action id>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the action's id");await k(e,t,`decline the action ${n}`);let s=await h(e,t,"POST",`/stores/actions/${T(n)}/decline`,void 0,J());e.out.result(s,()=>e.out.line(`Declined ${Es[s.kind]??s.kind} of ${Za(s)}.`))}},Ep={"3m":"MONTHLY_RENEWAL_EVERY_THREE_MINUTES","5m":"MONTHLY_RENEWAL_EVERY_FIVE_MINUTES","15m":"MONTHLY_RENEWAL_EVERY_FIFTEEN_MINUTES","30m":"MONTHLY_RENEWAL_EVERY_THIRTY_MINUTES","1h":"MONTHLY_RENEWAL_EVERY_ONE_HOUR"},dv=e=>Object.entries(Ep).find(([,t])=>t===e)?.[0]??e,pN=100;function cN(e,t){t.testers.length===0&&e.out.line("The team has no sandbox tester yet."),e.out.table(t.testers,[{header:"email",value:n=>n.email},{header:"name",value:n=>`${n.first_name} ${n.last_name}`.trim()},{header:"storefront",value:n=>n.territory},{header:"monthly renews every",value:n=>dv(n.subscription_renewal_rate)},{header:"interrupted",value:n=>n.interrupt_purchases?"yes":"no"},{header:"id",value:n=>n.id}]),t.create_in&&e.out.note(`A person makes another, Apple's API makes none: ${t.create_in}`)}async function pv(e,t,n){let s=(await h(e,t,"GET","/stores/apple/sandbox-testers")).testers,a=[];for(let i of n){let r=s.find(o=>o.id===i||o.email.toLowerCase()===i.toLowerCase());if(!r)throw new y("no_such_tester",`the team has no sandbox tester ${i}`,{hint:`its testers: ${s.map(o=>o.email).join(", ")||"none \u2014 App Store Connect \u203A Users and Access \u203A Sandbox makes one"}`});a.some(o=>o.id===r.id)||a.push(r)}return a}var uN={name:"stores:apple:sandbox-testers",summary:"the Apple team's sandbox testers: the accounts that buy in the App Store's sandbox, how fast their subscriptions renew",details:["They are the team's, every environment's alike. Only a person makes one: App Store Connect \u203A Users and Access \u203A Sandbox."],scope:"environment",async run(e){let t=await w(e),n=await h(e,t,"GET","/stores/apple/sandbox-testers");e.out.result(n,()=>cN(e,n))}},mN={name:"stores:apple:sandbox-testers:set",summary:"change how a sandbox tester buys: how fast its monthly subscriptions renew, whether its purchases are interrupted, its storefront",usage:"<email|id> [--renewal 3m|5m|15m|30m|1h] [--interrupt on|off] [--storefront <code>]",details:["A monthly subscription renews at the rate given; a yearly one in proportion. Apple renews one 12 times at most, then lets it end.","An interrupted purchase stops for an action of the buyer's, as when a bank asks for one: what the app does then is tested."],args:{min:1,max:1},flags:{renewal:{type:"string",value:"rate",description:"every 3m, 5m, 15m, 30m or 1h"},interrupt:{type:"string",value:"on|off",description:"interrupt its purchases"},storefront:{type:"string",value:"code",description:"the storefront it buys in, three letters (USA, DEU, TUR \u2026)"}},scope:"environment",async run(e){let t=await w(e),n={},s=e.flags.renewal;if(s!==void 0){let l=Ep[s.trim().toLowerCase()];if(l===void 0)throw g(`--renewal ${s}: a monthly subscription renews every ${Object.keys(Ep).join(", ")}`);n.subscription_renewal_rate=l}let a=e.flags.interrupt;if(a!==void 0){if(a!=="on"&&a!=="off")throw g("--interrupt is on or off");n.interrupt_purchases=a==="on"}let i=e.flags.storefront?.trim().toUpperCase();if(i!==void 0){if(!za.has(i))throw g(`--storefront ${e.flags.storefront}: not an App Store storefront`,"three letters, its country's ISO 3166-1 code: USA, DEU, TUR \u2026");n.territory=i}if(Object.keys(n).length===0)throw g("nothing to change: --renewal, --interrupt or --storefront");let[r]=await pv(e,t,[e.args[0]]);await k(e,t,`change the sandbox tester ${r.email}`);let o=await h(e,t,"PATCH",`/stores/apple/sandbox-testers/${T(r.id)}`,n,J());e.out.result(o,()=>{e.out.line(`${o.email}: monthly subscriptions renew every ${dv(o.subscription_renewal_rate)}, purchases ${o.interrupt_purchases?"interrupted":"not interrupted"}, storefront ${o.territory}.`),n.territory!==void 0&&e.out.line("Sign out of the sandbox account on the device and in again for the storefront to change there.")})}},hN={name:"stores:apple:sandbox-testers:clear",summary:"clear sandbox testers' purchase history: each buys again as for the first time, introductory offers included",usage:"<email|id>\u2026",details:["Apple clears them after it answers, which can take minutes. Then sign out of the sandbox account on the device and in again."],args:{min:1,max:pN},scope:"environment",async run(e){let t=await w(e),n=await pv(e,t,e.args);await k(e,t,`clear what ${n.map(s=>s.email).join(", ")} bought in the sandbox`),await h(e,t,"POST","/stores/apple/sandbox-testers/clear-purchase-history",{tester_ids:n.map(s=>s.id)},J()),e.out.result({cleared:n.map(s=>s.email)},()=>{e.out.line(`Apple is clearing what ${n.map(s=>s.email).join(", ")} bought in the sandbox.`),e.out.line("Once it has (minutes), sign out of the sandbox account on the device and in again.")})}};function gN(e,t,n){if(n.threads.length===0){e.out.line("App Review has written nothing in this app's Resolution Center.");return}for(let s of n.threads){e.out.line(`thread ${s.id} \u2014 ${s.type??"?"}${s.state?`, ${s.state}`:""}${s.last_message_at?`, last ${Y(s.last_message_at)}`:""}${s.can_reply?"":" (takes no answer)"}`);for(let a of s.rejections)for(let i of a.reasons)e.out.line(` guideline ${i.section??"?"}: ${i.description??""}`);for(let a of s.messages){e.out.line(` ${a.from??"message"}${a.created_at?` ${Y(a.created_at)}`:""}:`);for(let i of a.body.split(`
|
|
677
677
|
`))e.out.line(` ${i}`)}for(let a of s.attachments)e.out.line(` attachment ${a.id}: ${a.file_name??"?"}${a.file_size?` (${a.file_size} bytes)`:""} \u2014 GET /stores/apps/${t}/review/threads/${s.id}/attachments/${a.id}`);s.draft&&e.out.line(` answer not sent yet: ${s.draft.body}`)}}var fN={name:"stores:app-review",summary:"an iOS app's Resolution Center, read with the Apple ID: App Review's messages, the guidelines a rejection names, its attachments, the answer not sent yet",usage:"<app id>",details:["Apple's API gives no reason for a rejection: the Apple ID signed in for the environment reads it (stores:apple:connect --apple-id). The five threads written to last."],args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s=await h(e,t,"GET",`/stores/apps/${T(n)}/review`);e.out.result(s,()=>gN(e,n,s))}},yN={name:"stores:app-review:answer",summary:"write the answer to an App Review thread, as App Store Connect's draft; --send sends it",usage:"<app id> <thread id> [--file <answer.txt>] [--send]",details:["The answer is read from --file, or piped in. Without --send it stays a draft, which App Store Connect's website shows too; with --send it goes to App Review."],args:{min:2,max:2},flags:{file:{type:"string",value:"answer.txt",description:"the answer (default: stdin)"},send:{type:"boolean",description:"send it to App Review once written"}},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s=fe(e,1,"the thread's id"),a=(await Xe(e,e.flags.file,"the answer")).trim(),i=e.flags.send===!0;await k(e,t,i?`send an answer to App Review on thread ${s}`:`write an answer to App Review on thread ${s}`);let r=await h(e,t,"PUT",`/stores/apps/${T(n)}/review/threads/${T(s)}/draft`,{body:a},J());if(!i){e.out.result(r,()=>e.out.line(`Wrote the answer as a draft (${r.id}); send it with --send, or from App Store Connect.`));return}let o=await h(e,t,"POST",`/stores/apps/${T(n)}/review/threads/${T(s)}/draft/send`,void 0,J());e.out.result(o,()=>e.out.line(`Sent the answer to App Review (message ${o.id}).`))}};function cv(e,t){e.out.line(`App Privacy: ${t.published?"published":"not published"}`),t.usages.length===0?e.out.line("No line is written."):e.out.table(t.usages,[{header:"category",value:n=>n.category??""},{header:"purpose",value:n=>n.purpose??""},{header:"data protection",value:n=>n.data_protection}])}var bN={name:"stores:privacy",summary:"an iOS app's App Privacy details as App Store Connect has them, read with the Apple ID",usage:"<app id>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s=await h(e,t,"GET",`/stores/apps/${T(n)}/privacy`);e.out.result(s,()=>cv(e,s))}},wN={name:"stores:privacy:set",summary:"write an iOS app's App Privacy details at Apple with the Apple ID, and publish them with --publish",usage:"<app id> --file <usages.json> [--publish]",details:[`The file is the details' lines in Apple's words: [{"category":"USER_ID","purpose":"APP_FUNCTIONALITY","data_protection":"DATA_LINKED_TO_YOU"}], or [{"data_protection":"DATA_NOT_COLLECTED"}] alone. What Apple has and the file lacks is removed; what the file has and Apple lacks is made.`],args:{min:1,max:1},flags:{file:{type:"string",value:"usages.json",description:"the lines (default: stdin)"},publish:{type:"boolean",description:"publish them once written"}},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s=Fe(await Xe(e,e.flags.file,"the App Privacy lines"),"the App Privacy lines"),a=Array.isArray(s)?s:s?.usages;if(!Array.isArray(a))throw g('the file is a list of lines, or {"usages": [...]}');await k(e,t,`write the App Privacy details of ${n} at Apple${e.flags.publish===!0?" and publish them":""}`);let i={usages:a,publish:e.flags.publish===!0},r=await h(e,t,"PUT",`/stores/apps/${T(n)}/privacy`,i,J());e.out.result(r,()=>cv(e,r))}},vN={name:"stores:apps:record",summary:"make a linked iOS app's App Store Connect record with the Apple ID \u2014 Apple's API leaves it to a person on the website \u2014 and link the app to it",usage:"<app id> --name <App Store name> [--sku <sku>] [--locale <en-US>] [--company <seller name>]",args:{min:1,max:1},flags:{name:{type:"string",value:"name",description:"its App Store name (30 characters at most)"},sku:{type:"string",value:"sku",description:"the record's own id in the team (default: the bundle id)"},locale:{type:"string",value:"locale",description:"its store page's first language (default: en-US)"},company:{type:"string",value:"name",description:"the seller's name, which a team's first app sets"}},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id"),s=e.flags.name;if(s===void 0||s.trim()==="")throw g("--name is the app's App Store name");let a={name:s.trim()};e.flags.sku!==void 0&&(a.sku=e.flags.sku),e.flags.locale!==void 0&&(a.primary_locale=e.flags.locale),e.flags.company!==void 0&&(a.company_name=e.flags.company),await k(e,t,`make the App Store Connect record "${a.name}" for ${n}`);let i=await h(e,t,"POST",`/stores/apps/${T(n)}/record`,a,J());e.out.result(i,()=>e.out.line(`Made the App Store Connect record ${i.asc_app_id??"?"} for ${i.bundle_id}, and linked ${i.name} to it.`))}},_N={name:"stores:apps:record:remove",summary:"remove a linked iOS app's App Store Connect record with the Apple ID, as App Store Connect's Remove App does (an app never approved)",usage:"<app id>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=fe(e,0,"the app's id");await k(e,t,`remove the App Store Connect record of ${n}`),await h(e,t,"DELETE",`/stores/apps/${T(n)}/record`,void 0,J()),e.out.result({removed:!0},()=>e.out.line(`Removed the App Store Connect record of ${n}; the app stays linked, with no record.`))}},uv=[G2,K2,F2,B2,J2,H2,V2,X2,Y2,Z2,Q2,eO,tO,uN,mN,hN,sO,aO,vN,_N,gO,iO,rO,oO,dO,cO,uO,mO,hO,fO,wO,vO,$O,kO,SO,AO,PO,RO,EO,TO,CO,jO,NO,IO,DO,MO,nN,sN,aN,UO,KO,FO,BO,WO,VO,YO,ZO,QO,eN,tN,fN,yN,bN,wN,iN,rN,dN];import{createHash as UN}from"node:crypto";import{mkdir as KN,writeFile as FN}from"node:fs/promises";import{dirname as BN}from"node:path";import{spawn as $N}from"node:child_process";import{accessSync as kN,constants as SN,mkdtempSync as AN,readFileSync as PN,rmSync as RN}from"node:fs";import{tmpdir as EN}from"node:os";import{delimiter as TN,join as ra}from"node:path";import{pathToFileURL as CN}from"node:url";function mv(e,t=process.platform){let n=r=>{try{return kN(r,SN.X_OK),!0}catch{return!1}},s=e.PALBASE_BROWSER?.trim();if(s)return n(s)?{path:s}:{named:s};let a=[];if(t==="darwin")for(let r of["/Applications",ra(e.HOME??"","Applications")])a.push(`${r}/Google Chrome.app/Contents/MacOS/Google Chrome`,`${r}/Chromium.app/Contents/MacOS/Chromium`,`${r}/Microsoft Edge.app/Contents/MacOS/Microsoft Edge`,`${r}/Brave Browser.app/Contents/MacOS/Brave Browser`);else if(t==="win32")for(let r of[e.PROGRAMFILES,e["PROGRAMFILES(X86)"],e.LOCALAPPDATA])r&&a.push(ra(r,"Google","Chrome","Application","chrome.exe"),ra(r,"Microsoft","Edge","Application","msedge.exe"),ra(r,"Chromium","Application","chrome.exe"));else for(let r of(e.PATH??"").split(TN).filter(Boolean))for(let o of["google-chrome","google-chrome-stable","chromium","chromium-browser","microsoft-edge","microsoft-edge-stable","brave-browser"])a.push(ra(r,o));let i=a.find(n);return i?{path:i}:{}}function hv(e){return(e.PALBASE_BROWSER_ARGS??"").split(/\s+/).filter(Boolean)}var tr=class extends Error{noSandbox;constructor(t){let n=t.split(`
|
|
678
678
|
`).map(i=>i.replace(/^\[[^\]]*\]\s*/,"").trim()).filter(Boolean),s=n.some(i=>i.includes("No usable sandbox")),a=s?"it has no sandbox to run in here":[...n].reverse().find(i=>/FATAL|ERROR|error/.test(i))??n.at(-1);super(`the browser closed as it started${a?`: ${a.slice(0,200)}`:""}`),this.noSandbox=s}},ll=e=>new Promise(t=>setTimeout(t,e));function jN(e){let[t,n]=e.split(`
|
|
679
|
-
`),s=Number(t);return n?.startsWith("/devtools/browser/")&&Number.isInteger(s)&&s>0&&s<65536?s:void 0}async function gv(e,t,n,s={}){let a=s.timeoutMs??3e4,i=AN(ra(EN(),"palbase-preview-")),r=$N(e,["--headless=new","--disable-gpu","--hide-scrollbars","--no-first-run","--no-default-browser-check","--disable-extensions","--disable-background-networking","--disable-sync","--mute-audio","--autoplay-policy=no-user-gesture-required",`--user-data-dir=${i}`,"--remote-debugging-port=0",...s.args??[],"about:blank"],{stdio:["ignore","ignore","pipe"]}),o="";r.stderr?.on("data",p=>{o=(o+p.toString("utf8")).slice(-8192)});let l=!1;r.once("exit",()=>{l=!0});let d=new Promise((p,c)=>r.once("error",m=>c(new Error(`the browser did not start: ${m.message}`))));try{return await Promise.race([d,(async()=>{let p;for(let b=Date.now()+2e4;p===void 0&&Date.now()<b&&!l;await ll(100))try{p=jN(PN(ra(i,"DevToolsActivePort"),"utf8"))}catch{}if(p===void 0)throw l?new tr(o):new Error("the browser did not open its DevTools port in 20 s");let c;for(let b=Date.now()+1e4;c===void 0;await ll(100))try{c=await(await fetch(`http://127.0.0.1:${p}/json/list`)).json()}catch(v){if(Date.now()>b||l)throw new Error(`the browser's DevTools did not answer: ${v instanceof Error?v.message:String(v)}`)}let m=c.find(b=>b.type==="page");if(!m)throw new Error("the browser opened no page");let f=await ON(m.webSocketDebuggerUrl);try{await f.send("Page.enable");let b=[];for(let v of n){await f.send("Emulation.setDeviceMetricsOverride",{width:v.width,height:v.height,deviceScaleFactor:v.scale,mobile:!1}),await f.send("Page.navigate",{url:`${CN(t).href}?${v.query}`});let R=!1;for(let K=Date.now()+a;!R&&Date.now()<K;)await ll(100),R=(await f.send("Runtime.evaluate",{expression:"document.readyState === 'complete' && document.body?.dataset.ready === '1'",returnByValue:!0})).result?.value===!0;if(!R)throw new Error(`the page did not finish drawing in ${Math.round(a/1e3)} s`);let A=await f.send("Runtime.evaluate",{expression:"JSON.stringify({ error: document.body.dataset.error, selected: document.body.dataset.selected, findings: document.body.dataset.findings })",returnByValue:!0}),{error:C,selected:N,findings:j}=JSON.parse(String(A.result.value)),U=v.height;if(v.full&&!C){let K=await f.send("Runtime.evaluate",{expression:"window.PALBASE_FULL()",awaitPromise:!0,returnByValue:!0}),L=Number(K.result?.value);Number.isFinite(L)&&L>U&&(U=Math.min(L,16e3),await f.send("Emulation.setDeviceMetricsOverride",{width:v.width,height:U,deviceScaleFactor:v.scale,mobile:!1}),await f.send("Runtime.evaluate",{expression:"new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => r(1))))",awaitPromise:!0}))}let G=v.measureOnly?void 0:await f.send("Page.captureScreenshot",{format:"png",captureBeyondViewport:!1});b.push({png:G?Buffer.from(String(G.data),"base64"):new Uint8Array,height:U,...C?{error:C}:{},...N?{selected:N}:{},...j?{findings:JSON.parse(j)}:{}})}return b}finally{f.close()}})()])}finally{r.kill();for(let p=0;p<20&&!l;p++)await ll(50);l||r.kill("SIGKILL");try{RN(i,{recursive:!0,force:!0,maxRetries:10,retryDelay:100})}catch{}}}async function ON(e){let t=new WebSocket(e);await new Promise((a,i)=>{t.addEventListener("open",()=>a(),{once:!0}),t.addEventListener("error",()=>i(new Error("the browser refused the DevTools connection")),{once:!0})});let n=0,s=new Map;return t.addEventListener("message",a=>{let i=JSON.parse(String(a.data));if(i.id===void 0)return;let r=s.get(i.id);s.delete(i.id),i.error?r?.reject(new Error(i.error.message)):r?.resolve(i.result??{})}),t.addEventListener("close",()=>{for(let a of s.values())a.reject(new Error("the browser closed the DevTools connection"));s.clear()}),{send(a,i={}){let r=++n;return new Promise((o,l)=>{s.set(r,{resolve:o,reject:l}),t.send(JSON.stringify({id:r,method:a,params:i}))})},close:()=>t.close()}}function fv(){return Promise.resolve('"use strict";(()=>{var Ue=o=>`pw-font-${o}`;function Se(o){return(typeof o=="string"?/^asset:([0-9a-f-]{36})$/.exec(o):null)?.[1]}async function dt(o){let t=new DataView(o.buffer,o.byteOffset,o.byteLength),n=-1;for(let b=o.length-22;b>=Math.max(0,o.length-22-65535);b--)if(t.getUint32(b,!0)===101010256){n=b;break}if(n<0)throw new Error("not a zip");let i=t.getUint16(n+10,!0),c=t.getUint32(n+16,!0),p=new Map,m=0;for(let b=0;b<i;b++){if(t.getUint32(c,!0)!==33639248)throw new Error("a broken zip");let y=t.getUint16(c+10,!0),w=t.getUint32(c+20,!0),v=t.getUint32(c+24,!0),x=t.getUint16(c+28,!0),_=t.getUint16(c+30,!0),O=t.getUint16(c+32,!0),L=t.getUint32(c+42,!0),R=new TextDecoder().decode(o.subarray(c+46,c+46+x));if(c+=46+x+_+O,R.endsWith("/"))continue;if(R.startsWith("/")||R.split("/").includes(".."))throw new Error("a path leaving the zip");if(m+=v,p.size>=200||m>20971520)throw new Error("a zip too large");let j=L+30+t.getUint16(L+26,!0)+t.getUint16(L+28,!0),N=o.subarray(j,j+w);if(y===0)p.set(R,N);else if(y===8)p.set(R,await Ut(N));else throw new Error("a zip entry compressed another way")}return p}async function Ut(o){let t=new Response(new Uint8Array(o)).body.pipeThrough(new DecompressionStream("deflate-raw"));return new Uint8Array(await new Response(t).arrayBuffer())}var Wt={html:"text/html",css:"text/css",js:"text/javascript",mjs:"text/javascript",json:"application/json",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",svg:"image/svg+xml",mp4:"video/mp4",webm:"video/webm",woff2:"font/woff2",woff:"font/woff",ttf:"font/ttf",otf:"font/otf"};function ct(o,t){let n=Wt[o.split(".").pop()?.toLowerCase()??""]??"application/octet-stream",i="";for(let c=0;c<t.length;c+=32768)i+=String.fromCharCode(...t.subarray(c,c+32768));return`data:${n};base64,${btoa(i)}`}var Kt="default-src \'none\'; img-src data:; media-src data:; font-src data:; style-src \'unsafe-inline\' data:; script-src \'unsafe-inline\' data:";function pt(o){let t=o.get("index.html");if(!t)return;let n=new TextDecoder().decode(t),i=w=>new TextDecoder().decode(o.get(w)),c=w=>{let v=w.replace(/^\\.\\//,"").split(/[?#]/)[0];return o.has(v)?v:void 0},p=w=>w.replace(/url\\(\\s*([\'"]?)([^\'")]+)\\1\\s*\\)/g,(v,x,_)=>{let O=c(_);return O?`url("${ct(O,o.get(O))}")`:v}),m=globalThis.DOMParser;if(!m)return;let b=new m().parseFromString(n,"text/html");for(let w of[...b.querySelectorAll(\'link[rel~="stylesheet"][href]\')]){let v=c(w.getAttribute("href")),x=b.createElement("style");x.textContent=v?p(i(v)):"",w.replaceWith(x)}for(let w of[...b.querySelectorAll("style")])w.textContent=p(w.textContent??"");for(let w of[...b.querySelectorAll("[src], [href], [poster]")])for(let v of["src","href","poster"]){let x=w.getAttribute(v);if(x===null)continue;let _=c(x);_?w.setAttribute(v,ct(_,o.get(_))):/^(https?:)?\\/\\//i.test(x)&&w.removeAttribute(v)}for(let w of[...b.querySelectorAll("[style]")])w.setAttribute("style",p(w.getAttribute("style")??""));let y=b.createElement("meta");return y.setAttribute("http-equiv","Content-Security-Policy"),y.setAttribute("content",Kt),b.head.prepend(y),`<!doctype html>${b.documentElement.outerHTML}`}var Gt={ios:44,android:44,web:24},ut=.12;function se(o){let t=/^rgba?\\(([\\d.]+),\\s*([\\d.]+),\\s*([\\d.]+)(?:,\\s*([\\d.]+))?\\)$/.exec(o.trim());return t?[Number(t[1]),Number(t[2]),Number(t[3]),t[4]===void 0?1:Number(t[4])]:void 0}var Me;function Xt(o){if(o.trim()==="")return;let t=se(o);return t||(Me??=document.body.appendChild(document.createElement("i")),Me.style.color="",Me.style.color=o.trim(),Me.style.color===""?void 0:se(getComputedStyle(Me).color))}var Ge=(o,t)=>{let n=o[3]+t[3]*(1-o[3]);if(n===0)return[0,0,0,0];let i=c=>(o[c]*o[3]+t[c]*t[3]*(1-o[3]))/n;return[i(0),i(1),i(2),n]};function ft([o,t,n]){let i=c=>{let p=c/255;return p<=.04045?p/12.92:((p+.055)/1.055)**2.4};return .2126*i(o)+.7152*i(t)+.0722*i(n)}function gt(o,t){let[n,i]=[ft(o),ft(t)].sort((c,p)=>p-c);return(n+.05)/(i+.05)}var ht=([o,t,n])=>`#${[o,t,n].map(i=>Math.round(i).toString(16).padStart(2,"0")).join("").toUpperCase()}`,We=o=>`${(Math.floor(o*10)/10).toFixed(1)}:1`,Z=o=>Math.round(o);function He(o){return o.parentElement??o.getRootNode().host??null}function yt(o){let t=[],n=1;for(let c=o;c;c=He(c)){let p=getComputedStyle(c);if(p.backgroundImage!=="none")return;let m=se(p.backgroundColor);if(m&&m[3]>0&&t.push(m),t.length===0&&(n*=Number(p.opacity)),m&&m[3]>=1)break}let i=[255,255,255,1];for(let c of t.reverse())i=Ge(c,i);return{color:i,opacity:n}}function Yt(o){for(let t=o;t;t=He(t)){let n=getComputedStyle(t);if(n.backgroundImage!=="none")return t;let i=se(n.backgroundColor);if(i&&i[3]>=1)return}}function mt(o){let t=yt(o),n=se(getComputedStyle(o).color);if(!t||!n)return;let i=n[3];for(let c=o;c;c=He(c)){let p=getComputedStyle(c);i*=Number(p.opacity);let m=se(p.backgroundColor);if(m&&m[3]>0)break}return{text:Ge([n[0],n[1],n[2],i],t.color),bg:t.color}}function le(o){let t=o.getBoundingClientRect();if(t.width<1||t.height<1)return!1;for(let n=o;n;n=He(n)){let i=getComputedStyle(n);if(i.visibility==="hidden"||i.display==="none"||Number(i.opacity)===0)return!1}return!0}var Ce=o=>o.closest("[data-pw-path]")?.dataset.pwPath??"the page";function wt(o){let t=(o.innerText??o.textContent??"").replace(/\\s+/g," ").trim();return t.length>40?`${t.slice(0,39)}\\u2026`:t}var ue=o=>{let t=wt(o),n=o.dataset?.pwType??o.getAttribute("role")??o.closest("[data-pw-path]")?.dataset.pwType??o.tagName.toLowerCase();return`${Ce(o)}${t?` "${t}"`:` (${n}${o.getAttribute("aria-label")?` "${o.getAttribute("aria-label")}"`:""})`}`},bt="button, [role=radio], [role=tab], [role=switch], a[href]";function Zt(o,t){for(let n=o.parentElement;n&&t.contains(n);n=n.parentElement){if(n.classList.contains("pw2-body")||n.classList.contains("pw2"))return;let i=getComputedStyle(n);if(i.overflowX!=="visible"||i.overflowY!=="visible")return n}}function Ke(o,t){for(let n=o.parentElement;n&&t.contains(n);n=n.parentElement){if(n.classList.contains("pw-track")||n.classList.contains("pw-carousel"))return!0;let i=getComputedStyle(n).overflowX;if((i==="auto"||i==="scroll")&&!n.classList.contains("pw2-body"))return!0}return!1}function kt(o,t){let n=[],i=(u,h,M)=>n.push({code:u,where:typeof h=="string"?h:ue(h),message:M}),c=o.querySelector(".pw2"),p=o.querySelector(".pw2-body"),m=o.querySelector(".pw2-foot"),b=c.getBoundingClientRect(),y=m&&le(m)?m.getBoundingClientRect():void 0,w=()=>{let u=p.getBoundingClientRect(),h=c.getBoundingClientRect(),M=m&&le(m)?m.getBoundingClientRect():void 0;return{top:Math.max(u.top,h.top),bottom:Math.min(u.bottom,h.bottom,M&&M.height>0?M.top:1/0)}},v=w(),x=[...o.querySelectorAll("[data-pw-path]")].filter(le),_=u=>u.dataset.pwType??"",O=u=>p.contains(u),L=(u,h)=>{let M=u.getBoundingClientRect(),E=Math.max(M.top,h.top),P=Math.min(M.bottom,h.bottom);for(let $=u.parentElement;$&&o.contains($)&&!$.classList.contains("pw2-body")&&!$.classList.contains("pw2");$=$.parentElement){let k=getComputedStyle($);if(k.overflowX==="visible"&&k.overflowY==="visible")continue;let D=$.getBoundingClientRect();Math.min(M.right,D.right)-Math.max(M.left,D.left)<=0&&(P=E),E=Math.max(E,D.top),P=Math.min(P,D.bottom)}return{top:E,bottom:P,r:M,area:h}},R=u=>L(u,O(u)?v:b),j=Math.max(c.scrollWidth-c.clientWidth,p.scrollWidth-p.clientWidth);j>1&&i("overflow_x","the page",`the paywall is ${Z(j)}px wider than the screen: it moves sideways`);let N=new Set;for(let u of x){if(Ke(u,o)||[...N].some(E=>E.contains(u)))continue;let h=u.getBoundingClientRect(),M=Math.max(b.left-h.left,h.right-b.right);M>1&&(N.add(u),i("overflow_x",u,`it reaches ${Z(M)}px past the screen\'s ${h.right>b.right?"right":"left"} edge`))}let Q=x.filter(u=>_(u)==="text");for(let u of Q){if(u.classList.contains("pw-clamp")&&u.scrollHeight>u.clientHeight+1){i("text_cut",u,"its text is cut off: it needs more lines than its max_lines gives at this size");continue}if(u.scrollWidth>u.clientWidth+1){i("text_cut",u,`a word is ${Z(u.scrollWidth-u.clientWidth)}px wider than its place and is cut`);continue}let h=Ke(u,o)?void 0:Zt(u,o);if(h){let P=u.getBoundingClientRect(),$=h.getBoundingClientRect(),k=Math.max($.top-P.top,P.bottom-$.bottom,$.left-P.left,P.right-$.right);if(k>1){i("text_cut",u,`${Z(k)}px of its text is hidden by ${Ce(h)}, which clips what overflows it`);continue}}let M=document.createTreeWalker(u,NodeFilter.SHOW_TEXT),E;for(let P=M.nextNode();P&&!E;P=M.nextNode())for(let $ of(P.textContent??"").matchAll(/\\S+/g)){let k=document.createRange();if(k.setStart(P,$.index),k.setEnd(P,$.index+$[0].length),new Set([...k.getClientRects()].filter(q=>q.width>0).map(q=>Math.round(q.top))).size>1){E=$[0];break}}E&&i("word_broken",u,`"${E}" is broken across lines: a word, a price above all, is drawn whole`)}let te=x.filter(u=>_(u)==="purchase_button"&&!o.querySelector(".pw-layer")?.contains(u));if(te.length===0)i("purchase_hidden","the paywall","nothing on it buys: it has no purchase button where it is drawn");else if(!te.some(u=>{let h=R(u);return h.r.top>=h.area.top-1&&h.r.bottom<=h.area.bottom+1})){let u=R(te[0]),h=u.r.top>=u.area.bottom?`${Z(u.r.top-u.area.bottom)}px below what shows`:`${Z(u.r.height-Math.max(0,u.bottom-u.top))}px of it hidden`;i("purchase_hidden",te[0],`the purchase button is not on the screen as the paywall opens (${h}): a customer scrolls to find it \\u2014 keep it in the fixed footer`)}if(y&&y.height>0){let u=[p,c].filter(M=>/^(auto|scroll)$/.test(getComputedStyle(M).overflowY)&&M.scrollHeight>M.clientHeight+1),h=u.map(M=>M.scrollTop);for(let M of u)M.scrollTop=M.scrollHeight;try{let M=w(),E=new Set;for(let P of x.filter($=>O($)&&$.matches(bt))){if(Ke(P,o)||[...E].some(k=>k.contains(P)))continue;let $=L(P,{top:-1/0,bottom:1/0});if($.bottom>$.top&&$.bottom>M.bottom+1){E.add(P);let k=Math.min($.bottom-M.bottom,$.bottom-$.top);i("covered_by_footer",P,`${Z(k)}px of its ${Z($.r.height)}px ${k>=$.bottom-$.top-1?"(all of it) ":""}stay under the fixed footer with the paywall scrolled to its end: nothing brings it into view \\u2014 end the body with room as tall as the footer (padding or a spacer)`)}}}finally{u.forEach((M,E)=>{M.scrollTop=h[E]})}}let ve=new Set(["stack","tabs","switch","carousel","countdown"]),he=[...o.querySelectorAll(".pw-switchrow, .pw-tablist, .pw-dots")].filter(le);he.push(...x.filter(u=>{let h=_(u);if(h==="spacer")return!1;if(!ve.has(h))return!0;let M=u.parentElement;if(M&&(M.classList.contains("pw2-head")||M.classList.contains("pw2-body")||M.classList.contains("pw2-foot")))return!1;let E=getComputedStyle(u),P=se(E.backgroundColor);return E.backgroundImage!=="none"||P!==void 0&&P[3]>0||u.style.getPropertyValue("--pw-bw")!==""}));let me=he.filter(u=>{let h=R(u);return h.bottom>h.top}),Ae=me.map(R).map(u=>[u.top,u.bottom]).sort((u,h)=>u[0]-h[0]),K={size:0,from:b.top,to:b.top},X=b.top;for(let[u,h]of Ae)u-X>K.size&&(K={size:u-X,from:X,to:u}),X=Math.max(X,h);if(b.bottom-X>K.size&&(K={size:b.bottom-X,from:X,to:b.bottom}),K.size>t.height*ut){let u=me.filter(E=>Math.abs(R(E).bottom-K.from)<1).pop(),h=me.find(E=>Math.abs(R(E).top-K.to)<1),M=u&&h?`between ${ue(u)} and ${ue(h)}`:u?`below ${ue(u)}`:h?`above ${ue(h)}`:"on the screen";i("large_gap",u?Ce(u):h?Ce(h):"the paywall",`a ${Z(K.size)}px empty band (${Math.round(K.size/t.height*100)}% of the screen) ${M}: no single empty space is over ${Math.round(ut*100)}%`)}let xe=new Set,be=document.createTreeWalker(c,NodeFilter.SHOW_TEXT);for(let u=be.nextNode();u;u=be.nextNode())(u.textContent??"").trim()!==""&&u.parentElement&&xe.add(u.parentElement);let ne=new Map;for(let u of xe){if(!le(u)||u.closest(".pw-grad")||u.closest("button:disabled, [aria-disabled=true]"))continue;let h=mt(u);if(!h){let D=Yt(u);D&&ne.set(D,[...ne.get(D)??[],wt(u)]);continue}let M=getComputedStyle(u),E=parseFloat(M.fontSize),P=E>=24||E>=18.66&&Number(M.fontWeight)>=700,$=P?3:4.5,k=gt(h.text,h.bg);k<$&&i("contrast",u,`its text is ${We(k)} against what is behind it (${ht(h.text)} on ${ht(h.bg)}): ${P?"large ":""}text needs ${We($)}`)}for(let[u,h]of ne){let M=h.slice(0,3).map(P=>`"${P}"`).join(", "),E=u.dataset?.pwPath!==void 0||u.closest("[data-pw-path]")?ue(u).replace(/ ".*"$/,""):"the page";n.push({code:"unmeasured_contrast",where:E,message:`not measured: ${h.length} text(s) over its picture or gradient \\u2014 ${M}${h.length>3?" \\u2026":""} \\u2014 whose colors the check does not read; look at them (purchases:paywalls:preview)`,note:!0})}let B=u=>{let h=getComputedStyle(u),M=se(h.backgroundColor);return h.backgroundImage!=="none"||M!==void 0&&M[3]>0||(u.style?.getPropertyValue("--pw-bw")??"")!==""||parseFloat(h.borderTopWidth)>0},ye=u=>{for(let h=u,M=0;h&&M<4;h=h.firstElementChild,M++)if(B(h))return h;return u},de=new Map;for(let u of[...o.querySelectorAll("[role=radio], [role=tab]")].filter(le)){let h=u.parentElement;de.set(h,[...de.get(h)??[],u])}for(let[,u]of de){let h=u.find(k=>k.getAttribute("aria-checked")==="true"||k.getAttribute("aria-selected")==="true");if(!h||u.length<2)continue;let M=k=>{let D=ye(k),q=yt(D),oe=getComputedStyle(D),U=Xt(oe.getPropertyValue("--pw-bc"))??se(oe.borderTopColor),pe=parseFloat(oe.getPropertyValue("--pw-bw"))||parseFloat(oe.borderTopWidth)||0,Le=[...k.querySelectorAll("*")].find(Ie=>[...Ie.childNodes].some(_e=>_e.nodeType===3&&(_e.textContent??"").trim()!==""));return{bg:q?.color,border:pe>0&&U&&q?Ge(U,q.color):q?.color,text:Le?mt(Le)?.text:void 0}},E=M(h),P=1/0,$;for(let k of u.filter(D=>D!==h)){let D=M(k),q=[[E.bg,D.bg],[E.border,D.border],[E.text,D.text]].filter(([U,pe])=>U&&pe);if(q.length===0)continue;let oe=Math.max(...q.map(([U,pe])=>gt(U,pe)));oe<P&&(P=oe,$=k)}if($&&P<3){let k=h.getAttribute("role")==="tab"?"tab":"package";i("selection_contrast",h,`the selected ${k} differs from ${ue($)} by ${We(P)} at most \\u2014 in its fill, its border and its text: what shows it is selected needs 3:1`)}}let Y=Gt[t.platform];for(let u of[...o.querySelectorAll(bt)].filter(le)){if(u.closest(".pw-text")||u.closest(".pw-dots")||u.getAttribute("role")==="switch"||u.disabled)continue;let h=u.getBoundingClientRect();(h.width<Y||h.height<Y)&&i("small_target",u,`it is ${Z(h.width)}\\xD7${Z(h.height)}: ${t.platform==="web"?"a pointer needs":"a finger needs"} ${Y}\\xD7${Y} \\u2014 give it padding or a height`)}for(let u of x.filter(h=>_(h)==="image"||_(h)==="video")){let h=u.querySelector("img, video");if(!h||(h instanceof HTMLImageElement?h.complete&&h.naturalWidth===0:h.readyState<2)){let E=t.nodeAt(u.dataset.pwPath??"")?.src;i("image_missing",u.dataset.pwPath??"an image",`the ${_(u)} did not load${typeof E=="string"?` (${E})`:""}: it is drawn as an empty frame`)}}for(let u of x.filter(h=>_(h)==="package")){let h=[...u.querySelectorAll("[data-pw-type=text]")].filter(le).map(E=>(E.textContent??"").replace(/\\s+/g," ").trim()).filter(E=>E!==""),M=(E,P)=>{let $=D=>` ${D.replace(/[^\\p{L}\\p{N}]+/gu," ").trim()} `,k=$(E);return k.trim().length>=3&&$(P).includes(k)};e:for(let E=0;E<h.length;E++)for(let P=0;P<h.length;P++)if(!(E===P||h[E].length>h[P].length)&&M(h[E],h[P])){i("repeated_text",u,`"${h[E]}" is said twice in one package: in "${h[E]}" and in "${h[P]}"`);break e}}return n}var ce=(o,t,n)=>`M${o-n} ${t}a${n} ${n} 0 1 0 ${2*n} 0a${n} ${n} 0 1 0 ${-2*n} 0`,Oe={ad_free:["M3 7h18v10H3z","M4 4l16 16"],bell:["M6 16v-5a6 6 0 0 1 12 0v5l2 2H4z","M10 21a2 2 0 0 0 4 0"],bolt:["M13 2L4 14h7l-1 8 9-12h-7z"],book:["M5 4h11a3 3 0 0 1 3 3v13H8a3 3 0 0 1-3-3z","M5 17a3 3 0 0 1 3-3h11"],chart:["M3 20h18","M6 20v-8","M11 20V5","M16 20v-6","M21 20V9"],chat:["M4 5h16v11H9l-5 4z"],check:["M5 12l5 5 9-10"],check_circle:[ce(12,12,9),"M8 12l3 3 5-6"],clock:[ce(12,12,9),"M12 7v5l3 2"],cloud:["M7 18a4 4 0 0 1-.5-7.97A6 6 0 0 1 18 9a4.5 4.5 0 0 1-.5 9z"],crown:["M3 8l4 4 5-7 5 7 4-4-2 11H5z"],download:["M12 4v11","M7 10l5 5 5-5","M4 20h16"],gift:["M3 9h18v4H3z","M5 13v8h14v-8","M12 9v12","M12 9C10 5 6 5 6 7.5S12 9 12 9zm0 0c2-4 6-4 6-1.5S12 9 12 9z"],globe:[ce(12,12,9),"M3 12h18","M12 3a14 14 0 0 1 0 18a14 14 0 0 1 0-18z"],heart:["M12 20s-7-4.5-9-9a4.5 4.5 0 0 1 9-3 4.5 4.5 0 0 1 9 3c-2 4.5-9 9-9 9z"],infinity:["M7 9a3 3 0 1 0 0 6c3 0 7-6 10-6a3 3 0 1 1 0 6c-3 0-7-6-10-6z"],lock_open:["M5 11h14v10H5z","M8 11V7a4 4 0 0 1 7.5-2"],music:["M9 18V5l11-2v13",ce(6,18,3),ce(17,16,3)],people:[ce(9,8,3.5),"M2 20a7 7 0 0 1 14 0","M16 4.5a3.5 3.5 0 0 1 0 7","M18 14a6 6 0 0 1 4 6"],person:[ce(12,8,4),"M4 21a8 8 0 0 1 16 0"],photo:["M3 5h18v14H3z",ce(8.5,9.5,1.5),"M3 17l5-5 4 4 3-3 6 6"],shield:["M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z"],sparkles:["M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8z","M19 15l.8 2.2L22 18l-2.2.8L19 21l-.8-2.2L16 18l2.2-.8z"],star:["M12 3l2.8 5.7 6.2.9-4.5 4.4 1 6.2L12 17.3l-5.5 2.9 1-6.2L3 9.6l6.2-.9z"],video:["M3 6h12v12H3z","M15 10l6-3v10l-6-3z"],arrow_right:["M4 12h15","M13 6l6 6-6 6"],calendar:["M4 6h16v15H4z","M4 10h16","M8 3v5","M16 3v5"],close:["M6 6l12 12","M18 6L6 18"],lock:["M5 11h14v10H5z","M8 11V7a4 4 0 0 1 8 0v4"],play:["M7 4l13 8-13 8z"],quote:["M5 17c3 0 4-2 4-5V7H4v5h3","M15 17c3 0 4-2 4-5V7h-5v5h3"],trophy:["M7 4h10v5a5 5 0 0 1-10 0z","M7 6H4v2a3 3 0 0 0 3 3","M17 6h3v2a3 3 0 0 1-3 3","M12 14v4","M8 21h8","M9 18h6v3H9z"]};var vt="http://www.w3.org/2000/svg";function ze(o,t,n){let i=o.createElementNS(vt,"svg");i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("width",String(n)),i.setAttribute("height",String(n)),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.setAttribute("aria-hidden","true"),i.setAttribute("focusable","false");for(let c of t){let p=o.createElementNS(vt,"path");p.setAttribute("d",c),i.append(p)}return i}var g=(o,t=!1)=>({kind:"value",value:"plain",def:o,required:t}),J=o=>({kind:"value",value:"color",def:o}),xt=o=>({kind:"value",value:"spacing",def:o}),Qt=o=>({kind:"value",value:"radius",def:o}),ge=(o=!1)=>({kind:"text",required:o}),Xe=(o,t=!1)=>({kind:"list",item:o,required:t}),Ee=(o,t=!1)=>({kind:"object",item:o,required:t}),St=(o=!1)=>({kind:"component",required:o}),Ye={kind:"components"},Mt={stack:{axis:g("vertical"),spacing:xt(0),align:g("center"),distribution:g("start"),scroll:g(!1),children:Ye},text:{text:ge(),spans:Xe("span"),font:g(),size:g(),weight:g(),line_height:g(),letter_spacing:g(),color:{kind:"value",value:"textColor",def:"text"},align:g("center"),max_lines:g(),uppercase:g(!1)},image:{src:g(void 0,!0),fit:g("fit"),aspect:g(),mask:Ee("mask"),overlay:{kind:"value",value:"textColor"},alt:ge(),decorative:g(!1)},icon:{name:g(void 0,!0),color:J("accent"),size:g(24)},video:{src:g(void 0,!0),poster:g(),autoplay:g(!0),loop:g(!0),mute:g(!0),controls:g(!1),fit:g("fill"),aspect:g(),alt:ge()},button:{action:Ee("action",!0),content:St(!0)},purchase_button:{content:St(!0),package:g()},package:{product:g(void 0,!0),plan:g(void 0,!0),selected:g(!1),offer:g(),children:Ye},tabs:{},switch:{},carousel:{pages:Ye,peek:g(0),spacing:g(8),loop:g(!1),auto_advance_ms:g(),indicator:Ee("indicator"),height:g("")},countdown:{},timeline:{items:Xe("timeline_item",!0),line_color:J("accent"),line_width:g(2),icon_color:J("on_accent"),color:J("text"),spacing:g(16)},features:{items:Xe("feature",!0),icon_color:J("accent"),color:J("text"),spacing:g(12)},spacer:{size:xt()},divider:{color:J("muted"),thickness:g(1)},custom_html:{src:g(void 0,!0),height:g("",!0)}},en={style:{padding:{kind:"edges"},margin:{kind:"edges"},width:g(""),height:g(""),max_width:g(),background:{kind:"fill"},border:Ee("border"),corners:{kind:"corners"},shadow:Ee("shadow"),opacity:g(1)},border:{width:g(),color:J("")},shadow:{color:J(""),radius:g(0),x:g(0),y:g(0)},linear:{type:g(""),angle:g(180),stops:g()},radial:{type:g(""),center_x:g(.5),center_y:g(.5),radius:g(.5),stops:g()},image_fill:{type:g(""),src:g(),fit:g("fill")},video_fill:{type:g(""),src:g(),poster:g(),loop:g(!0)},animation:{type:g(""),duration_ms:g(300),delay_ms:g(0),easing:g("ease_out")},action:{type:g(""),url:g(),sheet:g(),package:g()},mask:{shape:g(""),radius:Qt(0),depth:g(16)},span:{text:ge(!0),bold:g(!1),italic:g(!1),underline:g(!1),strikethrough:g(!1),color:J(""),link:g()},timeline_item:{icon:g(void 0,!0),title:ge(!0),text:ge(),color:J("")},feature:{icon:g(void 0,!0),text:ge(!0)},indicator:{style:g("dots"),color:J("muted"),active_color:J("accent"),size:g(8),spacing:g(6)},typography:{font:g("system"),size:g(),weight:g(400),line_height:g(),letter_spacing:g(0),text_style:g("body")}},Et=new Set(["package","purchase_button"]),tn={action:{type:g(""),url:g(),link:g(),sheet:g(),placement:g(),name:g(),value:g(),offer:g(),dismiss:g(!0)},presentation:{type:g(""),position:g("bottom"),auto_dismiss_seconds:g(),dismissible:g(!0),backdrop:J("#00000080")}},nn={modal:["type","dismissible","backdrop"],fullscreen:["type"],banner:["type","position","auto_dismiss_seconds","dismissible"],card:["type"]},on={linear:"linear",radial:"radial",image:"image_fill",video:"video_fill"},sn=["top","bottom","leading","trailing"],rn=["top_leading","top_trailing","bottom_leading","bottom_trailing"],an=Object.keys(Mt),zn=an.filter(o=>!Et.has(o)),Rt=/\\{\\{\\s*([^{}]*?)\\s*\\}\\}/g,we=(o,t)=>typeof o=="object"&&o!==null&&Object.hasOwn(o,t),T=o=>typeof o=="object"&&o!==null&&!Array.isArray(o)?o:{},ie=o=>Array.isArray(o)?o:[],fe=(o,t)=>o??t;function ln(o){let t="";for(let n of new TextEncoder().encode(o)){let i=String.fromCharCode(n);t+=/^[A-Za-z0-9._~-]$/.test(i)?i:`%${n.toString(16).toUpperCase().padStart(2,"0")}`}return t}function cn(o){let t=Math.floor(o/86400),n=Math.floor(o%86400/3600),i=Math.floor(o%3600/60),c=o%60,p=b=>String(b).padStart(2,"0");return{countdown:t>0?`${t}d ${p(n)}:${p(i)}:${p(c)}`:n>0?`${n}:${p(i)}:${p(c)}`:`${p(i)}:${p(c)}`,days:String(t),hours:p(n),minutes:p(i),seconds:p(c)}}function dn(o){let t=new Map,n=c=>{if(Array.isArray(c))return c.forEach(n);if(typeof c!="object"||c===null)return;let p=c;if(p.type==="package"&&typeof p.offer=="string"){let m=`${p.product}.${p.plan}`;t.has(m)||t.set(m,p.offer)}for(let m of Object.keys(p).sort())n(p[m])},i=o;for(let c of["header","root","footer","sheets"])n(i[c]);return t}function Fe(o,t){return new je("paywall",o,t).resolve()}function At(o,t){let{variables:n,...i}=t;return new je("message",o,{...i,packages:{"":{...n}}}).resolve()}var je=class{kind;d;opts;lang;texts={};palette;typography={};radii;spacing;packages;offers;selected="";tab="";paths=new WeakMap;tabsShown={};switchesOn={};countdowns={};constructor(t,n,i){this.kind=t,this.d=n,this.opts=i,this.offers=dn(n);let c={};for(let[w,v]of Object.entries(i.packages??{})){let x={...v};this.open(w)||(v.price!==void 0?x.offer_price=v.price:delete x.offer_price),c[w]=x}this.packages=c;let p=T(this.d.locales),m=String(this.d.default_locale??""),b=i.locale;we(p,b)||(b=b.split("-")[0]??"",we(p,b)||(b=m)),this.lang=b;for(let w of[m,b])for(let[v,x]of Object.entries(T(p[w])))typeof x=="string"&&(this.texts[v]=x);let y=T(this.d.theme);this.palette=T(T(y.colors)[i.appearance]);for(let[w,v]of Object.entries(T(y.typography))){let x={};for(let[_,O]of Object.entries(this.objectFields("typography"))){let L=fe(T(v)[_],O.def);L!=null&&(x[_]=L)}this.typography[w]=x}this.radii=T(y.radii),this.spacing=T(y.spacing)}open(t){let n=this.offers.get(t);return n!==void 0&&(this.opts.offers??[]).includes(n)}fields(t){if(!(this.kind==="message"&&Et.has(t)))return Mt[t]}objectFields(t){return(this.kind==="message"?tn[t]:void 0)??en[t]??{}}resolve(){let[t,n]=this.initialState();this.tab=t,this.selected=this.kind==="paywall"?n:"";let i={theme:{colors:this.palette,typography:this.typography,radii:this.radii,spacing:this.spacing}};this.kind==="paywall"&&(i.selected=n);let c=this.d.presentation;if(typeof c=="object"&&c!==null){let m=this.item("presentation",T(c),void 0)??{},b=nn[String(T(c).type)]??[];for(let y of Object.keys(m))b.includes(y)||delete m[y];i.presentation=m}for(let m of["header","root","footer"]){let b=this.d[m];if(typeof b=="object"&&b!==null){let y=this.component(T(b),m,"",!1);y&&(i[m]=y)}}let p={};if(typeof this.d.sheets=="object"&&this.d.sheets!==null){let m={};for(let[b,y]of Object.entries(T(this.d.sheets))){let w=this.component(T(T(y).root),`sheets.${b}.root`,"",!1);w&&(m[b]=w);let v=this.text(T(y).title,this.packages[this.selected]);v!==null&&(p[b]=v)}i.sheets=m}return{tree:i,pathOf:m=>this.paths.get(m),tabs:this.tabsShown,switches:this.switchesOn,sheetTitles:p,countdowns:this.countdowns,language:this.lang}}switchOn(t,n){return this.opts.switches&&Object.hasOwn(this.opts.switches,n)?this.opts.switches[n]:this.opts.switch?this.opts.switch==="on":t.default===!0}tabShown(t,n){let c=ie(t.tabs).map(T).map(m=>String(m.id)),p=this.opts.tabs?.[n];return p!==void 0&&c.includes(p)?p:this.opts.tab?this.opts.tab:typeof t.default=="string"&&t.default!==""?t.default:c[0]??""}initialState(){let t="",n="",i="",c="",p=(b,y)=>{if(Array.isArray(b)){b.forEach((v,x)=>p(v,`${y}[${x}]`));return}if(typeof b!="object"||b===null)return;let w=b;switch(w.type){case"package":{let v=`${w.product}.${w.plan}`;i===""&&(i=v),w.selected===!0&&n===""&&(n=v);break}case"switch":{let v=this.switchOn(w,y),x=v?w.on_package:w.off_package;typeof x=="string"&&c===""&&(c=x),p(v?w.on:w.off,`${y}.${v?"on":"off"}`);return}case"tabs":{let v=this.tabShown(w,y);t===""&&(t=v),ie(w.tabs).forEach((x,_)=>{let O=T(x);O.id===v&&(typeof O.package=="string"&&c===""&&(c=O.package),p(O.content,`${y}.tabs[${_}].content`))});return}}for(let v of Object.keys(w).sort())v!=="sheets"&&p(w[v],y===""?v:`${y}.${v}`)};for(let b of["header","root","footer"])p(this.d[b],b);let m=this.opts.selected||c||n||i;return[t,m]}holds(t,n){let i=n||this.selected;for(let[c,p]of Object.entries(t))switch(c){case"selected_package":if(!ie(p).includes(this.selected))return!1;break;case"intro_eligible":if((this.opts.eligible??[]).includes(i)!==p)return!1;break;case"offer_open":if(this.open(i)!==p)return!1;break;case"platform":if(!ie(p).includes(this.opts.platform))return!1;break;case"locale":if(!ie(p).includes(this.opts.locale)&&!ie(p).includes(this.lang))return!1;break;case"appearance":if(p!==this.opts.appearance)return!1;break;case"tab":if(p!==this.tab)return!1;break}return!0}component(t,n,i,c){if(typeof t.visible=="object"&&t.visible!==null&&!this.holds(T(t.visible),i))return null;let p=String(t.type),m=i,b=c;p==="package"&&(m=`${t.product}.${t.plan}`,b=m===this.selected);let y={type:p};this.paths.set(y,n),we(t,"id")&&(y.id=t.id);let w={...T(t.style)};b&&Object.assign(w,T(T(t.states).selected)),Object.keys(w).length>0&&(y.style=this.style(w)),typeof t.animation=="object"&&t.animation!==null&&(y.animation=this.defaults(T(t.animation),this.objectFields("animation")));let v=this.packages[m||this.selected];switch(p){case"tabs":return this.tabs(t,y,n,m);case"switch":return this.switchOf(t,y,n,m,b);case"countdown":return this.countdown(t,y,n,m,b);case"purchase_button":{let x=typeof t.package=="string"?t.package:this.selected;y.package=x,this.open(x)&&(y.offer=this.offers.get(x));let _=this.component(T(t.content),`${n}.content`,x,b);return _?(y.content=_,y):null}case"package":y.product=t.product,y.plan=t.plan,y.selected=b,typeof t.offer=="string"&&(this.opts.offers??[]).includes(t.offer)&&(y.offer=t.offer)}for(let[x,_]of Object.entries(this.fields(p)??{})){if(p==="package"&&(x==="product"||x==="plan"||x==="selected"||x==="offer"))continue;let O=t[x],L=we(t,x);switch(_.kind){case"component":{if(!L)continue;let R=this.component(T(O),`${n}.${x}`,m,b);if(!R&&_.required)return null;R&&(y[x]=R);break}case"components":{let R=[];ie(O).forEach((j,N)=>{let Q=this.component(T(j),`${n}.${x}[${N}]`,m,b);Q&&R.push(Q)}),y[x]=R;break}case"text":{let R=this.text(O,v);if(R!==null)y[x]=R;else if(_.required||p==="text"&&x==="text"&&L)return null;break}case"list":{let R=[];for(let j of ie(O)){let N=this.item(_.item,T(j),v);N&&R.push(N)}if(p==="text"&&R.length===0&&L)return null;L&&(y[x]=R);break}case"object":{if(L){let R=this.object(T(O),_.item,v);if(R===null&&_.required)return null;y[x]=R}else x==="indicator"&&(y[x]=this.object({},_.item,v));break}case"value":{let R=this.value(fe(O,_.def),_);R!=null&&R!==""&&(y[x]=R);break}}}return p==="text"&&this.typeStyle(y),y}typeStyle(t){if(typeof t.size!="string"){t.size!==void 0&&t.size!==null&&(t.text_style="body");return}let n=this.typography[t.size];for(let i of["font","weight","line_height","letter_spacing","text_style"])!we(t,i)&&n?.[i]!==void 0&&n?.[i]!==null&&(t[i]=n[i]);t.size=n?.size??null}tabs(t,n,i,c){let p=this.tabShown(t,i);this.tabsShown[i]=p;let m=[];return ie(t.tabs).forEach((b,y)=>{let w=T(b),v=w.id===p,x=this.component(T(w.label),`${i}.tabs[${y}].label`,c,v);if(m.push({id:w.id,selected:v,label:x}),v){let _=this.component(T(w.content),`${i}.tabs[${y}].content`,c,!1);_&&(n.content=_)}}),n.tabs=m,typeof t.bar=="object"&&t.bar!==null&&(n.bar=this.style(T(t.bar))),n}switchOf(t,n,i,c,p){let m=this.switchOn(t,i);this.switchesOn[i]=m,n.on=m;let b=this.text(t.label,this.packages[c||this.selected]);b!==null&&(n.label=b),n.tint=this.color(String(fe(t.tint,"accent")));let y=m?"on":"off",w=this.component(T(t[y]),`${i}.${y}`,c,p);return w&&(n.content=w),n}countdown(t,n,i,c,p){let m=T(t.target),b=this.opts.now??Date.now(),y;if(typeof m.after_open_seconds=="number"?y=Math.trunc(m.after_open_seconds)-(this.opts.openedSecondsAgo??0):y=Math.trunc((Date.parse(String(m.at))-b)/1e3),y>0){n.state="counting",n.remaining_seconds=y,this.countdowns[i]=y;let w=this.packages,v={};for(let[_,O]of Object.entries(w))v[_]={...O,...cn(y)};this.packages=v;let x=this.component(T(t.counting),`${i}.counting`,c,p);return x&&(n.content=x),this.packages=w,n}if(n.state="ended",n.remaining_seconds=0,typeof t.ended=="object"&&t.ended!==null){let w=this.component(T(t.ended),`${i}.ended`,c,p);w&&(n.content=w)}return n}item(t,n,i){let c={};for(let[p,m]of Object.entries(this.objectFields(t))){let b=n[p];if(m.kind==="text"){let y=this.text(b,i);if(y!==null)c[p]=y;else if(m.required)return null}else{let y=m.def,w=this.value(fe(b,y),m);w!=null&&(we(n,p)||y!=null&&y!=="")&&(c[p]=w)}}return c}object(t,n,i){if(n==="style")return this.style(t);let c=this.item(n,t,i)??{};if(n==="action")for(let p of["url","link"]){if(typeof c[p]!="string")continue;let m=pn(c[p],i);if(m===null)return null;c[p]=m}return c}defaults(t,n){let i={};for(let[c,p]of Object.entries(n)){let m=fe(t[c],p.def);m!=null&&m!==""&&(i[c]=m)}return i}style(t){let n={};for(let[i,c]of Object.entries(t)){let p=this.objectFields("style")[i];if(!p){n[i]=c;continue}switch(p.kind){case"edges":n[i]=this.sides(c,sn,this.spacing);break;case"corners":n[i]=this.sides(c,rn,this.radii);break;case"fill":n[i]=this.fill(c);break;case"object":{let m=T(c),b={};for(let[y,w]of Object.entries(this.objectFields(p.item))){let v=fe(m[y],w.def);v!=null&&v!==""&&(b[y]=this.value(v,w))}n[i]=b;break}default:n[i]=c}}return n}sides(t,n,i){let c={};for(let p of n){let m=typeof t=="object"&&t!==null?fe(T(t)[p],0):t;c[p]=Ze(m,i)}return c}fill(t){if(typeof t=="string")return{type:"color",color:this.color(t)};let n=T(t),i=this.defaults(n,this.objectFields(on[String(n.type)]??""));return Array.isArray(n.stops)&&(i.stops=n.stops.map(c=>({color:this.color(String(T(c).color)),at:T(c).at}))),i}value(t,n){if(n.kind!=="value")return t;switch(n.value){case"color":return typeof t=="string"&&t!==""?this.color(t):t;case"textColor":return typeof t=="string"?this.color(t):t==null?t:this.fill(t);case"spacing":return Ze(t,this.spacing);case"radius":return Ze(t,this.radii);default:return t}}color(t){let n=Object.hasOwn(this.palette,t)?this.palette[t]:void 0;return typeof n=="string"?n:t}text(t,n){let i;if(typeof t=="string")i=t;else if(typeof t=="object"&&t!==null&&!Array.isArray(t)){let p=t.t;i=typeof p=="string"&&Object.hasOwn(this.texts,p)?this.texts[p]:""}else return null;let c=!1;return i=i.replace(Rt,(p,m)=>{let b=n&&Object.hasOwn(n,m)?n[m]:void 0;return typeof b!="string"||b===""?(c=!0,""):b}),c||i.trim()===""?null:i}};function pn(o,t){let n=!1,i=o.replace(Rt,(c,p)=>{let m=t&&Object.hasOwn(t,p)?t[p]:void 0;return typeof m!="string"||m===""?(n=!0,""):ln(m)});return n?null:i}function Ze(o,t){return typeof o=="string"?Object.hasOwn(t,o)?t[o]:null:o}var un={packages:"Choose a plan",close:"Close",restore:"Restore purchases",page:(o,t)=>`${o} of ${t}`},ke={system:\'-apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif\',rounded:\'ui-rounded, "SF Pro Rounded", Nunito, "Varela Round", system-ui, -apple-system, sans-serif\',serif:\'ui-serif, "New York", "Iowan Old Style", Georgia, "Times New Roman", serif\',mono:\'ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace\'},fn=1.35,Lt=20,gn=new Set(["button","purchase_button","package","text"]),hn=new Set(["ar","he","fa","ur","ps","yi","dv","ug","ku","sd"]),_t={ease_out:"cubic-bezier(0.16, 1, 0.3, 1)",ease_in_out:"cubic-bezier(0.65, 0, 0.35, 1)",spring:"cubic-bezier(0.34, 1.56, 0.64, 1)"},mn={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},bn={start:"flex-start",center:"center",end:"flex-end",space_between:"space-between",space_around:"space-around",space_evenly:"space-evenly"},yn={stack:["children"],package:["children"],button:["content"],purchase_button:["content"],tabs:["tabs","content"],switch:["content"],carousel:["pages"],countdown:["content"]},wn={package:["selected"],purchase_button:["package"],switch:["on"],countdown:["state","remaining_seconds"]},kn=`\n:host{display:block;height:100%}\n.pw2{position:relative;box-sizing:border-box;display:flex;flex-direction:column;height:100%;overflow:hidden;font-family:${ke.system};font-size:1rem;line-height:1.3;-webkit-font-smoothing:antialiased;-webkit-text-size-adjust:100%;text-rendering:optimizeLegibility}\n.pw2 *,.pw2 *::before,.pw2 *::after{box-sizing:border-box}\n.pw2-head,.pw2-foot{flex:none;display:flex;flex-direction:column;position:relative;z-index:1}\n.pw2-head[hidden],.pw2-foot[hidden]{display:none}\n.pw2-foot{max-height:30%;overflow-y:auto;scrollbar-width:none}\n.pw2-foot .pw-text{font-size:min(var(--pw-fs,1rem),var(--pw-fs-max,21.6px))}\n.pw2.pw2-large{overflow-y:auto;overscroll-behavior:contain;scrollbar-width:none}\n.pw2.pw2-large>.pw2-body{flex:1 0 auto;overflow:visible;min-height:auto}\n.pw2.pw2-large>.pw2-foot{position:sticky;bottom:0}\n.pw2:not(.pw2-fit){padding-left:env(safe-area-inset-left,0px);padding-right:env(safe-area-inset-right,0px)}\n.pw2:not(.pw2-fit)>.pw2-head,.pw2:not(.pw2-fit)>.pw2-body.pw2-top{padding-top:env(safe-area-inset-top,0px)}\n.pw2:not(.pw2-fit)>.pw2-foot,.pw2:not(.pw2-fit)>.pw2-body.pw2-bottom{padding-bottom:env(safe-area-inset-bottom,0px)}\n.pw2.pw2-fit{height:auto;flex:0 1 auto;min-height:0}\n.pw2-body{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;display:flex;flex-direction:column;overscroll-behavior:contain;scrollbar-width:none}\n.pw2-body::-webkit-scrollbar{display:none}\n.pw2-body>.pw-c{flex:1 0 auto}\n/* A part as wide as its place \\u2014 narrower when it says how wide it is at most, then in the middle, as SwiftUI\'s stacks place it. */\n.pw2-head>.pw-c,.pw2-body>.pw-c,.pw2-foot>.pw-c{align-self:center;width:100%}\n.pw-c{position:relative;min-width:0}\n.pw-c[style*="--pw-bw"]{isolation:isolate}\n.pw-c[style*="--pw-bw"]::after{content:"";position:absolute;inset:0;border:var(--pw-bw) solid var(--pw-bc);border-radius:inherit;pointer-events:none;z-index:2}\n.pw-stack{display:flex;flex-direction:column}\n.pw-stack.h{flex-direction:row}\n.pw-stack.z{display:grid}\n.pw-stack.z>.pw-c{grid-area:1/1}\n.pw-stack.scroll{overflow-y:auto;scrollbar-width:none}\n.pw-stack.h.scroll{overflow-x:auto;overflow-y:hidden}\n.pw-stack.scroll>.pw-c{flex-shrink:0}\n.pw-text{margin:0;overflow-wrap:break-word;white-space:pre-line}\n/* A text beside others wraps between its words, never inside one: a price stays whole, what is beside it wraps. */\n.pw-stack.h>.pw-text{min-width:min-content}\n.pw-text a{color:inherit}\n.pw-clamp{display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden}\n.pw-grad{-webkit-background-clip:text;background-clip:text;color:transparent!important;-webkit-text-fill-color:transparent}\n.pw-icon{display:inline-flex;flex:none}\n.pw-icon svg{display:block}\n.pw-img{overflow:hidden;flex:none}\n.pw-img img,.pw-img video{display:block;width:100%;height:100%}\n.pw-img.natural img{height:auto}\n.pw-overlay{position:absolute;inset:0;pointer-events:none}\n.pw-bgvideo{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;z-index:-1;pointer-events:none}\nbutton.pw-c{font:inherit;color:inherit;background:none;border:0;margin:0;padding:0;cursor:pointer;text-align:inherit;display:flex;flex-direction:column;align-items:stretch;justify-content:center;-webkit-tap-highlight-color:transparent;transition:opacity .15s ease,transform .15s ease}\nbutton.pw-c:active{transform:scale(.98)}\nbutton.pw-c:disabled{cursor:default;opacity:.5}\n.pw-pkg{cursor:pointer;display:flex;flex-direction:column;transition:background-color .2s ease,border-color .2s ease,box-shadow .2s ease}\n.pw-pkg[aria-disabled=true]{cursor:default;opacity:.55}\n:focus-visible{outline:2px solid currentColor;outline-offset:2px}\n.pw-features{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}\n.pw-feature{display:flex;align-items:center;gap:12px;text-align:start}\n.pw-timeline{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}\n.pw-step{display:grid;grid-template-columns:auto 1fr;column-gap:14px;position:relative;text-align:start}\n.pw-dot{width:32px;height:32px;border-radius:50%;display:grid;place-items:center;position:relative;z-index:1}\n.pw-line{position:absolute;left:calc(16px - var(--pw-line-w)/2);top:32px;width:var(--pw-line-w);bottom:calc(-1 * var(--pw-gap))}\n.pw-step:last-child .pw-line{display:none}\n.pw-step-title{font-weight:600}\n.pw-step-text{opacity:.72;font-size:.9375rem;margin-top:2px}\n.pw-tabs{display:flex;flex-direction:column;gap:12px}\n.pw-tablist{display:flex}\n.pw-tab{flex:1 1 0;min-width:0;font:inherit;color:inherit;background:none;border:0;margin:0;padding:0;cursor:pointer;display:flex}\n.pw-tab>.pw-c{flex:1 1 auto}\n.pw-switch{display:flex;flex-direction:column;gap:12px}\n.pw-switchcontent{display:flex;flex-direction:column}\n.pw-switchrow{display:flex;align-items:center;justify-content:space-between;gap:12px;text-align:start}\n.pw-toggle{flex:none;width:51px;height:31px;border-radius:999px;border:0;padding:2px;cursor:pointer;background:var(--pw-off);transition:background-color .2s ease}\n.pw-toggle[aria-checked=true]{background:var(--pw-tint)}\n.pw-toggle i{display:block;width:27px;height:27px;border-radius:50%;background:#fff;box-shadow:0 2px 4px #0003;transition:transform .2s ease}\n.pw-toggle[aria-checked=true] i{transform:translateX(20px)}\n.pw-carousel{display:flex;flex-direction:column;gap:12px;min-width:0}\n.pw-track{display:flex;overflow-x:auto;scroll-snap-type:x mandatory;scrollbar-width:none;scroll-behavior:smooth;padding-inline:var(--pw-peek);scroll-padding-inline:var(--pw-peek);gap:var(--pw-gap)}\n.pw-track::-webkit-scrollbar{display:none}\n.pw-track>.pw-c{flex:none;width:100%;scroll-snap-align:center}\n.pw-dots{display:flex;justify-content:center;gap:var(--pw-dot-gap)}\n.pw-dots button{border:0;padding:0;cursor:pointer;width:var(--pw-dot);height:var(--pw-dot);border-radius:999px;background:var(--pw-dot-c);transition:width .25s ease,background-color .25s ease}\n.pw-dots.bars button{width:calc(var(--pw-dot) * 3)}\n.pw-dots button[aria-current=true]{background:var(--pw-dot-on)}\n.pw-dots.dots button[aria-current=true]{width:calc(var(--pw-dot) * 2.5)}\n.pw-html{display:block;width:100%;border:0;pointer-events:none;background:transparent}\n.pw-spacer{flex:1 1 0}\n.pw-stack:not(.h):not(.z)>.greedy-h,.pw-pkg>.greedy-h,button.pw-c>.greedy-h{align-self:stretch}\n.pw-stack.h>.greedy-h{flex:1 1 0}\n.pw-stack.z>.greedy-h{justify-self:stretch}\n.pw-stack:not(.h):not(.z)>.greedy-v,.pw-pkg>.greedy-v{flex:1 1 auto}\n.pw-stack.h>.greedy-v,.pw-stack.z>.greedy-v{align-self:stretch}\n.pw-layer{position:absolute;inset:0;z-index:5;display:flex;flex-direction:column;justify-content:flex-end;background:#0007}\n.pw-sheet{max-height:92%;overflow-y:auto;border-radius:16px 16px 0 0;display:flex;flex-direction:column;outline:none;padding-bottom:env(safe-area-inset-bottom,0px)}\n.pw-sheet>.pw-c{flex:1 0 auto}\n.pw-grab{width:36px;height:5px;border-radius:3px;background:currentColor;opacity:.25;margin:8px auto 0;flex:none}\n[data-pw-highlight]{outline:2px solid #2E7CF6!important;outline-offset:-1px}\n[data-pw-hover]:not([data-pw-highlight]){outline:1px dashed #2E7CF6aa!important;outline-offset:-1px}\n.pw-editing button,.pw-editing .pw-pkg,.pw-editing a{cursor:default}\n@media (prefers-reduced-motion:reduce){.pw2 *{transition:none!important;scroll-behavior:auto!important}}\n`,Re=o=>{if(typeof o!="string"||o.length>2048)return!1;try{let t=new URL(o);return t.protocol==="https:"&&t.hostname!==""&&t.username===""&&t.password===""}catch{return!1}},vn=o=>{if(typeof o!="string"||o.length>2048||/[\\s\\u0000-\\u001f\\u007f]/.test(o))return!1;if(Re(o))return!0;let t=/^([a-z][a-z0-9+.-]{1,31}):(.+)$/.exec(o)?.[1];if(!t||xn.has(t))return!1;try{let n=new URL(o);return n.username===""&&n.password===""}catch{return!1}},xn=new Set(["https","http","javascript","data","file","vbscript","about","blob","content","intent"]),Sn=o=>`${String(o.product)}.${String(o.plan)}`,Ne=o=>{let[t,n]=o.split(".");return{product:t??"",plan:n??""}},C=o=>`${Number(o)||0}px`,Pt=o=>`${o/16}rem`,Mn=0;function $t(o,t,n){return En("paywall",o,t,n)}function En(o,t,n,i){let c=t.ownerDocument,p=c.defaultView,m=`pw${++Mn}`,b=c.createElement("div");b.setAttribute(o==="paywall"?"data-palbase-paywall":"data-palbase-message",""),b.style.display="block",b.style.height="100%";let y=b.attachShadow({mode:"open"});Rn(c,y,kn);let w=c.createElement("div");w.className="pw2";let v=c.createElement("div");v.className="pw2-head";let x=c.createElement("div");x.className="pw2-body";let _=c.createElement("div");_.className="pw2-foot";let O=c.createElement("div");w.append(v,x,_),y.append(w),t.replaceChildren(b);let L={...n},R={openedAt:Date.now(),...n.state},j,N=new Map,Q=new Map,te=!1,ve=null,he,me=!1,Ae=c.defaultView?.ResizeObserver,K=typeof Ae=="function"?new Ae(()=>{w.classList.toggle("pw2-large",u()>=Lt),h()}):null;K?.observe(w);let X=()=>h();c.fonts?.addEventListener?.("loadingdone",X);let xe=null,be=p?.matchMedia?.("(prefers-reduced-motion: reduce)"),ne=()=>L.reduceMotion??be?.matches??!1,B=()=>!!i.editor,ye={...un,...i.labels},de=()=>j.tree.selected??"";function Y(){let e=R.now??Date.now(),l={locale:L.locale,appearance:L.appearance,platform:L.platform??"web",tabs:R.tabs??{},switches:R.switches??{},openedSecondsAgo:Math.max(0,Math.floor((e-(R.openedAt??e))/1e3)),now:e};j=o==="paywall"?Fe(L.definition,{...l,packages:L.packages??{},eligible:L.eligible??[],offers:L.offers??[],...R.selected?{selected:R.selected}:{}}):At(L.definition,{...l,variables:L.variables??{}});let a=j.tree.theme.colors,s=j.tree.presentation?.type,r=o==="message"&&s!==void 0&&s!=="fullscreen";w.classList.toggle("pw2-fit",r),b.style.display=r?"flex":"block",b.style.flexDirection=r?"column":"",b.style.minHeight=r?"0":"",b.style.flex=r?"0 1 auto":"",b.style.height=r?"auto":"100%",w.style.background=r?"":a.background??"",w.style.color=a.text??"",w.classList.toggle("pw-editing",B()),w.classList.toggle("pw2-large",u()>=Lt),w.lang=j.language,w.dir=hn.has(j.language.split("-")[0]??"")?"rtl":"ltr",Q=new Map,M(v,j.tree.header,"vertical"),M(x,j.tree.root,"vertical"),M(_,j.tree.footer,"vertical"),v.hidden=!j.tree.header,_.hidden=!j.tree.footer,x.classList.toggle("pw2-top",!j.tree.header),x.classList.toggle("pw2-bottom",!j.tree.footer),Vt();for(let[d,f]of N)Q.has(d)||f.cleanup.forEach(S=>S());N=Q,ve&&rt(ve);for(let d of N.values())d.type==="custom_html"&&it(d.el);h(),clearTimeout(he),me||=b.isConnected,R.now===void 0&&Object.keys(j.countdowns).length>0&&(he=setTimeout(()=>{me&&!b.isConnected||Y()},1e3-Date.now()%1e3+5))}function u(){let e=c.documentElement,l=e&&p?parseFloat(p.getComputedStyle(e).fontSize):NaN;return Number.isFinite(l)?l:16}function h(){let e=[];for(let a of N.values()){if(a.type!=="text")continue;let s=a.el,r=s.dataset.pwFit??s.style.fontSize;if(!r||(s.style.fontSize=r,delete s.dataset.pwFit,!/^\\S+$/.test(s.textContent??"")))continue;let d=s.parentElement,f=d&&p?p.getComputedStyle(d):null,S=d&&f?d.clientWidth-parseFloat(f.paddingLeft||"0")-parseFloat(f.paddingRight||"0"):1/0,A=Math.min(s.clientWidth,S);e.push({e:s,base:r,k:A<=0||s.scrollWidth<=A+.5?1:Math.max(.6,A/s.scrollWidth)})}let l=a=>a.closest(".pw-stack.h");for(let a of e){let s=Math.min(a.k,...e.filter(r=>r!==a&&r.base===a.base&&l(r.e)&&l(r.e)===l(a.e)).map(r=>r.k));s>=1||(a.e.dataset.pwFit=a.base,a.e.style.fontSize=`calc(${a.base} * ${s.toFixed(3)})`)}}function M(e,l,a){let s=l?E(l,a,{inControl:!1,inSheet:!1,inFooter:e===_}):null;re(e,s?[s]:[])}function E(e,l,a){let s=j.pathOf(e)??"",r=P(e),d=N.get(s),f;if(d&&d.type===e.type&&d.key===r&&d.axis===l&&!Q.has(s))f=d;else{let A=D(e,s,l,a);if(!A)return null;f={el:A.el,type:e.type,key:r,styleKey:"",axis:l,slots:A.slots,cleanup:A.cleanup??[]},f.el.classList.add("pw-c"),f.el.dataset.pwPath=s,f.el.dataset.pwType=e.type,e.id&&(f.el.dataset.pwId=e.id),d&&d.cleanup.forEach(z=>z()),Ft(f.el,e)}let S=`${JSON.stringify(e.style??null)}|${l}`;return f.styleKey!==S&&(Qe(f.el,e,l),f.styleKey=S),Q.set(s,f),Ot(f,e),zt(f,e,a),f.el}function P(e){let l=new Set(["style",...yn[e.type]??[],...wn[e.type]??[]]),a={};for(let[s,r]of Object.entries(e))l.has(s)||(a[s]=r);return e.type==="tabs"&&(a.tabs=e.tabs.map(s=>s.id)),e.type==="carousel"&&(a.pages=e.pages.length),e.type==="stack"&&(a.greedy=e.children.some(s=>s.type==="spacer"&&typeof s.size!="number")),(e.type==="image"||e.type==="video"||e.type==="custom_html")&&(a.asset=$(e)),JSON.stringify(a)}function $(e){let l=Se(e.src);return l?(L.assets?.[l]?.url??L.assets?.[l]?.html?.length??"none").toString():""}function k(e,l){let a=c.createElement(e);return l&&(a.className=l),a}function D(e,l,a,s){let r=e;switch(e.type){case"stack":{let d=k("div",`pw-stack${r.axis==="horizontal"?" h":r.axis==="z"?" z":""}${r.scroll?" scroll":""}`);return r.axis!=="z"&&r.children.some(f=>f.type==="spacer"&&typeof f.size!="number")&&d.classList.add(r.axis==="horizontal"?"greedy-h":"greedy-v"),d.style.gap=C(r.spacing),r.axis==="z"?d.style.placeItems=r.align==="stretch"?"stretch":String(r.align??"center"):(d.style.alignItems=mn[String(r.align)]??"center",d.style.justifyContent=bn[String(r.distribution)]??"flex-start"),{el:d,slots:{children:d}}}case"text":return{el:q(r,s),slots:{}};case"icon":{let d=Oe[String(r.name)];if(!d)return null;let f=k("span","pw-icon");return f.style.color=String(r.color??""),f.append(ze(c,d,Number(r.size)||24)),f.setAttribute("aria-hidden","true"),{el:f,slots:{}}}case"image":return pe(r);case"video":return Le(r);case"features":{let d=k("ul","pw-features");d.style.gap=C(r.spacing);for(let f of r.items??[]){let S=k("li","pw-feature"),A=Oe[f.icon];if(A){let I=ze(c,A,22);I.style.color=String(r.icon_color),I.style.flex="none",S.append(I)}let z=k("span");z.textContent=f.text,z.style.color=String(r.color),S.append(z),d.append(S)}return{el:d,slots:{}}}case"timeline":{let d=k("ol","pw-timeline");d.style.gap=C(r.spacing),d.style.setProperty("--pw-gap",C(r.spacing)),d.style.setProperty("--pw-line-w",C(r.line_width));for(let f of r.items??[]){let S=k("li","pw-step"),A=k("span","pw-dot");A.style.background=f.color??String(r.line_color),A.style.color=String(r.icon_color);let z=Oe[f.icon];z&&A.append(ze(c,z,18)),A.setAttribute("aria-hidden","true");let I=k("span","pw-line");I.style.background=String(r.line_color),I.setAttribute("aria-hidden","true");let G=k("span");G.style.color=String(r.color);let ae=k("span","pw-step-title");if(ae.textContent=f.title,G.append(ae),f.text){let F=k("span","pw-step-text");F.style.display="block",F.textContent=f.text,G.append(F)}S.append(A,G,I),d.append(S)}return{el:d,slots:{}}}case"spacer":{let d=k("div","pw-spacer");return d.setAttribute("aria-hidden","true"),typeof r.size=="number"&&(d.style.flex="none",a==="horizontal"?d.style.width=C(r.size):d.style.height=C(r.size)),{el:d,slots:{}}}case"divider":{let d=k("div","pw-divider");return d.setAttribute("role","separator"),d.style.background=String(r.color),d.style.alignSelf="stretch",d.style.flex="none",a==="horizontal"?(d.setAttribute("aria-orientation","vertical"),d.style.width=C(r.thickness)):d.style.height=C(r.thickness),{el:d,slots:{}}}case"button":return Ie(r,s,l);case"purchase_button":{let d=k("button","pw-buy");return d.type="button",d.addEventListener("click",()=>{ot(d,()=>Bt(d.dataset.package??"",d.dataset.offer))}),{el:d,slots:{content:d}}}case"package":{let d=k("div","pw-pkg");return d.setAttribute("role","radio"),d.addEventListener("click",()=>qe(d)),d.addEventListener("keydown",f=>Nt(f,d)),{el:d,slots:{children:d}}}case"tabs":return Tt(r,l);case"switch":return Ct(r,l);case"carousel":return Ht(r);case"countdown":{let d=k("div","pw-countdown");return d.setAttribute("role","timer"),d.setAttribute("aria-live","off"),{el:d,slots:{content:d}}}case"custom_html":{let d=L.assets?.[Se(r.src)??""];if(!d?.html)return null;let f=k("iframe","pw-html");return f.setAttribute("sandbox","allow-scripts"),f.setAttribute("aria-hidden","true"),f.setAttribute("title",""),f.tabIndex=-1,f.srcdoc=d.html,typeof r.height=="number"?f.style.height=C(r.height):typeof r.height=="string"&&r.height.endsWith("%")?f.style.height=r.height:r.height==="fill"&&(f.style.flex="1 1 0"),f.addEventListener("load",()=>it(f)),{el:f,slots:{}}}default:return null}}function q(e,l){let a=String(e.text_style??"body"),s=l.inControl?"span":a==="large_title"?"h1":a==="title"||a==="title2"?"h2":a==="title3"?"h3":"p",r=k(s,"pw-text");l.inControl&&(r.style.display="block"),r.style.fontFamily=oe(e.font);let d=typeof e.size=="number"?e.size:16;if(l.inFooter?(r.style.setProperty("--pw-fs",Pt(d)),r.style.setProperty("--pw-fs-max",`${Number((d*fn).toFixed(2))}px`)):r.style.fontSize=Pt(d),typeof e.weight=="number"&&(r.style.fontWeight=String(e.weight)),typeof e.line_height=="number"&&(r.style.lineHeight=String(e.line_height)),typeof e.letter_spacing=="number"&&e.letter_spacing!==0&&(r.style.letterSpacing=C(e.letter_spacing)),r.style.textAlign=String(e.align??"center"),e.uppercase===!0&&(r.style.textTransform="uppercase"),typeof e.max_lines=="number"&&(r.classList.add("pw-clamp"),r.style.setProperty("-webkit-line-clamp",String(e.max_lines))),typeof e.color=="string"?r.style.color=e.color:e.color&&typeof e.color=="object"&&(r.classList.add("pw-grad"),r.style.backgroundImage=Ve(e.color)??""),Array.isArray(e.spans))for(let f of e.spans){let S=f.link==="terms"?L.links?.terms:f.link==="privacy"?L.links?.privacy:f.link,A=Re(S)&&!l.inControl,z=k(A?"a":"span");z.textContent=String(f.text),f.bold&&(z.style.fontWeight="700"),f.italic&&(z.style.fontStyle="italic");let I=[f.underline?"underline":"",f.strikethrough?"line-through":""].filter(Boolean).join(" ");I&&(z.style.textDecoration=I),typeof f.color=="string"&&f.color!==""&&(z.style.color=f.color),A&&Re(S)&&(z.href=S,z.target="_blank",z.rel="noopener noreferrer",z.addEventListener("click",G=>{B()||!i.onLink||(G.preventDefault(),i.onLink(S))})),r.append(z)}else r.textContent=String(e.text??"");return r}function oe(e){if(typeof e!="string")return ke.system;let l=Se(e);if(l){let a=L.assets?.[l]?.family;return a?`"${a}", ${ke.system}`:ke.system}return ke[e]??ke.system}function U(e){let l=Se(e);return l?L.assets?.[l]?.url||void 0:Re(e)?e:void 0}function pe(e){let l=k("div","pw-img");typeof e.aspect=="number"&&(l.style.aspectRatio=String(e.aspect));let a=U(e.src),s=e.mask;if(s?.shape==="circle")l.style.borderRadius="50%";else if(s?.shape==="rect"&&s.radius)l.style.borderRadius=C(s.radius);else if(s?.shape==="convex")l.style.setProperty("border-end-start-radius",`50% ${C(s.depth)}`),l.style.setProperty("border-end-end-radius",`50% ${C(s.depth)}`);else if(s?.shape==="concave"){let r=`radial-gradient(ellipse 50% ${C(s.depth)} at 50% 100%, transparent 98%, #000 100%)`;l.style.setProperty("-webkit-mask-image",r),l.style.setProperty("mask-image",r)}if(a){let r=k("img");r.src=a,r.decoding="async",r.style.objectFit=e.fit==="fill"?"cover":"contain",e.decorative===!0?(r.alt="",l.setAttribute("aria-hidden","true")):r.alt=String(e.alt??""),r.addEventListener("error",()=>r.style.visibility="hidden"),l.append(r)}if(e.overlay&&typeof e.overlay=="object"){let r=k("div","pw-overlay");r.style.backgroundImage=Ve(e.overlay)??"",l.append(r)}return{el:l,slots:{}}}function Le(e){let l=k("div","pw-img");typeof e.aspect=="number"&&(l.style.aspectRatio=String(e.aspect));let a=U(e.src);if(a){let s=k("video");s.src=a;let r=U(e.poster);r&&(s.poster=r),s.muted=e.mute!==!1,s.loop=e.loop!==!1,s.playsInline=!0,s.controls=e.controls===!0,s.preload="auto",s.style.objectFit=e.fit==="fit"?"contain":"cover",s.autoplay=e.autoplay!==!1&&!ne()&&!B(),typeof e.alt=="string"?s.setAttribute("aria-label",e.alt):s.setAttribute("aria-hidden","true"),l.append(s)}return{el:l,slots:{}}}function Ie(e,l,a){let s=e.action??{},r,d=s.type==="restore"||s.type==="offer_code"||s.type==="request_push"||s.type==="show_paywall"||s.type==="offer",f=o==="message"&&s.type!=="close"&&s.type!=="sheet"&&s.dismiss!==!1;switch(s.type){case"close":l.inSheet?r=()=>Te(null):i.onClose&&(r=()=>i.onClose());break;case"restore":i.onRestore&&(r=()=>i.onRestore());break;case"offer_code":i.onOfferCode&&(L.platform??"web")!=="web"&&(r=()=>i.onOfferCode());break;case"open_url":case"terms":case"privacy":{let A=s.type==="open_url"?s.url:s.type==="terms"?L.links?.terms:L.links?.privacy;Re(A)&&(r=()=>i.onLink?i.onLink(A):void p?.open(A,"_blank","noopener,noreferrer"));break}case"sheet":s.sheet&&(r=()=>Te(s.sheet));break;case"select_package":s.package&&(r=()=>Je(s.package));break;case"deep_link":{let A=s.link;vn(A)&&(r=()=>i.onDeepLink?i.onDeepLink(A):p?.location.assign(A));break}case"request_push":i.onRequestPush&&(r=()=>i.onRequestPush());break;case"show_paywall":s.placement&&i.onShowPaywall&&(r=()=>i.onShowPaywall(s.placement));break;case"custom":s.name&&i.onCustom&&(r=()=>i.onCustom(s.name,s.value));break;case"offer":s.offer&&i.onOffer&&(r=()=>i.onOffer(s.offer));break}if(!r&&!B())return null;let S=k("button");return S.type="button",s.type==="close"&&S.setAttribute("aria-label",ye.close),S.addEventListener("click",()=>{if(!r||B())return;o==="message"&&i.onAction?.(_e(s,a,e.id));let A=f?()=>i.onClose?.():void 0;d?ot(S,async()=>{await r(),A?.()}):(r(),A?.())}),{el:S,slots:{content:S}}}function _e(e,l,a){let s={type:e.type,dismiss:e.type==="sheet"?!1:e.type==="close"||e.dismiss!==!1,path:l};for(let r of["url","link","placement","name","value","sheet","offer"])typeof e[r]=="string"&&(s[r]=e[r]);return typeof a=="string"&&(s.id=a),s}function Tt(e,l){let a=k("div","pw-tabs"),s=k("div","pw-tablist");s.setAttribute("role","tablist");let r=k("div","pw-tabpanel");r.setAttribute("role","tabpanel"),r.id=`${m}-${l}-panel`;let d={content:r},f=e.tabs.map(S=>S.id);return f.forEach((S,A)=>{let z=k("button","pw-tab");z.type="button",z.setAttribute("role","tab"),z.id=`${m}-${l}-tab-${A}`,z.setAttribute("aria-controls",r.id),z.dataset.tab=S,z.addEventListener("click",()=>tt(l,S)),z.addEventListener("keydown",I=>{let G=I.key==="ArrowRight"?A+1:I.key==="ArrowLeft"?A-1:I.key==="Home"?0:I.key==="End"?f.length-1:-2;if(G===-2)return;I.preventDefault();let ae=f[(G+f.length)%f.length];tt(l,ae),s.querySelector(`[data-tab="${ae}"]`)?.focus()}),s.append(z),d[`label:${S}`]=z}),a.append(s,r),d.bar=s,{el:a,slots:d}}function Ct(e,l){let a=k("div","pw-switch"),s=k("div","pw-switchrow"),r=k("span","pw-switchlabel");r.id=`${m}-${l}-label`;let d=k("button","pw-toggle");d.type="button",d.setAttribute("role","switch"),d.setAttribute("aria-labelledby",r.id),d.append(k("i")),d.addEventListener("click",()=>It(l,d.getAttribute("aria-checked")!=="true")),s.append(r,d);let f=k("div","pw-switchcontent");return a.append(s,f),{el:a,slots:{content:f,label:r,toggle:d}}}function Ht(e){let l=k("div","pw-carousel");l.setAttribute("role","region"),l.setAttribute("aria-roledescription","carousel");let a=k("div","pw-track");a.tabIndex=0,a.style.setProperty("--pw-peek",C(e.peek)),a.style.setProperty("--pw-gap",C(e.spacing)),typeof e.height=="number"&&(a.style.minHeight=C(e.height));let s=e.indicator??{},r=k("div",`pw-dots ${s.style??"dots"}`);r.style.setProperty("--pw-dot",C(s.size??8)),r.style.setProperty("--pw-dot-gap",C(s.spacing??6)),r.style.setProperty("--pw-dot-c",s.color??"#8888"),r.style.setProperty("--pw-dot-on",s.active_color??"currentColor"),s.style==="none"&&(r.hidden=!0),l.append(a,r);let d=()=>[...a.children].filter(F=>F instanceof(p?.HTMLElement??HTMLElement)),f=()=>{let F=d(),W=a.scrollLeft+a.clientWidth/2,V=0;return F.forEach((ee,qt)=>{Math.abs(ee.offsetLeft+ee.offsetWidth/2-W)<Math.abs((F[V]?.offsetLeft??0)+(F[V]?.offsetWidth??0)/2-W)&&(V=qt)}),V},S=F=>{let W=d();if(W.length===0)return;let V=e.loop?(F+W.length)%W.length:Math.max(0,Math.min(W.length-1,F)),ee=W[V];a.scrollTo?.({left:ee.offsetLeft-(a.clientWidth-ee.offsetWidth)/2,behavior:ne()?"auto":"smooth"}),A(V)},A=F=>{[...r.children].forEach((W,V)=>W.setAttribute("aria-current",String(V===F)))};a.addEventListener("scroll",()=>A(f()),{passive:!0}),a.addEventListener("keydown",F=>{F.key!=="ArrowRight"&&F.key!=="ArrowLeft"||(F.preventDefault(),S(f()+(F.key==="ArrowRight"?1:-1)))});let z=!1,I=()=>z=!0,G=()=>z=!1;l.addEventListener("pointerenter",I),l.addEventListener("pointerleave",G),l.addEventListener("focusin",I),l.addEventListener("focusout",G);let ae=[];if(typeof e.auto_advance_ms=="number"){let F=setInterval(()=>{if(z||ne()||B())return;let W=d(),V=f();!e.loop&&V>=W.length-1||S(V+1)},e.auto_advance_ms);ae.push(()=>clearInterval(F))}return l.pwDots=F=>{r.children.length!==F&&(r.replaceChildren(...Array.from({length:F},(W,V)=>{let ee=k("button");return ee.type="button",ee.setAttribute("aria-label",ye.page(V+1,F)),ee.addEventListener("click",()=>S(V)),ee})),A(f()))},{el:l,slots:{pages:a},cleanup:ae}}function Ot(e,l){let a=l;switch(l.type){case"package":{let s=Sn(a),d=!!L.packages?.[s]?.price;e.el.dataset.package=s,e.el.setAttribute("aria-checked",String(a.selected===!0)),e.el.setAttribute("aria-disabled",String(!d));break}case"purchase_button":{let s=String(a.package);e.el.dataset.package=s,typeof a.offer=="string"?e.el.dataset.offer=a.offer:delete e.el.dataset.offer,e.el.disabled=te||!L.packages?.[s]?.price;break}case"switch":{let s=e.slots.toggle;s.setAttribute("aria-checked",String(a.on===!0)),s.style.setProperty("--pw-tint",String(a.tint??"")),s.style.setProperty("--pw-off",`color-mix(in srgb, ${j.tree.theme.colors.muted??"#888888"} 45%, transparent)`),e.slots.label.textContent=String(a.label??""),e.slots.label.hidden=a.label===void 0;break}case"tabs":{for(let s of a.tabs){let r=e.slots[`label:${s.id}`];r.setAttribute("aria-selected",String(s.selected)),r.tabIndex=s.selected?0:-1,s.selected&&e.slots.content.setAttribute("aria-labelledby",r.id)}a.bar&&Qe(e.slots.bar,{type:"stack",style:a.bar},"vertical");break}}}function zt(e,l,a){let s=l,r={...a,inControl:a.inControl||l.type==="button"||l.type==="purchase_button"||l.type==="package"};switch(l.type){case"stack":case"package":{let d=l.type==="stack"?String(s.axis??"vertical"):"vertical",f=s.children.map(A=>[A,E(A,d,r)]).filter(A=>A[1]!==null),S=f.map(A=>A[1]);re(e.slots.children,S),jt(d,f),l.type==="stack"&&Pe(e.el,S);break}case"button":case"purchase_button":{let d=s.content?E(s.content,"vertical",r):null;re(e.slots.content,d?[d]:[]);break}case"countdown":case"switch":{let d=s.content?E(s.content,"vertical",r):null;re(e.slots.content,d?[d]:[]),Pe(e.slots.content,d?[d]:[]);break}case"tabs":{for(let f of s.tabs){let S=f.label?E(f.label,"vertical",{...r,inControl:!0}):null;re(e.slots[`label:${f.id}`],S?[S]:[])}let d=s.content?E(s.content,"vertical",r):null;re(e.slots.content,d?[d]:[]),Pe(e.slots.content,d?[d]:[]);break}case"carousel":{let d=s.pages.map(f=>E(f,"page",r)).filter(Boolean);d.forEach((f,S)=>{f.setAttribute("role","group"),f.setAttribute("aria-roledescription","slide"),f.setAttribute("aria-label",ye.page(S+1,d.length))}),re(e.slots.pages,d),Pe(e.slots.pages,d),e.el.pwDots?.(d.length);break}}}function jt(e,l){let a=e==="horizontal"?"width":e==="vertical"?"height":null;if(!a)return;let s=f=>f?a==="width"?f.leading+f.trailing:f.top+f.bottom:0,r=l.filter(([f])=>f.style?.[a]==="fill"),d=Math.max(0,...r.map(([f])=>s(f.style?.padding)+s(f.style?.margin)));for(let[f,S]of r)S.style.flexBasis=C(d-s(f.style?.margin))}function Pe(e,l){let a=l.filter(r=>r.dataset.pwType==="package");if(a.length===0){e.getAttribute("role")==="radiogroup"&&e.removeAttribute("role");return}e.setAttribute("role","radiogroup"),e.setAttribute("aria-label",ye.packages);let s=a.find(r=>r.getAttribute("aria-checked")==="true")??a[0];for(let r of a)r.tabIndex=r===s?0:-1}function re(e,l){let a=()=>[...e.children].filter(r=>r.dataset?.pwPath!==void 0),s=a();for(let r of s)l.includes(r)||r.remove();s=a(),l.forEach((r,d)=>{s[d]!==r&&(e.insertBefore(r,s[d]??null),s=a())})}let Be=new WeakMap;function H(e,l,a){e.style.setProperty(l,a),Be.get(e).push(l)}function Qe(e,l,a){for(let f of Be.get(e)??[])e.style.removeProperty(f);Be.set(e,[]);for(let f of[...e.children])f.classList.contains("pw-bgvideo")&&f.remove();let s=l.style;if(l.type==="image"&&e.classList.toggle("natural",typeof l.aspect!="number"&&(s?.height===void 0||s.height==="fit")),!s)return;let r=(f,S)=>{S&&(H(e,`${f}-block-start`,C(S.top)),H(e,`${f}-block-end`,C(S.bottom)),H(e,`${f}-inline-start`,C(S.leading)),H(e,`${f}-inline-end`,C(S.trailing)))};r("padding",s.padding),r("margin",s.margin),et(e,"width",s.width,a),typeof s.height=="number"&&gn.has(l.type)?(H(e,"min-height",C(s.height)),a==="vertical"&&H(e,"flex","none")):et(e,"height",s.height,a),typeof s.max_width=="number"&&H(e,"max-width",C(s.max_width));let d=s.background;if(d){if(d.type==="color")H(e,"background-color",d.color);else if(d.type==="linear"||d.type==="radial")H(e,"background-image",Ve(d)??"");else if(d.type==="image"){let f=U(d.src);f&&(H(e,"background-image",`url("${f.replace(/"/g,"%22")}")`),H(e,"background-size",d.fit==="fit"?"contain":"cover"),H(e,"background-position","center"),H(e,"background-repeat","no-repeat"))}else if(d.type==="video"){let f=U(d.src);if(f){let S=k("video","pw-bgvideo");S.src=f;let A=U(d.poster);A&&(S.poster=A),S.muted=!0,S.loop=d.loop!==!1,S.playsInline=!0,S.autoplay=!ne()&&!B(),S.setAttribute("aria-hidden","true"),H(e,"isolation","isolate"),e.prepend(S)}}}if(s.border&&l.type==="custom_html"?H(e,"border",`${C(s.border.width)} solid ${s.border.color??"transparent"}`):s.border&&(H(e,"--pw-bw",C(s.border.width)),H(e,"--pw-bc",s.border.color??"transparent")),s.corners){let f=s.corners;H(e,"border-start-start-radius",C(f.top_leading)),H(e,"border-start-end-radius",C(f.top_trailing)),H(e,"border-end-start-radius",C(f.bottom_leading)),H(e,"border-end-end-radius",C(f.bottom_trailing)),(l.type==="image"||l.type==="video"||d?.type==="image"||d?.type==="video")&&H(e,"overflow","hidden")}s.shadow&&H(e,"box-shadow",`${C(s.shadow.x)} ${C(s.shadow.y)} ${C(s.shadow.radius)} ${s.shadow.color}`),typeof s.opacity=="number"&&s.opacity!==1&&H(e,"opacity",String(s.opacity))}function et(e,l,a,s){if(a==null||a==="")return;if(s==="page"){l==="height"&&H(e,"height",a==="fill"?"100%":typeof a=="number"?C(a):a==="fit"?"fit-content":String(a));return}let r=s==="horizontal"?"width":s==="vertical"?"height":null;a==="fill"?l===r?(H(e,"flex","1 1 0"),H(e,`min-${l}`,"0")):s==="z"?H(e,l,"100%"):(H(e,"align-self","stretch"),H(e,l,"auto")):a==="fit"?(l===r&&H(e,"flex","0 0 auto"),H(e,l,"fit-content")):(H(e,l,typeof a=="number"?C(a):String(a)),l===r&&H(e,"flex","none"))}function Ve(e){let l=a=>a.map(s=>`${s.color} ${(s.at*100).toFixed(2)}%`).join(", ");if(e.type==="linear")return`linear-gradient(${e.angle}deg, ${l(e.stops)})`;if(e.type==="radial"){let a=`${(e.radius*100).toFixed(2)}%`;return`radial-gradient(ellipse ${a} ${a} at ${(e.center_x*100).toFixed(2)}% ${(e.center_y*100).toFixed(2)}%, ${l(e.stops)})`}}function Ft(e,l){let a=l.animation;if(!a||L.animate===!1||ne()||typeof e.animate!="function")return;let s=24,d={fade:{opacity:0},slide_up:{opacity:0,transform:`translateY(${s}px)`},slide_down:{opacity:0,transform:`translateY(-${s}px)`},slide_leading:{opacity:0,transform:`translateX(-${s}px)`},slide_trailing:{opacity:0,transform:`translateX(${s}px)`},scale:{opacity:0,transform:"scale(0.92)"}}[a.type];d&&e.animate([d,{opacity:1,transform:"none"}],{duration:a.duration_ms,delay:a.delay_ms,easing:_t[a.easing]??_t.ease_out,fill:"backwards"})}function $e(){i.onState?.({...R}),Y()}function Je(e){R.selected===e&&de()===e||(R.selected=e,$e(),i.onSelect?.(Ne(e)))}function qe(e){B()||e.getAttribute("aria-disabled")==="true"||Je(e.dataset.package??"")}function Nt(e,l){if(e.key===" "||e.key==="Enter"){e.preventDefault(),qe(l);return}let a=e.key==="ArrowDown"||e.key==="ArrowRight"?1:e.key==="ArrowUp"||e.key==="ArrowLeft"?-1:0;if(a===0)return;e.preventDefault();let s=l.closest("[role=radiogroup]"),d=(s?[...s.children].filter(A=>A.dataset.pwType==="package"):[l]).filter(A=>A.getAttribute("aria-disabled")!=="true"),f=d.indexOf(l),S=d[(f+a+d.length)%d.length];S&&(qe(S),(N.get(S.dataset.pwPath??"")?.el??S).focus())}function tt(e,l){if(B())return;R.tabs={...R.tabs,[e]:l};let a=Dt(e,l);a&&(R.selected=a),$e()}function Dt(e,l){return nt(e)?.tabs?.find(s=>s.id===l)?.package}function It(e,l){if(B())return;R.switches={...R.switches,[e]:l};let a=nt(e),s=l?a?.on_package:a?.off_package;s&&(R.selected=s),$e()}function nt(e){let l=L.definition;for(let a of e.match(/[^.[\\]]+/g)??[])l=l?.[/^\\d+$/.test(a)?Number(a):a];return l}async function ot(e,l){if(!(B()||te)){te=!0,e.disabled=!0,e.setAttribute("aria-busy","true");try{await l()}finally{te=!1,e.removeAttribute("aria-busy"),e.disabled=!1;for(let a of N.values())a.type==="purchase_button"&&(a.el.disabled=!L.packages?.[a.el.dataset.package??""]?.price)}}}async function Bt(e,l){!L.packages?.[e]?.price||!i.onPurchase||await i.onPurchase(l!==void 0?{...Ne(e),offer:l}:Ne(e))}function Te(e){B()&&e!==null&&R.sheet===e||(e&&!R.sheet&&(xe=y.activeElement??null),R.sheet=e,$e(),e||xe?.focus())}function Vt(){let e=R.sheet,l=e?j.tree.sheets?.[e]:void 0;if(!l){O.remove();return}O.className="pw-layer";let a=O.firstElementChild;if(!a){a=k("div","pw-sheet"),a.setAttribute("role","dialog"),a.setAttribute("aria-modal","true"),a.tabIndex=-1;let r=k("div","pw-grab");r.setAttribute("aria-hidden","true"),a.append(r),O.append(a),O.addEventListener("click",d=>{d.target===O&&!B()&&Te(null)}),a.addEventListener("keydown",d=>Jt(d,a))}a.style.background=j.tree.theme.colors.background??"",a.setAttribute("aria-label",j.sheetTitles[e]??"");let s=E(l,"vertical",{inControl:!1,inSheet:!0});re(a,s?[s]:[]),O.isConnected||(w.append(O),queueMicrotask(()=>(st(a)[0]??a).focus()))}function st(e){return[...e.querySelectorAll(\'button:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])\')].filter(l=>!l.hidden)}function Jt(e,l){if(e.key==="Escape"){e.preventDefault(),Te(null);return}if(e.key!=="Tab")return;let a=st(l);if(a.length===0){e.preventDefault();return}let s=a[0],r=a[a.length-1],d=y.activeElement;e.shiftKey&&d===s?(e.preventDefault(),r.focus()):!e.shiftKey&&d===r&&(e.preventDefault(),s.focus())}function it(e){try{let l=o==="paywall"?{type:"palbase.paywall",package:de()}:{type:"palbase.message"};e.contentWindow?.postMessage({...l,locale:j.language,appearance:L.appearance},"*")}catch{}}function rt(e){for(let l of y.querySelectorAll("[data-pw-highlight]"))l.removeAttribute("data-pw-highlight");ve=e,e&&N.get(e)?.el.setAttribute("data-pw-highlight","")}let at=e=>e.composedPath().find(l=>l instanceof(p?.HTMLElement??HTMLElement)&&l.dataset.pwPath!==void 0);w.addEventListener("click",e=>{if(!i.editor)return;let l=at(e);l&&(e.preventDefault(),e.stopPropagation(),i.editor.onPick(l.dataset.pwPath))},!0),w.addEventListener("pointerover",e=>{if(i.editor){for(let l of y.querySelectorAll("[data-pw-hover]"))l.removeAttribute("data-pw-hover");at(e)?.setAttribute("data-pw-hover","")}}),w.addEventListener("pointerleave",()=>{for(let e of y.querySelectorAll("[data-pw-hover]"))e.removeAttribute("data-pw-hover")});let lt=()=>Y();return be?.addEventListener?.("change",lt),Y(),{get selected(){let e=de();return e?Ne(e):null},get state(){return{...R}},select(e){Je(e)},update(e){L={...L,...e},e.state&&Object.assign(R,e.state),Y()},highlight(e){rt(e)},replay(){for(let e of N.values())e.cleanup.forEach(l=>l());N=new Map;for(let e of[v,x,_])e.replaceChildren();Y()},destroy(){clearTimeout(he),K?.disconnect(),c.fonts?.removeEventListener?.("loadingdone",X),be?.removeEventListener?.("change",lt);for(let e of N.values())e.cleanup.forEach(l=>l());b.remove()}}}function Rn(o,t,n){let i=o.defaultView;try{if(i&&"adoptedStyleSheets"in t&&typeof i.CSSStyleSheet=="function"){let p=new i.CSSStyleSheet;p.replaceSync(n),t.adoptedStyleSheets=[p];return}}catch{}let c=o.createElement("style");c.textContent=n,t.append(c)}function An(o,t){let n=o;for(let i of t.split(".")){let c=/^([^[\\]]+)((?:\\[\\d+\\])*)$/.exec(i);if(!c||typeof n!="object"||n===null)return;n=n[c[1]];for(let p of c[2].matchAll(/\\[(\\d+)\\]/g))n=Array.isArray(n)?n[Number(p[1])]:void 0}return typeof n=="object"&&n!==null?n:void 0}var Ln=o=>Uint8Array.from(atob(o),t=>t.charCodeAt(0));async function _n(o){let t={};for(let n of o.assets){let i=Ln(n.data);if((n.kind==="image"||n.kind==="video")&&(t[n.id]={kind:n.kind,url:URL.createObjectURL(new Blob([i],{type:n.type}))}),n.kind==="font"){let c=new FontFace(Ue(n.id),i,{display:"block"});await c.load(),document.fonts.add(c),t[n.id]={kind:"font",url:"",family:Ue(n.id)}}if(n.kind==="html"){let c=pt(await dt(i));c!==void 0&&(t[n.id]={kind:"html",url:"",html:c})}}return t}function Pn(o,t){let n=o.catalog[t.platform]??{packages:{},eligible:[]},i=Fe(o.definition,{locale:o.locale,appearance:t.appearance,platform:t.platform,packages:n.packages,eligible:n.eligible}),c=o.state;return{...c.selected?{selected:c.selected}:{},...c.tab?{tabs:Object.fromEntries(Object.keys(i.tabs).map(p=>[p,c.tab]))}:{},...c.switch?{switches:Object.fromEntries(Object.keys(i.switches).map(p=>[p,c.switch==="on"]))}:{},...c.sheet?{sheet:c.sheet}:{}}}async function $n(o){let t=[...o.querySelectorAll("img, video")];await Promise.race([Promise.all(t.map(n=>n instanceof HTMLImageElement?n.complete?Promise.resolve():n.decode().catch(()=>{}):n.readyState>=2?Promise.resolve():new Promise(i=>{n.addEventListener("loadeddata",()=>i(),{once:!0}),n.addEventListener("error",()=>i(),{once:!0})}))),new Promise(n=>setTimeout(n,5e3))])}var De=()=>new Promise(o=>requestAnimationFrame(()=>o(void 0)));async function Tn(){let o=window.PALBASE_PREVIEW,t=o.shots[Number(new URLSearchParams(location.search).get("shot")??"0")]??o.shots[0];document.documentElement.style.fontSize=`${t.fontSize}px`,document.documentElement.style.colorScheme=t.appearance;let n=document.getElementById("screen");Object.assign(n.style,{width:`${t.width}px`,height:`${t.height}px`,paddingTop:`${t.top}px`,paddingBottom:`${t.bottom}px`});let i=document.getElementById("paywall"),c=o.catalog[t.platform]??{packages:{},eligible:[]},p=$t(i,{definition:o.definition,locale:o.locale,appearance:t.appearance,platform:t.platform,packages:c.packages,eligible:c.eligible,links:o.links,assets:await _n(o),state:Pn(o,t),animate:!1,reduceMotion:!0},{onPurchase:()=>{},onRestore:()=>{},onClose:()=>{},onLink:()=>{},onOfferCode:()=>{}}),m=i.querySelector("[data-palbase-paywall]")?.shadowRoot;if(!m)throw new Error("the renderer drew nothing");let b=getComputedStyle(m.querySelector(".pw2")).backgroundColor;n.style.background=b==="rgba(0, 0, 0, 0)"||b==="transparent"?t.appearance==="dark"?"#000":"#fff":b,await document.fonts.ready,await $n(m),await De(),await De(),document.body.dataset.selected=p.selected?`${p.selected.product}.${p.selected.plan}`:"",o.check&&(document.body.dataset.findings=JSON.stringify(kt(m,{platform:t.platform,width:t.width,height:t.height,nodeAt:y=>An(o.definition,y)}))),window.PALBASE_FULL=async()=>{let y=Math.max(...[".pw2-body",".pw2"].map(v=>m.querySelector(v)).map(v=>v.scrollHeight-v.clientHeight)),w=Math.max(t.height,Math.ceil(n.offsetHeight+y));return n.style.height=`${w}px`,await De(),await De(),w}}Tn().then(()=>{document.body.dataset.ready="1"},o=>{document.body.dataset.error=o instanceof Error?o.message:String(o),document.body.dataset.ready="1"});})();\n')}function Gp(e){let t=/^P(\d+)([DWMY])$/.exec(e??"");if(!t)return null;let n=Number(t[1]);if(!Number.isSafeInteger(n)||n<1)return null;switch(t[2]){case"D":return{count:n,unit:"day",months:n*12/365};case"W":return{count:n,unit:"week",months:n*12/52};case"M":return{count:n,unit:"month",months:n};default:return{count:n,unit:"year",months:n*12}}}function yv(e){try{return new Intl.NumberFormat("en",{style:"currency",currency:e}).resolvedOptions().maximumFractionDigits??2}catch{return 2}}function qp(e,t,n){let s=e/10**yv(t);try{return new Intl.NumberFormat(n,{style:"currency",currency:t}).format(s)}catch{return`${s.toFixed(yv(t))} ${t}`}}function NN(e,t){try{let n=new Intl.NumberFormat(t,{style:"unit",unit:e.unit,unitDisplay:"long"});return e.count>1?n.format(e.count):n.formatToParts(1).filter(a=>a.type==="unit").map(a=>a.value).join("").trim()||n.format(1)}catch{return e.count>1?`${e.count} ${e.unit}s`:e.unit}}var IN={en:e=>`${e} free`,tr:e=>`${e} \xFCcretsiz`,de:e=>`${e} kostenlos`,es:e=>`${e} gratis`,it:e=>`${e} gratis`,nl:e=>`${e} gratis`,pt:e=>`${e} gr\xE1tis`,sv:e=>`${e} gratis`,da:e=>`${e} gratis`,nb:e=>`${e} gratis`};function LN(e,t){let n;try{n=new Intl.NumberFormat(t,{style:"unit",unit:e.unit,unitDisplay:"long"}).format(e.count)}catch{n=`${e.count} ${e.unit}${e.count>1?"s":""}`}let s=IN[t.split("-")[0].toLowerCase()];return s?s(n):n}function DN(e,t){try{return new Intl.NumberFormat(t,{style:"percent",maximumFractionDigits:0}).format(e)}catch{return`${Math.round(e*100)}%`}}function bv(e,t){let n=new Map,s=new Map;for(let i of e){let r=Gp(i.period);if(!r)continue;let o=i.price.amount/r.months;n.set(i.key,o),s.set(i.price.currency,Math.max(s.get(i.price.currency)??0,o))}let a={};for(let i of e){let r={product_name:i.productName,price:qp(i.price.amount,i.price.currency,t)},o=Gp(i.period);if(o){r.period=NN(o,t),r.price_per_month=qp(Math.round(n.get(i.key)),i.price.currency,t);let d=s.get(i.price.currency)??0,p=d>0?Math.floor((1-n.get(i.key)/d)*100)/100:0;p>=.01&&(r.savings=DN(p,t))}let l=i.intro?.mode==="free_trial"?Gp(i.intro.duration):null;l&&(r.trial=LN(l,t)),i.offer&&(r.offer_price=qp(Math.floor((i.price.amount*(100-i.offer.percentOff)+50)/100),i.price.currency,t)),a[i.key]=r}return a}var H=(e,t=!1)=>({kind:"value",value:"plain",def:e,required:t}),Ut=e=>({kind:"value",value:"color",def:e}),wv=e=>({kind:"value",value:"spacing",def:e}),MN=e=>({kind:"value",value:"radius",def:e}),oa=(e=!1)=>({kind:"text",required:e}),Up=(e,t=!1)=>({kind:"list",item:e,required:t}),nr=(e,t=!1)=>({kind:"object",item:e,required:t}),vv=(e=!1)=>({kind:"component",required:e}),Kp={kind:"components"},xN={stack:{axis:H("vertical"),spacing:wv(0),align:H("center"),distribution:H("start"),scroll:H(!1),children:Kp},text:{text:oa(),spans:Up("span"),font:H(),size:H(),weight:H(),line_height:H(),letter_spacing:H(),color:{kind:"value",value:"textColor",def:"text"},align:H("center"),max_lines:H(),uppercase:H(!1)},image:{src:H(void 0,!0),fit:H("fit"),aspect:H(),mask:nr("mask"),overlay:{kind:"value",value:"textColor"},alt:oa(),decorative:H(!1)},icon:{name:H(void 0,!0),color:Ut("accent"),size:H(24)},video:{src:H(void 0,!0),poster:H(),autoplay:H(!0),loop:H(!0),mute:H(!0),controls:H(!1),fit:H("fill"),aspect:H(),alt:oa()},button:{action:nr("action",!0),content:vv(!0)},purchase_button:{content:vv(!0),package:H()},package:{product:H(void 0,!0),plan:H(void 0,!0),selected:H(!1),offer:H(),children:Kp},tabs:{},switch:{},carousel:{pages:Kp,peek:H(0),spacing:H(8),loop:H(!1),auto_advance_ms:H(),indicator:nr("indicator"),height:H("")},countdown:{},timeline:{items:Up("timeline_item",!0),line_color:Ut("accent"),line_width:H(2),icon_color:Ut("on_accent"),color:Ut("text"),spacing:H(16)},features:{items:Up("feature",!0),icon_color:Ut("accent"),color:Ut("text"),spacing:H(12)},spacer:{size:wv()},divider:{color:Ut("muted"),thickness:H(1)},custom_html:{src:H(void 0,!0),height:H("",!0)}},Dz={style:{padding:{kind:"edges"},margin:{kind:"edges"},width:H(""),height:H(""),max_width:H(),background:{kind:"fill"},border:nr("border"),corners:{kind:"corners"},shadow:nr("shadow"),opacity:H(1)},border:{width:H(),color:Ut("")},shadow:{color:Ut(""),radius:H(0),x:H(0),y:H(0)},linear:{type:H(""),angle:H(180),stops:H()},radial:{type:H(""),center_x:H(.5),center_y:H(.5),radius:H(.5),stops:H()},image_fill:{type:H(""),src:H(),fit:H("fill")},video_fill:{type:H(""),src:H(),poster:H(),loop:H(!0)},animation:{type:H(""),duration_ms:H(300),delay_ms:H(0),easing:H("ease_out")},action:{type:H(""),url:H(),sheet:H(),package:H()},mask:{shape:H(""),radius:MN(0),depth:H(16)},span:{text:oa(!0),bold:H(!1),italic:H(!1),underline:H(!1),strikethrough:H(!1),color:Ut(""),link:H()},timeline_item:{icon:H(void 0,!0),title:oa(!0),text:oa(),color:Ut("")},feature:{icon:H(void 0,!0),text:oa(!0)},indicator:{style:H("dots"),color:Ut("muted"),active_color:Ut("accent"),size:H(8),spacing:H(6)},typography:{font:H("system"),size:H(),weight:H(400),line_height:H(),letter_spacing:H(0),text_style:H("body")}},GN=new Set(["package","purchase_button"]),Mz={action:{type:H(""),url:H(),link:H(),sheet:H(),placement:H(),name:H(),value:H(),offer:H(),dismiss:H(!0)},presentation:{type:H(""),position:H("bottom"),auto_dismiss_seconds:H(),dismissible:H(!0),backdrop:Ut("#00000080")}};var qN=Object.keys(xN),xz=qN.filter(e=>!GN.has(e));var Fp=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{};function sr(e){let t=[],n=a=>{if(Array.isArray(a))return a.forEach(n);if(typeof a!="object"||a===null)return;let i=a;if(i.type==="package"&&typeof i.product=="string"&&typeof i.plan=="string"){let r=`${i.product}.${i.plan}`;t.includes(r)||t.push(r)}for(let r of Object.keys(i).sort())n(i[r])},s=e;for(let a of["header","root","footer"])n(s[a]);for(let a of Object.keys(Fp(s.sheets)).sort())n(Fp(Fp(s.sheets)[a]).root);return t}var _v=["ios","android","web"],$v=["light","dark"],WN={default:16,largest:24},zN={ios:{width:393,height:852,top:54,bottom:34},android:{width:412,height:915,top:40,bottom:24},web:{width:1024,height:720,top:0,bottom:0}},Wp=2,JN={terms:"https://example.com/terms",privacy:"https://example.com/privacy"};function Bp(e,t,n,s){let a=e.flags[t];if(a===void 0)return s;if(!n.includes(a))throw g(`--${t} is one of ${n.join(", ")}`);return a}function kv(e,t){let n=e.flags[t];if(n===void 0)return;let s=Number(n);if(!Number.isInteger(s)||s<200||s>4e3)throw g(`--${t} is a whole number of CSS pixels, 200 to 4000`);return s}function HN(e){let t={};for(let n of e??[]){let s=n.indexOf("="),[a,i]=s<0?[n,""]:[n.slice(0,s),n.slice(s+1)];if(a==="tab"&&i!=="")t.tab=i;else if(a==="sheet"&&i!=="")t.sheet=i;else if(a==="switch"&&(i==="on"||i==="off"))t.switch=i;else throw g(`--state ${n}: it names tab=<id>, switch=on|off or sheet=<id>`)}return t}function VN(e,t){if(e)return e[t]?.name??e[t.split("-")[0]]?.name??Object.values(e).find(n=>n.name)?.name}function XN(e){let t=e.split(".").slice(1).join(".").toLowerCase(),[n,s]=/year|annual|12m/.test(t)?["P1Y",5999]:/week/.test(t)?["P1W",499]:/life|forever|once|onetime|one_time/.test(t)?[void 0,14999]:["P1M",999];return{key:e,productName:e.split(".")[0],price:{amount:s,currency:"USD"},...n?{period:n}:{}}}function YN(e,t,n,s){let a=[],i=[];for(let o of n){let[l,d]=o.split("."),p=e?.products.find(f=>f.key===l),c=p?.channels[t],m=c?.plans.find(f=>f.key===d);if(!p||!c||!m){a.push(XN(o)),i.push(o);continue}a.push({key:o,productName:VN(c.locales,s)??p.key,price:{amount:m.price.amount,currency:m.price.currency},period:m.period,intro:m.intro})}let r=a.filter(o=>o.intro?.mode==="free_trial").map(o=>o.key);return{packages:bv(a,s),eligible:r,sampled:i}}function ZN(e){return[...new Set([...JSON.stringify(e).matchAll(/asset:([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/g)].map(t=>t[1]))]}async function QN(e,t,n){if(n.length===0)return{assets:[],left:[]};let s=await Ya(e,t),a=Wt(e.cloud,t.env_ref),i=[],r=[];for(let o of n){let l=s.find(d=>d.id===o);if(!l){r.push(`asset:${o} is not one of the project's assets`);continue}try{let d;try{d=new URL(l.url)}catch{throw new Error("its address is not one")}if(d.origin!==a)throw new Error(`its address is not the environment's (${a}) \u2014 ${d.protocol==="https:"||d.protocol==="http:"?d.host:d.protocol}: the CLI does not ask another host`);let p=await e.io.fetch(d.href,{credentials:"omit",redirect:"manual"});if(!p.ok)throw new Error(`its address answered ${p.status}`);let c=Buffer.from(await p.arrayBuffer());if(UN("sha256").update(c).digest("hex")!==l.sha256.toLowerCase())throw new Error("its bytes are not the ones registered");i.push({id:o,kind:l.kind,type:l.content_type,data:c.toString("base64")})}catch(d){r.push(`${l.ref} could not be had: ${d instanceof Error?d.message:String(d)}`)}}return{assets:i,left:r}}function eI(e,t,n){let s=JSON.stringify(n).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");return`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${t.replace(/[&<>"]/g,i=>`&#${i.charCodeAt(0)};`)} \u2014 paywall preview</title>
|
|
679
|
+
`),s=Number(t);return n?.startsWith("/devtools/browser/")&&Number.isInteger(s)&&s>0&&s<65536?s:void 0}async function gv(e,t,n,s={}){let a=s.timeoutMs??3e4,i=AN(ra(EN(),"palbase-preview-")),r=$N(e,["--headless=new","--disable-gpu","--hide-scrollbars","--no-first-run","--no-default-browser-check","--disable-extensions","--disable-background-networking","--disable-sync","--mute-audio","--autoplay-policy=no-user-gesture-required",`--user-data-dir=${i}`,"--remote-debugging-port=0",...s.args??[],"about:blank"],{stdio:["ignore","ignore","pipe"]}),o="";r.stderr?.on("data",p=>{o=(o+p.toString("utf8")).slice(-8192)});let l=!1;r.once("exit",()=>{l=!0});let d=new Promise((p,c)=>r.once("error",m=>c(new Error(`the browser did not start: ${m.message}`))));try{return await Promise.race([d,(async()=>{let p;for(let b=Date.now()+2e4;p===void 0&&Date.now()<b&&!l;await ll(100))try{p=jN(PN(ra(i,"DevToolsActivePort"),"utf8"))}catch{}if(p===void 0)throw l?new tr(o):new Error("the browser did not open its DevTools port in 20 s");let c;for(let b=Date.now()+1e4;c===void 0;await ll(100))try{c=await(await fetch(`http://127.0.0.1:${p}/json/list`)).json()}catch(v){if(Date.now()>b||l)throw new Error(`the browser's DevTools did not answer: ${v instanceof Error?v.message:String(v)}`)}let m=c.find(b=>b.type==="page");if(!m)throw new Error("the browser opened no page");let f=await ON(m.webSocketDebuggerUrl);try{await f.send("Page.enable");let b=[];for(let v of n){await f.send("Emulation.setDeviceMetricsOverride",{width:v.width,height:v.height,deviceScaleFactor:v.scale,mobile:!1}),await f.send("Page.navigate",{url:`${CN(t).href}?${v.query}`});let R=!1;for(let K=Date.now()+a;!R&&Date.now()<K;)await ll(100),R=(await f.send("Runtime.evaluate",{expression:"document.readyState === 'complete' && document.body?.dataset.ready === '1'",returnByValue:!0})).result?.value===!0;if(!R)throw new Error(`the page did not finish drawing in ${Math.round(a/1e3)} s`);let A=await f.send("Runtime.evaluate",{expression:"JSON.stringify({ error: document.body.dataset.error, selected: document.body.dataset.selected, findings: document.body.dataset.findings })",returnByValue:!0}),{error:C,selected:N,findings:j}=JSON.parse(String(A.result.value)),U=v.height;if(v.full&&!C){let K=await f.send("Runtime.evaluate",{expression:"window.PALBASE_FULL()",awaitPromise:!0,returnByValue:!0}),L=Number(K.result?.value);Number.isFinite(L)&&L>U&&(U=Math.min(L,16e3),await f.send("Emulation.setDeviceMetricsOverride",{width:v.width,height:U,deviceScaleFactor:v.scale,mobile:!1}),await f.send("Runtime.evaluate",{expression:"new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => r(1))))",awaitPromise:!0}))}let G=v.measureOnly?void 0:await f.send("Page.captureScreenshot",{format:"png",captureBeyondViewport:!1});b.push({png:G?Buffer.from(String(G.data),"base64"):new Uint8Array,height:U,...C?{error:C}:{},...N?{selected:N}:{},...j?{findings:JSON.parse(j)}:{}})}return b}finally{f.close()}})()])}finally{r.kill();for(let p=0;p<20&&!l;p++)await ll(50);l||r.kill("SIGKILL");try{RN(i,{recursive:!0,force:!0,maxRetries:10,retryDelay:100})}catch{}}}async function ON(e){let t=new WebSocket(e);await new Promise((a,i)=>{t.addEventListener("open",()=>a(),{once:!0}),t.addEventListener("error",()=>i(new Error("the browser refused the DevTools connection")),{once:!0})});let n=0,s=new Map;return t.addEventListener("message",a=>{let i=JSON.parse(String(a.data));if(i.id===void 0)return;let r=s.get(i.id);s.delete(i.id),i.error?r?.reject(new Error(i.error.message)):r?.resolve(i.result??{})}),t.addEventListener("close",()=>{for(let a of s.values())a.reject(new Error("the browser closed the DevTools connection"));s.clear()}),{send(a,i={}){let r=++n;return new Promise((o,l)=>{s.set(r,{resolve:o,reject:l}),t.send(JSON.stringify({id:r,method:a,params:i}))})},close:()=>t.close()}}function fv(){return Promise.resolve('"use strict";(()=>{var Ue=o=>`pw-font-${o}`;function Se(o){return(typeof o=="string"?/^asset:([0-9a-f-]{36})$/.exec(o):null)?.[1]}async function dt(o){let t=new DataView(o.buffer,o.byteOffset,o.byteLength),n=-1;for(let b=o.length-22;b>=Math.max(0,o.length-22-65535);b--)if(t.getUint32(b,!0)===101010256){n=b;break}if(n<0)throw new Error("not a zip");let i=t.getUint16(n+10,!0),c=t.getUint32(n+16,!0),p=new Map,m=0;for(let b=0;b<i;b++){if(t.getUint32(c,!0)!==33639248)throw new Error("a broken zip");let y=t.getUint16(c+10,!0),w=t.getUint32(c+20,!0),v=t.getUint32(c+24,!0),x=t.getUint16(c+28,!0),_=t.getUint16(c+30,!0),O=t.getUint16(c+32,!0),L=t.getUint32(c+42,!0),R=new TextDecoder().decode(o.subarray(c+46,c+46+x));if(c+=46+x+_+O,R.endsWith("/"))continue;if(R.startsWith("/")||R.split("/").includes(".."))throw new Error("a path leaving the zip");if(m+=v,p.size>=200||m>20971520)throw new Error("a zip too large");let j=L+30+t.getUint16(L+26,!0)+t.getUint16(L+28,!0),N=o.subarray(j,j+w);if(y===0)p.set(R,N);else if(y===8)p.set(R,await Ut(N));else throw new Error("a zip entry compressed another way")}return p}async function Ut(o){let t=new Response(new Uint8Array(o)).body.pipeThrough(new DecompressionStream("deflate-raw"));return new Uint8Array(await new Response(t).arrayBuffer())}var Wt={html:"text/html",css:"text/css",js:"text/javascript",mjs:"text/javascript",json:"application/json",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",svg:"image/svg+xml",mp4:"video/mp4",webm:"video/webm",woff2:"font/woff2",woff:"font/woff",ttf:"font/ttf",otf:"font/otf"};function ct(o,t){let n=Wt[o.split(".").pop()?.toLowerCase()??""]??"application/octet-stream",i="";for(let c=0;c<t.length;c+=32768)i+=String.fromCharCode(...t.subarray(c,c+32768));return`data:${n};base64,${btoa(i)}`}var Kt="default-src \'none\'; img-src data:; media-src data:; font-src data:; style-src \'unsafe-inline\' data:; script-src \'unsafe-inline\' data:";function pt(o){let t=o.get("index.html");if(!t)return;let n=new TextDecoder().decode(t),i=w=>new TextDecoder().decode(o.get(w)),c=w=>{let v=w.replace(/^\\.\\//,"").split(/[?#]/)[0];return o.has(v)?v:void 0},p=w=>w.replace(/url\\(\\s*([\'"]?)([^\'")]+)\\1\\s*\\)/g,(v,x,_)=>{let O=c(_);return O?`url("${ct(O,o.get(O))}")`:v}),m=globalThis.DOMParser;if(!m)return;let b=new m().parseFromString(n,"text/html");for(let w of[...b.querySelectorAll(\'link[rel~="stylesheet"][href]\')]){let v=c(w.getAttribute("href")),x=b.createElement("style");x.textContent=v?p(i(v)):"",w.replaceWith(x)}for(let w of[...b.querySelectorAll("style")])w.textContent=p(w.textContent??"");for(let w of[...b.querySelectorAll("[src], [href], [poster]")])for(let v of["src","href","poster"]){let x=w.getAttribute(v);if(x===null)continue;let _=c(x);_?w.setAttribute(v,ct(_,o.get(_))):/^(https?:)?\\/\\//i.test(x)&&w.removeAttribute(v)}for(let w of[...b.querySelectorAll("[style]")])w.setAttribute("style",p(w.getAttribute("style")??""));let y=b.createElement("meta");return y.setAttribute("http-equiv","Content-Security-Policy"),y.setAttribute("content",Kt),b.head.prepend(y),`<!doctype html>${b.documentElement.outerHTML}`}var Gt={ios:44,android:44,web:24,macos:28},ut=.12;function se(o){let t=/^rgba?\\(([\\d.]+),\\s*([\\d.]+),\\s*([\\d.]+)(?:,\\s*([\\d.]+))?\\)$/.exec(o.trim());return t?[Number(t[1]),Number(t[2]),Number(t[3]),t[4]===void 0?1:Number(t[4])]:void 0}var Me;function Xt(o){if(o.trim()==="")return;let t=se(o);return t||(Me??=document.body.appendChild(document.createElement("i")),Me.style.color="",Me.style.color=o.trim(),Me.style.color===""?void 0:se(getComputedStyle(Me).color))}var Ge=(o,t)=>{let n=o[3]+t[3]*(1-o[3]);if(n===0)return[0,0,0,0];let i=c=>(o[c]*o[3]+t[c]*t[3]*(1-o[3]))/n;return[i(0),i(1),i(2),n]};function ft([o,t,n]){let i=c=>{let p=c/255;return p<=.04045?p/12.92:((p+.055)/1.055)**2.4};return .2126*i(o)+.7152*i(t)+.0722*i(n)}function gt(o,t){let[n,i]=[ft(o),ft(t)].sort((c,p)=>p-c);return(n+.05)/(i+.05)}var ht=([o,t,n])=>`#${[o,t,n].map(i=>Math.round(i).toString(16).padStart(2,"0")).join("").toUpperCase()}`,We=o=>`${(Math.floor(o*10)/10).toFixed(1)}:1`,Z=o=>Math.round(o);function He(o){return o.parentElement??o.getRootNode().host??null}function yt(o){let t=[],n=1;for(let c=o;c;c=He(c)){let p=getComputedStyle(c);if(p.backgroundImage!=="none")return;let m=se(p.backgroundColor);if(m&&m[3]>0&&t.push(m),t.length===0&&(n*=Number(p.opacity)),m&&m[3]>=1)break}let i=[255,255,255,1];for(let c of t.reverse())i=Ge(c,i);return{color:i,opacity:n}}function Yt(o){for(let t=o;t;t=He(t)){let n=getComputedStyle(t);if(n.backgroundImage!=="none")return t;let i=se(n.backgroundColor);if(i&&i[3]>=1)return}}function mt(o){let t=yt(o),n=se(getComputedStyle(o).color);if(!t||!n)return;let i=n[3];for(let c=o;c;c=He(c)){let p=getComputedStyle(c);i*=Number(p.opacity);let m=se(p.backgroundColor);if(m&&m[3]>0)break}return{text:Ge([n[0],n[1],n[2],i],t.color),bg:t.color}}function le(o){let t=o.getBoundingClientRect();if(t.width<1||t.height<1)return!1;for(let n=o;n;n=He(n)){let i=getComputedStyle(n);if(i.visibility==="hidden"||i.display==="none"||Number(i.opacity)===0)return!1}return!0}var Ce=o=>o.closest("[data-pw-path]")?.dataset.pwPath??"the page";function wt(o){let t=(o.innerText??o.textContent??"").replace(/\\s+/g," ").trim();return t.length>40?`${t.slice(0,39)}\\u2026`:t}var ue=o=>{let t=wt(o),n=o.dataset?.pwType??o.getAttribute("role")??o.closest("[data-pw-path]")?.dataset.pwType??o.tagName.toLowerCase();return`${Ce(o)}${t?` "${t}"`:` (${n}${o.getAttribute("aria-label")?` "${o.getAttribute("aria-label")}"`:""})`}`},bt="button, [role=radio], [role=tab], [role=switch], a[href]";function Zt(o,t){for(let n=o.parentElement;n&&t.contains(n);n=n.parentElement){if(n.classList.contains("pw2-body")||n.classList.contains("pw2"))return;let i=getComputedStyle(n);if(i.overflowX!=="visible"||i.overflowY!=="visible")return n}}function Ke(o,t){for(let n=o.parentElement;n&&t.contains(n);n=n.parentElement){if(n.classList.contains("pw-track")||n.classList.contains("pw-carousel"))return!0;let i=getComputedStyle(n).overflowX;if((i==="auto"||i==="scroll")&&!n.classList.contains("pw2-body"))return!0}return!1}function kt(o,t){let n=[],i=(u,h,M)=>n.push({code:u,where:typeof h=="string"?h:ue(h),message:M}),c=o.querySelector(".pw2"),p=o.querySelector(".pw2-body"),m=o.querySelector(".pw2-foot"),b=c.getBoundingClientRect(),y=m&&le(m)?m.getBoundingClientRect():void 0,w=()=>{let u=p.getBoundingClientRect(),h=c.getBoundingClientRect(),M=m&&le(m)?m.getBoundingClientRect():void 0;return{top:Math.max(u.top,h.top),bottom:Math.min(u.bottom,h.bottom,M&&M.height>0?M.top:1/0)}},v=w(),x=[...o.querySelectorAll("[data-pw-path]")].filter(le),_=u=>u.dataset.pwType??"",O=u=>p.contains(u),L=(u,h)=>{let M=u.getBoundingClientRect(),E=Math.max(M.top,h.top),P=Math.min(M.bottom,h.bottom);for(let $=u.parentElement;$&&o.contains($)&&!$.classList.contains("pw2-body")&&!$.classList.contains("pw2");$=$.parentElement){let k=getComputedStyle($);if(k.overflowX==="visible"&&k.overflowY==="visible")continue;let D=$.getBoundingClientRect();Math.min(M.right,D.right)-Math.max(M.left,D.left)<=0&&(P=E),E=Math.max(E,D.top),P=Math.min(P,D.bottom)}return{top:E,bottom:P,r:M,area:h}},R=u=>L(u,O(u)?v:b),j=Math.max(c.scrollWidth-c.clientWidth,p.scrollWidth-p.clientWidth);j>1&&i("overflow_x","the page",`the paywall is ${Z(j)}px wider than the screen: it moves sideways`);let N=new Set;for(let u of x){if(Ke(u,o)||[...N].some(E=>E.contains(u)))continue;let h=u.getBoundingClientRect(),M=Math.max(b.left-h.left,h.right-b.right);M>1&&(N.add(u),i("overflow_x",u,`it reaches ${Z(M)}px past the screen\'s ${h.right>b.right?"right":"left"} edge`))}let Q=x.filter(u=>_(u)==="text");for(let u of Q){if(u.classList.contains("pw-clamp")&&u.scrollHeight>u.clientHeight+1){i("text_cut",u,"its text is cut off: it needs more lines than its max_lines gives at this size");continue}if(u.scrollWidth>u.clientWidth+1){i("text_cut",u,`a word is ${Z(u.scrollWidth-u.clientWidth)}px wider than its place and is cut`);continue}let h=Ke(u,o)?void 0:Zt(u,o);if(h){let P=u.getBoundingClientRect(),$=h.getBoundingClientRect(),k=Math.max($.top-P.top,P.bottom-$.bottom,$.left-P.left,P.right-$.right);if(k>1){i("text_cut",u,`${Z(k)}px of its text is hidden by ${Ce(h)}, which clips what overflows it`);continue}}let M=document.createTreeWalker(u,NodeFilter.SHOW_TEXT),E;for(let P=M.nextNode();P&&!E;P=M.nextNode())for(let $ of(P.textContent??"").matchAll(/\\S+/g)){let k=document.createRange();if(k.setStart(P,$.index),k.setEnd(P,$.index+$[0].length),new Set([...k.getClientRects()].filter(q=>q.width>0).map(q=>Math.round(q.top))).size>1){E=$[0];break}}E&&i("word_broken",u,`"${E}" is broken across lines: a word, a price above all, is drawn whole`)}let te=x.filter(u=>_(u)==="purchase_button"&&!o.querySelector(".pw-layer")?.contains(u));if(te.length===0)i("purchase_hidden","the paywall","nothing on it buys: it has no purchase button where it is drawn");else if(!te.some(u=>{let h=R(u);return h.r.top>=h.area.top-1&&h.r.bottom<=h.area.bottom+1})){let u=R(te[0]),h=u.r.top>=u.area.bottom?`${Z(u.r.top-u.area.bottom)}px below what shows`:`${Z(u.r.height-Math.max(0,u.bottom-u.top))}px of it hidden`;i("purchase_hidden",te[0],`the purchase button is not on the screen as the paywall opens (${h}): a customer scrolls to find it \\u2014 keep it in the fixed footer`)}if(y&&y.height>0){let u=[p,c].filter(M=>/^(auto|scroll)$/.test(getComputedStyle(M).overflowY)&&M.scrollHeight>M.clientHeight+1),h=u.map(M=>M.scrollTop);for(let M of u)M.scrollTop=M.scrollHeight;try{let M=w(),E=new Set;for(let P of x.filter($=>O($)&&$.matches(bt))){if(Ke(P,o)||[...E].some(k=>k.contains(P)))continue;let $=L(P,{top:-1/0,bottom:1/0});if($.bottom>$.top&&$.bottom>M.bottom+1){E.add(P);let k=Math.min($.bottom-M.bottom,$.bottom-$.top);i("covered_by_footer",P,`${Z(k)}px of its ${Z($.r.height)}px ${k>=$.bottom-$.top-1?"(all of it) ":""}stay under the fixed footer with the paywall scrolled to its end: nothing brings it into view \\u2014 end the body with room as tall as the footer (padding or a spacer)`)}}}finally{u.forEach((M,E)=>{M.scrollTop=h[E]})}}let ve=new Set(["stack","tabs","switch","carousel","countdown"]),he=[...o.querySelectorAll(".pw-switchrow, .pw-tablist, .pw-dots")].filter(le);he.push(...x.filter(u=>{let h=_(u);if(h==="spacer")return!1;if(!ve.has(h))return!0;let M=u.parentElement;if(M&&(M.classList.contains("pw2-head")||M.classList.contains("pw2-body")||M.classList.contains("pw2-foot")))return!1;let E=getComputedStyle(u),P=se(E.backgroundColor);return E.backgroundImage!=="none"||P!==void 0&&P[3]>0||u.style.getPropertyValue("--pw-bw")!==""}));let me=he.filter(u=>{let h=R(u);return h.bottom>h.top}),Ae=me.map(R).map(u=>[u.top,u.bottom]).sort((u,h)=>u[0]-h[0]),K={size:0,from:b.top,to:b.top},X=b.top;for(let[u,h]of Ae)u-X>K.size&&(K={size:u-X,from:X,to:u}),X=Math.max(X,h);if(b.bottom-X>K.size&&(K={size:b.bottom-X,from:X,to:b.bottom}),K.size>t.height*ut){let u=me.filter(E=>Math.abs(R(E).bottom-K.from)<1).pop(),h=me.find(E=>Math.abs(R(E).top-K.to)<1),M=u&&h?`between ${ue(u)} and ${ue(h)}`:u?`below ${ue(u)}`:h?`above ${ue(h)}`:"on the screen";i("large_gap",u?Ce(u):h?Ce(h):"the paywall",`a ${Z(K.size)}px empty band (${Math.round(K.size/t.height*100)}% of the screen) ${M}: no single empty space is over ${Math.round(ut*100)}%`)}let xe=new Set,be=document.createTreeWalker(c,NodeFilter.SHOW_TEXT);for(let u=be.nextNode();u;u=be.nextNode())(u.textContent??"").trim()!==""&&u.parentElement&&xe.add(u.parentElement);let ne=new Map;for(let u of xe){if(!le(u)||u.closest(".pw-grad")||u.closest("button:disabled, [aria-disabled=true]"))continue;let h=mt(u);if(!h){let D=Yt(u);D&&ne.set(D,[...ne.get(D)??[],wt(u)]);continue}let M=getComputedStyle(u),E=parseFloat(M.fontSize),P=E>=24||E>=18.66&&Number(M.fontWeight)>=700,$=P?3:4.5,k=gt(h.text,h.bg);k<$&&i("contrast",u,`its text is ${We(k)} against what is behind it (${ht(h.text)} on ${ht(h.bg)}): ${P?"large ":""}text needs ${We($)}`)}for(let[u,h]of ne){let M=h.slice(0,3).map(P=>`"${P}"`).join(", "),E=u.dataset?.pwPath!==void 0||u.closest("[data-pw-path]")?ue(u).replace(/ ".*"$/,""):"the page";n.push({code:"unmeasured_contrast",where:E,message:`not measured: ${h.length} text(s) over its picture or gradient \\u2014 ${M}${h.length>3?" \\u2026":""} \\u2014 whose colors the check does not read; look at them (purchases:paywalls:preview)`,note:!0})}let B=u=>{let h=getComputedStyle(u),M=se(h.backgroundColor);return h.backgroundImage!=="none"||M!==void 0&&M[3]>0||(u.style?.getPropertyValue("--pw-bw")??"")!==""||parseFloat(h.borderTopWidth)>0},ye=u=>{for(let h=u,M=0;h&&M<4;h=h.firstElementChild,M++)if(B(h))return h;return u},de=new Map;for(let u of[...o.querySelectorAll("[role=radio], [role=tab]")].filter(le)){let h=u.parentElement;de.set(h,[...de.get(h)??[],u])}for(let[,u]of de){let h=u.find(k=>k.getAttribute("aria-checked")==="true"||k.getAttribute("aria-selected")==="true");if(!h||u.length<2)continue;let M=k=>{let D=ye(k),q=yt(D),oe=getComputedStyle(D),U=Xt(oe.getPropertyValue("--pw-bc"))??se(oe.borderTopColor),pe=parseFloat(oe.getPropertyValue("--pw-bw"))||parseFloat(oe.borderTopWidth)||0,Le=[...k.querySelectorAll("*")].find(Ie=>[...Ie.childNodes].some(_e=>_e.nodeType===3&&(_e.textContent??"").trim()!==""));return{bg:q?.color,border:pe>0&&U&&q?Ge(U,q.color):q?.color,text:Le?mt(Le)?.text:void 0}},E=M(h),P=1/0,$;for(let k of u.filter(D=>D!==h)){let D=M(k),q=[[E.bg,D.bg],[E.border,D.border],[E.text,D.text]].filter(([U,pe])=>U&&pe);if(q.length===0)continue;let oe=Math.max(...q.map(([U,pe])=>gt(U,pe)));oe<P&&(P=oe,$=k)}if($&&P<3){let k=h.getAttribute("role")==="tab"?"tab":"package";i("selection_contrast",h,`the selected ${k} differs from ${ue($)} by ${We(P)} at most \\u2014 in its fill, its border and its text: what shows it is selected needs 3:1`)}}let Y=Gt[t.platform];for(let u of[...o.querySelectorAll(bt)].filter(le)){if(u.closest(".pw-text")||u.closest(".pw-dots")||u.getAttribute("role")==="switch"||u.disabled)continue;let h=u.getBoundingClientRect();(h.width<Y||h.height<Y)&&i("small_target",u,`it is ${Z(h.width)}\\xD7${Z(h.height)}: ${t.platform==="web"||t.platform==="macos"?"a pointer needs":"a finger needs"} ${Y}\\xD7${Y} \\u2014 give it padding or a height`)}for(let u of x.filter(h=>_(h)==="image"||_(h)==="video")){let h=u.querySelector("img, video");if(!h||(h instanceof HTMLImageElement?h.complete&&h.naturalWidth===0:h.readyState<2)){let E=t.nodeAt(u.dataset.pwPath??"")?.src;i("image_missing",u.dataset.pwPath??"an image",`the ${_(u)} did not load${typeof E=="string"?` (${E})`:""}: it is drawn as an empty frame`)}}for(let u of x.filter(h=>_(h)==="package")){let h=[...u.querySelectorAll("[data-pw-type=text]")].filter(le).map(E=>(E.textContent??"").replace(/\\s+/g," ").trim()).filter(E=>E!==""),M=(E,P)=>{let $=D=>` ${D.replace(/[^\\p{L}\\p{N}]+/gu," ").trim()} `,k=$(E);return k.trim().length>=3&&$(P).includes(k)};e:for(let E=0;E<h.length;E++)for(let P=0;P<h.length;P++)if(!(E===P||h[E].length>h[P].length)&&M(h[E],h[P])){i("repeated_text",u,`"${h[E]}" is said twice in one package: in "${h[E]}" and in "${h[P]}"`);break e}}return n}var ce=(o,t,n)=>`M${o-n} ${t}a${n} ${n} 0 1 0 ${2*n} 0a${n} ${n} 0 1 0 ${-2*n} 0`,Oe={ad_free:["M3 7h18v10H3z","M4 4l16 16"],bell:["M6 16v-5a6 6 0 0 1 12 0v5l2 2H4z","M10 21a2 2 0 0 0 4 0"],bolt:["M13 2L4 14h7l-1 8 9-12h-7z"],book:["M5 4h11a3 3 0 0 1 3 3v13H8a3 3 0 0 1-3-3z","M5 17a3 3 0 0 1 3-3h11"],chart:["M3 20h18","M6 20v-8","M11 20V5","M16 20v-6","M21 20V9"],chat:["M4 5h16v11H9l-5 4z"],check:["M5 12l5 5 9-10"],check_circle:[ce(12,12,9),"M8 12l3 3 5-6"],clock:[ce(12,12,9),"M12 7v5l3 2"],cloud:["M7 18a4 4 0 0 1-.5-7.97A6 6 0 0 1 18 9a4.5 4.5 0 0 1-.5 9z"],crown:["M3 8l4 4 5-7 5 7 4-4-2 11H5z"],download:["M12 4v11","M7 10l5 5 5-5","M4 20h16"],gift:["M3 9h18v4H3z","M5 13v8h14v-8","M12 9v12","M12 9C10 5 6 5 6 7.5S12 9 12 9zm0 0c2-4 6-4 6-1.5S12 9 12 9z"],globe:[ce(12,12,9),"M3 12h18","M12 3a14 14 0 0 1 0 18a14 14 0 0 1 0-18z"],heart:["M12 20s-7-4.5-9-9a4.5 4.5 0 0 1 9-3 4.5 4.5 0 0 1 9 3c-2 4.5-9 9-9 9z"],infinity:["M7 9a3 3 0 1 0 0 6c3 0 7-6 10-6a3 3 0 1 1 0 6c-3 0-7-6-10-6z"],lock_open:["M5 11h14v10H5z","M8 11V7a4 4 0 0 1 7.5-2"],music:["M9 18V5l11-2v13",ce(6,18,3),ce(17,16,3)],people:[ce(9,8,3.5),"M2 20a7 7 0 0 1 14 0","M16 4.5a3.5 3.5 0 0 1 0 7","M18 14a6 6 0 0 1 4 6"],person:[ce(12,8,4),"M4 21a8 8 0 0 1 16 0"],photo:["M3 5h18v14H3z",ce(8.5,9.5,1.5),"M3 17l5-5 4 4 3-3 6 6"],shield:["M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z"],sparkles:["M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8z","M19 15l.8 2.2L22 18l-2.2.8L19 21l-.8-2.2L16 18l2.2-.8z"],star:["M12 3l2.8 5.7 6.2.9-4.5 4.4 1 6.2L12 17.3l-5.5 2.9 1-6.2L3 9.6l6.2-.9z"],video:["M3 6h12v12H3z","M15 10l6-3v10l-6-3z"],arrow_right:["M4 12h15","M13 6l6 6-6 6"],calendar:["M4 6h16v15H4z","M4 10h16","M8 3v5","M16 3v5"],close:["M6 6l12 12","M18 6L6 18"],lock:["M5 11h14v10H5z","M8 11V7a4 4 0 0 1 8 0v4"],play:["M7 4l13 8-13 8z"],quote:["M5 17c3 0 4-2 4-5V7H4v5h3","M15 17c3 0 4-2 4-5V7h-5v5h3"],trophy:["M7 4h10v5a5 5 0 0 1-10 0z","M7 6H4v2a3 3 0 0 0 3 3","M17 6h3v2a3 3 0 0 1-3 3","M12 14v4","M8 21h8","M9 18h6v3H9z"]};var vt="http://www.w3.org/2000/svg";function ze(o,t,n){let i=o.createElementNS(vt,"svg");i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("width",String(n)),i.setAttribute("height",String(n)),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.setAttribute("aria-hidden","true"),i.setAttribute("focusable","false");for(let c of t){let p=o.createElementNS(vt,"path");p.setAttribute("d",c),i.append(p)}return i}var g=(o,t=!1)=>({kind:"value",value:"plain",def:o,required:t}),J=o=>({kind:"value",value:"color",def:o}),xt=o=>({kind:"value",value:"spacing",def:o}),Qt=o=>({kind:"value",value:"radius",def:o}),ge=(o=!1)=>({kind:"text",required:o}),Xe=(o,t=!1)=>({kind:"list",item:o,required:t}),Ee=(o,t=!1)=>({kind:"object",item:o,required:t}),St=(o=!1)=>({kind:"component",required:o}),Ye={kind:"components"},Mt={stack:{axis:g("vertical"),spacing:xt(0),align:g("center"),distribution:g("start"),scroll:g(!1),children:Ye},text:{text:ge(),spans:Xe("span"),font:g(),size:g(),weight:g(),line_height:g(),letter_spacing:g(),color:{kind:"value",value:"textColor",def:"text"},align:g("center"),max_lines:g(),uppercase:g(!1)},image:{src:g(void 0,!0),fit:g("fit"),aspect:g(),mask:Ee("mask"),overlay:{kind:"value",value:"textColor"},alt:ge(),decorative:g(!1)},icon:{name:g(void 0,!0),color:J("accent"),size:g(24)},video:{src:g(void 0,!0),poster:g(),autoplay:g(!0),loop:g(!0),mute:g(!0),controls:g(!1),fit:g("fill"),aspect:g(),alt:ge()},button:{action:Ee("action",!0),content:St(!0)},purchase_button:{content:St(!0),package:g()},package:{product:g(void 0,!0),plan:g(void 0,!0),selected:g(!1),offer:g(),children:Ye},tabs:{},switch:{},carousel:{pages:Ye,peek:g(0),spacing:g(8),loop:g(!1),auto_advance_ms:g(),indicator:Ee("indicator"),height:g("")},countdown:{},timeline:{items:Xe("timeline_item",!0),line_color:J("accent"),line_width:g(2),icon_color:J("on_accent"),color:J("text"),spacing:g(16)},features:{items:Xe("feature",!0),icon_color:J("accent"),color:J("text"),spacing:g(12)},spacer:{size:xt()},divider:{color:J("muted"),thickness:g(1)},custom_html:{src:g(void 0,!0),height:g("",!0)}},en={style:{padding:{kind:"edges"},margin:{kind:"edges"},width:g(""),height:g(""),max_width:g(),background:{kind:"fill"},border:Ee("border"),corners:{kind:"corners"},shadow:Ee("shadow"),opacity:g(1)},border:{width:g(),color:J("")},shadow:{color:J(""),radius:g(0),x:g(0),y:g(0)},linear:{type:g(""),angle:g(180),stops:g()},radial:{type:g(""),center_x:g(.5),center_y:g(.5),radius:g(.5),stops:g()},image_fill:{type:g(""),src:g(),fit:g("fill")},video_fill:{type:g(""),src:g(),poster:g(),loop:g(!0)},animation:{type:g(""),duration_ms:g(300),delay_ms:g(0),easing:g("ease_out")},action:{type:g(""),url:g(),sheet:g(),package:g()},mask:{shape:g(""),radius:Qt(0),depth:g(16)},span:{text:ge(!0),bold:g(!1),italic:g(!1),underline:g(!1),strikethrough:g(!1),color:J(""),link:g()},timeline_item:{icon:g(void 0,!0),title:ge(!0),text:ge(),color:J("")},feature:{icon:g(void 0,!0),text:ge(!0)},indicator:{style:g("dots"),color:J("muted"),active_color:J("accent"),size:g(8),spacing:g(6)},typography:{font:g("system"),size:g(),weight:g(400),line_height:g(),letter_spacing:g(0),text_style:g("body")}},Et=new Set(["package","purchase_button"]),tn={action:{type:g(""),url:g(),link:g(),sheet:g(),placement:g(),name:g(),value:g(),offer:g(),dismiss:g(!0)},presentation:{type:g(""),position:g("bottom"),auto_dismiss_seconds:g(),dismissible:g(!0),backdrop:J("#00000080")}},nn={modal:["type","dismissible","backdrop"],fullscreen:["type"],banner:["type","position","auto_dismiss_seconds","dismissible"],card:["type"]},on={linear:"linear",radial:"radial",image:"image_fill",video:"video_fill"},sn=["top","bottom","leading","trailing"],rn=["top_leading","top_trailing","bottom_leading","bottom_trailing"],an=Object.keys(Mt),zn=an.filter(o=>!Et.has(o)),Rt=/\\{\\{\\s*([^{}]*?)\\s*\\}\\}/g,we=(o,t)=>typeof o=="object"&&o!==null&&Object.hasOwn(o,t),T=o=>typeof o=="object"&&o!==null&&!Array.isArray(o)?o:{},ie=o=>Array.isArray(o)?o:[],fe=(o,t)=>o??t;function ln(o){let t="";for(let n of new TextEncoder().encode(o)){let i=String.fromCharCode(n);t+=/^[A-Za-z0-9._~-]$/.test(i)?i:`%${n.toString(16).toUpperCase().padStart(2,"0")}`}return t}function cn(o){let t=Math.floor(o/86400),n=Math.floor(o%86400/3600),i=Math.floor(o%3600/60),c=o%60,p=b=>String(b).padStart(2,"0");return{countdown:t>0?`${t}d ${p(n)}:${p(i)}:${p(c)}`:n>0?`${n}:${p(i)}:${p(c)}`:`${p(i)}:${p(c)}`,days:String(t),hours:p(n),minutes:p(i),seconds:p(c)}}function dn(o){let t=new Map,n=c=>{if(Array.isArray(c))return c.forEach(n);if(typeof c!="object"||c===null)return;let p=c;if(p.type==="package"&&typeof p.offer=="string"){let m=`${p.product}.${p.plan}`;t.has(m)||t.set(m,p.offer)}for(let m of Object.keys(p).sort())n(p[m])},i=o;for(let c of["header","root","footer","sheets"])n(i[c]);return t}function Fe(o,t){return new je("paywall",o,t).resolve()}function At(o,t){let{variables:n,...i}=t;return new je("message",o,{...i,packages:{"":{...n}}}).resolve()}var je=class{kind;d;opts;lang;texts={};palette;typography={};radii;spacing;packages;offers;selected="";tab="";paths=new WeakMap;tabsShown={};switchesOn={};countdowns={};constructor(t,n,i){this.kind=t,this.d=n,this.opts=i,this.offers=dn(n);let c={};for(let[w,v]of Object.entries(i.packages??{})){let x={...v};this.open(w)||(v.price!==void 0?x.offer_price=v.price:delete x.offer_price),c[w]=x}this.packages=c;let p=T(this.d.locales),m=String(this.d.default_locale??""),b=i.locale;we(p,b)||(b=b.split("-")[0]??"",we(p,b)||(b=m)),this.lang=b;for(let w of[m,b])for(let[v,x]of Object.entries(T(p[w])))typeof x=="string"&&(this.texts[v]=x);let y=T(this.d.theme);this.palette=T(T(y.colors)[i.appearance]);for(let[w,v]of Object.entries(T(y.typography))){let x={};for(let[_,O]of Object.entries(this.objectFields("typography"))){let L=fe(T(v)[_],O.def);L!=null&&(x[_]=L)}this.typography[w]=x}this.radii=T(y.radii),this.spacing=T(y.spacing)}open(t){let n=this.offers.get(t);return n!==void 0&&(this.opts.offers??[]).includes(n)}fields(t){if(!(this.kind==="message"&&Et.has(t)))return Mt[t]}objectFields(t){return(this.kind==="message"?tn[t]:void 0)??en[t]??{}}resolve(){let[t,n]=this.initialState();this.tab=t,this.selected=this.kind==="paywall"?n:"";let i={theme:{colors:this.palette,typography:this.typography,radii:this.radii,spacing:this.spacing}};this.kind==="paywall"&&(i.selected=n);let c=this.d.presentation;if(typeof c=="object"&&c!==null){let m=this.item("presentation",T(c),void 0)??{},b=nn[String(T(c).type)]??[];for(let y of Object.keys(m))b.includes(y)||delete m[y];i.presentation=m}for(let m of["header","root","footer"]){let b=this.d[m];if(typeof b=="object"&&b!==null){let y=this.component(T(b),m,"",!1);y&&(i[m]=y)}}let p={};if(typeof this.d.sheets=="object"&&this.d.sheets!==null){let m={};for(let[b,y]of Object.entries(T(this.d.sheets))){let w=this.component(T(T(y).root),`sheets.${b}.root`,"",!1);w&&(m[b]=w);let v=this.text(T(y).title,this.packages[this.selected]);v!==null&&(p[b]=v)}i.sheets=m}return{tree:i,pathOf:m=>this.paths.get(m),tabs:this.tabsShown,switches:this.switchesOn,sheetTitles:p,countdowns:this.countdowns,language:this.lang}}switchOn(t,n){return this.opts.switches&&Object.hasOwn(this.opts.switches,n)?this.opts.switches[n]:this.opts.switch?this.opts.switch==="on":t.default===!0}tabShown(t,n){let c=ie(t.tabs).map(T).map(m=>String(m.id)),p=this.opts.tabs?.[n];return p!==void 0&&c.includes(p)?p:this.opts.tab?this.opts.tab:typeof t.default=="string"&&t.default!==""?t.default:c[0]??""}initialState(){let t="",n="",i="",c="",p=(b,y)=>{if(Array.isArray(b)){b.forEach((v,x)=>p(v,`${y}[${x}]`));return}if(typeof b!="object"||b===null)return;let w=b;switch(w.type){case"package":{let v=`${w.product}.${w.plan}`;i===""&&(i=v),w.selected===!0&&n===""&&(n=v);break}case"switch":{let v=this.switchOn(w,y),x=v?w.on_package:w.off_package;typeof x=="string"&&c===""&&(c=x),p(v?w.on:w.off,`${y}.${v?"on":"off"}`);return}case"tabs":{let v=this.tabShown(w,y);t===""&&(t=v),ie(w.tabs).forEach((x,_)=>{let O=T(x);O.id===v&&(typeof O.package=="string"&&c===""&&(c=O.package),p(O.content,`${y}.tabs[${_}].content`))});return}}for(let v of Object.keys(w).sort())v!=="sheets"&&p(w[v],y===""?v:`${y}.${v}`)};for(let b of["header","root","footer"])p(this.d[b],b);let m=this.opts.selected||c||n||i;return[t,m]}holds(t,n){let i=n||this.selected;for(let[c,p]of Object.entries(t))switch(c){case"selected_package":if(!ie(p).includes(this.selected))return!1;break;case"intro_eligible":if((this.opts.eligible??[]).includes(i)!==p)return!1;break;case"offer_open":if(this.open(i)!==p)return!1;break;case"platform":if(!ie(p).includes(this.opts.platform))return!1;break;case"locale":if(!ie(p).includes(this.opts.locale)&&!ie(p).includes(this.lang))return!1;break;case"appearance":if(p!==this.opts.appearance)return!1;break;case"tab":if(p!==this.tab)return!1;break}return!0}component(t,n,i,c){if(typeof t.visible=="object"&&t.visible!==null&&!this.holds(T(t.visible),i))return null;let p=String(t.type),m=i,b=c;p==="package"&&(m=`${t.product}.${t.plan}`,b=m===this.selected);let y={type:p};this.paths.set(y,n),we(t,"id")&&(y.id=t.id);let w={...T(t.style)};b&&Object.assign(w,T(T(t.states).selected)),Object.keys(w).length>0&&(y.style=this.style(w)),typeof t.animation=="object"&&t.animation!==null&&(y.animation=this.defaults(T(t.animation),this.objectFields("animation")));let v=this.packages[m||this.selected];switch(p){case"tabs":return this.tabs(t,y,n,m);case"switch":return this.switchOf(t,y,n,m,b);case"countdown":return this.countdown(t,y,n,m,b);case"purchase_button":{let x=typeof t.package=="string"?t.package:this.selected;y.package=x,this.open(x)&&(y.offer=this.offers.get(x));let _=this.component(T(t.content),`${n}.content`,x,b);return _?(y.content=_,y):null}case"package":y.product=t.product,y.plan=t.plan,y.selected=b,typeof t.offer=="string"&&(this.opts.offers??[]).includes(t.offer)&&(y.offer=t.offer)}for(let[x,_]of Object.entries(this.fields(p)??{})){if(p==="package"&&(x==="product"||x==="plan"||x==="selected"||x==="offer"))continue;let O=t[x],L=we(t,x);switch(_.kind){case"component":{if(!L)continue;let R=this.component(T(O),`${n}.${x}`,m,b);if(!R&&_.required)return null;R&&(y[x]=R);break}case"components":{let R=[];ie(O).forEach((j,N)=>{let Q=this.component(T(j),`${n}.${x}[${N}]`,m,b);Q&&R.push(Q)}),y[x]=R;break}case"text":{let R=this.text(O,v);if(R!==null)y[x]=R;else if(_.required||p==="text"&&x==="text"&&L)return null;break}case"list":{let R=[];for(let j of ie(O)){let N=this.item(_.item,T(j),v);N&&R.push(N)}if(p==="text"&&R.length===0&&L)return null;L&&(y[x]=R);break}case"object":{if(L){let R=this.object(T(O),_.item,v);if(R===null&&_.required)return null;y[x]=R}else x==="indicator"&&(y[x]=this.object({},_.item,v));break}case"value":{let R=this.value(fe(O,_.def),_);R!=null&&R!==""&&(y[x]=R);break}}}return p==="text"&&this.typeStyle(y),y}typeStyle(t){if(typeof t.size!="string"){t.size!==void 0&&t.size!==null&&(t.text_style="body");return}let n=this.typography[t.size];for(let i of["font","weight","line_height","letter_spacing","text_style"])!we(t,i)&&n?.[i]!==void 0&&n?.[i]!==null&&(t[i]=n[i]);t.size=n?.size??null}tabs(t,n,i,c){let p=this.tabShown(t,i);this.tabsShown[i]=p;let m=[];return ie(t.tabs).forEach((b,y)=>{let w=T(b),v=w.id===p,x=this.component(T(w.label),`${i}.tabs[${y}].label`,c,v);if(m.push({id:w.id,selected:v,label:x}),v){let _=this.component(T(w.content),`${i}.tabs[${y}].content`,c,!1);_&&(n.content=_)}}),n.tabs=m,typeof t.bar=="object"&&t.bar!==null&&(n.bar=this.style(T(t.bar))),n}switchOf(t,n,i,c,p){let m=this.switchOn(t,i);this.switchesOn[i]=m,n.on=m;let b=this.text(t.label,this.packages[c||this.selected]);b!==null&&(n.label=b),n.tint=this.color(String(fe(t.tint,"accent")));let y=m?"on":"off",w=this.component(T(t[y]),`${i}.${y}`,c,p);return w&&(n.content=w),n}countdown(t,n,i,c,p){let m=T(t.target),b=this.opts.now??Date.now(),y;if(typeof m.after_open_seconds=="number"?y=Math.trunc(m.after_open_seconds)-(this.opts.openedSecondsAgo??0):y=Math.trunc((Date.parse(String(m.at))-b)/1e3),y>0){n.state="counting",n.remaining_seconds=y,this.countdowns[i]=y;let w=this.packages,v={};for(let[_,O]of Object.entries(w))v[_]={...O,...cn(y)};this.packages=v;let x=this.component(T(t.counting),`${i}.counting`,c,p);return x&&(n.content=x),this.packages=w,n}if(n.state="ended",n.remaining_seconds=0,typeof t.ended=="object"&&t.ended!==null){let w=this.component(T(t.ended),`${i}.ended`,c,p);w&&(n.content=w)}return n}item(t,n,i){let c={};for(let[p,m]of Object.entries(this.objectFields(t))){let b=n[p];if(m.kind==="text"){let y=this.text(b,i);if(y!==null)c[p]=y;else if(m.required)return null}else{let y=m.def,w=this.value(fe(b,y),m);w!=null&&(we(n,p)||y!=null&&y!=="")&&(c[p]=w)}}return c}object(t,n,i){if(n==="style")return this.style(t);let c=this.item(n,t,i)??{};if(n==="action")for(let p of["url","link"]){if(typeof c[p]!="string")continue;let m=pn(c[p],i);if(m===null)return null;c[p]=m}return c}defaults(t,n){let i={};for(let[c,p]of Object.entries(n)){let m=fe(t[c],p.def);m!=null&&m!==""&&(i[c]=m)}return i}style(t){let n={};for(let[i,c]of Object.entries(t)){let p=this.objectFields("style")[i];if(!p){n[i]=c;continue}switch(p.kind){case"edges":n[i]=this.sides(c,sn,this.spacing);break;case"corners":n[i]=this.sides(c,rn,this.radii);break;case"fill":n[i]=this.fill(c);break;case"object":{let m=T(c),b={};for(let[y,w]of Object.entries(this.objectFields(p.item))){let v=fe(m[y],w.def);v!=null&&v!==""&&(b[y]=this.value(v,w))}n[i]=b;break}default:n[i]=c}}return n}sides(t,n,i){let c={};for(let p of n){let m=typeof t=="object"&&t!==null?fe(T(t)[p],0):t;c[p]=Ze(m,i)}return c}fill(t){if(typeof t=="string")return{type:"color",color:this.color(t)};let n=T(t),i=this.defaults(n,this.objectFields(on[String(n.type)]??""));return Array.isArray(n.stops)&&(i.stops=n.stops.map(c=>({color:this.color(String(T(c).color)),at:T(c).at}))),i}value(t,n){if(n.kind!=="value")return t;switch(n.value){case"color":return typeof t=="string"&&t!==""?this.color(t):t;case"textColor":return typeof t=="string"?this.color(t):t==null?t:this.fill(t);case"spacing":return Ze(t,this.spacing);case"radius":return Ze(t,this.radii);default:return t}}color(t){let n=Object.hasOwn(this.palette,t)?this.palette[t]:void 0;return typeof n=="string"?n:t}text(t,n){let i;if(typeof t=="string")i=t;else if(typeof t=="object"&&t!==null&&!Array.isArray(t)){let p=t.t;i=typeof p=="string"&&Object.hasOwn(this.texts,p)?this.texts[p]:""}else return null;let c=!1;return i=i.replace(Rt,(p,m)=>{let b=n&&Object.hasOwn(n,m)?n[m]:void 0;return typeof b!="string"||b===""?(c=!0,""):b}),c||i.trim()===""?null:i}};function pn(o,t){let n=!1,i=o.replace(Rt,(c,p)=>{let m=t&&Object.hasOwn(t,p)?t[p]:void 0;return typeof m!="string"||m===""?(n=!0,""):ln(m)});return n?null:i}function Ze(o,t){return typeof o=="string"?Object.hasOwn(t,o)?t[o]:null:o}var un={packages:"Choose a plan",close:"Close",restore:"Restore purchases",page:(o,t)=>`${o} of ${t}`},ke={system:\'-apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif\',rounded:\'ui-rounded, "SF Pro Rounded", Nunito, "Varela Round", system-ui, -apple-system, sans-serif\',serif:\'ui-serif, "New York", "Iowan Old Style", Georgia, "Times New Roman", serif\',mono:\'ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace\'},fn=1.35,Lt=20,gn=new Set(["button","purchase_button","package","text"]),hn=new Set(["ar","he","fa","ur","ps","yi","dv","ug","ku","sd"]),_t={ease_out:"cubic-bezier(0.16, 1, 0.3, 1)",ease_in_out:"cubic-bezier(0.65, 0, 0.35, 1)",spring:"cubic-bezier(0.34, 1.56, 0.64, 1)"},mn={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},bn={start:"flex-start",center:"center",end:"flex-end",space_between:"space-between",space_around:"space-around",space_evenly:"space-evenly"},yn={stack:["children"],package:["children"],button:["content"],purchase_button:["content"],tabs:["tabs","content"],switch:["content"],carousel:["pages"],countdown:["content"]},wn={package:["selected"],purchase_button:["package"],switch:["on"],countdown:["state","remaining_seconds"]},kn=`\n:host{display:block;height:100%}\n.pw2{position:relative;box-sizing:border-box;display:flex;flex-direction:column;height:100%;overflow:hidden;font-family:${ke.system};font-size:1rem;line-height:1.3;-webkit-font-smoothing:antialiased;-webkit-text-size-adjust:100%;text-rendering:optimizeLegibility}\n.pw2 *,.pw2 *::before,.pw2 *::after{box-sizing:border-box}\n.pw2-head,.pw2-foot{flex:none;display:flex;flex-direction:column;position:relative;z-index:1}\n.pw2-head[hidden],.pw2-foot[hidden]{display:none}\n.pw2-foot{max-height:30%;overflow-y:auto;scrollbar-width:none}\n.pw2-foot .pw-text{font-size:min(var(--pw-fs,1rem),var(--pw-fs-max,21.6px))}\n.pw2.pw2-large{overflow-y:auto;overscroll-behavior:contain;scrollbar-width:none}\n.pw2.pw2-large>.pw2-body{flex:1 0 auto;overflow:visible;min-height:auto}\n.pw2.pw2-large>.pw2-foot{position:sticky;bottom:0}\n.pw2:not(.pw2-fit){padding-left:env(safe-area-inset-left,0px);padding-right:env(safe-area-inset-right,0px)}\n.pw2:not(.pw2-fit)>.pw2-head,.pw2:not(.pw2-fit)>.pw2-body.pw2-top{padding-top:env(safe-area-inset-top,0px)}\n.pw2:not(.pw2-fit)>.pw2-foot,.pw2:not(.pw2-fit)>.pw2-body.pw2-bottom{padding-bottom:env(safe-area-inset-bottom,0px)}\n.pw2.pw2-fit{height:auto;flex:0 1 auto;min-height:0}\n.pw2-body{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;display:flex;flex-direction:column;overscroll-behavior:contain;scrollbar-width:none}\n.pw2-body::-webkit-scrollbar{display:none}\n.pw2-body>.pw-c{flex:1 0 auto}\n/* A part as wide as its place \\u2014 narrower when it says how wide it is at most, then in the middle, as SwiftUI\'s stacks place it. */\n.pw2-head>.pw-c,.pw2-body>.pw-c,.pw2-foot>.pw-c{align-self:center;width:100%}\n.pw-c{position:relative;min-width:0}\n.pw-c[style*="--pw-bw"]{isolation:isolate}\n.pw-c[style*="--pw-bw"]::after{content:"";position:absolute;inset:0;border:var(--pw-bw) solid var(--pw-bc);border-radius:inherit;pointer-events:none;z-index:2}\n.pw-stack{display:flex;flex-direction:column}\n.pw-stack.h{flex-direction:row}\n.pw-stack.z{display:grid}\n.pw-stack.z>.pw-c{grid-area:1/1}\n.pw-stack.scroll{overflow-y:auto;scrollbar-width:none}\n.pw-stack.h.scroll{overflow-x:auto;overflow-y:hidden}\n.pw-stack.scroll>.pw-c{flex-shrink:0}\n.pw-text{margin:0;overflow-wrap:break-word;white-space:pre-line}\n/* A text beside others wraps between its words, never inside one: a price stays whole, what is beside it wraps. */\n.pw-stack.h>.pw-text{min-width:min-content}\n.pw-text a{color:inherit}\n.pw-clamp{display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden}\n.pw-grad{-webkit-background-clip:text;background-clip:text;color:transparent!important;-webkit-text-fill-color:transparent}\n.pw-icon{display:inline-flex;flex:none}\n.pw-icon svg{display:block}\n.pw-img{overflow:hidden;flex:none}\n.pw-img img,.pw-img video{display:block;width:100%;height:100%}\n.pw-img.natural img{height:auto}\n.pw-overlay{position:absolute;inset:0;pointer-events:none}\n.pw-bgvideo{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;z-index:-1;pointer-events:none}\nbutton.pw-c{font:inherit;color:inherit;background:none;border:0;margin:0;padding:0;cursor:pointer;text-align:inherit;display:flex;flex-direction:column;align-items:stretch;justify-content:center;-webkit-tap-highlight-color:transparent;transition:opacity .15s ease,transform .15s ease}\nbutton.pw-c:active{transform:scale(.98)}\nbutton.pw-c:disabled{cursor:default;opacity:.5}\n.pw-pkg{cursor:pointer;display:flex;flex-direction:column;transition:background-color .2s ease,border-color .2s ease,box-shadow .2s ease}\n.pw-pkg[aria-disabled=true]{cursor:default;opacity:.55}\n:focus-visible{outline:2px solid currentColor;outline-offset:2px}\n.pw-features{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}\n.pw-feature{display:flex;align-items:center;gap:12px;text-align:start}\n.pw-timeline{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}\n.pw-step{display:grid;grid-template-columns:auto 1fr;column-gap:14px;position:relative;text-align:start}\n.pw-dot{width:32px;height:32px;border-radius:50%;display:grid;place-items:center;position:relative;z-index:1}\n.pw-line{position:absolute;left:calc(16px - var(--pw-line-w)/2);top:32px;width:var(--pw-line-w);bottom:calc(-1 * var(--pw-gap))}\n.pw-step:last-child .pw-line{display:none}\n.pw-step-title{font-weight:600}\n.pw-step-text{opacity:.72;font-size:.9375rem;margin-top:2px}\n.pw-tabs{display:flex;flex-direction:column;gap:12px}\n.pw-tablist{display:flex}\n.pw-tab{flex:1 1 0;min-width:0;font:inherit;color:inherit;background:none;border:0;margin:0;padding:0;cursor:pointer;display:flex}\n.pw-tab>.pw-c{flex:1 1 auto}\n.pw-switch{display:flex;flex-direction:column;gap:12px}\n.pw-switchcontent{display:flex;flex-direction:column}\n.pw-switchrow{display:flex;align-items:center;justify-content:space-between;gap:12px;text-align:start}\n.pw-toggle{flex:none;width:51px;height:31px;border-radius:999px;border:0;padding:2px;cursor:pointer;background:var(--pw-off);transition:background-color .2s ease}\n.pw-toggle[aria-checked=true]{background:var(--pw-tint)}\n.pw-toggle i{display:block;width:27px;height:27px;border-radius:50%;background:#fff;box-shadow:0 2px 4px #0003;transition:transform .2s ease}\n.pw-toggle[aria-checked=true] i{transform:translateX(20px)}\n.pw-carousel{display:flex;flex-direction:column;gap:12px;min-width:0}\n.pw-track{display:flex;overflow-x:auto;scroll-snap-type:x mandatory;scrollbar-width:none;scroll-behavior:smooth;padding-inline:var(--pw-peek);scroll-padding-inline:var(--pw-peek);gap:var(--pw-gap)}\n.pw-track::-webkit-scrollbar{display:none}\n.pw-track>.pw-c{flex:none;width:100%;scroll-snap-align:center}\n.pw-dots{display:flex;justify-content:center;gap:var(--pw-dot-gap)}\n.pw-dots button{border:0;padding:0;cursor:pointer;width:var(--pw-dot);height:var(--pw-dot);border-radius:999px;background:var(--pw-dot-c);transition:width .25s ease,background-color .25s ease}\n.pw-dots.bars button{width:calc(var(--pw-dot) * 3)}\n.pw-dots button[aria-current=true]{background:var(--pw-dot-on)}\n.pw-dots.dots button[aria-current=true]{width:calc(var(--pw-dot) * 2.5)}\n.pw-html{display:block;width:100%;border:0;pointer-events:none;background:transparent}\n.pw-spacer{flex:1 1 0}\n.pw-stack:not(.h):not(.z)>.greedy-h,.pw-pkg>.greedy-h,button.pw-c>.greedy-h{align-self:stretch}\n.pw-stack.h>.greedy-h{flex:1 1 0}\n.pw-stack.z>.greedy-h{justify-self:stretch}\n.pw-stack:not(.h):not(.z)>.greedy-v,.pw-pkg>.greedy-v{flex:1 1 auto}\n.pw-stack.h>.greedy-v,.pw-stack.z>.greedy-v{align-self:stretch}\n.pw-layer{position:absolute;inset:0;z-index:5;display:flex;flex-direction:column;justify-content:flex-end;background:#0007}\n.pw-sheet{max-height:92%;overflow-y:auto;border-radius:16px 16px 0 0;display:flex;flex-direction:column;outline:none;padding-bottom:env(safe-area-inset-bottom,0px)}\n.pw-sheet>.pw-c{flex:1 0 auto}\n.pw-grab{width:36px;height:5px;border-radius:3px;background:currentColor;opacity:.25;margin:8px auto 0;flex:none}\n[data-pw-highlight]{outline:2px solid #2E7CF6!important;outline-offset:-1px}\n[data-pw-hover]:not([data-pw-highlight]){outline:1px dashed #2E7CF6aa!important;outline-offset:-1px}\n.pw-editing button,.pw-editing .pw-pkg,.pw-editing a{cursor:default}\n@media (prefers-reduced-motion:reduce){.pw2 *{transition:none!important;scroll-behavior:auto!important}}\n`,Re=o=>{if(typeof o!="string"||o.length>2048)return!1;try{let t=new URL(o);return t.protocol==="https:"&&t.hostname!==""&&t.username===""&&t.password===""}catch{return!1}},vn=o=>{if(typeof o!="string"||o.length>2048||/[\\s\\u0000-\\u001f\\u007f]/.test(o))return!1;if(Re(o))return!0;let t=/^([a-z][a-z0-9+.-]{1,31}):(.+)$/.exec(o)?.[1];if(!t||xn.has(t))return!1;try{let n=new URL(o);return n.username===""&&n.password===""}catch{return!1}},xn=new Set(["https","http","javascript","data","file","vbscript","about","blob","content","intent"]),Sn=o=>`${String(o.product)}.${String(o.plan)}`,Ne=o=>{let[t,n]=o.split(".");return{product:t??"",plan:n??""}},C=o=>`${Number(o)||0}px`,Pt=o=>`${o/16}rem`,Mn=0;function $t(o,t,n){return En("paywall",o,t,n)}function En(o,t,n,i){let c=t.ownerDocument,p=c.defaultView,m=`pw${++Mn}`,b=c.createElement("div");b.setAttribute(o==="paywall"?"data-palbase-paywall":"data-palbase-message",""),b.style.display="block",b.style.height="100%";let y=b.attachShadow({mode:"open"});Rn(c,y,kn);let w=c.createElement("div");w.className="pw2";let v=c.createElement("div");v.className="pw2-head";let x=c.createElement("div");x.className="pw2-body";let _=c.createElement("div");_.className="pw2-foot";let O=c.createElement("div");w.append(v,x,_),y.append(w),t.replaceChildren(b);let L={...n},R={openedAt:Date.now(),...n.state},j,N=new Map,Q=new Map,te=!1,ve=null,he,me=!1,Ae=c.defaultView?.ResizeObserver,K=typeof Ae=="function"?new Ae(()=>{w.classList.toggle("pw2-large",u()>=Lt),h()}):null;K?.observe(w);let X=()=>h();c.fonts?.addEventListener?.("loadingdone",X);let xe=null,be=p?.matchMedia?.("(prefers-reduced-motion: reduce)"),ne=()=>L.reduceMotion??be?.matches??!1,B=()=>!!i.editor,ye={...un,...i.labels},de=()=>j.tree.selected??"";function Y(){let e=R.now??Date.now(),l={locale:L.locale,appearance:L.appearance,platform:L.platform??"web",tabs:R.tabs??{},switches:R.switches??{},openedSecondsAgo:Math.max(0,Math.floor((e-(R.openedAt??e))/1e3)),now:e};j=o==="paywall"?Fe(L.definition,{...l,packages:L.packages??{},eligible:L.eligible??[],offers:L.offers??[],...R.selected?{selected:R.selected}:{}}):At(L.definition,{...l,variables:L.variables??{}});let a=j.tree.theme.colors,s=j.tree.presentation?.type,r=o==="message"&&s!==void 0&&s!=="fullscreen";w.classList.toggle("pw2-fit",r),b.style.display=r?"flex":"block",b.style.flexDirection=r?"column":"",b.style.minHeight=r?"0":"",b.style.flex=r?"0 1 auto":"",b.style.height=r?"auto":"100%",w.style.background=r?"":a.background??"",w.style.color=a.text??"",w.classList.toggle("pw-editing",B()),w.classList.toggle("pw2-large",u()>=Lt),w.lang=j.language,w.dir=hn.has(j.language.split("-")[0]??"")?"rtl":"ltr",Q=new Map,M(v,j.tree.header,"vertical"),M(x,j.tree.root,"vertical"),M(_,j.tree.footer,"vertical"),v.hidden=!j.tree.header,_.hidden=!j.tree.footer,x.classList.toggle("pw2-top",!j.tree.header),x.classList.toggle("pw2-bottom",!j.tree.footer),Vt();for(let[d,f]of N)Q.has(d)||f.cleanup.forEach(S=>S());N=Q,ve&&rt(ve);for(let d of N.values())d.type==="custom_html"&&it(d.el);h(),clearTimeout(he),me||=b.isConnected,R.now===void 0&&Object.keys(j.countdowns).length>0&&(he=setTimeout(()=>{me&&!b.isConnected||Y()},1e3-Date.now()%1e3+5))}function u(){let e=c.documentElement,l=e&&p?parseFloat(p.getComputedStyle(e).fontSize):NaN;return Number.isFinite(l)?l:16}function h(){let e=[];for(let a of N.values()){if(a.type!=="text")continue;let s=a.el,r=s.dataset.pwFit??s.style.fontSize;if(!r||(s.style.fontSize=r,delete s.dataset.pwFit,!/^\\S+$/.test(s.textContent??"")))continue;let d=s.parentElement,f=d&&p?p.getComputedStyle(d):null,S=d&&f?d.clientWidth-parseFloat(f.paddingLeft||"0")-parseFloat(f.paddingRight||"0"):1/0,A=Math.min(s.clientWidth,S);e.push({e:s,base:r,k:A<=0||s.scrollWidth<=A+.5?1:Math.max(.6,A/s.scrollWidth)})}let l=a=>a.closest(".pw-stack.h");for(let a of e){let s=Math.min(a.k,...e.filter(r=>r!==a&&r.base===a.base&&l(r.e)&&l(r.e)===l(a.e)).map(r=>r.k));s>=1||(a.e.dataset.pwFit=a.base,a.e.style.fontSize=`calc(${a.base} * ${s.toFixed(3)})`)}}function M(e,l,a){let s=l?E(l,a,{inControl:!1,inSheet:!1,inFooter:e===_}):null;re(e,s?[s]:[])}function E(e,l,a){let s=j.pathOf(e)??"",r=P(e),d=N.get(s),f;if(d&&d.type===e.type&&d.key===r&&d.axis===l&&!Q.has(s))f=d;else{let A=D(e,s,l,a);if(!A)return null;f={el:A.el,type:e.type,key:r,styleKey:"",axis:l,slots:A.slots,cleanup:A.cleanup??[]},f.el.classList.add("pw-c"),f.el.dataset.pwPath=s,f.el.dataset.pwType=e.type,e.id&&(f.el.dataset.pwId=e.id),d&&d.cleanup.forEach(z=>z()),Ft(f.el,e)}let S=`${JSON.stringify(e.style??null)}|${l}`;return f.styleKey!==S&&(Qe(f.el,e,l),f.styleKey=S),Q.set(s,f),Ot(f,e),zt(f,e,a),f.el}function P(e){let l=new Set(["style",...yn[e.type]??[],...wn[e.type]??[]]),a={};for(let[s,r]of Object.entries(e))l.has(s)||(a[s]=r);return e.type==="tabs"&&(a.tabs=e.tabs.map(s=>s.id)),e.type==="carousel"&&(a.pages=e.pages.length),e.type==="stack"&&(a.greedy=e.children.some(s=>s.type==="spacer"&&typeof s.size!="number")),(e.type==="image"||e.type==="video"||e.type==="custom_html")&&(a.asset=$(e)),JSON.stringify(a)}function $(e){let l=Se(e.src);return l?(L.assets?.[l]?.url??L.assets?.[l]?.html?.length??"none").toString():""}function k(e,l){let a=c.createElement(e);return l&&(a.className=l),a}function D(e,l,a,s){let r=e;switch(e.type){case"stack":{let d=k("div",`pw-stack${r.axis==="horizontal"?" h":r.axis==="z"?" z":""}${r.scroll?" scroll":""}`);return r.axis!=="z"&&r.children.some(f=>f.type==="spacer"&&typeof f.size!="number")&&d.classList.add(r.axis==="horizontal"?"greedy-h":"greedy-v"),d.style.gap=C(r.spacing),r.axis==="z"?d.style.placeItems=r.align==="stretch"?"stretch":String(r.align??"center"):(d.style.alignItems=mn[String(r.align)]??"center",d.style.justifyContent=bn[String(r.distribution)]??"flex-start"),{el:d,slots:{children:d}}}case"text":return{el:q(r,s),slots:{}};case"icon":{let d=Oe[String(r.name)];if(!d)return null;let f=k("span","pw-icon");return f.style.color=String(r.color??""),f.append(ze(c,d,Number(r.size)||24)),f.setAttribute("aria-hidden","true"),{el:f,slots:{}}}case"image":return pe(r);case"video":return Le(r);case"features":{let d=k("ul","pw-features");d.style.gap=C(r.spacing);for(let f of r.items??[]){let S=k("li","pw-feature"),A=Oe[f.icon];if(A){let I=ze(c,A,22);I.style.color=String(r.icon_color),I.style.flex="none",S.append(I)}let z=k("span");z.textContent=f.text,z.style.color=String(r.color),S.append(z),d.append(S)}return{el:d,slots:{}}}case"timeline":{let d=k("ol","pw-timeline");d.style.gap=C(r.spacing),d.style.setProperty("--pw-gap",C(r.spacing)),d.style.setProperty("--pw-line-w",C(r.line_width));for(let f of r.items??[]){let S=k("li","pw-step"),A=k("span","pw-dot");A.style.background=f.color??String(r.line_color),A.style.color=String(r.icon_color);let z=Oe[f.icon];z&&A.append(ze(c,z,18)),A.setAttribute("aria-hidden","true");let I=k("span","pw-line");I.style.background=String(r.line_color),I.setAttribute("aria-hidden","true");let G=k("span");G.style.color=String(r.color);let ae=k("span","pw-step-title");if(ae.textContent=f.title,G.append(ae),f.text){let F=k("span","pw-step-text");F.style.display="block",F.textContent=f.text,G.append(F)}S.append(A,G,I),d.append(S)}return{el:d,slots:{}}}case"spacer":{let d=k("div","pw-spacer");return d.setAttribute("aria-hidden","true"),typeof r.size=="number"&&(d.style.flex="none",a==="horizontal"?d.style.width=C(r.size):d.style.height=C(r.size)),{el:d,slots:{}}}case"divider":{let d=k("div","pw-divider");return d.setAttribute("role","separator"),d.style.background=String(r.color),d.style.alignSelf="stretch",d.style.flex="none",a==="horizontal"?(d.setAttribute("aria-orientation","vertical"),d.style.width=C(r.thickness)):d.style.height=C(r.thickness),{el:d,slots:{}}}case"button":return Ie(r,s,l);case"purchase_button":{let d=k("button","pw-buy");return d.type="button",d.addEventListener("click",()=>{ot(d,()=>Bt(d.dataset.package??"",d.dataset.offer))}),{el:d,slots:{content:d}}}case"package":{let d=k("div","pw-pkg");return d.setAttribute("role","radio"),d.addEventListener("click",()=>qe(d)),d.addEventListener("keydown",f=>Nt(f,d)),{el:d,slots:{children:d}}}case"tabs":return Tt(r,l);case"switch":return Ct(r,l);case"carousel":return Ht(r);case"countdown":{let d=k("div","pw-countdown");return d.setAttribute("role","timer"),d.setAttribute("aria-live","off"),{el:d,slots:{content:d}}}case"custom_html":{let d=L.assets?.[Se(r.src)??""];if(!d?.html)return null;let f=k("iframe","pw-html");return f.setAttribute("sandbox","allow-scripts"),f.setAttribute("aria-hidden","true"),f.setAttribute("title",""),f.tabIndex=-1,f.srcdoc=d.html,typeof r.height=="number"?f.style.height=C(r.height):typeof r.height=="string"&&r.height.endsWith("%")?f.style.height=r.height:r.height==="fill"&&(f.style.flex="1 1 0"),f.addEventListener("load",()=>it(f)),{el:f,slots:{}}}default:return null}}function q(e,l){let a=String(e.text_style??"body"),s=l.inControl?"span":a==="large_title"?"h1":a==="title"||a==="title2"?"h2":a==="title3"?"h3":"p",r=k(s,"pw-text");l.inControl&&(r.style.display="block"),r.style.fontFamily=oe(e.font);let d=typeof e.size=="number"?e.size:16;if(l.inFooter?(r.style.setProperty("--pw-fs",Pt(d)),r.style.setProperty("--pw-fs-max",`${Number((d*fn).toFixed(2))}px`)):r.style.fontSize=Pt(d),typeof e.weight=="number"&&(r.style.fontWeight=String(e.weight)),typeof e.line_height=="number"&&(r.style.lineHeight=String(e.line_height)),typeof e.letter_spacing=="number"&&e.letter_spacing!==0&&(r.style.letterSpacing=C(e.letter_spacing)),r.style.textAlign=String(e.align??"center"),e.uppercase===!0&&(r.style.textTransform="uppercase"),typeof e.max_lines=="number"&&(r.classList.add("pw-clamp"),r.style.setProperty("-webkit-line-clamp",String(e.max_lines))),typeof e.color=="string"?r.style.color=e.color:e.color&&typeof e.color=="object"&&(r.classList.add("pw-grad"),r.style.backgroundImage=Ve(e.color)??""),Array.isArray(e.spans))for(let f of e.spans){let S=f.link==="terms"?L.links?.terms:f.link==="privacy"?L.links?.privacy:f.link,A=Re(S)&&!l.inControl,z=k(A?"a":"span");z.textContent=String(f.text),f.bold&&(z.style.fontWeight="700"),f.italic&&(z.style.fontStyle="italic");let I=[f.underline?"underline":"",f.strikethrough?"line-through":""].filter(Boolean).join(" ");I&&(z.style.textDecoration=I),typeof f.color=="string"&&f.color!==""&&(z.style.color=f.color),A&&Re(S)&&(z.href=S,z.target="_blank",z.rel="noopener noreferrer",z.addEventListener("click",G=>{B()||!i.onLink||(G.preventDefault(),i.onLink(S))})),r.append(z)}else r.textContent=String(e.text??"");return r}function oe(e){if(typeof e!="string")return ke.system;let l=Se(e);if(l){let a=L.assets?.[l]?.family;return a?`"${a}", ${ke.system}`:ke.system}return ke[e]??ke.system}function U(e){let l=Se(e);return l?L.assets?.[l]?.url||void 0:Re(e)?e:void 0}function pe(e){let l=k("div","pw-img");typeof e.aspect=="number"&&(l.style.aspectRatio=String(e.aspect));let a=U(e.src),s=e.mask;if(s?.shape==="circle")l.style.borderRadius="50%";else if(s?.shape==="rect"&&s.radius)l.style.borderRadius=C(s.radius);else if(s?.shape==="convex")l.style.setProperty("border-end-start-radius",`50% ${C(s.depth)}`),l.style.setProperty("border-end-end-radius",`50% ${C(s.depth)}`);else if(s?.shape==="concave"){let r=`radial-gradient(ellipse 50% ${C(s.depth)} at 50% 100%, transparent 98%, #000 100%)`;l.style.setProperty("-webkit-mask-image",r),l.style.setProperty("mask-image",r)}if(a){let r=k("img");r.src=a,r.decoding="async",r.style.objectFit=e.fit==="fill"?"cover":"contain",e.decorative===!0?(r.alt="",l.setAttribute("aria-hidden","true")):r.alt=String(e.alt??""),r.addEventListener("error",()=>r.style.visibility="hidden"),l.append(r)}if(e.overlay&&typeof e.overlay=="object"){let r=k("div","pw-overlay");r.style.backgroundImage=Ve(e.overlay)??"",l.append(r)}return{el:l,slots:{}}}function Le(e){let l=k("div","pw-img");typeof e.aspect=="number"&&(l.style.aspectRatio=String(e.aspect));let a=U(e.src);if(a){let s=k("video");s.src=a;let r=U(e.poster);r&&(s.poster=r),s.muted=e.mute!==!1,s.loop=e.loop!==!1,s.playsInline=!0,s.controls=e.controls===!0,s.preload="auto",s.style.objectFit=e.fit==="fit"?"contain":"cover",s.autoplay=e.autoplay!==!1&&!ne()&&!B(),typeof e.alt=="string"?s.setAttribute("aria-label",e.alt):s.setAttribute("aria-hidden","true"),l.append(s)}return{el:l,slots:{}}}function Ie(e,l,a){let s=e.action??{},r,d=s.type==="restore"||s.type==="offer_code"||s.type==="request_push"||s.type==="show_paywall"||s.type==="offer",f=o==="message"&&s.type!=="close"&&s.type!=="sheet"&&s.dismiss!==!1;switch(s.type){case"close":l.inSheet?r=()=>Te(null):i.onClose&&(r=()=>i.onClose());break;case"restore":i.onRestore&&(r=()=>i.onRestore());break;case"offer_code":i.onOfferCode&&(L.platform??"web")!=="web"&&(r=()=>i.onOfferCode());break;case"open_url":case"terms":case"privacy":{let A=s.type==="open_url"?s.url:s.type==="terms"?L.links?.terms:L.links?.privacy;Re(A)&&(r=()=>i.onLink?i.onLink(A):void p?.open(A,"_blank","noopener,noreferrer"));break}case"sheet":s.sheet&&(r=()=>Te(s.sheet));break;case"select_package":s.package&&(r=()=>Je(s.package));break;case"deep_link":{let A=s.link;vn(A)&&(r=()=>i.onDeepLink?i.onDeepLink(A):p?.location.assign(A));break}case"request_push":i.onRequestPush&&(r=()=>i.onRequestPush());break;case"show_paywall":s.placement&&i.onShowPaywall&&(r=()=>i.onShowPaywall(s.placement));break;case"custom":s.name&&i.onCustom&&(r=()=>i.onCustom(s.name,s.value));break;case"offer":s.offer&&i.onOffer&&(r=()=>i.onOffer(s.offer));break}if(!r&&!B())return null;let S=k("button");return S.type="button",s.type==="close"&&S.setAttribute("aria-label",ye.close),S.addEventListener("click",()=>{if(!r||B())return;o==="message"&&i.onAction?.(_e(s,a,e.id));let A=f?()=>i.onClose?.():void 0;d?ot(S,async()=>{await r(),A?.()}):(r(),A?.())}),{el:S,slots:{content:S}}}function _e(e,l,a){let s={type:e.type,dismiss:e.type==="sheet"?!1:e.type==="close"||e.dismiss!==!1,path:l};for(let r of["url","link","placement","name","value","sheet","offer"])typeof e[r]=="string"&&(s[r]=e[r]);return typeof a=="string"&&(s.id=a),s}function Tt(e,l){let a=k("div","pw-tabs"),s=k("div","pw-tablist");s.setAttribute("role","tablist");let r=k("div","pw-tabpanel");r.setAttribute("role","tabpanel"),r.id=`${m}-${l}-panel`;let d={content:r},f=e.tabs.map(S=>S.id);return f.forEach((S,A)=>{let z=k("button","pw-tab");z.type="button",z.setAttribute("role","tab"),z.id=`${m}-${l}-tab-${A}`,z.setAttribute("aria-controls",r.id),z.dataset.tab=S,z.addEventListener("click",()=>tt(l,S)),z.addEventListener("keydown",I=>{let G=I.key==="ArrowRight"?A+1:I.key==="ArrowLeft"?A-1:I.key==="Home"?0:I.key==="End"?f.length-1:-2;if(G===-2)return;I.preventDefault();let ae=f[(G+f.length)%f.length];tt(l,ae),s.querySelector(`[data-tab="${ae}"]`)?.focus()}),s.append(z),d[`label:${S}`]=z}),a.append(s,r),d.bar=s,{el:a,slots:d}}function Ct(e,l){let a=k("div","pw-switch"),s=k("div","pw-switchrow"),r=k("span","pw-switchlabel");r.id=`${m}-${l}-label`;let d=k("button","pw-toggle");d.type="button",d.setAttribute("role","switch"),d.setAttribute("aria-labelledby",r.id),d.append(k("i")),d.addEventListener("click",()=>It(l,d.getAttribute("aria-checked")!=="true")),s.append(r,d);let f=k("div","pw-switchcontent");return a.append(s,f),{el:a,slots:{content:f,label:r,toggle:d}}}function Ht(e){let l=k("div","pw-carousel");l.setAttribute("role","region"),l.setAttribute("aria-roledescription","carousel");let a=k("div","pw-track");a.tabIndex=0,a.style.setProperty("--pw-peek",C(e.peek)),a.style.setProperty("--pw-gap",C(e.spacing)),typeof e.height=="number"&&(a.style.minHeight=C(e.height));let s=e.indicator??{},r=k("div",`pw-dots ${s.style??"dots"}`);r.style.setProperty("--pw-dot",C(s.size??8)),r.style.setProperty("--pw-dot-gap",C(s.spacing??6)),r.style.setProperty("--pw-dot-c",s.color??"#8888"),r.style.setProperty("--pw-dot-on",s.active_color??"currentColor"),s.style==="none"&&(r.hidden=!0),l.append(a,r);let d=()=>[...a.children].filter(F=>F instanceof(p?.HTMLElement??HTMLElement)),f=()=>{let F=d(),W=a.scrollLeft+a.clientWidth/2,V=0;return F.forEach((ee,qt)=>{Math.abs(ee.offsetLeft+ee.offsetWidth/2-W)<Math.abs((F[V]?.offsetLeft??0)+(F[V]?.offsetWidth??0)/2-W)&&(V=qt)}),V},S=F=>{let W=d();if(W.length===0)return;let V=e.loop?(F+W.length)%W.length:Math.max(0,Math.min(W.length-1,F)),ee=W[V];a.scrollTo?.({left:ee.offsetLeft-(a.clientWidth-ee.offsetWidth)/2,behavior:ne()?"auto":"smooth"}),A(V)},A=F=>{[...r.children].forEach((W,V)=>W.setAttribute("aria-current",String(V===F)))};a.addEventListener("scroll",()=>A(f()),{passive:!0}),a.addEventListener("keydown",F=>{F.key!=="ArrowRight"&&F.key!=="ArrowLeft"||(F.preventDefault(),S(f()+(F.key==="ArrowRight"?1:-1)))});let z=!1,I=()=>z=!0,G=()=>z=!1;l.addEventListener("pointerenter",I),l.addEventListener("pointerleave",G),l.addEventListener("focusin",I),l.addEventListener("focusout",G);let ae=[];if(typeof e.auto_advance_ms=="number"){let F=setInterval(()=>{if(z||ne()||B())return;let W=d(),V=f();!e.loop&&V>=W.length-1||S(V+1)},e.auto_advance_ms);ae.push(()=>clearInterval(F))}return l.pwDots=F=>{r.children.length!==F&&(r.replaceChildren(...Array.from({length:F},(W,V)=>{let ee=k("button");return ee.type="button",ee.setAttribute("aria-label",ye.page(V+1,F)),ee.addEventListener("click",()=>S(V)),ee})),A(f()))},{el:l,slots:{pages:a},cleanup:ae}}function Ot(e,l){let a=l;switch(l.type){case"package":{let s=Sn(a),d=!!L.packages?.[s]?.price;e.el.dataset.package=s,e.el.setAttribute("aria-checked",String(a.selected===!0)),e.el.setAttribute("aria-disabled",String(!d));break}case"purchase_button":{let s=String(a.package);e.el.dataset.package=s,typeof a.offer=="string"?e.el.dataset.offer=a.offer:delete e.el.dataset.offer,e.el.disabled=te||!L.packages?.[s]?.price;break}case"switch":{let s=e.slots.toggle;s.setAttribute("aria-checked",String(a.on===!0)),s.style.setProperty("--pw-tint",String(a.tint??"")),s.style.setProperty("--pw-off",`color-mix(in srgb, ${j.tree.theme.colors.muted??"#888888"} 45%, transparent)`),e.slots.label.textContent=String(a.label??""),e.slots.label.hidden=a.label===void 0;break}case"tabs":{for(let s of a.tabs){let r=e.slots[`label:${s.id}`];r.setAttribute("aria-selected",String(s.selected)),r.tabIndex=s.selected?0:-1,s.selected&&e.slots.content.setAttribute("aria-labelledby",r.id)}a.bar&&Qe(e.slots.bar,{type:"stack",style:a.bar},"vertical");break}}}function zt(e,l,a){let s=l,r={...a,inControl:a.inControl||l.type==="button"||l.type==="purchase_button"||l.type==="package"};switch(l.type){case"stack":case"package":{let d=l.type==="stack"?String(s.axis??"vertical"):"vertical",f=s.children.map(A=>[A,E(A,d,r)]).filter(A=>A[1]!==null),S=f.map(A=>A[1]);re(e.slots.children,S),jt(d,f),l.type==="stack"&&Pe(e.el,S);break}case"button":case"purchase_button":{let d=s.content?E(s.content,"vertical",r):null;re(e.slots.content,d?[d]:[]);break}case"countdown":case"switch":{let d=s.content?E(s.content,"vertical",r):null;re(e.slots.content,d?[d]:[]),Pe(e.slots.content,d?[d]:[]);break}case"tabs":{for(let f of s.tabs){let S=f.label?E(f.label,"vertical",{...r,inControl:!0}):null;re(e.slots[`label:${f.id}`],S?[S]:[])}let d=s.content?E(s.content,"vertical",r):null;re(e.slots.content,d?[d]:[]),Pe(e.slots.content,d?[d]:[]);break}case"carousel":{let d=s.pages.map(f=>E(f,"page",r)).filter(Boolean);d.forEach((f,S)=>{f.setAttribute("role","group"),f.setAttribute("aria-roledescription","slide"),f.setAttribute("aria-label",ye.page(S+1,d.length))}),re(e.slots.pages,d),Pe(e.slots.pages,d),e.el.pwDots?.(d.length);break}}}function jt(e,l){let a=e==="horizontal"?"width":e==="vertical"?"height":null;if(!a)return;let s=f=>f?a==="width"?f.leading+f.trailing:f.top+f.bottom:0,r=l.filter(([f])=>f.style?.[a]==="fill"),d=Math.max(0,...r.map(([f])=>s(f.style?.padding)+s(f.style?.margin)));for(let[f,S]of r)S.style.flexBasis=C(d-s(f.style?.margin))}function Pe(e,l){let a=l.filter(r=>r.dataset.pwType==="package");if(a.length===0){e.getAttribute("role")==="radiogroup"&&e.removeAttribute("role");return}e.setAttribute("role","radiogroup"),e.setAttribute("aria-label",ye.packages);let s=a.find(r=>r.getAttribute("aria-checked")==="true")??a[0];for(let r of a)r.tabIndex=r===s?0:-1}function re(e,l){let a=()=>[...e.children].filter(r=>r.dataset?.pwPath!==void 0),s=a();for(let r of s)l.includes(r)||r.remove();s=a(),l.forEach((r,d)=>{s[d]!==r&&(e.insertBefore(r,s[d]??null),s=a())})}let Be=new WeakMap;function H(e,l,a){e.style.setProperty(l,a),Be.get(e).push(l)}function Qe(e,l,a){for(let f of Be.get(e)??[])e.style.removeProperty(f);Be.set(e,[]);for(let f of[...e.children])f.classList.contains("pw-bgvideo")&&f.remove();let s=l.style;if(l.type==="image"&&e.classList.toggle("natural",typeof l.aspect!="number"&&(s?.height===void 0||s.height==="fit")),!s)return;let r=(f,S)=>{S&&(H(e,`${f}-block-start`,C(S.top)),H(e,`${f}-block-end`,C(S.bottom)),H(e,`${f}-inline-start`,C(S.leading)),H(e,`${f}-inline-end`,C(S.trailing)))};r("padding",s.padding),r("margin",s.margin),et(e,"width",s.width,a),typeof s.height=="number"&&gn.has(l.type)?(H(e,"min-height",C(s.height)),a==="vertical"&&H(e,"flex","none")):et(e,"height",s.height,a),typeof s.max_width=="number"&&H(e,"max-width",C(s.max_width));let d=s.background;if(d){if(d.type==="color")H(e,"background-color",d.color);else if(d.type==="linear"||d.type==="radial")H(e,"background-image",Ve(d)??"");else if(d.type==="image"){let f=U(d.src);f&&(H(e,"background-image",`url("${f.replace(/"/g,"%22")}")`),H(e,"background-size",d.fit==="fit"?"contain":"cover"),H(e,"background-position","center"),H(e,"background-repeat","no-repeat"))}else if(d.type==="video"){let f=U(d.src);if(f){let S=k("video","pw-bgvideo");S.src=f;let A=U(d.poster);A&&(S.poster=A),S.muted=!0,S.loop=d.loop!==!1,S.playsInline=!0,S.autoplay=!ne()&&!B(),S.setAttribute("aria-hidden","true"),H(e,"isolation","isolate"),e.prepend(S)}}}if(s.border&&l.type==="custom_html"?H(e,"border",`${C(s.border.width)} solid ${s.border.color??"transparent"}`):s.border&&(H(e,"--pw-bw",C(s.border.width)),H(e,"--pw-bc",s.border.color??"transparent")),s.corners){let f=s.corners;H(e,"border-start-start-radius",C(f.top_leading)),H(e,"border-start-end-radius",C(f.top_trailing)),H(e,"border-end-start-radius",C(f.bottom_leading)),H(e,"border-end-end-radius",C(f.bottom_trailing)),(l.type==="image"||l.type==="video"||d?.type==="image"||d?.type==="video")&&H(e,"overflow","hidden")}s.shadow&&H(e,"box-shadow",`${C(s.shadow.x)} ${C(s.shadow.y)} ${C(s.shadow.radius)} ${s.shadow.color}`),typeof s.opacity=="number"&&s.opacity!==1&&H(e,"opacity",String(s.opacity))}function et(e,l,a,s){if(a==null||a==="")return;if(s==="page"){l==="height"&&H(e,"height",a==="fill"?"100%":typeof a=="number"?C(a):a==="fit"?"fit-content":String(a));return}let r=s==="horizontal"?"width":s==="vertical"?"height":null;a==="fill"?l===r?(H(e,"flex","1 1 0"),H(e,`min-${l}`,"0")):s==="z"?H(e,l,"100%"):(H(e,"align-self","stretch"),H(e,l,"auto")):a==="fit"?(l===r&&H(e,"flex","0 0 auto"),H(e,l,"fit-content")):(H(e,l,typeof a=="number"?C(a):String(a)),l===r&&H(e,"flex","none"))}function Ve(e){let l=a=>a.map(s=>`${s.color} ${(s.at*100).toFixed(2)}%`).join(", ");if(e.type==="linear")return`linear-gradient(${e.angle}deg, ${l(e.stops)})`;if(e.type==="radial"){let a=`${(e.radius*100).toFixed(2)}%`;return`radial-gradient(ellipse ${a} ${a} at ${(e.center_x*100).toFixed(2)}% ${(e.center_y*100).toFixed(2)}%, ${l(e.stops)})`}}function Ft(e,l){let a=l.animation;if(!a||L.animate===!1||ne()||typeof e.animate!="function")return;let s=24,d={fade:{opacity:0},slide_up:{opacity:0,transform:`translateY(${s}px)`},slide_down:{opacity:0,transform:`translateY(-${s}px)`},slide_leading:{opacity:0,transform:`translateX(-${s}px)`},slide_trailing:{opacity:0,transform:`translateX(${s}px)`},scale:{opacity:0,transform:"scale(0.92)"}}[a.type];d&&e.animate([d,{opacity:1,transform:"none"}],{duration:a.duration_ms,delay:a.delay_ms,easing:_t[a.easing]??_t.ease_out,fill:"backwards"})}function $e(){i.onState?.({...R}),Y()}function Je(e){R.selected===e&&de()===e||(R.selected=e,$e(),i.onSelect?.(Ne(e)))}function qe(e){B()||e.getAttribute("aria-disabled")==="true"||Je(e.dataset.package??"")}function Nt(e,l){if(e.key===" "||e.key==="Enter"){e.preventDefault(),qe(l);return}let a=e.key==="ArrowDown"||e.key==="ArrowRight"?1:e.key==="ArrowUp"||e.key==="ArrowLeft"?-1:0;if(a===0)return;e.preventDefault();let s=l.closest("[role=radiogroup]"),d=(s?[...s.children].filter(A=>A.dataset.pwType==="package"):[l]).filter(A=>A.getAttribute("aria-disabled")!=="true"),f=d.indexOf(l),S=d[(f+a+d.length)%d.length];S&&(qe(S),(N.get(S.dataset.pwPath??"")?.el??S).focus())}function tt(e,l){if(B())return;R.tabs={...R.tabs,[e]:l};let a=Dt(e,l);a&&(R.selected=a),$e()}function Dt(e,l){return nt(e)?.tabs?.find(s=>s.id===l)?.package}function It(e,l){if(B())return;R.switches={...R.switches,[e]:l};let a=nt(e),s=l?a?.on_package:a?.off_package;s&&(R.selected=s),$e()}function nt(e){let l=L.definition;for(let a of e.match(/[^.[\\]]+/g)??[])l=l?.[/^\\d+$/.test(a)?Number(a):a];return l}async function ot(e,l){if(!(B()||te)){te=!0,e.disabled=!0,e.setAttribute("aria-busy","true");try{await l()}finally{te=!1,e.removeAttribute("aria-busy"),e.disabled=!1;for(let a of N.values())a.type==="purchase_button"&&(a.el.disabled=!L.packages?.[a.el.dataset.package??""]?.price)}}}async function Bt(e,l){!L.packages?.[e]?.price||!i.onPurchase||await i.onPurchase(l!==void 0?{...Ne(e),offer:l}:Ne(e))}function Te(e){B()&&e!==null&&R.sheet===e||(e&&!R.sheet&&(xe=y.activeElement??null),R.sheet=e,$e(),e||xe?.focus())}function Vt(){let e=R.sheet,l=e?j.tree.sheets?.[e]:void 0;if(!l){O.remove();return}O.className="pw-layer";let a=O.firstElementChild;if(!a){a=k("div","pw-sheet"),a.setAttribute("role","dialog"),a.setAttribute("aria-modal","true"),a.tabIndex=-1;let r=k("div","pw-grab");r.setAttribute("aria-hidden","true"),a.append(r),O.append(a),O.addEventListener("click",d=>{d.target===O&&!B()&&Te(null)}),a.addEventListener("keydown",d=>Jt(d,a))}a.style.background=j.tree.theme.colors.background??"",a.setAttribute("aria-label",j.sheetTitles[e]??"");let s=E(l,"vertical",{inControl:!1,inSheet:!0});re(a,s?[s]:[]),O.isConnected||(w.append(O),queueMicrotask(()=>(st(a)[0]??a).focus()))}function st(e){return[...e.querySelectorAll(\'button:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])\')].filter(l=>!l.hidden)}function Jt(e,l){if(e.key==="Escape"){e.preventDefault(),Te(null);return}if(e.key!=="Tab")return;let a=st(l);if(a.length===0){e.preventDefault();return}let s=a[0],r=a[a.length-1],d=y.activeElement;e.shiftKey&&d===s?(e.preventDefault(),r.focus()):!e.shiftKey&&d===r&&(e.preventDefault(),s.focus())}function it(e){try{let l=o==="paywall"?{type:"palbase.paywall",package:de()}:{type:"palbase.message"};e.contentWindow?.postMessage({...l,locale:j.language,appearance:L.appearance},"*")}catch{}}function rt(e){for(let l of y.querySelectorAll("[data-pw-highlight]"))l.removeAttribute("data-pw-highlight");ve=e,e&&N.get(e)?.el.setAttribute("data-pw-highlight","")}let at=e=>e.composedPath().find(l=>l instanceof(p?.HTMLElement??HTMLElement)&&l.dataset.pwPath!==void 0);w.addEventListener("click",e=>{if(!i.editor)return;let l=at(e);l&&(e.preventDefault(),e.stopPropagation(),i.editor.onPick(l.dataset.pwPath))},!0),w.addEventListener("pointerover",e=>{if(i.editor){for(let l of y.querySelectorAll("[data-pw-hover]"))l.removeAttribute("data-pw-hover");at(e)?.setAttribute("data-pw-hover","")}}),w.addEventListener("pointerleave",()=>{for(let e of y.querySelectorAll("[data-pw-hover]"))e.removeAttribute("data-pw-hover")});let lt=()=>Y();return be?.addEventListener?.("change",lt),Y(),{get selected(){let e=de();return e?Ne(e):null},get state(){return{...R}},select(e){Je(e)},update(e){L={...L,...e},e.state&&Object.assign(R,e.state),Y()},highlight(e){rt(e)},replay(){for(let e of N.values())e.cleanup.forEach(l=>l());N=new Map;for(let e of[v,x,_])e.replaceChildren();Y()},destroy(){clearTimeout(he),K?.disconnect(),c.fonts?.removeEventListener?.("loadingdone",X),be?.removeEventListener?.("change",lt);for(let e of N.values())e.cleanup.forEach(l=>l());b.remove()}}}function Rn(o,t,n){let i=o.defaultView;try{if(i&&"adoptedStyleSheets"in t&&typeof i.CSSStyleSheet=="function"){let p=new i.CSSStyleSheet;p.replaceSync(n),t.adoptedStyleSheets=[p];return}}catch{}let c=o.createElement("style");c.textContent=n,t.append(c)}function An(o,t){let n=o;for(let i of t.split(".")){let c=/^([^[\\]]+)((?:\\[\\d+\\])*)$/.exec(i);if(!c||typeof n!="object"||n===null)return;n=n[c[1]];for(let p of c[2].matchAll(/\\[(\\d+)\\]/g))n=Array.isArray(n)?n[Number(p[1])]:void 0}return typeof n=="object"&&n!==null?n:void 0}var Ln=o=>Uint8Array.from(atob(o),t=>t.charCodeAt(0));async function _n(o){let t={};for(let n of o.assets){let i=Ln(n.data);if((n.kind==="image"||n.kind==="video")&&(t[n.id]={kind:n.kind,url:URL.createObjectURL(new Blob([i],{type:n.type}))}),n.kind==="font"){let c=new FontFace(Ue(n.id),i,{display:"block"});await c.load(),document.fonts.add(c),t[n.id]={kind:"font",url:"",family:Ue(n.id)}}if(n.kind==="html"){let c=pt(await dt(i));c!==void 0&&(t[n.id]={kind:"html",url:"",html:c})}}return t}function Pn(o,t){let n=o.catalog[t.platform]??{packages:{},eligible:[]},i=Fe(o.definition,{locale:o.locale,appearance:t.appearance,platform:t.platform,packages:n.packages,eligible:n.eligible}),c=o.state;return{...c.selected?{selected:c.selected}:{},...c.tab?{tabs:Object.fromEntries(Object.keys(i.tabs).map(p=>[p,c.tab]))}:{},...c.switch?{switches:Object.fromEntries(Object.keys(i.switches).map(p=>[p,c.switch==="on"]))}:{},...c.sheet?{sheet:c.sheet}:{}}}async function $n(o){let t=[...o.querySelectorAll("img, video")];await Promise.race([Promise.all(t.map(n=>n instanceof HTMLImageElement?n.complete?Promise.resolve():n.decode().catch(()=>{}):n.readyState>=2?Promise.resolve():new Promise(i=>{n.addEventListener("loadeddata",()=>i(),{once:!0}),n.addEventListener("error",()=>i(),{once:!0})}))),new Promise(n=>setTimeout(n,5e3))])}var De=()=>new Promise(o=>requestAnimationFrame(()=>o(void 0)));async function Tn(){let o=window.PALBASE_PREVIEW,t=o.shots[Number(new URLSearchParams(location.search).get("shot")??"0")]??o.shots[0];document.documentElement.style.fontSize=`${t.fontSize}px`,document.documentElement.style.colorScheme=t.appearance;let n=document.getElementById("screen");Object.assign(n.style,{width:`${t.width}px`,height:`${t.height}px`,paddingTop:`${t.top}px`,paddingBottom:`${t.bottom}px`});let i=document.getElementById("paywall"),c=o.catalog[t.platform]??{packages:{},eligible:[]},p=$t(i,{definition:o.definition,locale:o.locale,appearance:t.appearance,platform:t.platform,packages:c.packages,eligible:c.eligible,links:o.links,assets:await _n(o),state:Pn(o,t),animate:!1,reduceMotion:!0},{onPurchase:()=>{},onRestore:()=>{},onClose:()=>{},onLink:()=>{},onOfferCode:()=>{}}),m=i.querySelector("[data-palbase-paywall]")?.shadowRoot;if(!m)throw new Error("the renderer drew nothing");let b=getComputedStyle(m.querySelector(".pw2")).backgroundColor;n.style.background=b==="rgba(0, 0, 0, 0)"||b==="transparent"?t.appearance==="dark"?"#000":"#fff":b,await document.fonts.ready,await $n(m),await De(),await De(),document.body.dataset.selected=p.selected?`${p.selected.product}.${p.selected.plan}`:"",o.check&&(document.body.dataset.findings=JSON.stringify(kt(m,{platform:t.platform,width:t.width,height:t.height,nodeAt:y=>An(o.definition,y)}))),window.PALBASE_FULL=async()=>{let y=Math.max(...[".pw2-body",".pw2"].map(v=>m.querySelector(v)).map(v=>v.scrollHeight-v.clientHeight)),w=Math.max(t.height,Math.ceil(n.offsetHeight+y));return n.style.height=`${w}px`,await De(),await De(),w}}Tn().then(()=>{document.body.dataset.ready="1"},o=>{document.body.dataset.error=o instanceof Error?o.message:String(o),document.body.dataset.ready="1"});})();\n')}function Gp(e){let t=/^P(\d+)([DWMY])$/.exec(e??"");if(!t)return null;let n=Number(t[1]);if(!Number.isSafeInteger(n)||n<1)return null;switch(t[2]){case"D":return{count:n,unit:"day",months:n*12/365};case"W":return{count:n,unit:"week",months:n*12/52};case"M":return{count:n,unit:"month",months:n};default:return{count:n,unit:"year",months:n*12}}}function yv(e){try{return new Intl.NumberFormat("en",{style:"currency",currency:e}).resolvedOptions().maximumFractionDigits??2}catch{return 2}}function qp(e,t,n){let s=e/10**yv(t);try{return new Intl.NumberFormat(n,{style:"currency",currency:t}).format(s)}catch{return`${s.toFixed(yv(t))} ${t}`}}function NN(e,t){try{let n=new Intl.NumberFormat(t,{style:"unit",unit:e.unit,unitDisplay:"long"});return e.count>1?n.format(e.count):n.formatToParts(1).filter(a=>a.type==="unit").map(a=>a.value).join("").trim()||n.format(1)}catch{return e.count>1?`${e.count} ${e.unit}s`:e.unit}}var IN={en:e=>`${e} free`,tr:e=>`${e} \xFCcretsiz`,de:e=>`${e} kostenlos`,es:e=>`${e} gratis`,it:e=>`${e} gratis`,nl:e=>`${e} gratis`,pt:e=>`${e} gr\xE1tis`,sv:e=>`${e} gratis`,da:e=>`${e} gratis`,nb:e=>`${e} gratis`};function LN(e,t){let n;try{n=new Intl.NumberFormat(t,{style:"unit",unit:e.unit,unitDisplay:"long"}).format(e.count)}catch{n=`${e.count} ${e.unit}${e.count>1?"s":""}`}let s=IN[t.split("-")[0].toLowerCase()];return s?s(n):n}function DN(e,t){try{return new Intl.NumberFormat(t,{style:"percent",maximumFractionDigits:0}).format(e)}catch{return`${Math.round(e*100)}%`}}function bv(e,t){let n=new Map,s=new Map;for(let i of e){let r=Gp(i.period);if(!r)continue;let o=i.price.amount/r.months;n.set(i.key,o),s.set(i.price.currency,Math.max(s.get(i.price.currency)??0,o))}let a={};for(let i of e){let r={product_name:i.productName,price:qp(i.price.amount,i.price.currency,t)},o=Gp(i.period);if(o){r.period=NN(o,t),r.price_per_month=qp(Math.round(n.get(i.key)),i.price.currency,t);let d=s.get(i.price.currency)??0,p=d>0?Math.floor((1-n.get(i.key)/d)*100)/100:0;p>=.01&&(r.savings=DN(p,t))}let l=i.intro?.mode==="free_trial"?Gp(i.intro.duration):null;l&&(r.trial=LN(l,t)),i.offer&&(r.offer_price=qp(Math.floor((i.price.amount*(100-i.offer.percentOff)+50)/100),i.price.currency,t)),a[i.key]=r}return a}var H=(e,t=!1)=>({kind:"value",value:"plain",def:e,required:t}),Ut=e=>({kind:"value",value:"color",def:e}),wv=e=>({kind:"value",value:"spacing",def:e}),MN=e=>({kind:"value",value:"radius",def:e}),oa=(e=!1)=>({kind:"text",required:e}),Up=(e,t=!1)=>({kind:"list",item:e,required:t}),nr=(e,t=!1)=>({kind:"object",item:e,required:t}),vv=(e=!1)=>({kind:"component",required:e}),Kp={kind:"components"},xN={stack:{axis:H("vertical"),spacing:wv(0),align:H("center"),distribution:H("start"),scroll:H(!1),children:Kp},text:{text:oa(),spans:Up("span"),font:H(),size:H(),weight:H(),line_height:H(),letter_spacing:H(),color:{kind:"value",value:"textColor",def:"text"},align:H("center"),max_lines:H(),uppercase:H(!1)},image:{src:H(void 0,!0),fit:H("fit"),aspect:H(),mask:nr("mask"),overlay:{kind:"value",value:"textColor"},alt:oa(),decorative:H(!1)},icon:{name:H(void 0,!0),color:Ut("accent"),size:H(24)},video:{src:H(void 0,!0),poster:H(),autoplay:H(!0),loop:H(!0),mute:H(!0),controls:H(!1),fit:H("fill"),aspect:H(),alt:oa()},button:{action:nr("action",!0),content:vv(!0)},purchase_button:{content:vv(!0),package:H()},package:{product:H(void 0,!0),plan:H(void 0,!0),selected:H(!1),offer:H(),children:Kp},tabs:{},switch:{},carousel:{pages:Kp,peek:H(0),spacing:H(8),loop:H(!1),auto_advance_ms:H(),indicator:nr("indicator"),height:H("")},countdown:{},timeline:{items:Up("timeline_item",!0),line_color:Ut("accent"),line_width:H(2),icon_color:Ut("on_accent"),color:Ut("text"),spacing:H(16)},features:{items:Up("feature",!0),icon_color:Ut("accent"),color:Ut("text"),spacing:H(12)},spacer:{size:wv()},divider:{color:Ut("muted"),thickness:H(1)},custom_html:{src:H(void 0,!0),height:H("",!0)}},Dz={style:{padding:{kind:"edges"},margin:{kind:"edges"},width:H(""),height:H(""),max_width:H(),background:{kind:"fill"},border:nr("border"),corners:{kind:"corners"},shadow:nr("shadow"),opacity:H(1)},border:{width:H(),color:Ut("")},shadow:{color:Ut(""),radius:H(0),x:H(0),y:H(0)},linear:{type:H(""),angle:H(180),stops:H()},radial:{type:H(""),center_x:H(.5),center_y:H(.5),radius:H(.5),stops:H()},image_fill:{type:H(""),src:H(),fit:H("fill")},video_fill:{type:H(""),src:H(),poster:H(),loop:H(!0)},animation:{type:H(""),duration_ms:H(300),delay_ms:H(0),easing:H("ease_out")},action:{type:H(""),url:H(),sheet:H(),package:H()},mask:{shape:H(""),radius:MN(0),depth:H(16)},span:{text:oa(!0),bold:H(!1),italic:H(!1),underline:H(!1),strikethrough:H(!1),color:Ut(""),link:H()},timeline_item:{icon:H(void 0,!0),title:oa(!0),text:oa(),color:Ut("")},feature:{icon:H(void 0,!0),text:oa(!0)},indicator:{style:H("dots"),color:Ut("muted"),active_color:Ut("accent"),size:H(8),spacing:H(6)},typography:{font:H("system"),size:H(),weight:H(400),line_height:H(),letter_spacing:H(0),text_style:H("body")}},GN=new Set(["package","purchase_button"]),Mz={action:{type:H(""),url:H(),link:H(),sheet:H(),placement:H(),name:H(),value:H(),offer:H(),dismiss:H(!0)},presentation:{type:H(""),position:H("bottom"),auto_dismiss_seconds:H(),dismissible:H(!0),backdrop:Ut("#00000080")}};var qN=Object.keys(xN),xz=qN.filter(e=>!GN.has(e));var Fp=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{};function sr(e){let t=[],n=a=>{if(Array.isArray(a))return a.forEach(n);if(typeof a!="object"||a===null)return;let i=a;if(i.type==="package"&&typeof i.product=="string"&&typeof i.plan=="string"){let r=`${i.product}.${i.plan}`;t.includes(r)||t.push(r)}for(let r of Object.keys(i).sort())n(i[r])},s=e;for(let a of["header","root","footer"])n(s[a]);for(let a of Object.keys(Fp(s.sheets)).sort())n(Fp(Fp(s.sheets)[a]).root);return t}var _v=["ios","android","web","macos"],$v=["light","dark"],WN={default:16,largest:24},zN={ios:{width:393,height:852,top:54,bottom:34},android:{width:412,height:915,top:40,bottom:24},web:{width:1024,height:720,top:0,bottom:0},macos:{width:720,height:640,top:0,bottom:0}},Wp=2,JN={terms:"https://example.com/terms",privacy:"https://example.com/privacy"};function Bp(e,t,n,s){let a=e.flags[t];if(a===void 0)return s;if(!n.includes(a))throw g(`--${t} is one of ${n.join(", ")}`);return a}function kv(e,t){let n=e.flags[t];if(n===void 0)return;let s=Number(n);if(!Number.isInteger(s)||s<200||s>4e3)throw g(`--${t} is a whole number of CSS pixels, 200 to 4000`);return s}function HN(e){let t={};for(let n of e??[]){let s=n.indexOf("="),[a,i]=s<0?[n,""]:[n.slice(0,s),n.slice(s+1)];if(a==="tab"&&i!=="")t.tab=i;else if(a==="sheet"&&i!=="")t.sheet=i;else if(a==="switch"&&(i==="on"||i==="off"))t.switch=i;else throw g(`--state ${n}: it names tab=<id>, switch=on|off or sheet=<id>`)}return t}function VN(e,t){if(e)return e[t]?.name??e[t.split("-")[0]]?.name??Object.values(e).find(n=>n.name)?.name}function XN(e){let t=e.split(".").slice(1).join(".").toLowerCase(),[n,s]=/year|annual|12m/.test(t)?["P1Y",5999]:/week/.test(t)?["P1W",499]:/life|forever|once|onetime|one_time/.test(t)?[void 0,14999]:["P1M",999];return{key:e,productName:e.split(".")[0],price:{amount:s,currency:"USD"},...n?{period:n}:{}}}function YN(e,t,n,s){let a=[],i=[];for(let o of n){let[l,d]=o.split("."),p=e?.products.find(f=>f.key===l),c=p?.channels[t==="macos"?"ios":t],m=c?.plans.find(f=>f.key===d);if(!p||!c||!m){a.push(XN(o)),i.push(o);continue}a.push({key:o,productName:VN(c.locales,s)??p.key,price:{amount:m.price.amount,currency:m.price.currency},period:m.period,intro:m.intro})}let r=a.filter(o=>o.intro?.mode==="free_trial").map(o=>o.key);return{packages:bv(a,s),eligible:r,sampled:i}}function ZN(e){return[...new Set([...JSON.stringify(e).matchAll(/asset:([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/g)].map(t=>t[1]))]}async function QN(e,t,n){if(n.length===0)return{assets:[],left:[]};let s=await Ya(e,t),a=Wt(e.cloud,t.env_ref),i=[],r=[];for(let o of n){let l=s.find(d=>d.id===o);if(!l){r.push(`asset:${o} is not one of the project's assets`);continue}try{let d;try{d=new URL(l.url)}catch{throw new Error("its address is not one")}if(d.origin!==a)throw new Error(`its address is not the environment's (${a}) \u2014 ${d.protocol==="https:"||d.protocol==="http:"?d.host:d.protocol}: the CLI does not ask another host`);let p=await e.io.fetch(d.href,{credentials:"omit",redirect:"manual"});if(!p.ok)throw new Error(`its address answered ${p.status}`);let c=Buffer.from(await p.arrayBuffer());if(UN("sha256").update(c).digest("hex")!==l.sha256.toLowerCase())throw new Error("its bytes are not the ones registered");i.push({id:o,kind:l.kind,type:l.content_type,data:c.toString("base64")})}catch(d){r.push(`${l.ref} could not be had: ${d instanceof Error?d.message:String(d)}`)}}return{assets:i,left:r}}function eI(e,t,n){let s=JSON.stringify(n).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");return`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${t.replace(/[&<>"]/g,i=>`&#${i.charCodeAt(0)};`)} \u2014 paywall preview</title>
|
|
680
680
|
<style>html,body{margin:0}body{min-height:100vh;display:grid;place-items:center;background:#8E8E93}#screen{box-sizing:border-box;overflow:hidden}#paywall{height:100%}</style>
|
|
681
681
|
</head><body><div id="screen"><div id="paywall"></div></div>
|
|
682
682
|
<script>window.PALBASE_PREVIEW=${s};</script>
|
|
683
683
|
<script>${e.replace(/<\/script/gi,"<\\/script")}</script>
|
|
684
684
|
</body></html>
|
|
685
|
-
`}async function dl(e,t,n){let s=await Be(e.io.cwd,t);await KN(BN(s),{recursive:!0}),await Be(e.io.cwd,t),await FN(s,n)}var Pv={file:{type:"string",value:"paywall.json",description:"the definition to draw ('-': stdin)"},locale:{type:"string",value:"tag",description:"the reader's language (default: the definition's default_locale)"},package:{type:"string",value:"product.plan",description:"the package selected"},state:{type:"string",multiple:!0,value:"k=v,\u2026",description:"tab=<id> (every tabs component on it), switch=on|off, sheet=<id> (open)"},width:{type:"string",value:"px",description:"the screen's width in CSS pixels (default: the platform's)"},height:{type:"string",value:"px",description:"the screen's height (default: the platform's)"}};async function Rv(e,t,n,s){let a=e.args[0],i=e.flags.file;if(a===void 0==(i===void 0))throw g("draw a file (--file <paywall.json>) or a paywall's draft by its name, one of the two");let r=e.flags.platform!==void 0?[Bp(e,"platform",_v,"ios")]:n?[..._v]:["ios"],o=e.flags.appearance!==void 0?[Bp(e,"appearance",$v,"light")]:n?[...$v]:["light"],l=e.flags["text-size"]!==void 0?[Bp(e,"text-size",["default","largest"],"default")]:n?["default","largest"]:["default"],d=kv(e,"width"),p=kv(e,"height"),c=HN(Ie(e.flags.state)),m;if(i!==void 0)m=await al(e,i);else{let L=await aa(e,t,a);m=(await h(e,t,"GET",`/purchases/paywalls/${T(L.id)}`)).draft}if(typeof m.default_locale!="string"||typeof m.root!="object")throw g("this is no paywall definition: it has no root or default_locale (palbase purchases:paywalls:validate says what it lacks)");let f=e.flags.locale??m.default_locale,b=Zi(a!==void 0?a:m.name??"paywall"),v=sr(m);if(e.flags.package!==void 0){let L=e.flags.package;if(!v.includes(L))throw g(`--package ${L}: the paywall sells ${v.length===0?"no package":v.join(", ")}`);c.selected=L}let R=[];for(let L of r)for(let V of o)for(let de of l){let O=zN[L];R.push({platform:L,appearance:V,fontSize:WN[de],width:d??O.width,height:p??O.height,top:O.top,bottom:O.bottom,text:de})}let A=v.length===0?void 0:await h(e,t,"GET","/purchases/offerings"),C={},N={};for(let L of new Set(R.map(V=>V.platform))){let V=YN(A,L,v,f);C[L]={packages:V.packages,eligible:V.eligible},V.sampled.length>0&&(N[L]=V.sampled)}let{assets:j,left:U}=await QN(e,t,ZN(m)),G={definition:m,locale:f,catalog:C,links:JN,assets:j,state:c,shots:R.map(({text:L,...V})=>V),...s?{check:!0}:{}},K=eI(await fv(),m.name??b,G);return{name:b,shots:R,html:K,sampled:N,left:U,said(){for(let L of Object.keys(C)){let V=N[L];v.length!==0&&(V?e.out.note(`Prices on ${L}: sample prices for ${V.join(", ")} \u2014 the catalog does not sell ${V.length===1?"it":"them"} there${V.length<v.length?"; the catalog's for the rest":""}.`):e.out.note(`Prices on ${L}: the catalog's (revision ${A.revision}).`))}for(let L of U)e.out.warn(`${L}: drawn without it`)}}}var zp=4;async function Ev(e,t,n){let s=mv(e.io.env);if(s.path)return s.path;let a=`${mt}/.preview/${t.name}.html`;throw await dl(e,a,t.html),t.said(),new y("no_browser",`no browser to ${n} with: open ${a}`,{exitCode:3,hint:s.named!==void 0?`PALBASE_BROWSER names ${s.named}, which is not a program here`:"install Chrome, Chromium, Edge or Brave, or name one: PALBASE_BROWSER=<path>"})}async function Tv(e,t,n,s){let a=`${mt}/.preview/${t.name}.html`;await dl(e,a,t.html);try{return{page:a,taken:await gv(n,await Be(e.io.cwd,a),t.shots.map((i,r)=>({query:`shot=${r}`,width:i.width,height:i.height,scale:Wp,...s})),{args:hv(e.io.env)})}}catch(i){let r=i instanceof tr&&i.noSandbox?"in a container the browser often has none: PALBASE_BROWSER_ARGS=--no-sandbox runs it without one \u2014 and draws the paywall's HTML blocks, which the project's members wrote, without one too":`the page is ${a}: open it in a browser to see it`;throw new y("preview_failed",`the paywall was not drawn: ${i instanceof Error?i.message:String(i)}`,{hint:r,exitCode:zp})}}var Sv=e=>`${e.platform} ${e.appearance}${e.text==="largest"?" largest":""}`,Cv={name:"purchases:paywalls:preview",summary:"a picture of a paywall as an app draws it \u2014 the SDK's own renderer, in a headless browser \u2014 to look at before it is saved",usage:"<name|id> | --file <paywall.json> [--platform ios|android|web] [--appearance light|dark] [--locale <tag>] [--text-size default|largest] [--package <key>] [--state tab=<id>,switch=on|off,sheet=<id>] [--full] [--all] [--out <png>] [--html <file>]",details:["It draws the file being edited (--file), or a paywall's draft by its name. The picture is the platform's screen: its status bar and home indicator kept clear, as on a phone. --full draws the whole paywall instead: the part that scrolls in full, the header and the footer once.","Prices are the environment's catalog's, as the platform sells each package; a package it does not sell there is drawn at a sample price, and named. The project's assets are downloaded and drawn when their bytes are the ones registered.","It needs Chrome, Chromium, Edge or Brave (PALBASE_BROWSER names another; PALBASE_BROWSER_ARGS adds to its arguments, as --no-sandbox in a container that has no sandbox for it). Without one the page is written as HTML to open, and it exits 3; when the browser or the renderer cannot draw it, 4.",`--all draws every platform in both appearances at both text sizes into one folder (${mt}/.preview/<name>/). --html writes the page alone, to open in a browser. purchases:paywalls:check measures what is drawn and lists what is wrong.`],args:{min:0,max:1},flags:{...Pv,platform:{type:"string",value:"platform",description:"ios (default), android or web: the screen and the platform's rules"},appearance:{type:"string",value:"appearance",description:"light (default) or dark"},"text-size":{type:"string",value:"size",description:"default, or largest: every text at the largest size a reader sets"},full:{type:"boolean",description:"the whole paywall, as tall as it is, not the screen alone"},all:{type:"boolean",description:"every platform \xD7 appearance \xD7 text size, into one folder"},out:{type:"string",value:"file",description:`the PNG under palbase/ (default: ${mt}/.preview/<name>-<platform>-<appearance>.png); with --all, the folder`},html:{type:"string",value:"file",description:"write the page alone, as HTML under palbase/, to open in a browser"}},scope:"environment",async run(e){let t=await w(e),n=e.flags.all===!0;if(n&&(e.flags.platform!==void 0||e.flags.appearance!==void 0||e.flags["text-size"]!==void 0))throw g("--all draws every platform, appearance and text size: name none of them with it");let s=await Rv(e,t,n,!1),a=e.flags.html;if(a!==void 0){let f=Nt(e,"html",a,".html");await dl(e,f,s.html),s.said(),e.out.result({html:f},()=>e.out.line(`Wrote the page to ${f}: open it in a browser.`));return}let i=await Ev(e,s,"take the picture"),r=e.flags.full===!0,o=n?e.flags.out!==void 0?Nt(e,"out",`${e.flags.out.replace(/\/+$/,"")}/x.png`,".png").replace(/\/x\.png$/,""):`${mt}/.preview/${s.name}`:void 0,l=s.shots.map(f=>n?`${o}/${f.platform}-${f.appearance}-${f.text}${r?"-full":""}.png`:e.flags.out!==void 0?Nt(e,"out",e.flags.out,".png"):`${mt}/.preview/${s.name}-${f.platform}-${f.appearance}${f.text==="largest"?"-largest":""}${r?"-full":""}.png`),{page:d,taken:p}=await Tv(e,s,i,{full:r});for(let[f,b]of l.entries())await dl(e,b,p[f].png);s.said();let c=p.flatMap((f,b)=>f.error?[`${l[b]}: ${f.error}`]:[]),m=s.shots;if(e.out.result({pictures:m.map((f,b)=>({file:l[b],platform:f.platform,appearance:f.appearance,text_size:f.text,width:f.width,height:p[b].height,scale:Wp,full:r,selected:p[b].selected??null,...p[b].error?{error:p[b].error}:{}})),page:d,sampled_prices:s.sampled,assets_left_out:s.left},()=>{for(let[f,b]of l.entries())e.out.line(`${b} (${m[f].platform}, ${m[f].appearance}${m[f].text==="largest"?", largest text":""}, ${m[f].width}\xD7${p[f].height}${r?", whole":""} at ${Wp}x${p[f].selected?`, ${p[f].selected} selected`:""})`)}),c.length>0)throw new y("preview_failed",`the renderer could not draw it: ${c.join("; ")}`,{exitCode:zp})}};function Av(e){let t=new Map;for(let{screen:n,findings:s}of e)for(let{note:a,...i}of s){let r=`${i.code}\0${i.where}`,o=t.get(r)??{...i,screens:[]};o.screens.includes(n)||o.screens.push(n),t.set(r,o)}return[...t.values()]}var jv={name:"purchases:paywalls:check",summary:"measure a paywall as an app draws it, on every screen, and list what is wrong \u2014 code \u2014 where \u2014 what \u2014 exiting 1 while anything is",usage:"<name|id> | --file <paywall.json> [--platform \u2026] [--appearance \u2026] [--text-size \u2026] [--locale <tag>] [--package <key>] [--state \u2026]",details:["It draws the paywall with the SDK's own renderer in a headless browser \u2014 every platform, light and dark, at the default and the largest text size, unless a flag names one \u2014 and measures what shows:"," overflow_x: wider than the screen \xB7 text_cut: a text cut off \xB7 word_broken: a word (a price) broken across lines \xB7 purchase_hidden: no purchase button on the screen as it opens \xB7 covered_by_footer: an interactive part still under the fixed footer with the paywall scrolled to its end \xB7 large_gap: an empty band over 12% of the screen \xB7 contrast: text under WCAG's 4.5:1 (3:1 large) \xB7 selection_contrast: the selected package or tab under 3:1 from the others \xB7 small_target: a target under 44\xD744 on a phone, 24\xD724 on the web (a switch, a link inside a sentence and a carousel's dots aside) \xB7 image_missing: an image that did not load \xB7 repeated_text: the same words twice in one package.","Each names the component by its path in the definition (root.children[2]) and the words it shows. A text over a picture or a gradient is said apart, as not measured (unmeasured_contrast): a note, not a problem.","--json prints { problems: [{ code, where, message, screens }], notes: [ \u2026 ], screens }.","It exits 0 when nothing is wrong, 1 when something is (and on a refusal: --json then prints { error } instead), 3 without a browser, 4 when the browser or the renderer could not draw the paywall."],args:{min:0,max:1},flags:{...Pv,platform:{type:"string",value:"platform",description:"ios, android or web alone (default: all three)"},appearance:{type:"string",value:"appearance",description:"light or dark alone (default: both)"},"text-size":{type:"string",value:"size",description:"default or largest alone (default: both)"}},scope:"environment",async run(e){let t=await w(e),n=await Rv(e,t,!0,!0),s=await Ev(e,n,"measure it"),{taken:a}=await Tv(e,n,s,{measureOnly:!0});n.said();let i=a.flatMap((c,m)=>c.error?[`${Sv(n.shots[m])}: ${c.error}`]:[]);if(i.length>0)throw new y("preview_failed",`the renderer could not draw it: ${i.join("; ")}`,{exitCode:zp});let r=n.shots.map(Sv),o=a.map(c=>c.findings??[]),l=Av(o.map((c,m)=>({screen:r[m],findings:c.filter(f=>!f.note)}))),d=Av(o.map((c,m)=>({screen:r[m],findings:c.filter(f=>f.note)}))),p=c=>c.screens.length===r.length?"on every screen":`on ${c.screens.join(", ")}`;return e.out.result({problems:l,notes:d,screens:r},()=>{for(let m of l)e.out.line(`${m.code} \u2014 ${m.where} \u2014 ${m.message}`),e.out.line(` ${p(m)}`);for(let m of d)e.out.line(`note: ${m.code} \u2014 ${m.where} \u2014 ${m.message} (${p(m)})`);let c=new Set(l.flatMap(m=>m.screens)).size;e.out.line(l.length===0?`Nothing wrong on ${r.length} screen(s)${d.length>0?`; ${d.length} thing(s) not measured`:""}.`:`${l.length} problem(s), on ${c} of ${r.length} screen(s).`)}),l.length>0?1:void 0}};import{createHash as tI}from"node:crypto";import{mkdtemp as nI,rm as sI,stat as aI,writeFile as iI}from"node:fs/promises";import{tmpdir as rI}from"node:os";import{join as Ov}from"node:path";var Iv={"image/png":".png","image/jpeg":".jpg","image/webp":".webp","video/mp4":".mp4","video/quicktime":".mov","font/ttf":".ttf","font/otf":".otf","font/woff2":".woff2","application/zip":".zip"},oI=new Set(["image","video","font","html"]),lI=/^[a-z0-9][a-z0-9-]{0,62}$/,dI=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,pI=/^[0-9a-f]{64}$/i,cI=50<<20;function uI(e){let t=s=>{throw new y("unexpected_answer",`the environment answered a template the CLI does not take: ${s}`)},n=e;(typeof n!="object"||n===null)&&t("one is not an object"),(typeof n.key!="string"||!lI.test(n.key))&&t(`its key ${JSON.stringify(n.key)} is not lowercase letters, digits and dashes`),(typeof n.name!="string"||typeof n.description!="string")&&t(`${n.key} has no name or description`),(typeof n.definition!="object"||n.definition===null||Array.isArray(n.definition))&&t(`${n.key} has no definition`),Array.isArray(n.assets)||t(`${n.key} has no list of assets`);for(let s of n.assets)(typeof s?.id!="string"||!dI.test(s.id))&&t(`an asset of ${n.key} has the id ${JSON.stringify(s?.id)}, which is not a uuid`),oI.has(s.kind)||t(`the asset ${s.id} of ${n.key} is a ${JSON.stringify(s.kind)}, not an image, a video, a font or an HTML block`),Object.hasOwn(Iv,s.content_type)||t(`the asset ${s.id} of ${n.key} is ${JSON.stringify(s.content_type)}, which no paywall asset is`),(!Number.isInteger(s.size)||s.size<=0||s.size>cI)&&t(`the asset ${s.id} of ${n.key} is ${JSON.stringify(s.size)} bytes`),(typeof s.sha256!="string"||!pI.test(s.sha256))&&t(`the asset ${s.id} of ${n.key} has no SHA-256`);return n}async function Lv(e,t){let n=await h(e,t,"GET","/purchases/paywalls/templates");if(!Array.isArray(n?.templates))throw new y("unexpected_answer","the environment answered the templates without their list");return n.templates.map(uI)}var Nv={monthly:1,yearly:12,weekly:12/52,quarterly:3,once:0};function mI(e){let t=/^P(\d+)([DWMY])$/.exec(e??"");if(!t)return 0;let n=Number(t[1]);return t[2]==="D"?n*12/365:t[2]==="W"?n*12/52:t[2]==="M"?n:n*12}function hI(e,t){let n=t?.products??[],s=new Set(n.flatMap(c=>c.plans.map(m=>`${c.key}.${m.key}`))),a=[],i=[];for(let c of n){if(c.type==="consumable")continue;let m=c.plans.map(f=>({key:f.key,months:mI(f.period)}));(m.some(f=>f.months>0)?a:i).push({key:c.key,plans:m})}let r={},o=new Set;for(let c of e)s.has(c)&&(r[c]=c,o.add(c));let l=[...new Set(e.map(c=>c.split(".")[0]))],d={},p=new Set;for(let c of l){let m=[...a,...i].find(f=>f.key===c);m&&(d[c]=m,p.add(m.key))}for(let c of l){if(d[c])continue;let f=(e.some(b=>b.startsWith(`${c}.`)&&(Nv[b.split(".")[1]]??0)>0)?a:i).find(b=>!p.has(b.key));f&&(d[c]=f,p.add(f.key))}for(let c of e){if(r[c])continue;let[m,f]=c.split("."),b=d[m],v=Nv[f],R=b?.plans.find(A=>v!==void 0&&Math.abs(A.months-v)<.01&&!o.has(`${b.key}.${A.key}`));b&&R&&(r[c]=`${b.key}.${R.key}`,o.add(r[c]))}return r}function gI(e,t){let n=s=>{if(Array.isArray(s))return s.map(n);if(typeof s!="object"||s===null)return s;let a=s,i={};for(let[r,o]of Object.entries(a))(r==="package"||r==="on_package"||r==="off_package")&&typeof o=="string"?i[r]=t[o]??o:r==="selected_package"&&Array.isArray(o)?i[r]=o.map(l=>typeof l=="string"?t[l]??l:l):i[r]=n(o);if(a.type==="package"&&typeof a.product=="string"&&typeof a.plan=="string"){let r=t[`${a.product}.${a.plan}`];r&&([i.product,i.plan]=r.split("."))}return i};return n(e)}function fI(e,t){let n=s=>{if(Array.isArray(s))return s.map(n);if(typeof s=="string"){let a=/^asset:(.+)$/.exec(s)?.[1];return a&&t[a]?t[a]:s}return typeof s!="object"||s===null?s:Object.fromEntries(Object.entries(s).map(([a,i])=>[a,n(i)]))};return n(e)}function yI(e,t,n){let s={};for(let a of e??[]){let i=a.indexOf("="),[r,o]=i<0?[a,""]:[a.slice(0,i),a.slice(i+1)];if(!t.includes(r))throw g(`--package ${a}: the template sells ${t.join(", ")||"no package"}, not ${r}`);if(!n.has(o))throw g(`--package ${a}: the catalog sells no package ${o||"(none named)"}`,n.size>0?`the catalog's: ${[...n].join(", ")}`:"the catalog sells nothing yet: palbase purchases:catalog:put");s[r]=o}return s}var bI={name:"purchases:paywalls:templates",summary:"the module's designed paywalls to start from: each one's key, what it looks like, and the packages it sells",details:["palbase purchases:paywalls:new <name> --template <key> writes one to a file, selling the catalog's own packages."],scope:"environment",async run(e){let t=await w(e),s=(await Lv(e,t)).map(a=>({key:a.key,name:a.name,description:a.description,packages:sr(a.definition),assets:a.assets}));e.out.result({templates:s},()=>{e.out.table(s,[{header:"template",value:a=>a.key},{header:"name",value:a=>a.name},{header:"sells",value:a=>a.packages.join(", ")},{header:"what it looks like",value:a=>a.description}]),e.out.line("Make a paywall from one: palbase purchases:paywalls:new <name> --template <key>")})}};async function wI(e,t,n,s){let a=await Li(e,t),i=`${Wt(e.cloud,t.env_ref)}/purchases/paywalls/templates/${T(n)}/assets/${T(s.id)}`,r;try{r=await e.io.fetch(i,{headers:{apikey:a.key},redirect:"manual"})}catch(l){throw new y("network_error",`the template's ${s.kind} could not be downloaded: ${l instanceof Error?l.message:String(l)}`)}if(!r.ok)throw new y("template_asset_unavailable",`the template's ${s.kind} (${s.id}) could not be downloaded: the environment answered ${r.status}`);let o=Buffer.from(await r.arrayBuffer());if(o.length!==s.size||tI("sha256").update(o).digest("hex")!==s.sha256.toLowerCase())throw new y("template_asset_changed",`the template's ${s.kind} (${s.id}) did not arrive as the bytes the template names: nothing was uploaded`);return o}var vI={name:"purchases:paywalls:new",summary:"write a new paywall's definition to a file from one of the module's templates, selling the catalog's own packages, its pictures uploaded to the project",usage:`<name> --template <key> [--package <template package>=<product.plan> \u2026] [--out <${mt}/name.json>]`,details:["A template sells pro.monthly, pro.yearly, family.monthly, family.yearly and lifetime.once: each is renamed to the catalog's package that stands for it \u2014 the same one when the catalog sells it, else a plan of the same period. One that nothing stands for is said, and stays: --package pro.yearly=<product>.<plan> names it.","A template's pictures are uploaded to the project's public bucket paywall-assets (made when there is none; a private one is left as it is, and nothing is written) and registered; the definition names the project's assets in their place.","Nothing is saved to the environment but those assets: the file is edited, checked and looked at (purchases:paywalls:validate, :preview, :check), then saved with purchases:paywalls:put <name> --file <file> --revision 0."],args:{min:1,max:1},flags:{template:{type:"string",value:"key",description:"the template, as purchases:paywalls:templates lists them"},package:{type:"string",multiple:!0,value:"from=to",description:"a template's package and the catalog's that stands for it (repeat it, or a comma list)"},out:{type:"string",value:"file",description:`where under ${me}/ (default: ${mt}/<name>.json)`}},scope:"environment",async run(e){let t=await w(e),n=e.args[0].trim();if(n===""||[...n].length>100)throw g("a paywall's name is 1 to 100 characters");let s=e.flags.template;if(s===void 0||s.trim()==="")throw g("--template names the template to start from","palbase purchases:paywalls:templates lists them");let a=e.flags.out!==void 0?Nt(e,"out",e.flags.out,".json"):`${mt}/${Zi(n)}.json`;try{throw await aI(await Be(e.io.cwd,a)),new y("file_exists",`${a} is there already: a template is not written over a file`,{hint:"name another with --out, or remove the file"})}catch(A){if(A.code!=="ENOENT")throw A}let i=await Lv(e,t),r=i.find(A=>A.key===s);if(!r)throw new y("template_not_found",`no template ${JSON.stringify(s)}`,{hint:`the module's: ${i.map(A=>A.key).join(", ")}`});let o=sr(r.definition),l=(await h(e,t,"GET","/purchases/catalog")).catalog,d=new Set((l?.products??[]).flatMap(A=>A.plans.map(C=>`${A.key}.${C.key}`))),p={...hI(o,l),...yI(Ie(e.flags.package),o,d)},c=o.filter(A=>!p[A]),m=new Set([...JSON.stringify(r.definition).matchAll(/asset:([0-9a-f-]{36})/g)].map(A=>A[1])),f=r.assets.filter(A=>m.has(A.id)),b={},v=[];if(f.length>0){let A=await Ya(e,t),C=f.filter(N=>{let j=A.find(U=>U.sha256.toLowerCase()===N.sha256.toLowerCase()&&U.kind===N.kind);return j&&(b[N.id]=j.ref),!j});if(C.length>0){await k(e,t,`upload the template's ${C.length} asset(s) to the project's paywall-assets bucket and register ${C.length===1?"it":"them"}`),await Ap(e,t);let N=await nI(Ov(rI(),"palbase-template-"));try{for(let[j,U]of C.entries()){let G=Ov(N,`asset-${j}${Iv[U.content_type]}`);await iI(G,await wI(e,t,r.key,U));let K=await Pp(e,t,G,U.kind);b[U.id]=K.ref,v.push(K)}}finally{await sI(N,{recursive:!0,force:!0})}}}let R=fI(gI({...r.definition,name:n},p),b);await tl(e,a,R),e.out.result({file:a,template:r.key,name:n,packages:p,unmapped:c,assets:b,uploaded:v.map(A=>A.ref)},()=>{e.out.line(`Wrote ${n} to ${a}, from the template ${r.key}.`);for(let A of o)p[A]&&p[A]!==A&&e.out.line(` ${A} is the catalog's ${p[A]}`);for(let A of c)e.out.warn(`the catalog sells nothing that stands for ${A}: it stays ${A} in the file \u2014 a draft is warned of it, a publish refuses it. Name the catalog's: --package ${A}=<product>.<plan>, or change it in the file`);for(let A of v)e.out.line(` uploaded and registered its ${A.kind}: ${A.ref}`);e.out.line(`Edit it, then look at it and save it: palbase purchases:paywalls:preview --file ${a} \xB7 palbase purchases:paywalls:put ${JSON.stringify(n)} --file ${a} --revision 0`)})}},Dv=[bI,vI];import{writeFile as CI,mkdir as jI}from"node:fs/promises";import{dirname as OI}from"node:path";var _I=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,$I=/^[a-z][a-z0-9_]{0,19}$/,kI=/^[a-z0-9][a-z0-9_-]{0,63}$/;async function pl(e,t,n){let s=[],a;do{let i=new URLSearchParams({limit:"100",...n?{placement:n}:{},...a?{cursor:a}:{}}),r=await h(e,t,"GET",`/purchases/experiments?${i}`);s.push(...r.experiments),a=r.next_cursor}while(a&&s.length<1e3);return s}async function Jp(e,t){let n=e.args[0];if(n===void 0||n.trim()==="")throw g("the experiment's id or name is required");if(_I.test(n))try{return await h(e,t,"GET",`/purchases/experiments/${T(n.toLowerCase())}`)}catch(r){throw r instanceof W&&r.code==="experiment_not_found"?new y("experiment_not_found",`no experiment ${n}`,{hint:"palbase purchases:experiments lists them"}):r}let s=(await pl(e,t)).filter(r=>r.name===n),a=s.filter(r=>r.status==="running"),i=a.length===1?a[0]:s.length===1?s[0]:void 0;if(i)return i;throw s.length===0?new y("experiment_not_found",`no experiment ${JSON.stringify(n)}`,{hint:"palbase purchases:experiments lists them"}):new y("ambiguous_experiment",`${s.length} experiments are named ${JSON.stringify(n)}`,{hint:`name one by its id: ${s.map(r=>r.id).join(", ")}`})}function Mv(e,t){let n=e.variants.reduce((s,a)=>s+a.weight,0);return e.variants.map(s=>`${s.key}=${t.get(s.paywall_id)??s.paywall_id} ${Math.round(s.weight/n*100)}%`).join(", ")}function xv(e,t){throw e instanceof W&&e.code==="experiment_ended"?new y("experiment_ended",`${t.name} has ended (${t.status}): nothing was changed`):e}var SI={name:"purchases:experiments",summary:"the environment's paywall experiments: the placement each runs on, its variants and their shares, and how it ended",usage:"[--placement <placement>]",flags:{placement:{type:"string",value:"placement",description:"one placement's alone"}},scope:"environment",async run(e){let t=await w(e),[n,s]=await Promise.all([pl(e,t,e.flags.placement),Qn(e,t)]),a=new Map(s.map(i=>[i.id,i.name]));e.out.result({experiments:n},()=>{if(n.length===0){e.out.line("No experiment yet."),e.out.line("Start one: palbase purchases:experiments:start <placement> --variants <paywall>=50,<paywall>=50");return}e.out.table(n,[{header:"name",value:i=>i.name},{header:"id",value:i=>i.id},{header:"placement",value:i=>`${i.placement}${i.audience==="rules"?" (rules)":""}`},{header:"variants",value:i=>Mv(i,a)},{header:"status",value:i=>i.status==="won"?`won by ${i.winner}`:i.status},{header:"started",value:i=>Y(i.started_at)}])})}};function AI(e){let t=e??[];if(t.length<2||t.length>4)throw g("--variants names 2 to 4 paywalls, each with its weight: --variants aurora=50,cards=50");let n=t.map((s,a)=>{let i=/^(?:([^:=]+):)?([^=]+)=(\d+)$/.exec(s.trim());if(!i)throw g(`--variants ${s}: a variant is <paywall>=<weight>, or <key>:<paywall>=<weight>`);let r=i[1]??"abcd"[a],o=Number(i[3]);if(!$I.test(r))throw g(`--variants ${s}: a variant's key is lowercase letters, digits and _, at most 20, starting with a letter`);if(o<1||o>1e3)throw g(`--variants ${s}: a weight is 1 to 1000`);return{key:r,paywall:i[2],weight:o}});if(new Set(n.map(s=>s.key)).size!==n.length)throw g("--variants: every variant has a key of its own");return n}var PI={name:"purchases:experiments:start",summary:"start an experiment on a placement: each viewer is shown one of 2 to 4 published paywalls, by weight, the same one every time",usage:"<placement> --variants <paywall>=<weight>,<paywall>=<weight>[,\u2026] [--audience placement|rules] [--name <name>]",details:["audience placement (the default): everyone at the placement, decided before its rules; the placement is made when new and keeps its default for when the experiment ends.","audience rules: only the viewers the placement's rules send to it \u2014 a rule's target names the experiment (purchases:placements:rules:put).","The first variant is what a stop keeps. One experiment runs on a placement at a time; each variant's paywall must be published."],args:{min:1,max:1},flags:{variants:{type:"string",multiple:!0,value:"paywall=weight,\u2026",description:"the paywalls (name or id) and their weights; key:paywall=weight names a key (else a, b, c, d)"},audience:{type:"string",value:"audience",description:"placement (default) or rules"},name:{type:"string",value:"name",description:"the experiment's name (default: the placement and its paywalls)"}},scope:"environment",async run(e){let t=await w(e),n=e.args[0];if(!kI.test(n))throw g(`${JSON.stringify(n)} is not a placement's key: lowercase letters, digits, _ and -, at most 64`);let s=e.flags.audience;if(s!==void 0&&s!=="placement"&&s!=="rules")throw g("--audience is placement or rules");let a=AI(Ie(e.flags.variants)),i=await Qn(e,t),r=a.map(p=>{let c=sl(i,p.paywall);if(!c)throw new y("paywall_not_found",`no paywall ${JSON.stringify(p.paywall)}`,{hint:`the project's: ${i.map(m=>m.name).join(", ")||"none yet"}`});if(c.published_version===0)throw new y("unpublished_paywall",`${c.name} was never published: a variant shows a published paywall`,{hint:`palbase purchases:paywalls:publish ${JSON.stringify(c.name)}`});return{key:p.key,paywall_id:c.id,weight:p.weight}});if(new Set(r.map(p=>p.paywall_id)).size!==r.length)throw g("--variants: each variant is a paywall of its own");let o=new Map(i.map(p=>[p.id,p.name])),l=(e.flags.name??`${n}: ${r.map(p=>o.get(p.paywall_id)).join(" vs ")}`).slice(0,100);await k(e,t,`start ${JSON.stringify(l)} on ${n} (${s??"placement"}): ${r.map(p=>`${p.key}=${o.get(p.paywall_id)} \xD7${p.weight}`).join(", ")}`);let d;try{d=await h(e,t,"POST","/purchases/experiments",{name:l,placement:n,variants:r,...s?{audience:s}:{}},J())}catch(p){throw p instanceof W&&p.code==="experiment_running"?new y("experiment_running",`an experiment runs on ${n} already: one runs on a placement at a time`,{hint:"palbase purchases:experiments lists it; stop it or declare its winner first"}):p instanceof W&&p.code==="placement_not_found"?new y("placement_not_found",`the environment has no placement ${n}: an experiment for its rules runs on a placement that is there`,{hint:`palbase purchases:placements:set ${n} --paywall <name>`}):p instanceof W&&p.code==="invalid_experiment"?new y("invalid_experiment",`the experiment was not started: ${p.message}`):p}e.out.result(d,()=>{e.out.line(`Started ${d.name} (${d.id}) on ${n}: ${Mv(d,o)}.`),d.audience==="rules"&&e.out.line(`It shows only the viewers a rule sends it: a rule's target is { "experiment_id": "${d.id}" } (palbase purchases:placements:rules:put ${n}).`),e.out.line(`Its results: palbase purchases:experiments:results ${d.id}`)})}},RI={name:"purchases:experiments:stop",summary:"stop a running experiment, at once: what it showed becomes its first variant's paywall; its results stay",usage:"<id|name>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=await Jp(e,t);await k(e,t,`stop ${n.name} on ${n.placement}: its first variant (${n.variants[0]?.key}) stays`);let s;try{s=await h(e,t,"POST",`/purchases/experiments/${T(n.id)}/stop`,void 0,J())}catch(a){xv(a,n)}e.out.result(s,()=>e.out.line(`Stopped ${s.name}: ${s.placement} shows variant ${s.variants[0]?.key}'s paywall${s.audience==="rules"?" where its rules sent the experiment":""}.`))}},EI={name:"purchases:experiments:winner",summary:"end a running experiment with its winner: the winner's paywall becomes the placement's default \u2014 or, with --as-rule, a rule shows it to everyone",usage:"<id|name> --variant <key> [--as-rule]",details:["For an experiment for everyone at the placement, --as-rule rolls the winner out as a live rule at the top of its rules (to narrow later) and leaves the default as it is. For one for the rules, the rules that targeted it show the winner's paywall.","purchases:experiments:results says which variant leads and whether calling it is sound yet."],args:{min:1,max:1},flags:{variant:{type:"string",value:"key",description:"the winning variant's key"},"as-rule":{type:"boolean",description:"roll the winner out as a rule for everyone, at the top of the placement's rules"}},scope:"environment",async run(e){let t=await w(e),n=e.flags.variant;if(n===void 0||n.trim()==="")throw g("--variant is the winning variant's key");let s=await Jp(e,t);if(!s.variants.some(r=>r.key===n))throw g(`${s.name} has no variant ${n}: its variants are ${s.variants.map(r=>r.key).join(", ")}`);let a=e.flags["as-rule"]===!0;await k(e,t,`end ${s.name} with ${n} as its winner${a?", as a rule for everyone":""}`);let i;try{i=await h(e,t,"POST",`/purchases/experiments/${T(s.id)}/winner`,{variant:n,...a?{as_rule:!0}:{}},J())}catch(r){if(r instanceof W&&r.code==="too_many_rules")throw new y("too_many_rules",`${s.placement} has 50 rules, the most it holds: the winner cannot be added as one \u2014 nothing was changed`,{hint:"declare it without --as-rule, or take a rule out first"});xv(r,s)}e.out.result(i,()=>e.out.line(a?`${i.name} is won by ${n}: a rule at the top of ${i.placement}'s rules shows its paywall to everyone.`:`${i.name} is won by ${n}: ${i.placement} shows its paywall${i.audience==="rules"?" where its rules sent the experiment":""}.`))}};function Hp(e){let t=e.amount_micros/1e6;try{return new Intl.NumberFormat("en",{style:"currency",currency:e.currency}).format(t)}catch{return`${t.toFixed(2)} ${e.currency}`}}var ar=e=>`${(e*100).toFixed(1)}%`,TI={name:"purchases:experiments:results",summary:"what each variant's viewers did \u2014 exposures, viewers, purchases, conversion, revenue \u2014 each one's chance to convert best, and whether calling the leader is sound",usage:"<id|name> [--window-days <n>] [--sandbox]",details:["A purchase counts for the first variant its buyer saw, within the window after seeing it (7 days unless said): the purchases the stores confirmed, never what an app reports. Revenue is what was paid to date, renewals in, refunds out.","The chance to win is Bayesian (each variant's rate a Beta distribution): how likely each one is best. The leader is called soundly once every variant has been seen enough and its chance is high enough; until then the reasons are said."],args:{min:1,max:1},flags:{"window-days":{type:"string",value:"n",description:"the days after first seeing a variant a purchase counts for it, 1 to 90 (default 7)"},sandbox:{type:"boolean",description:"count the stores' test purchases too"}},scope:"environment",async run(e){let t=await w(e),n=Te(e.flags["window-days"],"window-days");if(n!==void 0&&(n<1||n>90))throw g("--window-days is 1 to 90");let s=await Jp(e,t),a=new URLSearchParams({...n!==void 0?{window_days:String(n)}:{},...e.flags.sandbox===!0?{sandbox:"true"}:{}}),[i,r]=await Promise.all([h(e,t,"GET",`/purchases/experiments/${T(s.id)}/results${a.size>0?`?${a}`:""}`),Qn(e,t)]),o=new Map(r.map(l=>[l.id,l.name]));e.out.result({...i,name:s.name},()=>{if(e.out.line(`${s.name} on ${s.placement}: ${i.status}${s.winner?`, won by ${s.winner}`:""} \u2014 purchases within ${i.window_days} day(s) of first seeing a variant${i.sandbox?", test purchases included":""}, counted ${Y(i.computed_at)}`),e.out.table(i.variants,[{header:"variant",value:l=>`${l.variant}${l.variant===i.leader?" (leads)":""}`},{header:"paywall",value:l=>o.get(l.paywall_id)??l.paywall_id},{header:"weight",value:l=>String(l.weight)},{header:"exposures",value:l=>String(l.exposures)},{header:"viewers",value:l=>String(l.viewers)},{header:"purchases",value:l=>String(l.purchases)},{header:"converted",value:l=>`${l.converters} (${ar(l.conversion_rate)})`},{header:"revenue",value:l=>l.revenue.length===0?"\u2014":l.revenue.map(Hp).join(" + ")},{header:"chance to win",value:l=>ar(l.chance_to_win)}]),i.confident)e.out.line(`Calling ${i.leader} the winner is sound: palbase purchases:experiments:winner ${s.id} --variant ${i.leader}`);else{e.out.line(`Not sound to call yet (each variant seen by ${i.confidence.min_viewers}, the leader at ${ar(i.confidence.min_chance)} to win):`);for(let l of i.confidence.reasons)e.out.line(` ${l.message}`)}})}},Gv=[SI,PI,RI,EI,TI];var NI=/^[a-z0-9_-]{1,64}$/;function Qa(e){let t=e.args[0];if(t===void 0||t.trim()==="")throw g("the placement's key is required");if(!NI.test(t))throw g(`${JSON.stringify(t)} is not a placement's key: lowercase letters, digits, _ and -, at most 64`);return t}async function rr(e,t){return new Map((await Qn(e,t)).map(n=>[n.id,n.name]))}var ir=(e,t)=>t===void 0?"\u2014":e.get(t)??t;function Uv(e){let t=e.field==="attribute"?`attribute ${e.key??"?"}`:e.field==="sdk_version"?`sdk_version (${e.sdk??"?"})`:e.field,n=e.values!==void 0?e.values.join(", "):e.value!==void 0?String(e.value):"";return`${t} ${e.op}${n===""?"":` ${n}`}`}function II(e,t){return e.paywall_id!==void 0?`paywall ${ir(t,e.paywall_id)}`:`experiment ${e.experiment_id??"?"}`}function LI(e){let t=[e.starts_at?`from ${Y(e.starts_at)}`:"",e.ends_at?`until ${Y(e.ends_at)}`:""].filter(Boolean);return t.length===0?"":` (${t.join(" ")} UTC)`}function Kv(e,t,n){t.forEach((s,a)=>{e.out.line(`${a+1}. ${s.name} \u2014 ${s.status??s.state}${LI(s)} \u2192 ${II(s.target,n)}`);let i=s.conditions??[];i.length===0&&e.out.line(" everyone");for(let r of i)e.out.line(` ${Uv(r)}`)})}var DI={name:"purchases:placements",summary:"the environment's placements: each one's default paywall, its rules and the experiment running on it",details:['An app asks for a placement by its key (pb.purchases.paywall("onboarding")): an experiment running for everyone there decides first, then the first of its rules that holds for the viewer, then its default paywall.'],scope:"environment",async run(e){let t=await w(e),[{placements:n},s]=await Promise.all([h(e,t,"GET","/purchases/placements"),rr(e,t)]),a=n.map(i=>({...i,paywall:i.paywall_id===void 0?null:ir(s,i.paywall_id)}));e.out.result({placements:a},()=>{if(a.length===0){e.out.line("No placement yet."),e.out.line("Give one a paywall: palbase purchases:placements:set <placement> --paywall <name>");return}e.out.table(a,[{header:"placement",value:i=>i.key},{header:"default paywall",value:i=>i.paywall??"\u2014"},{header:"rules",value:i=>String(i.rule_count)},{header:"experiment",value:i=>i.experiment_id??"\u2014"},{header:"changed",value:i=>Y(i.updated_at)}])})}};function Fv(e,t,n){throw e instanceof W&&e.code==="experiment_running"?new y("experiment_running",`an experiment runs on ${t}: ${n} while it runs`,{hint:"palbase purchases:experiments lists it; stop it or declare its winner first"}):e}var MI={name:"purchases:placements:set",summary:"give a placement its default paywall \u2014 what it shows whoever none of its rules holds for \u2014 making the placement when it is new",usage:"<placement> --paywall <name|id>",details:["The apps asking for it get the paywall's newest version they can draw; a paywall never published is nothing yet: they draw their own until it is."],args:{min:1,max:1},flags:{paywall:{type:"string",value:"name|id",description:"the paywall it shows"}},scope:"environment",async run(e){let t=await w(e),n=Qa(e),s=e.flags.paywall;if(s===void 0||s.trim()==="")throw g("--paywall names the paywall the placement shows");let a=await aa(e,t,s);await k(e,t,`show ${a.name} at ${n}`);let i;try{i=await h(e,t,"PUT",`/purchases/placements/${T(n)}`,{paywall_id:a.id},J())}catch(r){if(r instanceof W&&r.code==="too_many_placements")throw new y("too_many_placements","the project has 200 placements, the most it holds: nothing was made",{hint:"delete one no app asks for: palbase purchases:placements:delete <placement>"});Fv(r,n,"the experiment decides what it shows, and its end the default \u2014 it is not changed")}e.out.result({...i,paywall:a.name},()=>{e.out.line(`${n} shows ${a.name}${i.rule_count>0?` to whoever none of its ${i.rule_count} rule(s) holds for`:""}.`),a.published_version===0&&e.out.warn(`${a.name} was never published: the apps draw their own paywall until it is (palbase purchases:paywalls:publish ${JSON.stringify(a.name)})`)})}},xI={name:"purchases:placements:delete",summary:"forget a placement and its rules: the apps that ask for it draw their own paywall",usage:"<placement>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=Qa(e);await k(e,t,`delete the placement ${n} and its rules`);try{await h(e,t,"DELETE",`/purchases/placements/${T(n)}`,void 0,J())}catch(s){if(s instanceof W&&s.code==="placement_not_found")throw new y("placement_not_found",`the environment has no placement ${n}`,{hint:"palbase purchases:placements lists them"});Fv(s,n,"it is not deleted")}e.out.result({deleted:n},()=>e.out.line(`Deleted ${n}: the apps that ask for it draw their own paywall.`))}};async function Bv(e,t){let n=Fe(await Xe(e,t,"the rules"),"the rules"),s=Array.isArray(n)?n:typeof n=="object"&&n!==null&&Array.isArray(n.rules)?n.rules:void 0;if(s===void 0)throw g('the rules are { "rules": [ \u2026 ] }, as purchases:placements:rules:get --out writes them, or the list alone');return s.map(a=>{let{status:i,...r}=a;return r})}function Wv(e,t,n){if(t instanceof W&&t.code==="invalid_rules"){let s=(t.body??{}).problems??[];if(s.length>0){e.out.note(`The rules break ${s.length} rule(s):`);for(let a of s)e.out.note(` ${a.path}: ${a.code} \u2014 ${a.message}`)}throw new y("invalid_rules",`${n}: ${t.message}`,{hint:"fix each problem in the file; purchases:placements:preview --rules <file> tries them without saving"})}throw t}var GI={name:"purchases:placements:rules:get",summary:"a placement's rules, in the order they are read \u2014 each with its conditions, schedule and target \u2014 and their revision",usage:"<placement> [--out <palbase/\u2026.json>]",details:['--out writes them to a file to edit ({ "rules": [ \u2026 ] }); rules:put saves the edit on the revision printed.'],args:{min:1,max:1},flags:{out:{type:"string",value:"file",description:"write the rules to this file, under palbase/"}},scope:"environment",async run(e){let t=await w(e),n=Qa(e),s;try{s=await h(e,t,"GET",`/purchases/placements/${T(n)}/rules`)}catch(r){throw r instanceof W&&r.code==="placement_not_found"?new y("placement_not_found",`the environment has no placement ${n}`,{hint:`give it a paywall first: palbase purchases:placements:set ${n} --paywall <name>`}):r}let a=e.flags.out;if(a!==void 0){let r=Nt(e,"out",a,".json"),o=await Be(e.io.cwd,r);await jI(OI(o),{recursive:!0}),await Be(e.io.cwd,r),await CI(o,`${JSON.stringify({rules:s.rules.map(({status:l,...d})=>d)},null,2)}
|
|
686
|
-
`),e.out.result({file:r,placement:n,revision:s.revision},()=>{e.out.line(`Wrote revision ${s.revision} of ${n}'s ${s.rules.length} rule(s) to ${r}.`),e.out.line(`Save an edit of them: palbase purchases:placements:rules:put ${n} --file ${r} --revision ${s.revision}`)});return}let i=await rr(e,t);e.out.result(s,()=>{e.out.line(`${n}: revision ${s.revision} of its rules`),s.rules.length===0&&e.out.line("No rule: it shows its default paywall to everyone."),Kv(e,s.rules,i)})}},qI={name:"purchases:placements:rules:put",summary:"replace a placement's rules \u2014 all of them, in the order they are to be read \u2014 on the revision they were edited from",usage:"<placement> --file <rules.json> --revision <n>",details:["The first rule in effect whose conditions all hold for a viewer shows its target: a published paywall, or the variant of the experiment running on the placement for the rules. At most 50 rules of at most 10 conditions.","A condition reads country, platform, app, app_version, sdk_version, locale, entitlement, first_seen_days or an attribute the app sends; purchases:placements:preview tries rules against a viewer before they are saved (--rules).","Of two people editing at once, the second is told \u2014 the rules moved past the revision they edited \u2014 never overwritten."],args:{min:1,max:1},flags:{file:{type:"string",value:"rules.json",description:"the rules, as rules:get --out wrote them ('-' or none: stdin)"},revision:{type:"string",value:"n",description:"the revision they were edited from, as rules:get printed it"}},scope:"environment",async run(e){let t=await w(e),n=Qa(e),s=Te(e.flags.revision,"revision");if(s===void 0)throw g("--revision is the revision the rules were edited from: of two edits at once, the second is told, not saved over the first");let a=await Bv(e,e.flags.file);await k(e,t,`replace ${n}'s rules with ${a.length} rule(s) over revision ${s}`);let i;try{i=await h(e,t,"PUT",`/purchases/placements/${T(n)}/rules`,{rules:a},{"if-match":nl(s),...J()})}catch(o){if(o instanceof W&&o.status===412)throw new y("rules_changed",`${n}'s rules are no longer at revision ${s}: someone saved newer ones since they were read \u2014 nothing was saved`,{hint:`read them again (palbase purchases:placements:rules:get ${n} --out <file>), make the edit on them, and save with that revision`});if(o instanceof W&&o.code==="placement_not_found")throw new y("placement_not_found",`the environment has no placement ${n}`,{hint:`give it a paywall first: palbase purchases:placements:set ${n} --paywall <name>`});Wv(e,o,"the rules were not saved")}let r=await rr(e,t);e.out.result(i,()=>{e.out.line(`Saved revision ${i.revision} of ${n}'s rules:`),Kv(e,i.rules,r),i.rules.length===0&&e.out.line("No rule: it shows its default paywall to everyone.")})}};function qv(e){let t=Ie(e);if(t===void 0||t.length===0)return;let n={};for(let s of t){let a=s.indexOf("=");if(a<=0)throw g(`--attr ${s}: an attribute is key=value`);let i=An(s.slice(a+1));n[s.slice(0,a)]=typeof i=="number"||typeof i=="boolean"?i:s.slice(a+1)}return n}var UI={matched:"decided",unmet:"did not hold",unavailable:"its experiment no longer runs",not_reached:"not reached"},KI={name:"purchases:placements:preview",summary:"what a placement shows a viewer, and why: the experiment, the rule that decided \u2014 every rule, condition by condition \u2014 or the default",usage:"<placement> [--platform ios|android|web] [--country TR] [--app-version 2.1.0] [--sdk palbase-swift@0.2.0] [--locale tr-TR] [--attr key=value \u2026] [--user <id>] [--rules <file>] [--at <RFC3339>]",details:["The viewer is what its app would send. With --user, the user's entitlements and the days since they were first seen are the project's; the user (else an installation) is who an experiment's variant is drawn for.","--rules tries rules not yet saved (a rules:put file) instead of the saved ones; --at, a moment (a scheduled rule's start). Nothing is counted or changed."],args:{min:1,max:1},flags:{platform:{type:"string",value:"platform",description:"ios, android or web"},country:{type:"string",value:"code",description:"the store's country: ISO 3166-1, two or three letters"},"app-version":{type:"string",value:"version",description:"the app's version"},sdk:{type:"string",value:"name@version",description:"the SDK the app draws with (palbase-swift@0.2.0)"},locale:{type:"string",value:"tag",description:"the viewer's language (BCP 47)"},attr:{type:"string",multiple:!0,value:"key=value",description:"what the app says of the viewer (repeat it, or a comma list)"},user:{type:"string",value:"id",description:"the signed-in user"},rules:{type:"string",value:"file",description:"rules to try instead of the saved ones"},at:{type:"string",value:"RFC 3339",description:"the moment (default: now)"}},scope:"environment",async run(e){let t=await w(e),n=Qa(e),s=e.flags.platform;if(s!==void 0&&!["ios","android","web"].includes(s))throw g("--platform is one of ios, android, web");let a,i=e.flags.sdk;if(i!==void 0){let b=i.lastIndexOf("@");if(b<=0||b===i.length-1)throw g(`--sdk ${i}: it is the SDK's name and version, palbase-swift@0.2.0`);a={sdk:i.slice(0,b),sdk_version:i.slice(b+1)}}let r=e.flags.at;if(r!==void 0&&Number.isNaN(Date.parse(r)))throw g(`--at ${r}: a moment, as RFC 3339 writes it (2026-11-01T09:00:00Z)`);let o={...s?{platform:s}:{},...e.flags.country!==void 0?{country:e.flags.country}:{},...e.flags["app-version"]!==void 0?{app_version:e.flags["app-version"]}:{},...a??{},...e.flags.locale!==void 0?{locale:e.flags.locale}:{},...qv(e.flags.attr)?{attributes:qv(e.flags.attr)}:{},...e.flags.user!==void 0?{user_id:e.flags.user}:{}},l=e.flags.rules!==void 0?await Bv(e,e.flags.rules):void 0,d={context:o,...r?{at:r}:{},...l?{rules:l}:{}},p;try{p=(await wt(e,t,"POST",`/purchases/placements/${T(n)}/resolve-preview`,d,J())).body}catch(b){if(b instanceof W&&b.code==="placement_not_found")throw new y("placement_not_found",`the environment has no placement ${n}`,{hint:"palbase purchases:placements lists them"});if(b instanceof W&&b.code==="invalid_context")throw new y("invalid_context",`the viewer is not one the module reads: ${b.message}`);Wv(e,b,"the rules cannot be tried")}let[c,m]=await Promise.all([rr(e,t),l??h(e,t,"GET",`/purchases/placements/${T(n)}/rules`).then(b=>b.rules)]),f={experiment:`the experiment running for everyone there (${p.experiment_id??"?"}), variant ${p.variant??"?"}`,rule:`the rule ${p.steps.find(b=>b.rule_id===p.rule_id)?.name??p.rule_id??"?"}${p.variant?`, variant ${p.variant} of its experiment`:""}`,default:"its default paywall: no rule held",none:"nothing: it has no paywall for this viewer, and the app draws its own"};e.out.result({...p,paywall:p.paywall_id===void 0?null:ir(c,p.paywall_id)},()=>{e.out.line(p.source==="none"?`${n} shows ${f.none}.`:`${n} shows ${ir(c,p.paywall_id)} \u2014 from ${f[p.source]}.`),p.steps.length>0&&e.out.line(`Its ${l?"rules tried":"rules"}, at ${Y(p.at)} UTC:`),p.steps.forEach((b,v)=>{e.out.line(`${v+1}. ${b.name} \u2014 ${b.status}: ${UI[b.outcome]??b.outcome}`);let R=(m.find(A=>A.id!==void 0&&A.id===b.rule_id)??m[v])?.conditions;for(let A of b.conditions??[]){let C=R?.[A.index];e.out.line(` ${A.met?"\u2713":"\u2717"} ${C?Uv(C):A.field}${A.unknown?" \u2014 the viewer carries none":""}`)}})})}};function FI(e,t){let n=e.variant?`, variant ${e.variant}`:"";return e.kind==="rule"?`${e.rule_current?`rule ${e.rule_name??e.rule_id??"?"}`:`removed rule ${e.rule_id??"?"}`}${n}`:e.kind==="experiment"?`experiment ${t.get(e.experiment_id??"")??e.experiment_id??"?"}${n}`:e.kind}var BI={name:"purchases:placements:results",summary:"what each of a placement's rules showed and what its viewers did \u2014 exposures, viewers, purchases, conversion, revenue \u2014 beside the rules since removed, an experiment's variants and the default",usage:"<placement> [--days <n>] [--window-days <n>] [--sandbox]",details:["What was shown in the last days (30 unless said, at most 90). The rules come in the order they are read, then the rules the placement no longer has, the variants of an experiment for everyone there, its default.","A purchase counts once, for what its buyer saw first at the placement, within the window after seeing it (7 days unless said): the purchases the stores confirmed, never what an app reports. Revenue is what was paid to date, renewals in, refunds out."],args:{min:1,max:1},flags:{days:{type:"string",value:"n",description:"the days of what was shown the results look back over, 1 to 90 (default 30)"},"window-days":{type:"string",value:"n",description:"the days after first seeing what was shown a purchase counts for it, 1 to 90 (default 7)"},sandbox:{type:"boolean",description:"count the stores' test purchases too"}},scope:"environment",async run(e){let t=await w(e),n=Qa(e),s=Te(e.flags.days,"days");if(s!==void 0&&(s<1||s>90))throw g("--days is 1 to 90");let a=Te(e.flags["window-days"],"window-days");if(a!==void 0&&(a<1||a>90))throw g("--window-days is 1 to 90");let i=new URLSearchParams({...s!==void 0?{days:String(s)}:{},...a!==void 0?{window_days:String(a)}:{},...e.flags.sandbox===!0?{sandbox:"true"}:{}}),r;try{r=await h(e,t,"GET",`/purchases/placements/${T(n)}/results${i.size>0?`?${i}`:""}`)}catch(p){throw p instanceof W&&p.code==="placement_not_found"?new y("placement_not_found",`the environment has no placement ${n}`,{hint:"palbase purchases:placements lists them"}):p}let[o,l]=await Promise.all([rr(e,t),r.sources.some(p=>p.experiment_id!==void 0)?pl(e,t,n).then(p=>new Map(p.map(c=>[c.id,c.name]))):new Map]),d=r.sources.map(p=>({...p,paywall:ir(o,p.paywall_id)}));e.out.result({...r,sources:d},()=>{if(e.out.line(`${n}: what was shown in the last ${r.days} day(s), purchases within ${r.window_days} day(s) of first seeing it${r.sandbox?", test purchases included":""}, counted ${Y(r.computed_at)}`),d.length===0){e.out.line("No one was shown a paywall here yet.");return}e.out.table(d,[{header:"shown by",value:p=>FI(p,l)},{header:"paywall",value:p=>p.paywall},{header:"exposures",value:p=>String(p.exposures)},{header:"viewers",value:p=>String(p.viewers)},{header:"purchases",value:p=>String(p.purchases)},{header:"converted",value:p=>`${p.converters} (${ar(p.conversion_rate)})`},{header:"revenue",value:p=>p.revenue.length===0?"\u2014":p.revenue.map(Hp).join(" + ")}])})}},WI={name:"purchases:placements:attributes",summary:"the attribute keys the environment's apps sent with a placement's paywall, as they said them \u2014 suggestions for attribute conditions, the most used first, each with its JSON type and the hours it was seen in",details:["An app sends what it says of the viewer as attributes (pb.purchases.paywall(placement, { attributes })); the keys are kept, never the values. They are what apps said, unverified \u2014 anyone with the publishable key can send one \u2014: a help to write rules, not a list of what the app defines.","A key is seen again at most once an hour, and counted in one more hour as often. At most 200 are kept: past them a new key takes the place of the key seen longest ago once that one was last seen over a day ago, so keys sent once age out."],scope:"environment",async run(e){let t=await w(e),{attributes:n}=await h(e,t,"GET","/purchases/placements/attributes");e.out.result({attributes:n},()=>{if(n.length===0){e.out.line("No app has sent an attribute yet."),e.out.line(`An app sends them with a placement's paywall: pb.purchases.paywall("onboarding", { attributes: { plan: "free" } })`);return}e.out.table(n,[{header:"key",value:s=>s.key},{header:"type",value:s=>s.type},{header:"hours seen",value:s=>String(s.seen_hours)},{header:"last seen",value:s=>Y(s.last_seen_at)}])})}},zv=[DI,MI,xI,GI,qI,KI,BI,WI];import{basename as zI,extname as JI,resolve as HI}from"node:path";import{stat as VI}from"node:fs/promises";var XI=/^[a-z][a-z0-9_]{0,63}$/,YI=/^P(?:\d+W)?(?:\d+D)?(?:T(?:\d+H)?(?:\d+M)?)?$/;function Dn(e,t="the journey's key"){if(e===void 0||e.trim()==="")throw g(`${t} is required`);if(!XI.test(e))throw g(`${JSON.stringify(e)} is not a journey's key: 1 to 64 of a-z, 0-9 and _, starting with a letter (winback)`);return e}async function ZI(e,t,n){let s=[],a;do{let i=new URLSearchParams({limit:"200",...n?{status:n}:{},...a?{cursor:a}:{}}),r=await h(e,t,"GET",`/journeys?${i}`);s.push(...r.journeys),a=r.next_cursor}while(a);return s}async function Jv(e,t,n){try{return await h(e,t,"GET",`/journeys/${T(n)}`)}catch(s){if(s instanceof W&&s.code==="journey_not_found")return;throw s}}function Ts(e){return new y("journey_not_found",`no journey ${e}`,{hint:"palbase journeys lists them"})}function Hv(e,t){for(let n of t)e.out.line(` ${n.path}: ${n.message}`),n.fix&&e.out.line(` fix: ${n.fix}`)}function Vv(e,t){if(t instanceof W&&t.code==="invalid_journey"){let s=t.body?.problems??[];throw e.out.result({valid:!1,problems:s},()=>{e.out.line(`The journey breaks ${s.length===1?"a rule":`${s.length} rules`}:`),Hv(e,s)}),new y("invalid_journey",`the journey has ${s.length} problem${s.length===1?"":"s"}`,{hint:"fix each at its path; palbase journeys:validate <file> checks it again",reported:!0})}throw t}async function Xp(e,t){return Fe(await Xe(e,t,"the journey"),"the journey")}function Xv(e){switch(e.kind){case"event":return`on ${e.key}`;case"audience":return`joins audience ${e.key}`;case"inactive":return`away from ${e.key}`;default:return`members of ${e.key}`}}function Vp(e){let t=Math.round(e/6e4),n=Math.floor(t/1440),s=Math.floor(t%1440/60),a=t%60,i=[n?`${n}d`:"",s?`${s}h`:"",a?`${a}m`:""].filter(Boolean);return i.length?i.join(" "):"0m"}var QI={name:"journeys",summary:"the environment's journeys: each one's key, name, status, way in, and when it was published",usage:"[--status draft|live|stopped]",flags:{status:{type:"string",value:"status",description:"draft, live or stopped alone"}},scope:"environment",async run(e){let t=await w(e),n=e.flags.status;if(n!==void 0&&!["draft","live","stopped"].includes(n))throw g("--status is draft, live or stopped");let s=await ZI(e,t,n);e.out.result({journeys:s},()=>{if(s.length===0){e.out.line("No journey yet."),e.out.line("Write one as a JSON file, check it, walk a person through it, push it: palbase journeys:validate winback.json");return}e.out.table(s,[{header:"key",value:a=>a.key},{header:"name",value:a=>a.name},{header:"status",value:a=>a.status},{header:"entry",value:a=>Xv(a.entry)},{header:"published",value:a=>a.published_at?Y(a.published_at):"-"}])})}},eL={name:"journeys:get",summary:"a journey's definition, as JSON: to edit and push again (a draft), or to push under a new key (a published one)",usage:"<key>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=Dn(e.args[0]),s=await Jv(e,t,n);if(!s)throw Ts(n);e.out.result(s,()=>e.out.line(JSON.stringify(s.definition,null,2)))}},tL={name:"journeys:validate",summary:"check a journey file without saving it: every problem, at its path, with what to do about it",usage:"<file|->",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=await Xp(e,e.args[0]),s=await h(e,t,"POST","/journeys/validate",{definition:n});if(!s.valid)throw e.out.result(s,()=>{e.out.line(`The journey breaks ${s.problems.length===1?"a rule":`${s.problems.length} rules`}:`),Hv(e,s.problems)}),new y("invalid_journey",`the journey has ${s.problems.length} problem${s.problems.length===1?"":"s"}`,{reported:!0});let a=n;e.out.result(s,()=>e.out.line(`Valid: ${a.name}, ${Object.keys(a.steps??{}).length} steps from ${a.start}. Walk a person through it: palbase journeys:simulate ${e.args[0]}`))}},nL={name:"journeys:push",summary:"save a journey file as a draft \u2014 new, or the draft's new version \u2014 and, with --publish, publish it",usage:"<file|-> [--key <key>] [--publish]",details:["The key is --key, else the file's name (winback.json is winback).","A published journey does not change: push the file under a new key with --publish, then stop the old one (journeys:stop)."],args:{min:1,max:1},flags:{key:{type:"string",value:"key",description:"the journey's key (default: the file's name)"},publish:{type:"boolean",description:"publish it once saved: people enter from then on"}},scope:"environment",async run(e){let t=await w(e),n=e.args[0],s=e.flags.key??(n==="-"?void 0:zI(n,JI(n))),a=Dn(s,n==="-"?"the journey's key (--key, reading stdin)":"the journey's key"),i=await Xp(e,n),r=await Jv(e,t,a);if(r&&r.status!=="draft")throw new y("journey_published",`${a} is ${r.status}: a published journey does not change`,{hint:`push it under a new key and publish that, then stop this one: palbase journeys:push ${n} --key ${a}_next --publish && palbase journeys:stop ${a}`});let o;try{o=r?await h(e,t,"PUT",`/journeys/${T(a)}`,{definition:i}):await h(e,t,"POST","/journeys",{key:a,definition:i})}catch(l){Vv(e,l)}e.flags.publish===!0&&(await k(e,t,`publish ${a}: people enter it from now on`),o=await Yv(e,t,a)),e.out.result(o,()=>{e.out.line(`${r?"Saved":"Made"} ${o.key} (${o.name}): ${o.status}.`),o.status==="draft"&&e.out.line(`Publish it: palbase journeys:publish ${o.key}`)})}};async function Yv(e,t,n){try{return await h(e,t,"POST",`/journeys/${T(n)}/publish`)}catch(s){throw s instanceof W&&s.code==="live_journeys_limit"?new y("live_journeys_limit","the Free plan runs 2 journeys at once",{hint:"stop one (palbase journeys:stop <key>), or add a payment method to the organization in Studio"}):s instanceof W&&s.code==="journey_published"?new y("journey_published",`${n} is published already`):s instanceof W&&s.code==="journey_not_found"?Ts(n):s}}var sL={name:"journeys:publish",summary:"publish a draft: people enter it from now on, and it no longer changes",usage:"<key>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=Dn(e.args[0]);await k(e,t,`publish ${n}: people enter it from now on`);let s=await Yv(e,t,n);e.out.result(s,()=>e.out.line(`Published ${s.key} (${s.name}): people ${Xv(s.entry)} enter it.`))}};function aL(e){return(e??[]).map(t=>{let n=/^([^@]+)@(P[0-9A-Z]+)(?::(.*))?$/.exec(t.trim());if(!n||!YI.test(n[2]))throw g(`--event ${t}: an event is <name>@<while after entering>, the while ISO 8601 (PT2H, P1D, PT0M at once), its properties after a colon: purchases.purchase.completed@P1D:product_id=pro`);let s={name:n[1],after:n[2]};return n[3]&&(s.properties=Zv(n[3].split(";"))),s})}function Zv(e){let t={};for(let n of e){let s=n.indexOf("=");if(s<=0)throw g(`${n}: a property is name=value`);let a=n.slice(s+1);t[n.slice(0,s)]=a==="true"?!0:a==="false"?!1:a!==""&&Number.isFinite(Number(a))?Number(a):a}return t}var iL={name:"journeys:simulate",summary:"walk a made-up person through a journey \u2014 a file, or a key \u2014 as it would run: each step, when, what it would do, how it ends; nothing is sent",usage:"<file|key> [--user <id>] [--property name=value]\u2026 [--audience <id>]\u2026 [--timezone <zone>] [--event name@PT2H]\u2026 [--start <time>]",details:["The person enters at --start (now unless it says) and does each --event a while after entering: --event purchases.purchase.completed@P1D.","Their --property values are what branches read, --audience the audiences they are in, --timezone where a wait until a time of day is."],args:{min:1,max:1},flags:{user:{type:"string",value:"id",description:"the person's id (it picks their way at a split)"},property:{type:"string",multiple:!0,value:"name=value",description:"a property of theirs"},audience:{type:"string",multiple:!0,value:"id",description:"an audience they are in"},timezone:{type:"string",value:"zone",description:"their IANA time zone (Europe/Istanbul)"},event:{type:"string",multiple:!0,value:"name@while",description:"an event of theirs, a while after entering (PT2H, P1D)"},start:{type:"string",value:"time",description:"when they enter (RFC 3339); now unless it says"}},scope:"environment",async run(e){let t=await w(e),n=e.args[0],s=n==="-"||n.endsWith(".json")||await VI(HI(e.io.cwd,n)).then(m=>m.isFile(),()=>!1),a={};e.flags.user!==void 0&&(a.user_id=e.flags.user);let i=Ie(e.flags.property);i?.length&&(a.properties=Zv(i));let r=Ie(e.flags.audience);r?.length&&(a.audiences=r),e.flags.timezone!==void 0&&(a.timezone=e.flags.timezone);let o=aL(e.flags.event===void 0?void 0:(Array.isArray(e.flags.event)?e.flags.event:[e.flags.event]).map(String));o.length&&(a.events=o);let l={person:a};if(s?l.definition=await Xp(e,n):l.key=Dn(n),e.flags.start!==void 0){let m=new Date(e.flags.start);if(Number.isNaN(m.getTime()))throw g("--start is a time: 2026-10-21T09:00:00Z");l.start=m.toISOString()}let d;try{d=await h(e,t,"POST","/journeys/simulate",l)}catch(m){if(m instanceof W&&m.code==="journey_not_found")throw Ts(n);Vv(e,m)}let p=Date.parse(d.steps[0]?.at??l.start??d.end.at),c=l.start?Date.parse(l.start):p;e.out.result(d,()=>{e.out.table(d.steps,[{header:"after",value:m=>`+${Vp(Date.parse(m.at)-c)}`},{header:"step",value:m=>m.step},{header:"kind",value:m=>m.kind},{header:"outcome",value:m=>m.outcome},{header:"does",value:m=>m.note}]),e.out.line(`Ends ${d.end.reason} after ${Vp(Date.parse(d.end.at)-c)}.`),d.converted_at&&e.out.line(`Converted after ${Vp(Date.parse(d.converted_at)-c)}, once the run had completed.`)})}},rL={name:"journeys:stats",summary:"what came of a journey: who entered, how their runs ended, who is in it now, its goal's conversions, each step's outcomes",usage:"<key>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=Dn(e.args[0]),s;try{s=await h(e,t,"GET",`/journeys/${T(n)}/stats`)}catch(i){throw i instanceof W&&i.code==="journey_not_found"?Ts(n):i}let a=i=>Object.entries(i??{}).filter(([,r])=>r>0).map(([r,o])=>`${r} ${o}`).join(", ")||"-";e.out.result(s,()=>{e.out.line(`${s.key} (${s.status}): ${s.entered} entered, ${s.converted} converted${s.held?`, ${s.held} held for the month's people`:""}`),e.out.line(`In it now: ${s.in_progress.active} active, ${s.in_progress.waiting} waiting, ${s.in_progress.held} held. Ended: ${a(s.ended)}.`),e.out.table(s.steps,[{header:"step",value:i=>i.step},{header:"kind",value:i=>i.kind},{header:"outcomes",value:i=>a(i.outcomes)},{header:"converted",value:i=>i.converted?a(i.converted):""}])})}},oL={name:"journeys:runs",summary:"a journey's people: each run's state, the step it is at, how it ended, and the steps it took",usage:"<key> [--user <id>] [--state held|active|waiting|ended] [--limit <n>]",args:{min:1,max:1},flags:{user:{type:"string",value:"id",description:"one person's runs"},state:{type:"string",value:"state",description:"held, active, waiting or ended"},limit:{type:"string",value:"n",description:"how many, newest first (default 50, at most 200)"}},scope:"environment",async run(e){let t=await w(e),n=Dn(e.args[0]),s=new URLSearchParams;e.flags.user!==void 0&&s.set("user_id",e.flags.user),e.flags.state!==void 0&&s.set("state",e.flags.state),e.flags.limit!==void 0&&s.set("limit",e.flags.limit);let a;try{a=await h(e,t,"GET",`/journeys/${T(n)}/runs${s.size?`?${s}`:""}`)}catch(i){throw i instanceof W&&i.code==="journey_not_found"?Ts(n):i}e.out.result(a,()=>{if(a.runs.length===0){e.out.line("No one is or was in it.");return}e.out.table(a.runs,[{header:"user",value:i=>i.user_id},{header:"state",value:i=>i.state==="ended"?`ended ${i.end_reason}`:i.step?`${i.state} at ${i.step}`:i.state},{header:"entered",value:i=>Y(i.entered_at)},{header:"steps",value:i=>i.steps.map(r=>`${r.step} ${r.outcome}`).join(" \u2192 ")||"-"}])})}},lL={name:"journeys:stop",summary:"stop a live journey for good: no one enters it, the runs in it end, its report stays",usage:"<key>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=Dn(e.args[0]);await k(e,t,`stop ${n}: the people in it leave it now, and it does not start again`,e.global.yes?void 0:"A stopped journey does not start again");let s;try{s=await h(e,t,"POST",`/journeys/${T(n)}/stop`)}catch(a){throw a instanceof W&&a.code==="journey_not_found"?Ts(n):a instanceof W&&a.code==="journey_not_live"?new y("journey_not_live",`${n} is not live: a draft is deleted, a stopped one is stopped already`):a}e.out.result(s,()=>e.out.line(`Stopped ${s.key}. Its report stays: palbase journeys:stats ${s.key}`))}},dL={name:"journeys:copy",summary:"copy a journey's definition into a new draft: how a published journey is changed",usage:"<key> <new-key> [--name <name>]",args:{min:2,max:2},flags:{name:{type:"string",value:"name",description:"the copy's name (default: the journey's)"}},scope:"environment",async run(e){let t=await w(e),n=Dn(e.args[0]),s=Dn(e.args[1],"the copy's key"),a;try{a=await h(e,t,"POST",`/journeys/${T(n)}/copy`,{key:s,...e.flags.name?{name:e.flags.name}:{}})}catch(i){throw i instanceof W&&i.code==="journey_not_found"?Ts(n):i instanceof W&&i.code==="journey_exists"?new y("journey_exists",`the environment has a journey ${s}`):i}e.out.result(a,()=>e.out.line(`Copied ${n} into the draft ${a.key}: palbase journeys:get ${a.key} > ${a.key}.json, change it, push it.`))}},pL={name:"journeys:delete",summary:"delete a journey with its runs and its report; the people in a live one leave it at once",usage:"<key>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=Dn(e.args[0]);await k(e,t,`delete ${n}, its runs and its report`,e.global.yes?void 0:"A deleted journey and its report do not come back");try{await h(e,t,"DELETE",`/journeys/${T(n)}`)}catch(s){throw s instanceof W&&s.code==="journey_not_found"?Ts(n):s}e.out.result({deleted:n},()=>e.out.line(`Deleted ${n}.`))}},Qv=[QI,eL,tL,nL,sL,iL,rL,oL,lL,dL,pL];import{mkdir as cL,writeFile as uL}from"node:fs/promises";import{dirname as mL}from"node:path";var hL=`${me}/charts`,gL=/^\d{4}-\d{2}-\d{2}$/,fL=/^[A-Za-z]{3}$/,yL=["day","week","month"],t_=["gross","net_of_taxes","proceeds"],bL=["new_customers","new_paying_customers"],wL=["standard","small_business"],e_=20,Yp={gross:"gross",net_of_taxes:"net of taxes",proceeds:"proceeds"},vL={standard:"standard: 30%, 15% of a subscription's renewals after its first paid year in the App Store and of every subscription on Google Play",small_business:"15%: the App Store Small Business Program, Google Play's first million"};function ul(e,t){try{return new Intl.NumberFormat("en",{style:"currency",currency:t}).format(e)}catch{return`${e.toFixed(2)} ${t}`}}function lr(e,t,n){return e==="currency"?ul(t,n):e==="ratio"?`${(t*100).toFixed(1)}%`:Number.isInteger(t)?String(t):t.toFixed(2)}function or(e,t,n){let s=e.flags[t];if(s!==void 0){if(!n.includes(s))throw g(`--${t} is ${n.slice(0,-1).join(", ")} or ${n[n.length-1]}`);return s}}function ml(e,t){let n=e.flags[t];if(n!==void 0){if(typeof n!="string"||!fL.test(n))throw g(`--${t} is a currency's three letters: USD, EUR, TRY`);return n.toUpperCase()}}function cl(e,t){if(e instanceof W){if(e.code==="charts_busy")throw new y("charts_busy",`the charts are busy: ${D(e.message)}`,{hint:"ask again in half a minute, or for fewer days"});if(e.code==="too_many_charts")throw new y("too_many_charts",`too many charts counted in a row: ${D(e.message)}`,{hint:"ask again in a few seconds; the same chart asked again within a minute is answered at once"});if(e.code==="chart_too_large")throw new y("chart_too_large",D(e.message),{hint:"turn off --sandbox, or ask for a shorter range"});if(e.code==="chart_not_found")throw new y("chart_not_found",`no chart ${JSON.stringify(t)}`,{hint:"palbase purchases:charts lists them"})}throw e}var _L={flow:"what happened in each period",snapshot:"the state at the end of each period",ratio:"one measure over another, each period",cohort:"what began in each period, over its ages"},$L={name:"purchases:charts",summary:"the purchase charts, each with its definition: what it counts, over which period, and how refunds, product changes, resubscriptions and test purchases count",details:["A chart is read with purchases:charts:get <chart>; the figures of now with purchases:charts:overview."],scope:"environment",async run(e){let t=await w(e),n=await h(e,t,"GET","/purchases/charts");e.out.result(n,()=>{for(let s of n.charts){let a=[_L[s.kind]??s.kind,s.unit==="currency"?"money":s.unit,...s.segmentable?["segmentable"]:[],...s.window?["takes --window-days"]:[]];e.out.line(D(`${s.key} \u2014 ${s.name} (${a.join("; ")})`)),e.out.line(` ${D(s.description)}`)}e.out.line(),e.out.line("Segmented (--segment) and filtered (--filter dimension:value) by:"),e.out.table(n.dimensions,[{header:"dimension",value:s=>s.key},{header:"values",value:s=>s.description}]),e.out.line(D(`Money is counted as (--revenue-type): ${n.revenue_types.map(s=>Yp[s]??s).join(", ")}.`))})}},kL={name:"purchases:charts:overview",summary:"the project's figures at a glance: MRR, active subscriptions and trials now; revenue, new customers and active customers over the last 28 days",usage:"[--revenue-type gross|net_of_taxes|proceeds] [--currency <code>] [--sandbox]",flags:{"revenue-type":{type:"string",value:"type",description:"gross (default), net_of_taxes or proceeds"},currency:{type:"string",value:"code",description:"the currency to report money in (default: the reporting currency)"},sandbox:{type:"boolean",description:"count the stores' test purchases too"}},scope:"environment",async run(e){let t=or(e,"revenue-type",t_),n=ml(e,"currency"),s=await w(e),a=new URLSearchParams({...e.flags.sandbox===!0?{sandbox:"true"}:{},...t?{revenue_type:t}:{},...n?{currency:n}:{}}),i;try{i=await h(e,s,"GET",`/purchases/charts/overview${a.size>0?`?${a}`:""}`)}catch(r){cl(r)}e.out.result(i,()=>{let r=i.estimated?" (estimated)":"";e.out.line(D(`In ${i.currency}, ${Yp[i.revenue_type]??i.revenue_type}, test purchases ${i.sandbox?"included":"left out"}; the last 28 days since ${i.since} (UTC), counted ${Y(i.computed_at)}`)),e.out.table([["MRR",`${ul(i.mrr,i.currency)}${r}`],["Active subscriptions",String(i.active_subscriptions)],["Active trials",String(i.active_trials)],["Revenue, last 28 days",`${ul(i.revenue_last_28_days,i.currency)}${r}`],["New customers, last 28 days",String(i.new_customers_last_28_days)],["Active customers, last 28 days",String(i.active_customers_last_28_days)]],[{header:"figure",value:o=>o[0]},{header:"value",value:o=>o[1]}]),n_(e,i.unconverted)})}};function n_(e,t){t.length>0&&e.out.line(D(`Left out: amounts in ${t.join(", ")} \u2014 the European Central Bank publishes no rate of them.`))}function SL(e){let n=(e===void 0?[]:(Array.isArray(e)?e:[e]).map(String)).map(s=>{let a=s.indexOf(":"),i=a===-1?"":s.slice(0,a),r=a===-1?"":s.slice(a+1);if(!/^[a-z][a-z_]{0,31}$/.test(i)||r==="")throw g(`--filter ${s}: a filter is dimension:value (store:app_store, country:TR), one each --filter`);return{dimension:i,value:r}});if(n.length>e_)throw g(`--filter: at most ${e_} values`);return n}var AL=/^[=+\-@\t\r]/,PL=/^[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$/;function s_(e){let t=[],n=[],s="",a=!1,i=!1;for(let r=0;r<e.length;r++){let o=e[r];if(a){o==='"'&&e[r+1]==='"'?(s+='"',r++):o==='"'?a=!1:s+=o;continue}i=!0,o==='"'&&s===""?a=!0:o===","?(n.push(s),s=""):o===`
|
|
685
|
+
`}async function dl(e,t,n){let s=await Be(e.io.cwd,t);await KN(BN(s),{recursive:!0}),await Be(e.io.cwd,t),await FN(s,n)}var Pv={file:{type:"string",value:"paywall.json",description:"the definition to draw ('-': stdin)"},locale:{type:"string",value:"tag",description:"the reader's language (default: the definition's default_locale)"},package:{type:"string",value:"product.plan",description:"the package selected"},state:{type:"string",multiple:!0,value:"k=v,\u2026",description:"tab=<id> (every tabs component on it), switch=on|off, sheet=<id> (open)"},width:{type:"string",value:"px",description:"the screen's width in CSS pixels (default: the platform's)"},height:{type:"string",value:"px",description:"the screen's height (default: the platform's)"}};async function Rv(e,t,n,s){let a=e.args[0],i=e.flags.file;if(a===void 0==(i===void 0))throw g("draw a file (--file <paywall.json>) or a paywall's draft by its name, one of the two");let r=e.flags.platform!==void 0?[Bp(e,"platform",_v,"ios")]:n?[..._v]:["ios"],o=e.flags.appearance!==void 0?[Bp(e,"appearance",$v,"light")]:n?[...$v]:["light"],l=e.flags["text-size"]!==void 0?[Bp(e,"text-size",["default","largest"],"default")]:n?["default","largest"]:["default"],d=kv(e,"width"),p=kv(e,"height"),c=HN(Ie(e.flags.state)),m;if(i!==void 0)m=await al(e,i);else{let L=await aa(e,t,a);m=(await h(e,t,"GET",`/purchases/paywalls/${T(L.id)}`)).draft}if(typeof m.default_locale!="string"||typeof m.root!="object")throw g("this is no paywall definition: it has no root or default_locale (palbase purchases:paywalls:validate says what it lacks)");let f=e.flags.locale??m.default_locale,b=Zi(a!==void 0?a:m.name??"paywall"),v=sr(m);if(e.flags.package!==void 0){let L=e.flags.package;if(!v.includes(L))throw g(`--package ${L}: the paywall sells ${v.length===0?"no package":v.join(", ")}`);c.selected=L}let R=[];for(let L of r)for(let V of o)for(let de of l){let O=zN[L];R.push({platform:L,appearance:V,fontSize:WN[de],width:d??O.width,height:p??O.height,top:O.top,bottom:O.bottom,text:de})}let A=v.length===0?void 0:await h(e,t,"GET","/purchases/offerings"),C={},N={};for(let L of new Set(R.map(V=>V.platform))){let V=YN(A,L,v,f);C[L]={packages:V.packages,eligible:V.eligible},V.sampled.length>0&&(N[L]=V.sampled)}let{assets:j,left:U}=await QN(e,t,ZN(m)),G={definition:m,locale:f,catalog:C,links:JN,assets:j,state:c,shots:R.map(({text:L,...V})=>V),...s?{check:!0}:{}},K=eI(await fv(),m.name??b,G);return{name:b,shots:R,html:K,sampled:N,left:U,said(){for(let L of Object.keys(C)){let V=N[L];v.length!==0&&(V?e.out.note(`Prices on ${L}: sample prices for ${V.join(", ")} \u2014 the catalog does not sell ${V.length===1?"it":"them"} there${V.length<v.length?"; the catalog's for the rest":""}.`):e.out.note(`Prices on ${L}: the catalog's (revision ${A.revision}).`))}for(let L of U)e.out.warn(`${L}: drawn without it`)}}}var zp=4;async function Ev(e,t,n){let s=mv(e.io.env);if(s.path)return s.path;let a=`${mt}/.preview/${t.name}.html`;throw await dl(e,a,t.html),t.said(),new y("no_browser",`no browser to ${n} with: open ${a}`,{exitCode:3,hint:s.named!==void 0?`PALBASE_BROWSER names ${s.named}, which is not a program here`:"install Chrome, Chromium, Edge or Brave, or name one: PALBASE_BROWSER=<path>"})}async function Tv(e,t,n,s){let a=`${mt}/.preview/${t.name}.html`;await dl(e,a,t.html);try{return{page:a,taken:await gv(n,await Be(e.io.cwd,a),t.shots.map((i,r)=>({query:`shot=${r}`,width:i.width,height:i.height,scale:Wp,...s})),{args:hv(e.io.env)})}}catch(i){let r=i instanceof tr&&i.noSandbox?"in a container the browser often has none: PALBASE_BROWSER_ARGS=--no-sandbox runs it without one \u2014 and draws the paywall's HTML blocks, which the project's members wrote, without one too":`the page is ${a}: open it in a browser to see it`;throw new y("preview_failed",`the paywall was not drawn: ${i instanceof Error?i.message:String(i)}`,{hint:r,exitCode:zp})}}var Sv=e=>`${e.platform} ${e.appearance}${e.text==="largest"?" largest":""}`,Cv={name:"purchases:paywalls:preview",summary:"a picture of a paywall as an app draws it \u2014 the SDK's own renderer, in a headless browser \u2014 to look at before it is saved",usage:"<name|id> | --file <paywall.json> [--platform ios|android|web|macos] [--appearance light|dark] [--locale <tag>] [--text-size default|largest] [--package <key>] [--state tab=<id>,switch=on|off,sheet=<id>] [--full] [--all] [--out <png>] [--html <file>]",details:["It draws the file being edited (--file), or a paywall's draft by its name. The picture is the platform's screen: its status bar and home indicator kept clear, as on a phone. --full draws the whole paywall instead: the part that scrolls in full, the header and the footer once.","Prices are the environment's catalog's, as the platform sells each package; a package it does not sell there is drawn at a sample price, and named. The project's assets are downloaded and drawn when their bytes are the ones registered.","It needs Chrome, Chromium, Edge or Brave (PALBASE_BROWSER names another; PALBASE_BROWSER_ARGS adds to its arguments, as --no-sandbox in a container that has no sandbox for it). Without one the page is written as HTML to open, and it exits 3; when the browser or the renderer cannot draw it, 4.",`--all draws every platform in both appearances at both text sizes into one folder (${mt}/.preview/<name>/). --html writes the page alone, to open in a browser. purchases:paywalls:check measures what is drawn and lists what is wrong.`],args:{min:0,max:1},flags:{...Pv,platform:{type:"string",value:"platform",description:"ios (default), android or web: the screen and the platform's rules"},appearance:{type:"string",value:"appearance",description:"light (default) or dark"},"text-size":{type:"string",value:"size",description:"default, or largest: every text at the largest size a reader sets"},full:{type:"boolean",description:"the whole paywall, as tall as it is, not the screen alone"},all:{type:"boolean",description:"every platform \xD7 appearance \xD7 text size, into one folder"},out:{type:"string",value:"file",description:`the PNG under palbase/ (default: ${mt}/.preview/<name>-<platform>-<appearance>.png); with --all, the folder`},html:{type:"string",value:"file",description:"write the page alone, as HTML under palbase/, to open in a browser"}},scope:"environment",async run(e){let t=await w(e),n=e.flags.all===!0;if(n&&(e.flags.platform!==void 0||e.flags.appearance!==void 0||e.flags["text-size"]!==void 0))throw g("--all draws every platform, appearance and text size: name none of them with it");let s=await Rv(e,t,n,!1),a=e.flags.html;if(a!==void 0){let f=Nt(e,"html",a,".html");await dl(e,f,s.html),s.said(),e.out.result({html:f},()=>e.out.line(`Wrote the page to ${f}: open it in a browser.`));return}let i=await Ev(e,s,"take the picture"),r=e.flags.full===!0,o=n?e.flags.out!==void 0?Nt(e,"out",`${e.flags.out.replace(/\/+$/,"")}/x.png`,".png").replace(/\/x\.png$/,""):`${mt}/.preview/${s.name}`:void 0,l=s.shots.map(f=>n?`${o}/${f.platform}-${f.appearance}-${f.text}${r?"-full":""}.png`:e.flags.out!==void 0?Nt(e,"out",e.flags.out,".png"):`${mt}/.preview/${s.name}-${f.platform}-${f.appearance}${f.text==="largest"?"-largest":""}${r?"-full":""}.png`),{page:d,taken:p}=await Tv(e,s,i,{full:r});for(let[f,b]of l.entries())await dl(e,b,p[f].png);s.said();let c=p.flatMap((f,b)=>f.error?[`${l[b]}: ${f.error}`]:[]),m=s.shots;if(e.out.result({pictures:m.map((f,b)=>({file:l[b],platform:f.platform,appearance:f.appearance,text_size:f.text,width:f.width,height:p[b].height,scale:Wp,full:r,selected:p[b].selected??null,...p[b].error?{error:p[b].error}:{}})),page:d,sampled_prices:s.sampled,assets_left_out:s.left},()=>{for(let[f,b]of l.entries())e.out.line(`${b} (${m[f].platform}, ${m[f].appearance}${m[f].text==="largest"?", largest text":""}, ${m[f].width}\xD7${p[f].height}${r?", whole":""} at ${Wp}x${p[f].selected?`, ${p[f].selected} selected`:""})`)}),c.length>0)throw new y("preview_failed",`the renderer could not draw it: ${c.join("; ")}`,{exitCode:zp})}};function Av(e){let t=new Map;for(let{screen:n,findings:s}of e)for(let{note:a,...i}of s){let r=`${i.code}\0${i.where}`,o=t.get(r)??{...i,screens:[]};o.screens.includes(n)||o.screens.push(n),t.set(r,o)}return[...t.values()]}var jv={name:"purchases:paywalls:check",summary:"measure a paywall as an app draws it, on every screen, and list what is wrong \u2014 code \u2014 where \u2014 what \u2014 exiting 1 while anything is",usage:"<name|id> | --file <paywall.json> [--platform \u2026] [--appearance \u2026] [--text-size \u2026] [--locale <tag>] [--package <key>] [--state \u2026]",details:["It draws the paywall with the SDK's own renderer in a headless browser \u2014 every platform, light and dark, at the default and the largest text size, unless a flag names one \u2014 and measures what shows:"," overflow_x: wider than the screen \xB7 text_cut: a text cut off \xB7 word_broken: a word (a price) broken across lines \xB7 purchase_hidden: no purchase button on the screen as it opens \xB7 covered_by_footer: an interactive part still under the fixed footer with the paywall scrolled to its end \xB7 large_gap: an empty band over 12% of the screen \xB7 contrast: text under WCAG's 4.5:1 (3:1 large) \xB7 selection_contrast: the selected package or tab under 3:1 from the others \xB7 small_target: a target under 44\xD744 on a phone, 24\xD724 on the web (a switch, a link inside a sentence and a carousel's dots aside) \xB7 image_missing: an image that did not load \xB7 repeated_text: the same words twice in one package.","Each names the component by its path in the definition (root.children[2]) and the words it shows. A text over a picture or a gradient is said apart, as not measured (unmeasured_contrast): a note, not a problem.","--json prints { problems: [{ code, where, message, screens }], notes: [ \u2026 ], screens }.","It exits 0 when nothing is wrong, 1 when something is (and on a refusal: --json then prints { error } instead), 3 without a browser, 4 when the browser or the renderer could not draw the paywall."],args:{min:0,max:1},flags:{...Pv,platform:{type:"string",value:"platform",description:"ios, android, web or macos alone (default: all four)"},appearance:{type:"string",value:"appearance",description:"light or dark alone (default: both)"},"text-size":{type:"string",value:"size",description:"default or largest alone (default: both)"}},scope:"environment",async run(e){let t=await w(e),n=await Rv(e,t,!0,!0),s=await Ev(e,n,"measure it"),{taken:a}=await Tv(e,n,s,{measureOnly:!0});n.said();let i=a.flatMap((c,m)=>c.error?[`${Sv(n.shots[m])}: ${c.error}`]:[]);if(i.length>0)throw new y("preview_failed",`the renderer could not draw it: ${i.join("; ")}`,{exitCode:zp});let r=n.shots.map(Sv),o=a.map(c=>c.findings??[]),l=Av(o.map((c,m)=>({screen:r[m],findings:c.filter(f=>!f.note)}))),d=Av(o.map((c,m)=>({screen:r[m],findings:c.filter(f=>f.note)}))),p=c=>c.screens.length===r.length?"on every screen":`on ${c.screens.join(", ")}`;return e.out.result({problems:l,notes:d,screens:r},()=>{for(let m of l)e.out.line(`${m.code} \u2014 ${m.where} \u2014 ${m.message}`),e.out.line(` ${p(m)}`);for(let m of d)e.out.line(`note: ${m.code} \u2014 ${m.where} \u2014 ${m.message} (${p(m)})`);let c=new Set(l.flatMap(m=>m.screens)).size;e.out.line(l.length===0?`Nothing wrong on ${r.length} screen(s)${d.length>0?`; ${d.length} thing(s) not measured`:""}.`:`${l.length} problem(s), on ${c} of ${r.length} screen(s).`)}),l.length>0?1:void 0}};import{createHash as tI}from"node:crypto";import{mkdtemp as nI,rm as sI,stat as aI,writeFile as iI}from"node:fs/promises";import{tmpdir as rI}from"node:os";import{join as Ov}from"node:path";var Iv={"image/png":".png","image/jpeg":".jpg","image/webp":".webp","video/mp4":".mp4","video/quicktime":".mov","font/ttf":".ttf","font/otf":".otf","font/woff2":".woff2","application/zip":".zip"},oI=new Set(["image","video","font","html"]),lI=/^[a-z0-9][a-z0-9-]{0,62}$/,dI=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,pI=/^[0-9a-f]{64}$/i,cI=50<<20;function uI(e){let t=s=>{throw new y("unexpected_answer",`the environment answered a template the CLI does not take: ${s}`)},n=e;(typeof n!="object"||n===null)&&t("one is not an object"),(typeof n.key!="string"||!lI.test(n.key))&&t(`its key ${JSON.stringify(n.key)} is not lowercase letters, digits and dashes`),(typeof n.name!="string"||typeof n.description!="string")&&t(`${n.key} has no name or description`),(typeof n.definition!="object"||n.definition===null||Array.isArray(n.definition))&&t(`${n.key} has no definition`),Array.isArray(n.assets)||t(`${n.key} has no list of assets`);for(let s of n.assets)(typeof s?.id!="string"||!dI.test(s.id))&&t(`an asset of ${n.key} has the id ${JSON.stringify(s?.id)}, which is not a uuid`),oI.has(s.kind)||t(`the asset ${s.id} of ${n.key} is a ${JSON.stringify(s.kind)}, not an image, a video, a font or an HTML block`),Object.hasOwn(Iv,s.content_type)||t(`the asset ${s.id} of ${n.key} is ${JSON.stringify(s.content_type)}, which no paywall asset is`),(!Number.isInteger(s.size)||s.size<=0||s.size>cI)&&t(`the asset ${s.id} of ${n.key} is ${JSON.stringify(s.size)} bytes`),(typeof s.sha256!="string"||!pI.test(s.sha256))&&t(`the asset ${s.id} of ${n.key} has no SHA-256`);return n}async function Lv(e,t){let n=await h(e,t,"GET","/purchases/paywalls/templates");if(!Array.isArray(n?.templates))throw new y("unexpected_answer","the environment answered the templates without their list");return n.templates.map(uI)}var Nv={monthly:1,yearly:12,weekly:12/52,quarterly:3,once:0};function mI(e){let t=/^P(\d+)([DWMY])$/.exec(e??"");if(!t)return 0;let n=Number(t[1]);return t[2]==="D"?n*12/365:t[2]==="W"?n*12/52:t[2]==="M"?n:n*12}function hI(e,t){let n=t?.products??[],s=new Set(n.flatMap(c=>c.plans.map(m=>`${c.key}.${m.key}`))),a=[],i=[];for(let c of n){if(c.type==="consumable")continue;let m=c.plans.map(f=>({key:f.key,months:mI(f.period)}));(m.some(f=>f.months>0)?a:i).push({key:c.key,plans:m})}let r={},o=new Set;for(let c of e)s.has(c)&&(r[c]=c,o.add(c));let l=[...new Set(e.map(c=>c.split(".")[0]))],d={},p=new Set;for(let c of l){let m=[...a,...i].find(f=>f.key===c);m&&(d[c]=m,p.add(m.key))}for(let c of l){if(d[c])continue;let f=(e.some(b=>b.startsWith(`${c}.`)&&(Nv[b.split(".")[1]]??0)>0)?a:i).find(b=>!p.has(b.key));f&&(d[c]=f,p.add(f.key))}for(let c of e){if(r[c])continue;let[m,f]=c.split("."),b=d[m],v=Nv[f],R=b?.plans.find(A=>v!==void 0&&Math.abs(A.months-v)<.01&&!o.has(`${b.key}.${A.key}`));b&&R&&(r[c]=`${b.key}.${R.key}`,o.add(r[c]))}return r}function gI(e,t){let n=s=>{if(Array.isArray(s))return s.map(n);if(typeof s!="object"||s===null)return s;let a=s,i={};for(let[r,o]of Object.entries(a))(r==="package"||r==="on_package"||r==="off_package")&&typeof o=="string"?i[r]=t[o]??o:r==="selected_package"&&Array.isArray(o)?i[r]=o.map(l=>typeof l=="string"?t[l]??l:l):i[r]=n(o);if(a.type==="package"&&typeof a.product=="string"&&typeof a.plan=="string"){let r=t[`${a.product}.${a.plan}`];r&&([i.product,i.plan]=r.split("."))}return i};return n(e)}function fI(e,t){let n=s=>{if(Array.isArray(s))return s.map(n);if(typeof s=="string"){let a=/^asset:(.+)$/.exec(s)?.[1];return a&&t[a]?t[a]:s}return typeof s!="object"||s===null?s:Object.fromEntries(Object.entries(s).map(([a,i])=>[a,n(i)]))};return n(e)}function yI(e,t,n){let s={};for(let a of e??[]){let i=a.indexOf("="),[r,o]=i<0?[a,""]:[a.slice(0,i),a.slice(i+1)];if(!t.includes(r))throw g(`--package ${a}: the template sells ${t.join(", ")||"no package"}, not ${r}`);if(!n.has(o))throw g(`--package ${a}: the catalog sells no package ${o||"(none named)"}`,n.size>0?`the catalog's: ${[...n].join(", ")}`:"the catalog sells nothing yet: palbase purchases:catalog:put");s[r]=o}return s}var bI={name:"purchases:paywalls:templates",summary:"the module's designed paywalls to start from: each one's key, what it looks like, and the packages it sells",details:["palbase purchases:paywalls:new <name> --template <key> writes one to a file, selling the catalog's own packages."],scope:"environment",async run(e){let t=await w(e),s=(await Lv(e,t)).map(a=>({key:a.key,name:a.name,description:a.description,packages:sr(a.definition),assets:a.assets}));e.out.result({templates:s},()=>{e.out.table(s,[{header:"template",value:a=>a.key},{header:"name",value:a=>a.name},{header:"sells",value:a=>a.packages.join(", ")},{header:"what it looks like",value:a=>a.description}]),e.out.line("Make a paywall from one: palbase purchases:paywalls:new <name> --template <key>")})}};async function wI(e,t,n,s){let a=await Li(e,t),i=`${Wt(e.cloud,t.env_ref)}/purchases/paywalls/templates/${T(n)}/assets/${T(s.id)}`,r;try{r=await e.io.fetch(i,{headers:{apikey:a.key},redirect:"manual"})}catch(l){throw new y("network_error",`the template's ${s.kind} could not be downloaded: ${l instanceof Error?l.message:String(l)}`)}if(!r.ok)throw new y("template_asset_unavailable",`the template's ${s.kind} (${s.id}) could not be downloaded: the environment answered ${r.status}`);let o=Buffer.from(await r.arrayBuffer());if(o.length!==s.size||tI("sha256").update(o).digest("hex")!==s.sha256.toLowerCase())throw new y("template_asset_changed",`the template's ${s.kind} (${s.id}) did not arrive as the bytes the template names: nothing was uploaded`);return o}var vI={name:"purchases:paywalls:new",summary:"write a new paywall's definition to a file from one of the module's templates, selling the catalog's own packages, its pictures uploaded to the project",usage:`<name> --template <key> [--package <template package>=<product.plan> \u2026] [--out <${mt}/name.json>]`,details:["A template sells pro.monthly, pro.yearly, family.monthly, family.yearly and lifetime.once: each is renamed to the catalog's package that stands for it \u2014 the same one when the catalog sells it, else a plan of the same period. One that nothing stands for is said, and stays: --package pro.yearly=<product>.<plan> names it.","A template's pictures are uploaded to the project's public bucket paywall-assets (made when there is none; a private one is left as it is, and nothing is written) and registered; the definition names the project's assets in their place.","Nothing is saved to the environment but those assets: the file is edited, checked and looked at (purchases:paywalls:validate, :preview, :check), then saved with purchases:paywalls:put <name> --file <file> --revision 0."],args:{min:1,max:1},flags:{template:{type:"string",value:"key",description:"the template, as purchases:paywalls:templates lists them"},package:{type:"string",multiple:!0,value:"from=to",description:"a template's package and the catalog's that stands for it (repeat it, or a comma list)"},out:{type:"string",value:"file",description:`where under ${me}/ (default: ${mt}/<name>.json)`}},scope:"environment",async run(e){let t=await w(e),n=e.args[0].trim();if(n===""||[...n].length>100)throw g("a paywall's name is 1 to 100 characters");let s=e.flags.template;if(s===void 0||s.trim()==="")throw g("--template names the template to start from","palbase purchases:paywalls:templates lists them");let a=e.flags.out!==void 0?Nt(e,"out",e.flags.out,".json"):`${mt}/${Zi(n)}.json`;try{throw await aI(await Be(e.io.cwd,a)),new y("file_exists",`${a} is there already: a template is not written over a file`,{hint:"name another with --out, or remove the file"})}catch(A){if(A.code!=="ENOENT")throw A}let i=await Lv(e,t),r=i.find(A=>A.key===s);if(!r)throw new y("template_not_found",`no template ${JSON.stringify(s)}`,{hint:`the module's: ${i.map(A=>A.key).join(", ")}`});let o=sr(r.definition),l=(await h(e,t,"GET","/purchases/catalog")).catalog,d=new Set((l?.products??[]).flatMap(A=>A.plans.map(C=>`${A.key}.${C.key}`))),p={...hI(o,l),...yI(Ie(e.flags.package),o,d)},c=o.filter(A=>!p[A]),m=new Set([...JSON.stringify(r.definition).matchAll(/asset:([0-9a-f-]{36})/g)].map(A=>A[1])),f=r.assets.filter(A=>m.has(A.id)),b={},v=[];if(f.length>0){let A=await Ya(e,t),C=f.filter(N=>{let j=A.find(U=>U.sha256.toLowerCase()===N.sha256.toLowerCase()&&U.kind===N.kind);return j&&(b[N.id]=j.ref),!j});if(C.length>0){await k(e,t,`upload the template's ${C.length} asset(s) to the project's paywall-assets bucket and register ${C.length===1?"it":"them"}`),await Ap(e,t);let N=await nI(Ov(rI(),"palbase-template-"));try{for(let[j,U]of C.entries()){let G=Ov(N,`asset-${j}${Iv[U.content_type]}`);await iI(G,await wI(e,t,r.key,U));let K=await Pp(e,t,G,U.kind);b[U.id]=K.ref,v.push(K)}}finally{await sI(N,{recursive:!0,force:!0})}}}let R=fI(gI({...r.definition,name:n},p),b);await tl(e,a,R),e.out.result({file:a,template:r.key,name:n,packages:p,unmapped:c,assets:b,uploaded:v.map(A=>A.ref)},()=>{e.out.line(`Wrote ${n} to ${a}, from the template ${r.key}.`);for(let A of o)p[A]&&p[A]!==A&&e.out.line(` ${A} is the catalog's ${p[A]}`);for(let A of c)e.out.warn(`the catalog sells nothing that stands for ${A}: it stays ${A} in the file \u2014 a draft is warned of it, a publish refuses it. Name the catalog's: --package ${A}=<product>.<plan>, or change it in the file`);for(let A of v)e.out.line(` uploaded and registered its ${A.kind}: ${A.ref}`);e.out.line(`Edit it, then look at it and save it: palbase purchases:paywalls:preview --file ${a} \xB7 palbase purchases:paywalls:put ${JSON.stringify(n)} --file ${a} --revision 0`)})}},Dv=[bI,vI];import{writeFile as CI,mkdir as jI}from"node:fs/promises";import{dirname as OI}from"node:path";var _I=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,$I=/^[a-z][a-z0-9_]{0,19}$/,kI=/^[a-z0-9][a-z0-9_-]{0,63}$/;async function pl(e,t,n){let s=[],a;do{let i=new URLSearchParams({limit:"100",...n?{placement:n}:{},...a?{cursor:a}:{}}),r=await h(e,t,"GET",`/purchases/experiments?${i}`);s.push(...r.experiments),a=r.next_cursor}while(a&&s.length<1e3);return s}async function Jp(e,t){let n=e.args[0];if(n===void 0||n.trim()==="")throw g("the experiment's id or name is required");if(_I.test(n))try{return await h(e,t,"GET",`/purchases/experiments/${T(n.toLowerCase())}`)}catch(r){throw r instanceof W&&r.code==="experiment_not_found"?new y("experiment_not_found",`no experiment ${n}`,{hint:"palbase purchases:experiments lists them"}):r}let s=(await pl(e,t)).filter(r=>r.name===n),a=s.filter(r=>r.status==="running"),i=a.length===1?a[0]:s.length===1?s[0]:void 0;if(i)return i;throw s.length===0?new y("experiment_not_found",`no experiment ${JSON.stringify(n)}`,{hint:"palbase purchases:experiments lists them"}):new y("ambiguous_experiment",`${s.length} experiments are named ${JSON.stringify(n)}`,{hint:`name one by its id: ${s.map(r=>r.id).join(", ")}`})}function Mv(e,t){let n=e.variants.reduce((s,a)=>s+a.weight,0);return e.variants.map(s=>`${s.key}=${t.get(s.paywall_id)??s.paywall_id} ${Math.round(s.weight/n*100)}%`).join(", ")}function xv(e,t){throw e instanceof W&&e.code==="experiment_ended"?new y("experiment_ended",`${t.name} has ended (${t.status}): nothing was changed`):e}var SI={name:"purchases:experiments",summary:"the environment's paywall experiments: the placement each runs on, its variants and their shares, and how it ended",usage:"[--placement <placement>]",flags:{placement:{type:"string",value:"placement",description:"one placement's alone"}},scope:"environment",async run(e){let t=await w(e),[n,s]=await Promise.all([pl(e,t,e.flags.placement),Qn(e,t)]),a=new Map(s.map(i=>[i.id,i.name]));e.out.result({experiments:n},()=>{if(n.length===0){e.out.line("No experiment yet."),e.out.line("Start one: palbase purchases:experiments:start <placement> --variants <paywall>=50,<paywall>=50");return}e.out.table(n,[{header:"name",value:i=>i.name},{header:"id",value:i=>i.id},{header:"placement",value:i=>`${i.placement}${i.audience==="rules"?" (rules)":""}`},{header:"variants",value:i=>Mv(i,a)},{header:"status",value:i=>i.status==="won"?`won by ${i.winner}`:i.status},{header:"started",value:i=>Y(i.started_at)}])})}};function AI(e){let t=e??[];if(t.length<2||t.length>4)throw g("--variants names 2 to 4 paywalls, each with its weight: --variants aurora=50,cards=50");let n=t.map((s,a)=>{let i=/^(?:([^:=]+):)?([^=]+)=(\d+)$/.exec(s.trim());if(!i)throw g(`--variants ${s}: a variant is <paywall>=<weight>, or <key>:<paywall>=<weight>`);let r=i[1]??"abcd"[a],o=Number(i[3]);if(!$I.test(r))throw g(`--variants ${s}: a variant's key is lowercase letters, digits and _, at most 20, starting with a letter`);if(o<1||o>1e3)throw g(`--variants ${s}: a weight is 1 to 1000`);return{key:r,paywall:i[2],weight:o}});if(new Set(n.map(s=>s.key)).size!==n.length)throw g("--variants: every variant has a key of its own");return n}var PI={name:"purchases:experiments:start",summary:"start an experiment on a placement: each viewer is shown one of 2 to 4 published paywalls, by weight, the same one every time",usage:"<placement> --variants <paywall>=<weight>,<paywall>=<weight>[,\u2026] [--audience placement|rules] [--name <name>]",details:["audience placement (the default): everyone at the placement, decided before its rules; the placement is made when new and keeps its default for when the experiment ends.","audience rules: only the viewers the placement's rules send to it \u2014 a rule's target names the experiment (purchases:placements:rules:put).","The first variant is what a stop keeps. One experiment runs on a placement at a time; each variant's paywall must be published."],args:{min:1,max:1},flags:{variants:{type:"string",multiple:!0,value:"paywall=weight,\u2026",description:"the paywalls (name or id) and their weights; key:paywall=weight names a key (else a, b, c, d)"},audience:{type:"string",value:"audience",description:"placement (default) or rules"},name:{type:"string",value:"name",description:"the experiment's name (default: the placement and its paywalls)"}},scope:"environment",async run(e){let t=await w(e),n=e.args[0];if(!kI.test(n))throw g(`${JSON.stringify(n)} is not a placement's key: lowercase letters, digits, _ and -, at most 64`);let s=e.flags.audience;if(s!==void 0&&s!=="placement"&&s!=="rules")throw g("--audience is placement or rules");let a=AI(Ie(e.flags.variants)),i=await Qn(e,t),r=a.map(p=>{let c=sl(i,p.paywall);if(!c)throw new y("paywall_not_found",`no paywall ${JSON.stringify(p.paywall)}`,{hint:`the project's: ${i.map(m=>m.name).join(", ")||"none yet"}`});if(c.published_version===0)throw new y("unpublished_paywall",`${c.name} was never published: a variant shows a published paywall`,{hint:`palbase purchases:paywalls:publish ${JSON.stringify(c.name)}`});return{key:p.key,paywall_id:c.id,weight:p.weight}});if(new Set(r.map(p=>p.paywall_id)).size!==r.length)throw g("--variants: each variant is a paywall of its own");let o=new Map(i.map(p=>[p.id,p.name])),l=(e.flags.name??`${n}: ${r.map(p=>o.get(p.paywall_id)).join(" vs ")}`).slice(0,100);await k(e,t,`start ${JSON.stringify(l)} on ${n} (${s??"placement"}): ${r.map(p=>`${p.key}=${o.get(p.paywall_id)} \xD7${p.weight}`).join(", ")}`);let d;try{d=await h(e,t,"POST","/purchases/experiments",{name:l,placement:n,variants:r,...s?{audience:s}:{}},J())}catch(p){throw p instanceof W&&p.code==="experiment_running"?new y("experiment_running",`an experiment runs on ${n} already: one runs on a placement at a time`,{hint:"palbase purchases:experiments lists it; stop it or declare its winner first"}):p instanceof W&&p.code==="placement_not_found"?new y("placement_not_found",`the environment has no placement ${n}: an experiment for its rules runs on a placement that is there`,{hint:`palbase purchases:placements:set ${n} --paywall <name>`}):p instanceof W&&p.code==="invalid_experiment"?new y("invalid_experiment",`the experiment was not started: ${p.message}`):p}e.out.result(d,()=>{e.out.line(`Started ${d.name} (${d.id}) on ${n}: ${Mv(d,o)}.`),d.audience==="rules"&&e.out.line(`It shows only the viewers a rule sends it: a rule's target is { "experiment_id": "${d.id}" } (palbase purchases:placements:rules:put ${n}).`),e.out.line(`Its results: palbase purchases:experiments:results ${d.id}`)})}},RI={name:"purchases:experiments:stop",summary:"stop a running experiment, at once: what it showed becomes its first variant's paywall; its results stay",usage:"<id|name>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=await Jp(e,t);await k(e,t,`stop ${n.name} on ${n.placement}: its first variant (${n.variants[0]?.key}) stays`);let s;try{s=await h(e,t,"POST",`/purchases/experiments/${T(n.id)}/stop`,void 0,J())}catch(a){xv(a,n)}e.out.result(s,()=>e.out.line(`Stopped ${s.name}: ${s.placement} shows variant ${s.variants[0]?.key}'s paywall${s.audience==="rules"?" where its rules sent the experiment":""}.`))}},EI={name:"purchases:experiments:winner",summary:"end a running experiment with its winner: the winner's paywall becomes the placement's default \u2014 or, with --as-rule, a rule shows it to everyone",usage:"<id|name> --variant <key> [--as-rule]",details:["For an experiment for everyone at the placement, --as-rule rolls the winner out as a live rule at the top of its rules (to narrow later) and leaves the default as it is. For one for the rules, the rules that targeted it show the winner's paywall.","purchases:experiments:results says which variant leads and whether calling it is sound yet."],args:{min:1,max:1},flags:{variant:{type:"string",value:"key",description:"the winning variant's key"},"as-rule":{type:"boolean",description:"roll the winner out as a rule for everyone, at the top of the placement's rules"}},scope:"environment",async run(e){let t=await w(e),n=e.flags.variant;if(n===void 0||n.trim()==="")throw g("--variant is the winning variant's key");let s=await Jp(e,t);if(!s.variants.some(r=>r.key===n))throw g(`${s.name} has no variant ${n}: its variants are ${s.variants.map(r=>r.key).join(", ")}`);let a=e.flags["as-rule"]===!0;await k(e,t,`end ${s.name} with ${n} as its winner${a?", as a rule for everyone":""}`);let i;try{i=await h(e,t,"POST",`/purchases/experiments/${T(s.id)}/winner`,{variant:n,...a?{as_rule:!0}:{}},J())}catch(r){if(r instanceof W&&r.code==="too_many_rules")throw new y("too_many_rules",`${s.placement} has 50 rules, the most it holds: the winner cannot be added as one \u2014 nothing was changed`,{hint:"declare it without --as-rule, or take a rule out first"});xv(r,s)}e.out.result(i,()=>e.out.line(a?`${i.name} is won by ${n}: a rule at the top of ${i.placement}'s rules shows its paywall to everyone.`:`${i.name} is won by ${n}: ${i.placement} shows its paywall${i.audience==="rules"?" where its rules sent the experiment":""}.`))}};function Hp(e){let t=e.amount_micros/1e6;try{return new Intl.NumberFormat("en",{style:"currency",currency:e.currency}).format(t)}catch{return`${t.toFixed(2)} ${e.currency}`}}var ar=e=>`${(e*100).toFixed(1)}%`,TI={name:"purchases:experiments:results",summary:"what each variant's viewers did \u2014 exposures, viewers, purchases, conversion, revenue \u2014 each one's chance to convert best, and whether calling the leader is sound",usage:"<id|name> [--window-days <n>] [--sandbox]",details:["A purchase counts for the first variant its buyer saw, within the window after seeing it (7 days unless said): the purchases the stores confirmed, never what an app reports. Revenue is what was paid to date, renewals in, refunds out.","The chance to win is Bayesian (each variant's rate a Beta distribution): how likely each one is best. The leader is called soundly once every variant has been seen enough and its chance is high enough; until then the reasons are said."],args:{min:1,max:1},flags:{"window-days":{type:"string",value:"n",description:"the days after first seeing a variant a purchase counts for it, 1 to 90 (default 7)"},sandbox:{type:"boolean",description:"count the stores' test purchases too"}},scope:"environment",async run(e){let t=await w(e),n=Te(e.flags["window-days"],"window-days");if(n!==void 0&&(n<1||n>90))throw g("--window-days is 1 to 90");let s=await Jp(e,t),a=new URLSearchParams({...n!==void 0?{window_days:String(n)}:{},...e.flags.sandbox===!0?{sandbox:"true"}:{}}),[i,r]=await Promise.all([h(e,t,"GET",`/purchases/experiments/${T(s.id)}/results${a.size>0?`?${a}`:""}`),Qn(e,t)]),o=new Map(r.map(l=>[l.id,l.name]));e.out.result({...i,name:s.name},()=>{if(e.out.line(`${s.name} on ${s.placement}: ${i.status}${s.winner?`, won by ${s.winner}`:""} \u2014 purchases within ${i.window_days} day(s) of first seeing a variant${i.sandbox?", test purchases included":""}, counted ${Y(i.computed_at)}`),e.out.table(i.variants,[{header:"variant",value:l=>`${l.variant}${l.variant===i.leader?" (leads)":""}`},{header:"paywall",value:l=>o.get(l.paywall_id)??l.paywall_id},{header:"weight",value:l=>String(l.weight)},{header:"exposures",value:l=>String(l.exposures)},{header:"viewers",value:l=>String(l.viewers)},{header:"purchases",value:l=>String(l.purchases)},{header:"converted",value:l=>`${l.converters} (${ar(l.conversion_rate)})`},{header:"revenue",value:l=>l.revenue.length===0?"\u2014":l.revenue.map(Hp).join(" + ")},{header:"chance to win",value:l=>ar(l.chance_to_win)}]),i.confident)e.out.line(`Calling ${i.leader} the winner is sound: palbase purchases:experiments:winner ${s.id} --variant ${i.leader}`);else{e.out.line(`Not sound to call yet (each variant seen by ${i.confidence.min_viewers}, the leader at ${ar(i.confidence.min_chance)} to win):`);for(let l of i.confidence.reasons)e.out.line(` ${l.message}`)}})}},Gv=[SI,PI,RI,EI,TI];var NI=/^[a-z0-9_-]{1,64}$/;function Qa(e){let t=e.args[0];if(t===void 0||t.trim()==="")throw g("the placement's key is required");if(!NI.test(t))throw g(`${JSON.stringify(t)} is not a placement's key: lowercase letters, digits, _ and -, at most 64`);return t}async function rr(e,t){return new Map((await Qn(e,t)).map(n=>[n.id,n.name]))}var ir=(e,t)=>t===void 0?"\u2014":e.get(t)??t;function Uv(e){let t=e.field==="attribute"?`attribute ${e.key??"?"}`:e.field==="sdk_version"?`sdk_version (${e.sdk??"?"})`:e.field,n=e.values!==void 0?e.values.join(", "):e.value!==void 0?String(e.value):"";return`${t} ${e.op}${n===""?"":` ${n}`}`}function II(e,t){return e.paywall_id!==void 0?`paywall ${ir(t,e.paywall_id)}`:`experiment ${e.experiment_id??"?"}`}function LI(e){let t=[e.starts_at?`from ${Y(e.starts_at)}`:"",e.ends_at?`until ${Y(e.ends_at)}`:""].filter(Boolean);return t.length===0?"":` (${t.join(" ")} UTC)`}function Kv(e,t,n){t.forEach((s,a)=>{e.out.line(`${a+1}. ${s.name} \u2014 ${s.status??s.state}${LI(s)} \u2192 ${II(s.target,n)}`);let i=s.conditions??[];i.length===0&&e.out.line(" everyone");for(let r of i)e.out.line(` ${Uv(r)}`)})}var DI={name:"purchases:placements",summary:"the environment's placements: each one's default paywall, its rules and the experiment running on it",details:['An app asks for a placement by its key (pb.purchases.paywall("onboarding")): an experiment running for everyone there decides first, then the first of its rules that holds for the viewer, then its default paywall.'],scope:"environment",async run(e){let t=await w(e),[{placements:n},s]=await Promise.all([h(e,t,"GET","/purchases/placements"),rr(e,t)]),a=n.map(i=>({...i,paywall:i.paywall_id===void 0?null:ir(s,i.paywall_id)}));e.out.result({placements:a},()=>{if(a.length===0){e.out.line("No placement yet."),e.out.line("Give one a paywall: palbase purchases:placements:set <placement> --paywall <name>");return}e.out.table(a,[{header:"placement",value:i=>i.key},{header:"default paywall",value:i=>i.paywall??"\u2014"},{header:"rules",value:i=>String(i.rule_count)},{header:"experiment",value:i=>i.experiment_id??"\u2014"},{header:"changed",value:i=>Y(i.updated_at)}])})}};function Fv(e,t,n){throw e instanceof W&&e.code==="experiment_running"?new y("experiment_running",`an experiment runs on ${t}: ${n} while it runs`,{hint:"palbase purchases:experiments lists it; stop it or declare its winner first"}):e}var MI={name:"purchases:placements:set",summary:"give a placement its default paywall \u2014 what it shows whoever none of its rules holds for \u2014 making the placement when it is new",usage:"<placement> --paywall <name|id>",details:["The apps asking for it get the paywall's newest version they can draw; a paywall never published is nothing yet: they draw their own until it is."],args:{min:1,max:1},flags:{paywall:{type:"string",value:"name|id",description:"the paywall it shows"}},scope:"environment",async run(e){let t=await w(e),n=Qa(e),s=e.flags.paywall;if(s===void 0||s.trim()==="")throw g("--paywall names the paywall the placement shows");let a=await aa(e,t,s);await k(e,t,`show ${a.name} at ${n}`);let i;try{i=await h(e,t,"PUT",`/purchases/placements/${T(n)}`,{paywall_id:a.id},J())}catch(r){if(r instanceof W&&r.code==="too_many_placements")throw new y("too_many_placements","the project has 200 placements, the most it holds: nothing was made",{hint:"delete one no app asks for: palbase purchases:placements:delete <placement>"});Fv(r,n,"the experiment decides what it shows, and its end the default \u2014 it is not changed")}e.out.result({...i,paywall:a.name},()=>{e.out.line(`${n} shows ${a.name}${i.rule_count>0?` to whoever none of its ${i.rule_count} rule(s) holds for`:""}.`),a.published_version===0&&e.out.warn(`${a.name} was never published: the apps draw their own paywall until it is (palbase purchases:paywalls:publish ${JSON.stringify(a.name)})`)})}},xI={name:"purchases:placements:delete",summary:"forget a placement and its rules: the apps that ask for it draw their own paywall",usage:"<placement>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=Qa(e);await k(e,t,`delete the placement ${n} and its rules`);try{await h(e,t,"DELETE",`/purchases/placements/${T(n)}`,void 0,J())}catch(s){if(s instanceof W&&s.code==="placement_not_found")throw new y("placement_not_found",`the environment has no placement ${n}`,{hint:"palbase purchases:placements lists them"});Fv(s,n,"it is not deleted")}e.out.result({deleted:n},()=>e.out.line(`Deleted ${n}: the apps that ask for it draw their own paywall.`))}};async function Bv(e,t){let n=Fe(await Xe(e,t,"the rules"),"the rules"),s=Array.isArray(n)?n:typeof n=="object"&&n!==null&&Array.isArray(n.rules)?n.rules:void 0;if(s===void 0)throw g('the rules are { "rules": [ \u2026 ] }, as purchases:placements:rules:get --out writes them, or the list alone');return s.map(a=>{let{status:i,...r}=a;return r})}function Wv(e,t,n){if(t instanceof W&&t.code==="invalid_rules"){let s=(t.body??{}).problems??[];if(s.length>0){e.out.note(`The rules break ${s.length} rule(s):`);for(let a of s)e.out.note(` ${a.path}: ${a.code} \u2014 ${a.message}`)}throw new y("invalid_rules",`${n}: ${t.message}`,{hint:"fix each problem in the file; purchases:placements:preview --rules <file> tries them without saving"})}throw t}var GI={name:"purchases:placements:rules:get",summary:"a placement's rules, in the order they are read \u2014 each with its conditions, schedule and target \u2014 and their revision",usage:"<placement> [--out <palbase/\u2026.json>]",details:['--out writes them to a file to edit ({ "rules": [ \u2026 ] }); rules:put saves the edit on the revision printed.'],args:{min:1,max:1},flags:{out:{type:"string",value:"file",description:"write the rules to this file, under palbase/"}},scope:"environment",async run(e){let t=await w(e),n=Qa(e),s;try{s=await h(e,t,"GET",`/purchases/placements/${T(n)}/rules`)}catch(r){throw r instanceof W&&r.code==="placement_not_found"?new y("placement_not_found",`the environment has no placement ${n}`,{hint:`give it a paywall first: palbase purchases:placements:set ${n} --paywall <name>`}):r}let a=e.flags.out;if(a!==void 0){let r=Nt(e,"out",a,".json"),o=await Be(e.io.cwd,r);await jI(OI(o),{recursive:!0}),await Be(e.io.cwd,r),await CI(o,`${JSON.stringify({rules:s.rules.map(({status:l,...d})=>d)},null,2)}
|
|
686
|
+
`),e.out.result({file:r,placement:n,revision:s.revision},()=>{e.out.line(`Wrote revision ${s.revision} of ${n}'s ${s.rules.length} rule(s) to ${r}.`),e.out.line(`Save an edit of them: palbase purchases:placements:rules:put ${n} --file ${r} --revision ${s.revision}`)});return}let i=await rr(e,t);e.out.result(s,()=>{e.out.line(`${n}: revision ${s.revision} of its rules`),s.rules.length===0&&e.out.line("No rule: it shows its default paywall to everyone."),Kv(e,s.rules,i)})}},qI={name:"purchases:placements:rules:put",summary:"replace a placement's rules \u2014 all of them, in the order they are to be read \u2014 on the revision they were edited from",usage:"<placement> --file <rules.json> --revision <n>",details:["The first rule in effect whose conditions all hold for a viewer shows its target: a published paywall, or the variant of the experiment running on the placement for the rules. At most 50 rules of at most 10 conditions.","A condition reads country, platform, app, app_version, sdk_version, locale, entitlement, first_seen_days or an attribute the app sends; purchases:placements:preview tries rules against a viewer before they are saved (--rules).","Of two people editing at once, the second is told \u2014 the rules moved past the revision they edited \u2014 never overwritten."],args:{min:1,max:1},flags:{file:{type:"string",value:"rules.json",description:"the rules, as rules:get --out wrote them ('-' or none: stdin)"},revision:{type:"string",value:"n",description:"the revision they were edited from, as rules:get printed it"}},scope:"environment",async run(e){let t=await w(e),n=Qa(e),s=Te(e.flags.revision,"revision");if(s===void 0)throw g("--revision is the revision the rules were edited from: of two edits at once, the second is told, not saved over the first");let a=await Bv(e,e.flags.file);await k(e,t,`replace ${n}'s rules with ${a.length} rule(s) over revision ${s}`);let i;try{i=await h(e,t,"PUT",`/purchases/placements/${T(n)}/rules`,{rules:a},{"if-match":nl(s),...J()})}catch(o){if(o instanceof W&&o.status===412)throw new y("rules_changed",`${n}'s rules are no longer at revision ${s}: someone saved newer ones since they were read \u2014 nothing was saved`,{hint:`read them again (palbase purchases:placements:rules:get ${n} --out <file>), make the edit on them, and save with that revision`});if(o instanceof W&&o.code==="placement_not_found")throw new y("placement_not_found",`the environment has no placement ${n}`,{hint:`give it a paywall first: palbase purchases:placements:set ${n} --paywall <name>`});Wv(e,o,"the rules were not saved")}let r=await rr(e,t);e.out.result(i,()=>{e.out.line(`Saved revision ${i.revision} of ${n}'s rules:`),Kv(e,i.rules,r),i.rules.length===0&&e.out.line("No rule: it shows its default paywall to everyone.")})}};function qv(e){let t=Ie(e);if(t===void 0||t.length===0)return;let n={};for(let s of t){let a=s.indexOf("=");if(a<=0)throw g(`--attr ${s}: an attribute is key=value`);let i=An(s.slice(a+1));n[s.slice(0,a)]=typeof i=="number"||typeof i=="boolean"?i:s.slice(a+1)}return n}var UI={matched:"decided",unmet:"did not hold",unavailable:"its experiment no longer runs",not_reached:"not reached"},KI={name:"purchases:placements:preview",summary:"what a placement shows a viewer, and why: the experiment, the rule that decided \u2014 every rule, condition by condition \u2014 or the default",usage:"<placement> [--platform ios|android|web|macos] [--country TR] [--app-version 2.1.0] [--sdk palbase-swift@0.2.0] [--locale tr-TR] [--attr key=value \u2026] [--user <id>] [--rules <file>] [--at <RFC3339>]",details:["The viewer is what its app would send. With --user, the user's entitlements and the days since they were first seen are the project's; the user (else an installation) is who an experiment's variant is drawn for.","--rules tries rules not yet saved (a rules:put file) instead of the saved ones; --at, a moment (a scheduled rule's start). Nothing is counted or changed."],args:{min:1,max:1},flags:{platform:{type:"string",value:"platform",description:"ios, android, web or macos"},country:{type:"string",value:"code",description:"the store's country: ISO 3166-1, two or three letters"},"app-version":{type:"string",value:"version",description:"the app's version"},sdk:{type:"string",value:"name@version",description:"the SDK the app draws with (palbase-swift@0.2.0)"},locale:{type:"string",value:"tag",description:"the viewer's language (BCP 47)"},attr:{type:"string",multiple:!0,value:"key=value",description:"what the app says of the viewer (repeat it, or a comma list)"},user:{type:"string",value:"id",description:"the signed-in user"},rules:{type:"string",value:"file",description:"rules to try instead of the saved ones"},at:{type:"string",value:"RFC 3339",description:"the moment (default: now)"}},scope:"environment",async run(e){let t=await w(e),n=Qa(e),s=e.flags.platform;if(s!==void 0&&!["ios","android","web","macos"].includes(s))throw g("--platform is one of ios, android, web, macos");let a,i=e.flags.sdk;if(i!==void 0){let b=i.lastIndexOf("@");if(b<=0||b===i.length-1)throw g(`--sdk ${i}: it is the SDK's name and version, palbase-swift@0.2.0`);a={sdk:i.slice(0,b),sdk_version:i.slice(b+1)}}let r=e.flags.at;if(r!==void 0&&Number.isNaN(Date.parse(r)))throw g(`--at ${r}: a moment, as RFC 3339 writes it (2026-11-01T09:00:00Z)`);let o={...s?{platform:s}:{},...e.flags.country!==void 0?{country:e.flags.country}:{},...e.flags["app-version"]!==void 0?{app_version:e.flags["app-version"]}:{},...a??{},...e.flags.locale!==void 0?{locale:e.flags.locale}:{},...qv(e.flags.attr)?{attributes:qv(e.flags.attr)}:{},...e.flags.user!==void 0?{user_id:e.flags.user}:{}},l=e.flags.rules!==void 0?await Bv(e,e.flags.rules):void 0,d={context:o,...r?{at:r}:{},...l?{rules:l}:{}},p;try{p=(await wt(e,t,"POST",`/purchases/placements/${T(n)}/resolve-preview`,d,J())).body}catch(b){if(b instanceof W&&b.code==="placement_not_found")throw new y("placement_not_found",`the environment has no placement ${n}`,{hint:"palbase purchases:placements lists them"});if(b instanceof W&&b.code==="invalid_context")throw new y("invalid_context",`the viewer is not one the module reads: ${b.message}`);Wv(e,b,"the rules cannot be tried")}let[c,m]=await Promise.all([rr(e,t),l??h(e,t,"GET",`/purchases/placements/${T(n)}/rules`).then(b=>b.rules)]),f={experiment:`the experiment running for everyone there (${p.experiment_id??"?"}), variant ${p.variant??"?"}`,rule:`the rule ${p.steps.find(b=>b.rule_id===p.rule_id)?.name??p.rule_id??"?"}${p.variant?`, variant ${p.variant} of its experiment`:""}`,default:"its default paywall: no rule held",none:"nothing: it has no paywall for this viewer, and the app draws its own"};e.out.result({...p,paywall:p.paywall_id===void 0?null:ir(c,p.paywall_id)},()=>{e.out.line(p.source==="none"?`${n} shows ${f.none}.`:`${n} shows ${ir(c,p.paywall_id)} \u2014 from ${f[p.source]}.`),p.steps.length>0&&e.out.line(`Its ${l?"rules tried":"rules"}, at ${Y(p.at)} UTC:`),p.steps.forEach((b,v)=>{e.out.line(`${v+1}. ${b.name} \u2014 ${b.status}: ${UI[b.outcome]??b.outcome}`);let R=(m.find(A=>A.id!==void 0&&A.id===b.rule_id)??m[v])?.conditions;for(let A of b.conditions??[]){let C=R?.[A.index];e.out.line(` ${A.met?"\u2713":"\u2717"} ${C?Uv(C):A.field}${A.unknown?" \u2014 the viewer carries none":""}`)}})})}};function FI(e,t){let n=e.variant?`, variant ${e.variant}`:"";return e.kind==="rule"?`${e.rule_current?`rule ${e.rule_name??e.rule_id??"?"}`:`removed rule ${e.rule_id??"?"}`}${n}`:e.kind==="experiment"?`experiment ${t.get(e.experiment_id??"")??e.experiment_id??"?"}${n}`:e.kind}var BI={name:"purchases:placements:results",summary:"what each of a placement's rules showed and what its viewers did \u2014 exposures, viewers, purchases, conversion, revenue \u2014 beside the rules since removed, an experiment's variants and the default",usage:"<placement> [--days <n>] [--window-days <n>] [--sandbox]",details:["What was shown in the last days (30 unless said, at most 90). The rules come in the order they are read, then the rules the placement no longer has, the variants of an experiment for everyone there, its default.","A purchase counts once, for what its buyer saw first at the placement, within the window after seeing it (7 days unless said): the purchases the stores confirmed, never what an app reports. Revenue is what was paid to date, renewals in, refunds out."],args:{min:1,max:1},flags:{days:{type:"string",value:"n",description:"the days of what was shown the results look back over, 1 to 90 (default 30)"},"window-days":{type:"string",value:"n",description:"the days after first seeing what was shown a purchase counts for it, 1 to 90 (default 7)"},sandbox:{type:"boolean",description:"count the stores' test purchases too"}},scope:"environment",async run(e){let t=await w(e),n=Qa(e),s=Te(e.flags.days,"days");if(s!==void 0&&(s<1||s>90))throw g("--days is 1 to 90");let a=Te(e.flags["window-days"],"window-days");if(a!==void 0&&(a<1||a>90))throw g("--window-days is 1 to 90");let i=new URLSearchParams({...s!==void 0?{days:String(s)}:{},...a!==void 0?{window_days:String(a)}:{},...e.flags.sandbox===!0?{sandbox:"true"}:{}}),r;try{r=await h(e,t,"GET",`/purchases/placements/${T(n)}/results${i.size>0?`?${i}`:""}`)}catch(p){throw p instanceof W&&p.code==="placement_not_found"?new y("placement_not_found",`the environment has no placement ${n}`,{hint:"palbase purchases:placements lists them"}):p}let[o,l]=await Promise.all([rr(e,t),r.sources.some(p=>p.experiment_id!==void 0)?pl(e,t,n).then(p=>new Map(p.map(c=>[c.id,c.name]))):new Map]),d=r.sources.map(p=>({...p,paywall:ir(o,p.paywall_id)}));e.out.result({...r,sources:d},()=>{if(e.out.line(`${n}: what was shown in the last ${r.days} day(s), purchases within ${r.window_days} day(s) of first seeing it${r.sandbox?", test purchases included":""}, counted ${Y(r.computed_at)}`),d.length===0){e.out.line("No one was shown a paywall here yet.");return}e.out.table(d,[{header:"shown by",value:p=>FI(p,l)},{header:"paywall",value:p=>p.paywall},{header:"exposures",value:p=>String(p.exposures)},{header:"viewers",value:p=>String(p.viewers)},{header:"purchases",value:p=>String(p.purchases)},{header:"converted",value:p=>`${p.converters} (${ar(p.conversion_rate)})`},{header:"revenue",value:p=>p.revenue.length===0?"\u2014":p.revenue.map(Hp).join(" + ")}])})}},WI={name:"purchases:placements:attributes",summary:"the attribute keys the environment's apps sent with a placement's paywall, as they said them \u2014 suggestions for attribute conditions, the most used first, each with its JSON type and the hours it was seen in",details:["An app sends what it says of the viewer as attributes (pb.purchases.paywall(placement, { attributes })); the keys are kept, never the values. They are what apps said, unverified \u2014 anyone with the publishable key can send one \u2014: a help to write rules, not a list of what the app defines.","A key is seen again at most once an hour, and counted in one more hour as often. At most 200 are kept: past them a new key takes the place of the key seen longest ago once that one was last seen over a day ago, so keys sent once age out."],scope:"environment",async run(e){let t=await w(e),{attributes:n}=await h(e,t,"GET","/purchases/placements/attributes");e.out.result({attributes:n},()=>{if(n.length===0){e.out.line("No app has sent an attribute yet."),e.out.line(`An app sends them with a placement's paywall: pb.purchases.paywall("onboarding", { attributes: { plan: "free" } })`);return}e.out.table(n,[{header:"key",value:s=>s.key},{header:"type",value:s=>s.type},{header:"hours seen",value:s=>String(s.seen_hours)},{header:"last seen",value:s=>Y(s.last_seen_at)}])})}},zv=[DI,MI,xI,GI,qI,KI,BI,WI];import{basename as zI,extname as JI,resolve as HI}from"node:path";import{stat as VI}from"node:fs/promises";var XI=/^[a-z][a-z0-9_]{0,63}$/,YI=/^P(?:\d+W)?(?:\d+D)?(?:T(?:\d+H)?(?:\d+M)?)?$/;function Dn(e,t="the journey's key"){if(e===void 0||e.trim()==="")throw g(`${t} is required`);if(!XI.test(e))throw g(`${JSON.stringify(e)} is not a journey's key: 1 to 64 of a-z, 0-9 and _, starting with a letter (winback)`);return e}async function ZI(e,t,n){let s=[],a;do{let i=new URLSearchParams({limit:"200",...n?{status:n}:{},...a?{cursor:a}:{}}),r=await h(e,t,"GET",`/journeys?${i}`);s.push(...r.journeys),a=r.next_cursor}while(a);return s}async function Jv(e,t,n){try{return await h(e,t,"GET",`/journeys/${T(n)}`)}catch(s){if(s instanceof W&&s.code==="journey_not_found")return;throw s}}function Ts(e){return new y("journey_not_found",`no journey ${e}`,{hint:"palbase journeys lists them"})}function Hv(e,t){for(let n of t)e.out.line(` ${n.path}: ${n.message}`),n.fix&&e.out.line(` fix: ${n.fix}`)}function Vv(e,t){if(t instanceof W&&t.code==="invalid_journey"){let s=t.body?.problems??[];throw e.out.result({valid:!1,problems:s},()=>{e.out.line(`The journey breaks ${s.length===1?"a rule":`${s.length} rules`}:`),Hv(e,s)}),new y("invalid_journey",`the journey has ${s.length} problem${s.length===1?"":"s"}`,{hint:"fix each at its path; palbase journeys:validate <file> checks it again",reported:!0})}throw t}async function Xp(e,t){return Fe(await Xe(e,t,"the journey"),"the journey")}function Xv(e){switch(e.kind){case"event":return`on ${e.key}`;case"audience":return`joins audience ${e.key}`;case"inactive":return`away from ${e.key}`;default:return`members of ${e.key}`}}function Vp(e){let t=Math.round(e/6e4),n=Math.floor(t/1440),s=Math.floor(t%1440/60),a=t%60,i=[n?`${n}d`:"",s?`${s}h`:"",a?`${a}m`:""].filter(Boolean);return i.length?i.join(" "):"0m"}var QI={name:"journeys",summary:"the environment's journeys: each one's key, name, status, way in, and when it was published",usage:"[--status draft|live|stopped]",flags:{status:{type:"string",value:"status",description:"draft, live or stopped alone"}},scope:"environment",async run(e){let t=await w(e),n=e.flags.status;if(n!==void 0&&!["draft","live","stopped"].includes(n))throw g("--status is draft, live or stopped");let s=await ZI(e,t,n);e.out.result({journeys:s},()=>{if(s.length===0){e.out.line("No journey yet."),e.out.line("Write one as a JSON file, check it, walk a person through it, push it: palbase journeys:validate winback.json");return}e.out.table(s,[{header:"key",value:a=>a.key},{header:"name",value:a=>a.name},{header:"status",value:a=>a.status},{header:"entry",value:a=>Xv(a.entry)},{header:"published",value:a=>a.published_at?Y(a.published_at):"-"}])})}},eL={name:"journeys:get",summary:"a journey's definition, as JSON: to edit and push again (a draft), or to push under a new key (a published one)",usage:"<key>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=Dn(e.args[0]),s=await Jv(e,t,n);if(!s)throw Ts(n);e.out.result(s,()=>e.out.line(JSON.stringify(s.definition,null,2)))}},tL={name:"journeys:validate",summary:"check a journey file without saving it: every problem, at its path, with what to do about it",usage:"<file|->",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=await Xp(e,e.args[0]),s=await h(e,t,"POST","/journeys/validate",{definition:n});if(!s.valid)throw e.out.result(s,()=>{e.out.line(`The journey breaks ${s.problems.length===1?"a rule":`${s.problems.length} rules`}:`),Hv(e,s.problems)}),new y("invalid_journey",`the journey has ${s.problems.length} problem${s.problems.length===1?"":"s"}`,{reported:!0});let a=n;e.out.result(s,()=>e.out.line(`Valid: ${a.name}, ${Object.keys(a.steps??{}).length} steps from ${a.start}. Walk a person through it: palbase journeys:simulate ${e.args[0]}`))}},nL={name:"journeys:push",summary:"save a journey file as a draft \u2014 new, or the draft's new version \u2014 and, with --publish, publish it",usage:"<file|-> [--key <key>] [--publish]",details:["The key is --key, else the file's name (winback.json is winback).","A published journey does not change: push the file under a new key with --publish, then stop the old one (journeys:stop)."],args:{min:1,max:1},flags:{key:{type:"string",value:"key",description:"the journey's key (default: the file's name)"},publish:{type:"boolean",description:"publish it once saved: people enter from then on"}},scope:"environment",async run(e){let t=await w(e),n=e.args[0],s=e.flags.key??(n==="-"?void 0:zI(n,JI(n))),a=Dn(s,n==="-"?"the journey's key (--key, reading stdin)":"the journey's key"),i=await Xp(e,n),r=await Jv(e,t,a);if(r&&r.status!=="draft")throw new y("journey_published",`${a} is ${r.status}: a published journey does not change`,{hint:`push it under a new key and publish that, then stop this one: palbase journeys:push ${n} --key ${a}_next --publish && palbase journeys:stop ${a}`});let o;try{o=r?await h(e,t,"PUT",`/journeys/${T(a)}`,{definition:i}):await h(e,t,"POST","/journeys",{key:a,definition:i})}catch(l){Vv(e,l)}e.flags.publish===!0&&(await k(e,t,`publish ${a}: people enter it from now on`),o=await Yv(e,t,a)),e.out.result(o,()=>{e.out.line(`${r?"Saved":"Made"} ${o.key} (${o.name}): ${o.status}.`),o.status==="draft"&&e.out.line(`Publish it: palbase journeys:publish ${o.key}`)})}};async function Yv(e,t,n){try{return await h(e,t,"POST",`/journeys/${T(n)}/publish`)}catch(s){throw s instanceof W&&s.code==="live_journeys_limit"?new y("live_journeys_limit","the Free plan runs 2 journeys at once",{hint:"stop one (palbase journeys:stop <key>), or add a payment method to the organization in Studio"}):s instanceof W&&s.code==="journey_published"?new y("journey_published",`${n} is published already`):s instanceof W&&s.code==="journey_not_found"?Ts(n):s}}var sL={name:"journeys:publish",summary:"publish a draft: people enter it from now on, and it no longer changes",usage:"<key>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=Dn(e.args[0]);await k(e,t,`publish ${n}: people enter it from now on`);let s=await Yv(e,t,n);e.out.result(s,()=>e.out.line(`Published ${s.key} (${s.name}): people ${Xv(s.entry)} enter it.`))}};function aL(e){return(e??[]).map(t=>{let n=/^([^@]+)@(P[0-9A-Z]+)(?::(.*))?$/.exec(t.trim());if(!n||!YI.test(n[2]))throw g(`--event ${t}: an event is <name>@<while after entering>, the while ISO 8601 (PT2H, P1D, PT0M at once), its properties after a colon: purchases.purchase.completed@P1D:product_id=pro`);let s={name:n[1],after:n[2]};return n[3]&&(s.properties=Zv(n[3].split(";"))),s})}function Zv(e){let t={};for(let n of e){let s=n.indexOf("=");if(s<=0)throw g(`${n}: a property is name=value`);let a=n.slice(s+1);t[n.slice(0,s)]=a==="true"?!0:a==="false"?!1:a!==""&&Number.isFinite(Number(a))?Number(a):a}return t}var iL={name:"journeys:simulate",summary:"walk a made-up person through a journey \u2014 a file, or a key \u2014 as it would run: each step, when, what it would do, how it ends; nothing is sent",usage:"<file|key> [--user <id>] [--property name=value]\u2026 [--audience <id>]\u2026 [--timezone <zone>] [--event name@PT2H]\u2026 [--start <time>]",details:["The person enters at --start (now unless it says) and does each --event a while after entering: --event purchases.purchase.completed@P1D.","Their --property values are what branches read, --audience the audiences they are in, --timezone where a wait until a time of day is."],args:{min:1,max:1},flags:{user:{type:"string",value:"id",description:"the person's id (it picks their way at a split)"},property:{type:"string",multiple:!0,value:"name=value",description:"a property of theirs"},audience:{type:"string",multiple:!0,value:"id",description:"an audience they are in"},timezone:{type:"string",value:"zone",description:"their IANA time zone (Europe/Istanbul)"},event:{type:"string",multiple:!0,value:"name@while",description:"an event of theirs, a while after entering (PT2H, P1D)"},start:{type:"string",value:"time",description:"when they enter (RFC 3339); now unless it says"}},scope:"environment",async run(e){let t=await w(e),n=e.args[0],s=n==="-"||n.endsWith(".json")||await VI(HI(e.io.cwd,n)).then(m=>m.isFile(),()=>!1),a={};e.flags.user!==void 0&&(a.user_id=e.flags.user);let i=Ie(e.flags.property);i?.length&&(a.properties=Zv(i));let r=Ie(e.flags.audience);r?.length&&(a.audiences=r),e.flags.timezone!==void 0&&(a.timezone=e.flags.timezone);let o=aL(e.flags.event===void 0?void 0:(Array.isArray(e.flags.event)?e.flags.event:[e.flags.event]).map(String));o.length&&(a.events=o);let l={person:a};if(s?l.definition=await Xp(e,n):l.key=Dn(n),e.flags.start!==void 0){let m=new Date(e.flags.start);if(Number.isNaN(m.getTime()))throw g("--start is a time: 2026-10-21T09:00:00Z");l.start=m.toISOString()}let d;try{d=await h(e,t,"POST","/journeys/simulate",l)}catch(m){if(m instanceof W&&m.code==="journey_not_found")throw Ts(n);Vv(e,m)}let p=Date.parse(d.steps[0]?.at??l.start??d.end.at),c=l.start?Date.parse(l.start):p;e.out.result(d,()=>{e.out.table(d.steps,[{header:"after",value:m=>`+${Vp(Date.parse(m.at)-c)}`},{header:"step",value:m=>m.step},{header:"kind",value:m=>m.kind},{header:"outcome",value:m=>m.outcome},{header:"does",value:m=>m.note}]),e.out.line(`Ends ${d.end.reason} after ${Vp(Date.parse(d.end.at)-c)}.`),d.converted_at&&e.out.line(`Converted after ${Vp(Date.parse(d.converted_at)-c)}, once the run had completed.`)})}},rL={name:"journeys:stats",summary:"what came of a journey: who entered, how their runs ended, who is in it now, its goal's conversions, each step's outcomes",usage:"<key>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=Dn(e.args[0]),s;try{s=await h(e,t,"GET",`/journeys/${T(n)}/stats`)}catch(i){throw i instanceof W&&i.code==="journey_not_found"?Ts(n):i}let a=i=>Object.entries(i??{}).filter(([,r])=>r>0).map(([r,o])=>`${r} ${o}`).join(", ")||"-";e.out.result(s,()=>{e.out.line(`${s.key} (${s.status}): ${s.entered} entered, ${s.converted} converted${s.held?`, ${s.held} held for the month's people`:""}`),e.out.line(`In it now: ${s.in_progress.active} active, ${s.in_progress.waiting} waiting, ${s.in_progress.held} held. Ended: ${a(s.ended)}.`),e.out.table(s.steps,[{header:"step",value:i=>i.step},{header:"kind",value:i=>i.kind},{header:"outcomes",value:i=>a(i.outcomes)},{header:"converted",value:i=>i.converted?a(i.converted):""}])})}},oL={name:"journeys:runs",summary:"a journey's people: each run's state, the step it is at, how it ended, and the steps it took",usage:"<key> [--user <id>] [--state held|active|waiting|ended] [--limit <n>]",args:{min:1,max:1},flags:{user:{type:"string",value:"id",description:"one person's runs"},state:{type:"string",value:"state",description:"held, active, waiting or ended"},limit:{type:"string",value:"n",description:"how many, newest first (default 50, at most 200)"}},scope:"environment",async run(e){let t=await w(e),n=Dn(e.args[0]),s=new URLSearchParams;e.flags.user!==void 0&&s.set("user_id",e.flags.user),e.flags.state!==void 0&&s.set("state",e.flags.state),e.flags.limit!==void 0&&s.set("limit",e.flags.limit);let a;try{a=await h(e,t,"GET",`/journeys/${T(n)}/runs${s.size?`?${s}`:""}`)}catch(i){throw i instanceof W&&i.code==="journey_not_found"?Ts(n):i}e.out.result(a,()=>{if(a.runs.length===0){e.out.line("No one is or was in it.");return}e.out.table(a.runs,[{header:"user",value:i=>i.user_id},{header:"state",value:i=>i.state==="ended"?`ended ${i.end_reason}`:i.step?`${i.state} at ${i.step}`:i.state},{header:"entered",value:i=>Y(i.entered_at)},{header:"steps",value:i=>i.steps.map(r=>`${r.step} ${r.outcome}`).join(" \u2192 ")||"-"}])})}},lL={name:"journeys:stop",summary:"stop a live journey for good: no one enters it, the runs in it end, its report stays",usage:"<key>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=Dn(e.args[0]);await k(e,t,`stop ${n}: the people in it leave it now, and it does not start again`,e.global.yes?void 0:"A stopped journey does not start again");let s;try{s=await h(e,t,"POST",`/journeys/${T(n)}/stop`)}catch(a){throw a instanceof W&&a.code==="journey_not_found"?Ts(n):a instanceof W&&a.code==="journey_not_live"?new y("journey_not_live",`${n} is not live: a draft is deleted, a stopped one is stopped already`):a}e.out.result(s,()=>e.out.line(`Stopped ${s.key}. Its report stays: palbase journeys:stats ${s.key}`))}},dL={name:"journeys:copy",summary:"copy a journey's definition into a new draft: how a published journey is changed",usage:"<key> <new-key> [--name <name>]",args:{min:2,max:2},flags:{name:{type:"string",value:"name",description:"the copy's name (default: the journey's)"}},scope:"environment",async run(e){let t=await w(e),n=Dn(e.args[0]),s=Dn(e.args[1],"the copy's key"),a;try{a=await h(e,t,"POST",`/journeys/${T(n)}/copy`,{key:s,...e.flags.name?{name:e.flags.name}:{}})}catch(i){throw i instanceof W&&i.code==="journey_not_found"?Ts(n):i instanceof W&&i.code==="journey_exists"?new y("journey_exists",`the environment has a journey ${s}`):i}e.out.result(a,()=>e.out.line(`Copied ${n} into the draft ${a.key}: palbase journeys:get ${a.key} > ${a.key}.json, change it, push it.`))}},pL={name:"journeys:delete",summary:"delete a journey with its runs and its report; the people in a live one leave it at once",usage:"<key>",args:{min:1,max:1},scope:"environment",async run(e){let t=await w(e),n=Dn(e.args[0]);await k(e,t,`delete ${n}, its runs and its report`,e.global.yes?void 0:"A deleted journey and its report do not come back");try{await h(e,t,"DELETE",`/journeys/${T(n)}`)}catch(s){throw s instanceof W&&s.code==="journey_not_found"?Ts(n):s}e.out.result({deleted:n},()=>e.out.line(`Deleted ${n}.`))}},Qv=[QI,eL,tL,nL,sL,iL,rL,oL,lL,dL,pL];import{mkdir as cL,writeFile as uL}from"node:fs/promises";import{dirname as mL}from"node:path";var hL=`${me}/charts`,gL=/^\d{4}-\d{2}-\d{2}$/,fL=/^[A-Za-z]{3}$/,yL=["day","week","month"],t_=["gross","net_of_taxes","proceeds"],bL=["new_customers","new_paying_customers"],wL=["standard","small_business"],e_=20,Yp={gross:"gross",net_of_taxes:"net of taxes",proceeds:"proceeds"},vL={standard:"standard: 30%, 15% of a subscription's renewals after its first paid year in the App Store and of every subscription on Google Play",small_business:"15%: the App Store Small Business Program, Google Play's first million"};function ul(e,t){try{return new Intl.NumberFormat("en",{style:"currency",currency:t}).format(e)}catch{return`${e.toFixed(2)} ${t}`}}function lr(e,t,n){return e==="currency"?ul(t,n):e==="ratio"?`${(t*100).toFixed(1)}%`:Number.isInteger(t)?String(t):t.toFixed(2)}function or(e,t,n){let s=e.flags[t];if(s!==void 0){if(!n.includes(s))throw g(`--${t} is ${n.slice(0,-1).join(", ")} or ${n[n.length-1]}`);return s}}function ml(e,t){let n=e.flags[t];if(n!==void 0){if(typeof n!="string"||!fL.test(n))throw g(`--${t} is a currency's three letters: USD, EUR, TRY`);return n.toUpperCase()}}function cl(e,t){if(e instanceof W){if(e.code==="charts_busy")throw new y("charts_busy",`the charts are busy: ${D(e.message)}`,{hint:"ask again in half a minute, or for fewer days"});if(e.code==="too_many_charts")throw new y("too_many_charts",`too many charts counted in a row: ${D(e.message)}`,{hint:"ask again in a few seconds; the same chart asked again within a minute is answered at once"});if(e.code==="chart_too_large")throw new y("chart_too_large",D(e.message),{hint:"turn off --sandbox, or ask for a shorter range"});if(e.code==="chart_not_found")throw new y("chart_not_found",`no chart ${JSON.stringify(t)}`,{hint:"palbase purchases:charts lists them"})}throw e}var _L={flow:"what happened in each period",snapshot:"the state at the end of each period",ratio:"one measure over another, each period",cohort:"what began in each period, over its ages"},$L={name:"purchases:charts",summary:"the purchase charts, each with its definition: what it counts, over which period, and how refunds, product changes, resubscriptions and test purchases count",details:["A chart is read with purchases:charts:get <chart>; the figures of now with purchases:charts:overview."],scope:"environment",async run(e){let t=await w(e),n=await h(e,t,"GET","/purchases/charts");e.out.result(n,()=>{for(let s of n.charts){let a=[_L[s.kind]??s.kind,s.unit==="currency"?"money":s.unit,...s.segmentable?["segmentable"]:[],...s.window?["takes --window-days"]:[]];e.out.line(D(`${s.key} \u2014 ${s.name} (${a.join("; ")})`)),e.out.line(` ${D(s.description)}`)}e.out.line(),e.out.line("Segmented (--segment) and filtered (--filter dimension:value) by:"),e.out.table(n.dimensions,[{header:"dimension",value:s=>s.key},{header:"values",value:s=>s.description}]),e.out.line(D(`Money is counted as (--revenue-type): ${n.revenue_types.map(s=>Yp[s]??s).join(", ")}.`))})}},kL={name:"purchases:charts:overview",summary:"the project's figures at a glance: MRR, active subscriptions and trials now; revenue, new customers and active customers over the last 28 days",usage:"[--revenue-type gross|net_of_taxes|proceeds] [--currency <code>] [--sandbox]",flags:{"revenue-type":{type:"string",value:"type",description:"gross (default), net_of_taxes or proceeds"},currency:{type:"string",value:"code",description:"the currency to report money in (default: the reporting currency)"},sandbox:{type:"boolean",description:"count the stores' test purchases too"}},scope:"environment",async run(e){let t=or(e,"revenue-type",t_),n=ml(e,"currency"),s=await w(e),a=new URLSearchParams({...e.flags.sandbox===!0?{sandbox:"true"}:{},...t?{revenue_type:t}:{},...n?{currency:n}:{}}),i;try{i=await h(e,s,"GET",`/purchases/charts/overview${a.size>0?`?${a}`:""}`)}catch(r){cl(r)}e.out.result(i,()=>{let r=i.estimated?" (estimated)":"";e.out.line(D(`In ${i.currency}, ${Yp[i.revenue_type]??i.revenue_type}, test purchases ${i.sandbox?"included":"left out"}; the last 28 days since ${i.since} (UTC), counted ${Y(i.computed_at)}`)),e.out.table([["MRR",`${ul(i.mrr,i.currency)}${r}`],["Active subscriptions",String(i.active_subscriptions)],["Active trials",String(i.active_trials)],["Revenue, last 28 days",`${ul(i.revenue_last_28_days,i.currency)}${r}`],["New customers, last 28 days",String(i.new_customers_last_28_days)],["Active customers, last 28 days",String(i.active_customers_last_28_days)]],[{header:"figure",value:o=>o[0]},{header:"value",value:o=>o[1]}]),n_(e,i.unconverted)})}};function n_(e,t){t.length>0&&e.out.line(D(`Left out: amounts in ${t.join(", ")} \u2014 the European Central Bank publishes no rate of them.`))}function SL(e){let n=(e===void 0?[]:(Array.isArray(e)?e:[e]).map(String)).map(s=>{let a=s.indexOf(":"),i=a===-1?"":s.slice(0,a),r=a===-1?"":s.slice(a+1);if(!/^[a-z][a-z_]{0,31}$/.test(i)||r==="")throw g(`--filter ${s}: a filter is dimension:value (store:app_store, country:TR), one each --filter`);return{dimension:i,value:r}});if(n.length>e_)throw g(`--filter: at most ${e_} values`);return n}var AL=/^[=+\-@\t\r]/,PL=/^[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$/;function s_(e){let t=[],n=[],s="",a=!1,i=!1;for(let r=0;r<e.length;r++){let o=e[r];if(a){o==='"'&&e[r+1]==='"'?(s+='"',r++):o==='"'?a=!1:s+=o;continue}i=!0,o==='"'&&s===""?a=!0:o===","?(n.push(s),s=""):o===`
|
|
687
687
|
`||o==="\r"&&e[r+1]===`
|
|
688
688
|
`?(o==="\r"&&r++,n.push(s),t.push(n),n=[],s="",i=!1):s+=o}return(i||s!==""||n.length>0)&&(n.push(s),t.push(n)),t}var RL=e=>/[",\r\n]/.test(e)||/^\s/.test(e)?`"${e.replace(/"/g,'""')}"`:e;function EL(e){return`${s_(e).map(t=>t.map(n=>RL(AL.test(n)&&!PL.test(n)?`'${n}`:n)).join(",")).join(`
|
|
689
689
|
`)}
|