starknetkit
Version:
<!-- logo --> <p align="center"> <img width='300' src="https://starknetkit-website-git-blo-1541-argentlabs.vercel.app/starknetKit-logo.svg"> </p>
26 lines • 117 kB
JavaScript
"use strict";var En=Object.defineProperty;var Cn=(t,e,r)=>e in t?En(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var ke=(t,e,r)=>(Cn(t,typeof e!="symbol"?e+"":e,r),r);const $t=require("starknet"),C=require("./lastConnected-966555c5.cjs"),er=require("./getStarknetChainId-db957824.cjs"),Mt="https://web.argent.xyz",tr=`<svg
width="32"
height="28"
viewBox="0 0 18 14"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M1.5 0.4375C0.982233 0.4375 0.5625 0.857233 0.5625 1.375V12C0.5625 12.4144 0.72712 12.8118 1.02015 13.1049C1.31317 13.3979 1.7106 13.5625 2.125 13.5625H15.875C16.2894 13.5625 16.6868 13.3979 16.9799 13.1049C17.2729 12.8118 17.4375 12.4144 17.4375 12V1.375C17.4375 0.857233 17.0178 0.4375 16.5 0.4375H1.5ZM2.4375 3.50616V11.6875H15.5625V3.50616L9.63349 8.94108C9.27507 9.26964 8.72493 9.26964 8.36651 8.94108L2.4375 3.50616ZM14.0899 2.3125H3.91013L9 6.97822L14.0899 2.3125Z"
fill="currentColor"
/>
</svg>`,Rn="https://static.hydrogen.argent47.net/webwallet/iframe_whitelist_testnet.json",Sn="https://static.argent.net/webwallet/iframe_whitelist_mainnet.json";class wr extends Error{constructor(r,n){super(r);ke(this,"code");this.name="ConnectAndSignSessionError",this.code=n}}class xr extends Error{constructor(r,n){super(r);ke(this,"code");this.name="WebwalletError",this.code=n}}const K=$t.constants.NetworkName,On=K.SN_SEPOLIA;function Pn(t){try{const{origin:e}=new URL(t);if(e.includes("localhost")||e.includes("127.0.0.1"))return On;if(e.includes("hydrogen")||e.includes("sepolia-web.staging"))return K.SN_SEPOLIA;if(e.includes("staging"))return K.SN_MAIN;if(e.includes("dev")||e.includes("sepolia-web.argent.xyz"))return K.SN_SEPOLIA;if(e.includes("argent.xyz"))return K.SN_MAIN}catch{console.warn("Could not determine network from target URL, defaulting to mainnet-alpha")}return K.SN_MAIN}const An=385,Nn=775,In=385,jn=440,Ln=420,$n=438;function Mn(t){return t}function Dn(t){return t.length===0?Mn:t.length===1?t[0]:function(r){return t.reduce((n,s)=>s(n),r)}}function Zn(t){return typeof t=="object"&&t!==null&&"subscribe"in t}function rt(t){const e={subscribe(r){let n=null,s=!1,a=!1,i=!1;function o(){if(n===null){i=!0;return}a||(a=!0,typeof n=="function"?n():n&&n.unsubscribe())}return n=t({next(c){s||r.next?.(c)},error(c){s||(s=!0,r.error?.(c),o())},complete(){s||(s=!0,r.complete?.(),o())}}),i&&o(),{unsubscribe:o}},pipe(...r){return Dn(r)(e)}};return e}function Tr(t){return e=>{let r=0,n=null;const s=[];function a(){n||(n=e.subscribe({next(o){for(const c of s)c.next?.(o)},error(o){for(const c of s)c.error?.(o)},complete(){for(const o of s)o.complete?.()}}))}function i(){if(r===0&&n){const o=n;n=null,o.unsubscribe()}}return{subscribe(o){return r++,s.push(o),a(),{unsubscribe(){r--,i();const c=s.findIndex(u=>u===o);c>-1&&s.splice(c,1)}}}}}}function Un(t){return e=>({subscribe(r){let n=0;return e.subscribe({next(a){r.next?.(t(a,n++))},error(a){r.error?.(a)},complete(){r.complete?.()}})}})}function kr(t){return e=>({subscribe(r){return e.subscribe({next(n){t.next?.(n),r.next?.(n)},error(n){t.error?.(n),r.error?.(n)},complete(){t.complete?.(),r.complete?.()}})}})}let Wn=class Er extends Error{constructor(e){super(e),this.name="ObservableAbortError",Object.setPrototypeOf(this,Er.prototype)}};function Cr(t){let e;return{promise:new Promise((n,s)=>{let a=!1;function i(){a||(a=!0,s(new Wn("This operation was aborted.")),o.unsubscribe())}const o=t.subscribe({next(c){a=!0,n(c),i()},error(c){a=!0,s(c),i()},complete(){a=!0,i()}});e=i}),abort:e}}const qn=Object.freeze(Object.defineProperty({__proto__:null,isObservable:Zn,map:Un,observable:rt,observableToPromise:Cr,share:Tr,tap:kr},Symbol.toStringTag,{value:"Module"}));function Rr(t){return rt(e=>{function r(s=0,a=t.op){const i=t.links[s];if(!i)throw new Error("No more links to execute - did you forget to add an ending link?");return i({op:a,next(c){return r(s+1,c)}})}return r().subscribe(e)})}function rr(t){return Array.isArray(t)?t:[t]}function zn(t){return e=>{const r=rr(t.true).map(s=>s(e)),n=rr(t.false).map(s=>s(e));return s=>rt(a=>{const i=t.condition(s.op)?r:n;return Rr({op:s.op,links:i}).subscribe(a)})}}function Sr(t){const e=Object.create(null);for(const r in t){const n=t[r];e[n]=r}return e}const nt={PARSE_ERROR:-32700,BAD_REQUEST:-32600,INTERNAL_SERVER_ERROR:-32603,NOT_IMPLEMENTED:-32603,UNAUTHORIZED:-32001,FORBIDDEN:-32003,NOT_FOUND:-32004,METHOD_NOT_SUPPORTED:-32005,TIMEOUT:-32008,CONFLICT:-32009,PRECONDITION_FAILED:-32012,PAYLOAD_TOO_LARGE:-32013,UNPROCESSABLE_CONTENT:-32022,TOO_MANY_REQUESTS:-32029,CLIENT_CLOSED_REQUEST:-32099};Sr(nt);Sr(nt);const Bn={PARSE_ERROR:400,BAD_REQUEST:400,UNAUTHORIZED:401,NOT_FOUND:404,FORBIDDEN:403,METHOD_NOT_SUPPORTED:405,TIMEOUT:408,CONFLICT:409,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,UNPROCESSABLE_CONTENT:422,TOO_MANY_REQUESTS:429,CLIENT_CLOSED_REQUEST:499,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501};function Vn(t){return Bn[t]??500}function Or(t){return Vn(t.code)}const Pr=()=>{};function Ar(t,e){return new Proxy(Pr,{get(n,s){if(!(typeof s!="string"||s==="then"))return Ar(t,[...e,s])},apply(n,s,a){const i=e[e.length-1]==="apply";return t({args:i?a.length>=2?a[1]:[]:a,path:i?e.slice(0,-1):e})}})}const Dt=t=>Ar(t,[]),Zt=t=>new Proxy(Pr,{get(e,r){if(!(typeof r!="string"||r==="then"))return t(r)}});function Fn(t){const{path:e,error:r,config:n}=t,{code:s}=t.error,a={message:r.message,code:nt[s],data:{code:s,httpStatus:Or(r)}};return n.isDev&&typeof t.error.stack=="string"&&(a.data.stack=t.error.stack),typeof e=="string"&&(a.data.path=e),n.errorFormatter({...t,shape:a})}function nr(t,e){return"error"in e?{...e,error:t.transformer.output.serialize(e.error)}:"data"in e.result?{...e,result:{...e.result,data:t.transformer.output.serialize(e.result.data)}}:e}function Hn(t,e){return Array.isArray(e)?e.map(r=>nr(t,r)):nr(t,e)}function Gn(t){return!!t&&!Array.isArray(t)&&typeof t=="object"}class Jn extends Error{}function Ut(t){if(t instanceof Error)return t;const e=typeof t;if(!(e==="undefined"||e==="function"||t===null)){if(e!=="object")return new Error(String(t));if(Gn(t)){const r=new Jn;for(const n in t)r[n]=t[n];return r}}}const Yn=Object.freeze(Object.defineProperty({__proto__:null,createFlatProxy:Zt,createRecursiveProxy:Dt,getCauseFromUnknown:Ut,getErrorShape:Fn,transformTRPCResponse:Hn},Symbol.toStringTag,{value:"Module"}));function sr(t){return!!t&&!Array.isArray(t)&&typeof t=="object"}function Xn(t){return t instanceof Nr||t instanceof Error&&t.name==="TRPCClientError"}function Qn(t){return sr(t)&&sr(t.error)&&typeof t.error.code=="number"&&typeof t.error.message=="string"}let Nr=class Ee extends Error{static from(e,r={}){const n=e;return Xn(n)?(r.meta&&(n.meta={...n.meta,...r.meta}),n):Qn(n)?new Ee(n.error.message,{...r,result:n}):n instanceof Error?new Ee(n.message,{...r,cause:Ut(n)}):new Ee("Unknown error",{...r,cause:n})}constructor(e,r){const n=r?.cause;super(e,{cause:n}),this.meta=r?.meta,this.cause=n,this.shape=r?.result?.error,this.data=r?.result?.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,Ee.prototype)}};function Kn(t){return typeof FormData>"u"?!1:t instanceof FormData}const pt={css:{query:["72e3ff","3fb0d8"],mutation:["c5a3fc","904dfc"],subscription:["ff49e1","d83fbe"]},ansi:{regular:{query:["\x1B[30;46m","\x1B[97;46m"],mutation:["\x1B[30;45m","\x1B[97;45m"],subscription:["\x1B[30;42m","\x1B[97;42m"]},bold:{query:["\x1B[1;30;46m","\x1B[1;97;46m"],mutation:["\x1B[1;30;45m","\x1B[1;97;45m"],subscription:["\x1B[1;30;42m","\x1B[1;97;42m"]}}};function es(t){const{direction:e,type:r,path:n,id:s,input:a}=t,i=[],o=[];if(t.colorMode==="ansi"){const[h,y]=pt.ansi.regular[r],[T,k]=pt.ansi.bold[r],N="\x1B[0m";return i.push(e==="up"?h:y,e==="up"?">>":"<<",r,e==="up"?T:k,`#${s}`,n,N),e==="up"?o.push({input:t.input}):o.push({input:t.input,result:"result"in t.result?t.result.result:t.result,elapsedMs:t.elapsedMs}),{parts:i,args:o}}const[c,u]=pt.css[r],d=`
background-color: #${e==="up"?c:u};
color: ${e==="up"?"black":"white"};
padding: 2px;
`;return i.push("%c",e==="up"?">>":"<<",r,`#${s}`,`%c${n}%c`,"%O"),o.push(d,`${d}; font-weight: bold;`,`${d}; font-weight: normal;`),e==="up"?o.push({input:a,context:t.context}):o.push({input:a,result:t.result,elapsedMs:t.elapsedMs,context:t.context}),{parts:i,args:o}}const ts=({c:t=console,colorMode:e="css"})=>r=>{const n=r.input,s=Kn(n)?Object.fromEntries(n):n,{parts:a,args:i}=es({...r,colorMode:e,input:s}),o=r.direction==="down"&&r.result&&(r.result instanceof Error||"error"in r.result.result)?"error":"log";t[o].apply(null,[a.join(" ")].concat(i))};function rs(t={}){const{enabled:e=()=>!0}=t,r=t.colorMode??(typeof window>"u"?"ansi":"css"),{logger:n=ts({c:t.console,colorMode:r})}=t;return()=>({op:s,next:a})=>rt(i=>{e({...s,direction:"up"})&&n({...s,direction:"up"});const o=Date.now();function c(u){const d=Date.now()-o;e({...s,direction:"down",result:u})&&n({...s,direction:"down",elapsedMs:d,result:u})}return a(s).pipe(kr({next(u){c(u)},error(u){c(u)}})).subscribe(i)})}let ns=class{$request({type:e,input:r,path:n,context:s={}}){return Rr({links:this.links,op:{id:++this.requestId,type:e,path:n,input:r,context:s}}).pipe(Tr())}requestAsPromise(e){const r=this.$request(e),{promise:n,abort:s}=Cr(r);return new Promise((i,o)=>{e.signal?.addEventListener("abort",s),n.then(c=>{i(c.result.data)}).catch(c=>{o(Nr.from(c))})})}query(e,r,n){return this.requestAsPromise({type:"query",path:e,input:r,context:n?.context,signal:n?.signal})}mutation(e,r,n){return this.requestAsPromise({type:"mutation",path:e,input:r,context:n?.context,signal:n?.signal})}subscription(e,r,n){return this.$request({type:"subscription",path:e,input:r,context:n?.context}).subscribe({next(a){a.result.type==="started"?n.onStarted?.():a.result.type==="stopped"?n.onStopped?.():n.onData?.(a.result.data)},error(a){n.onError?.(a)},complete(){n.onComplete?.()}})}constructor(e){this.requestId=0;const r=(()=>{const n=e.transformer;return n?"input"in n?e.transformer:{input:n,output:n}:{input:{serialize:s=>s,deserialize:s=>s},output:{serialize:s=>s,deserialize:s=>s}}})();this.runtime={transformer:{serialize:n=>r.input.serialize(n),deserialize:n=>r.output.deserialize(n)},combinedTransformer:r},this.links=e.links.map(n=>n(this.runtime))}};const ss={query:"query",mutate:"mutation",subscribe:"subscription"},as=t=>ss[t];function is(t){return Zt(e=>t.hasOwnProperty(e)?t[e]:e==="__untypedClient"?t:Dt(({path:r,args:n})=>{const s=[e,...r],a=as(s.pop()),i=s.join(".");return t[a](i,...n)}))}function os(t){const e=new ns(t);return is(e)}function cs(t){if(t instanceof ye||t instanceof Error&&t.name==="TRPCError")return t;const e=new ye({code:"INTERNAL_SERVER_ERROR",cause:t});return t instanceof Error&&t.stack&&(e.stack=t.stack),e}class ye extends Error{constructor(e){const r=Ut(e.cause),n=e.message??r?.message??e.code;super(n,{cause:r}),this.code=e.code,this.name="TRPCError",this.cause||(this.cause=r)}}function us(t){return"input"in t?t:{input:t,output:t}}const Oe={_default:!0,input:{serialize:t=>t,deserialize:t=>t},output:{serialize:t=>t,deserialize:t=>t}},Pe=({shape:t})=>t;function ls(t){return Object.assign(Object.create(null),t)}const ds=["query","mutation","subscription"];function fs(t){return"router"in t._def}const ps={_ctx:null,_errorShape:null,_meta:null,queries:{},mutations:{},subscriptions:{},errorFormatter:Pe,transformer:Oe},hs=["then"];function Ir(t){return function(r){const n=new Set(Object.keys(r).filter(c=>hs.includes(c)));if(n.size>0)throw new Error("Reserved words used in `router({})` call: "+Array.from(n).join(", "));const s=ls({});function a(c,u=""){for(const[d,h]of Object.entries(c??{})){const y=`${u}${d}`;if(fs(h)){a(h._def.procedures,`${y}.`);continue}if(s[y])throw new Error(`Duplicate key: ${y}`);s[y]=h}}a(r);const i={_config:t,router:!0,procedures:s,...ps,record:r,queries:Object.entries(s).filter(c=>c[1]._def.query).reduce((c,[u,d])=>({...c,[u]:d}),{}),mutations:Object.entries(s).filter(c=>c[1]._def.mutation).reduce((c,[u,d])=>({...c,[u]:d}),{}),subscriptions:Object.entries(s).filter(c=>c[1]._def.subscription).reduce((c,[u,d])=>({...c,[u]:d}),{})},o={...r,_def:i,createCaller(c){return jr()(o)(c)},getErrorShape(c){const{path:u,error:d}=c,{code:h}=c.error,y={message:d.message,code:nt[h],data:{code:h,httpStatus:Or(d)}};return t.isDev&&typeof c.error.stack=="string"&&(y.data.stack=c.error.stack),typeof u=="string"&&(y.data.path=u),this._def._config.errorFormatter({...c,shape:y})}};return o}}function ms(t){const{type:e,path:r}=t;if(!(r in t.procedures)||!t.procedures[r]?._def[e])throw new ye({code:"NOT_FOUND",message:`No "${e}"-procedure on path "${r}"`});const n=t.procedures[r];return n(t)}function jr(){return function(e){const r=e._def;return function(s){return Dt(({path:i,args:o})=>{if(i.length===1&&ds.includes(i[0]))return ms({procedures:r.procedures,path:o[0],rawInput:o[1],ctx:s,type:i[0]});const c=i.join("."),u=r.procedures[c];let d="query";return u._def.mutation?d="mutation":u._def.subscription&&(d="subscription"),u({path:c,rawInput:o[0],ctx:s,type:d})})}}}const ar=typeof window>"u"||"Deno"in window||globalThis.process?.env?.NODE_ENV==="test"||!!globalThis.process?.env?.JEST_WORKER_ID||!!globalThis.process?.env?.VITEST_WORKER_ID;function ir(t){const e=t;if(typeof e=="function")return e;if(typeof e.parseAsync=="function")return e.parseAsync.bind(e);if(typeof e.parse=="function")return e.parse.bind(e);if(typeof e.validateSync=="function")return e.validateSync.bind(e);if(typeof e.create=="function")return e.create.bind(e);if(typeof e.assert=="function")return r=>(e.assert(r),r);throw new Error("Could not find a validator fn")}function Lr(t,...e){const r=Object.assign(Object.create(null),t);for(const n of e)for(const s in n){if(s in r&&r[s]!==n[s])throw new Error(`Duplicate key ${s}`);r[s]=n[s]}return r}function ys(){function t(r){return{_middlewares:r,unstable_pipe(n){const s="_middlewares"in n?n._middlewares:[n];return t([...r,...s])}}}function e(r){return t([r])}return e}function or(t){return t&&typeof t=="object"&&!Array.isArray(t)}function gs(t){const e=async({next:r,rawInput:n,input:s})=>{let a;try{a=await t(n)}catch(o){throw new ye({code:"BAD_REQUEST",cause:o})}const i=or(s)&&or(a)?{...s,...a}:a;return r({input:i})};return e._type="input",e}function _s(t){const e=async({next:r})=>{const n=await r();if(!n.ok)return n;try{const s=await t(n.data);return{...n,data:s}}catch(s){throw new ye({message:"Output validation failed",code:"INTERNAL_SERVER_ERROR",cause:s})}};return e._type="output",e}const $r="middlewareMarker";function fe(t,e){const{middlewares:r=[],inputs:n,meta:s,...a}=e;return Mr({...Lr(t,a),inputs:[...t.inputs,...n??[]],middlewares:[...t.middlewares,...r],meta:t.meta&&s?{...t.meta,...s}:s??t.meta})}function Mr(t={}){const e={inputs:[],middlewares:[],...t};return{_def:e,input(r){const n=ir(r);return fe(e,{inputs:[r],middlewares:[gs(n)]})},output(r){const n=ir(r);return fe(e,{output:r,middlewares:[_s(n)]})},meta(r){return fe(e,{meta:r})},unstable_concat(r){return fe(e,r._def)},use(r){const n="_middlewares"in r?r._middlewares:[r];return fe(e,{middlewares:n})},query(r){return ht({...e,query:!0},r)},mutation(r){return ht({...e,mutation:!0},r)},subscription(r){return ht({...e,subscription:!0},r)}}}function ht(t,e){const r=fe(t,{resolver:e,middlewares:[async function(s){const a=await e(s);return{marker:$r,ok:!0,data:a,ctx:s.ctx}}]});return bs(r._def)}const vs=`
This is a client-only function.
If you want to call this function on the server, see https://trpc.io/docs/server/server-side-calls
`.trim();function bs(t){const e=async function(n){if(!n||!("rawInput"in n))throw new Error(vs);const s=async(i={index:0,ctx:n.ctx})=>{try{const o=t.middlewares[i.index];return await o({ctx:i.ctx,type:n.type,path:n.path,rawInput:i.rawInput??n.rawInput,meta:t.meta,input:i.input,next(u){const d=u;return s({index:i.index+1,ctx:d&&"ctx"in d?{...i.ctx,...d.ctx}:i.ctx,input:d&&"input"in d?d.input:i.input,rawInput:d&&"rawInput"in d?d.rawInput:i.rawInput})}})}catch(o){return{ok:!1,error:cs(o),marker:$r}}},a=await s();if(!a)throw new ye({code:"INTERNAL_SERVER_ERROR",message:"No result from middlewares - did you forget to `return next()`?"});if(!a.ok)throw a.error;return a.data};return e._def=t,e.meta=t.meta,e}function ws(...t){const e=Lr({},...t.map(a=>a._def.record)),r=t.reduce((a,i)=>{if(i._def._config.errorFormatter&&i._def._config.errorFormatter!==Pe){if(a!==Pe&&a!==i._def._config.errorFormatter)throw new Error("You seem to have several error formatters");return i._def._config.errorFormatter}return a},Pe),n=t.reduce((a,i)=>{if(i._def._config.transformer&&i._def._config.transformer!==Oe){if(a!==Oe&&a!==i._def._config.transformer)throw new Error("You seem to have several transformers");return i._def._config.transformer}return a},Oe);return Ir({errorFormatter:r,transformer:n,isDev:t.some(a=>a._def._config.isDev),allowOutsideOfServer:t.some(a=>a._def._config.allowOutsideOfServer),isServer:t.some(a=>a._def._config.isServer),$types:t[0]?._def._config.$types})(e)}class Ge{context(){return new Ge}meta(){return new Ge}create(e){return Ts()(e)}}const xs=new Ge;function Ts(){return function(e){const r=e?.errorFormatter??Pe,s={transformer:us(e?.transformer??Oe),isDev:e?.isDev??globalThis.process?.env?.NODE_ENV!=="production",allowOutsideOfServer:e?.allowOutsideOfServer??!1,errorFormatter:r,isServer:e?.isServer??ar,$types:Zt(a=>{throw new Error(`Tried to access "$types.${a}" which is not available at runtime`)})};if(!(e?.isServer??ar)&&e?.allowOutsideOfServer!==!0)throw new Error("You're trying to use @trpc/server in a non-server environment. This is not supported by default.");return{_config:s,procedure:Mr({meta:e?.defaultMeta}),middleware:ys(),router:Ir(s),mergeRouters:ws,createCallerFactory:jr()}}}var kt={},st={},be={},P={};const we=C.getAugmentedNamespace(qn);var Wt={},Dr=we;function Zr(t){return Dr.observable(e=>{function r(s=0,a=t.op){const i=t.links[s];if(!i)throw new Error("No more links to execute - did you forget to add an ending link?");return i({op:a,next(c){return r(s+1,c)}})}return r().subscribe(e)})}function cr(t){return Array.isArray(t)?t:[t]}function ks(t){return e=>{const r=cr(t.true).map(s=>s(e)),n=cr(t.false).map(s=>s(e));return s=>Dr.observable(a=>{const i=t.condition(s.op)?r:n;return Zr({op:s.op,links:i}).subscribe(a)})}}Wt.createChain=Zr;Wt.splitLink=ks;var xe={};const Ur=C.getAugmentedNamespace(Yn);var Te={};function Et(t){return!!t&&!Array.isArray(t)&&typeof t=="object"}function Es(t,e){if("error"in t){const n=e.transformer.deserialize(t.error);return{ok:!1,error:{...t,error:n}}}return{ok:!0,result:{...t.result,...(!t.result.type||t.result.type==="data")&&{type:"data",data:e.transformer.deserialize(t.result.data)}}}}class mt extends Error{constructor(){super("Unable to transform response from server")}}function Cs(t,e){let r;try{r=Es(t,e)}catch{throw new mt}if(!r.ok&&(!Et(r.error.error)||typeof r.error.error.code!="number"))throw new mt;if(r.ok&&!Et(r.result))throw new mt;return r}Te.isObject=Et;Te.transformResult=Cs;var Rs=Ur,ur=Te;function Ss(t){return t instanceof Wr||t instanceof Error&&t.name==="TRPCClientError"}function Os(t){return ur.isObject(t)&&ur.isObject(t.error)&&typeof t.error.code=="number"&&typeof t.error.message=="string"}let Wr=class Ce extends Error{static from(e,r={}){const n=e;return Ss(n)?(r.meta&&(n.meta={...n.meta,...r.meta}),n):Os(n)?new Ce(n.error.message,{...r,result:n}):n instanceof Error?new Ce(n.message,{...r,cause:Rs.getCauseFromUnknown(n)}):new Ce("Unknown error",{...r,cause:n})}constructor(e,r){const n=r?.cause;super(e,{cause:n}),this.meta=r?.meta,this.cause=n,this.shape=r?.result?.error,this.data=r?.result?.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,Ce.prototype)}};xe.TRPCClientError=Wr;var H={},Ps=xe;const lr=t=>typeof t=="function";function qr(t){if(t)return t;if(typeof window<"u"&&lr(window.fetch))return window.fetch;if(typeof globalThis<"u"&&lr(globalThis.fetch))return globalThis.fetch;throw new Error("No fetch implementation found")}function As(t){return t||(typeof window<"u"&&window.AbortController?window.AbortController:typeof globalThis<"u"&&globalThis.AbortController?globalThis.AbortController:null)}function Ns(t){return{url:t.url.toString().replace(/\/$/,""),fetch:t.fetch,AbortController:As(t.AbortController)}}function Is(t){const e={};for(let r=0;r<t.length;r++){const n=t[r];e[r]=n}return e}const js={query:"GET",mutation:"POST"};function zr(t){return"input"in t?t.runtime.transformer.serialize(t.input):Is(t.inputs.map(e=>t.runtime.transformer.serialize(e)))}const Br=t=>{let e=t.url+"/"+t.path;const r=[];if("inputs"in t&&r.push("batch=1"),t.type==="query"){const n=zr(t);n!==void 0&&r.push(`input=${encodeURIComponent(JSON.stringify(n))}`)}return r.length&&(e+="?"+r.join("&")),e},Vr=t=>{if(t.type==="query")return;const e=zr(t);return e!==void 0?JSON.stringify(e):void 0},Ls=t=>Hr({...t,contentTypeHeader:"application/json",getUrl:Br,getBody:Vr});async function Fr(t,e){const r=t.getUrl(t),n=t.getBody(t),{type:s}=t,a=await t.headers();/* istanbul ignore if -- @preserve */if(s==="subscription")throw new Error("Subscriptions should use wsLink");const i={...t.contentTypeHeader?{"content-type":t.contentTypeHeader}:{},...t.batchModeHeader?{"trpc-batch-mode":t.batchModeHeader}:{},...a};return qr(t.fetch)(r,{method:js[s],signal:e?.signal,body:n,headers:i})}function Hr(t){const e=t.AbortController?new t.AbortController:null,r={};let n=!1;return{promise:new Promise((i,o)=>{Fr(t,e).then(c=>(r.response=c,n=!0,c.json())).then(c=>{r.responseJSON=c,i({json:c,meta:r})}).catch(c=>{n=!0,o(Ps.TRPCClientError.from(c,{meta:r}))})}),cancel:()=>{n||e?.abort()}}}H.fetchHTTPResponse=Fr;H.getBody=Vr;H.getFetch=qr;H.getUrl=Br;H.httpRequest=Hr;H.jsonHttpRequester=Ls;H.resolveHTTPLinkOptions=Ns;var qt={},$s=we,Ms=Te,dr=xe,Ct=H;const yt=()=>{throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new")};function gt(t){let e=null,r=null;const n=()=>{clearTimeout(r),r=null,e=null};function s(o){const c=[[]];let u=0;for(;;){const d=o[u];if(!d)break;const h=c[c.length-1];if(d.aborted){d.reject?.(new Error("Aborted")),u++;continue}if(t.validate(h.concat(d).map(T=>T.key))){h.push(d),u++;continue}if(h.length===0){d.reject?.(new Error("Input is too big for a single dispatch")),u++;continue}c.push([])}return c}function a(){const o=s(e);n();for(const c of o){if(!c.length)continue;const u={items:c,cancel:yt};for(const T of c)T.batch=u;const d=(T,k)=>{const N=u.items[T];N.resolve?.(k),N.batch=null,N.reject=null,N.resolve=null},{promise:h,cancel:y}=t.fetch(u.items.map(T=>T.key),d);u.cancel=y,h.then(T=>{for(let k=0;k<T.length;k++){const N=T[k];d(k,N)}for(const k of u.items)k.reject?.(new Error("Missing result")),k.batch=null}).catch(T=>{for(const k of u.items)k.reject?.(T),k.batch=null})}}function i(o){const c={aborted:!1,key:o,batch:null,resolve:yt,reject:yt},u=new Promise((h,y)=>{c.reject=y,c.resolve=h,e||(e=[]),e.push(c)});return r||(r=setTimeout(a)),{promise:u,cancel:()=>{c.aborted=!0,c.batch?.items.every(h=>h.aborted)&&(c.batch.cancel(),c.batch=null)}}}return{load:i}}function Gr(t){return function(r){const n=Ct.resolveHTTPLinkOptions(r),s=r.maxURLLength??1/0;return a=>{const i=h=>{const y=k=>{if(s===1/0)return!0;const N=k.map(G=>G.path).join(","),le=k.map(G=>G.input);return Ct.getUrl({...n,runtime:a,type:h,path:N,inputs:le}).length<=s},T=t({...n,runtime:a,type:h,opts:r});return{validate:y,fetch:T}},o=gt(i("query")),c=gt(i("mutation")),u=gt(i("subscription")),d={query:o,subscription:u,mutation:c};return({op:h})=>$s.observable(y=>{const T=d[h.type],{promise:k,cancel:N}=T.load(h);let le;return k.then(M=>{le=M;const G=Ms.transformResult(M.json,a);if(!G.ok){y.error(dr.TRPCClientError.from(G.error,{meta:M.meta}));return}y.next({context:M.meta,result:G.result}),y.complete()}).catch(M=>{y.error(dr.TRPCClientError.from(M,{meta:le?.meta}))}),()=>{N()}})}}}const Ds=t=>e=>{const r=e.map(i=>i.path).join(","),n=e.map(i=>i.input),{promise:s,cancel:a}=Ct.jsonHttpRequester({...t,path:r,inputs:n,headers(){return t.opts.headers?typeof t.opts.headers=="function"?t.opts.headers({opList:e}):t.opts.headers:{}}});return{promise:s.then(i=>(Array.isArray(i.json)?i.json:e.map(()=>i.json)).map(u=>({meta:i.meta,json:u}))),cancel:a}},Zs=Gr(Ds);qt.createHTTPBatchLink=Gr;qt.httpBatchLink=Zs;var at={};Object.defineProperty(at,"__esModule",{value:!0});var Us=we,Ws=Te,fr=xe,Jr=H;function Yr(t){return e=>{const r=Jr.resolveHTTPLinkOptions(e);return n=>({op:s})=>Us.observable(a=>{const{path:i,input:o,type:c}=s,{promise:u,cancel:d}=t.requester({...r,runtime:n,type:c,path:i,input:o,headers(){return e.headers?typeof e.headers=="function"?e.headers({op:s}):e.headers:{}}});let h;return u.then(y=>{h=y.meta;const T=Ws.transformResult(y.json,n);if(!T.ok){a.error(fr.TRPCClientError.from(T.error,{meta:h}));return}a.next({context:y.meta,result:T.result}),a.complete()}).catch(y=>{a.error(fr.TRPCClientError.from(y,{meta:h}))}),()=>{d()}})}}const qs=Yr({requester:Jr.jsonHttpRequester});at.httpLink=qs;at.httpLinkFactory=Yr;var zt={};Object.defineProperty(zt,"__esModule",{value:!0});var pr=we;function zs(t){return typeof FormData>"u"?!1:t instanceof FormData}const _t={css:{query:["72e3ff","3fb0d8"],mutation:["c5a3fc","904dfc"],subscription:["ff49e1","d83fbe"]},ansi:{regular:{query:["\x1B[30;46m","\x1B[97;46m"],mutation:["\x1B[30;45m","\x1B[97;45m"],subscription:["\x1B[30;42m","\x1B[97;42m"]},bold:{query:["\x1B[1;30;46m","\x1B[1;97;46m"],mutation:["\x1B[1;30;45m","\x1B[1;97;45m"],subscription:["\x1B[1;30;42m","\x1B[1;97;42m"]}}};function Bs(t){const{direction:e,type:r,path:n,id:s,input:a}=t,i=[],o=[];if(t.colorMode==="ansi"){const[h,y]=_t.ansi.regular[r],[T,k]=_t.ansi.bold[r],N="\x1B[0m";return i.push(e==="up"?h:y,e==="up"?">>":"<<",r,e==="up"?T:k,`#${s}`,n,N),e==="up"?o.push({input:t.input}):o.push({input:t.input,result:"result"in t.result?t.result.result:t.result,elapsedMs:t.elapsedMs}),{parts:i,args:o}}const[c,u]=_t.css[r],d=`
background-color: #${e==="up"?c:u};
color: ${e==="up"?"black":"white"};
padding: 2px;
`;return i.push("%c",e==="up"?">>":"<<",r,`#${s}`,`%c${n}%c`,"%O"),o.push(d,`${d}; font-weight: bold;`,`${d}; font-weight: normal;`),e==="up"?o.push({input:a,context:t.context}):o.push({input:a,result:t.result,elapsedMs:t.elapsedMs,context:t.context}),{parts:i,args:o}}const Vs=({c:t=console,colorMode:e="css"})=>r=>{const n=r.input,s=zs(n)?Object.fromEntries(n):n,{parts:a,args:i}=Bs({...r,colorMode:e,input:s}),o=r.direction==="down"&&r.result&&(r.result instanceof Error||"error"in r.result.result)?"error":"log";t[o].apply(null,[a.join(" ")].concat(i))};function Fs(t={}){const{enabled:e=()=>!0}=t,r=t.colorMode??(typeof window>"u"?"ansi":"css"),{logger:n=Vs({c:t.console,colorMode:r})}=t;return()=>({op:s,next:a})=>pr.observable(i=>{e({...s,direction:"up"})&&n({...s,direction:"up"});const o=Date.now();function c(u){const d=Date.now()-o;e({...s,direction:"down",result:u})&&n({...s,direction:"down",elapsedMs:d,result:u})}return a(s).pipe(pr.tap({next(u){c(u)},error(u){c(u)}})).subscribe(i)})}zt.loggerLink=Fs;var it={};Object.defineProperty(it,"__esModule",{value:!0});var Hs=we,Gs=Te,Xr=xe;/* istanbul ignore next -- @preserve */const Js=t=>t===0?0:Math.min(1e3*2**t,3e4);function Ys(t){const{url:e,WebSocket:r=WebSocket,retryDelayMs:n=Js,onOpen:s,onClose:a}=t;/* istanbul ignore next -- @preserve */if(!r)throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");let i=[];const o=Object.create(null);let c=0,u=null,d=null,h=Qt(),y="connecting";function T(){y!=="open"||u||(u=setTimeout(()=>{u=null,i.length===1?h.send(JSON.stringify(i.pop())):h.send(JSON.stringify(i)),i=[]}))}function k(){if(d!==null||y==="closed")return;const S=n(c++);le(S)}function N(){y="connecting";const S=h;h=Qt(),M(S)}function le(S){d||(y="connecting",d=setTimeout(N,S))}function M(S){Object.values(o).some(de=>de.ws===S)||S.close()}function G(){Object.values(o).forEach(S=>{S.type==="subscription"&&S.callbacks.complete()})}function Xt(S){i.some(A=>A.id===S.op.id)||Kt(S.op,S.callbacks)}function Qt(){const S=typeof e=="function"?e():e,A=new r(S);clearTimeout(d),d=null,A.addEventListener("open",()=>{/* istanbul ignore next -- @preserve */A===h&&(c=0,y="open",s?.(),T())}),A.addEventListener("error",()=>{A===h&&k()});const de=L=>{if(L.method==="reconnect"&&A===h){y==="open"&&a?.(),N();for(const E of Object.values(o))E.type==="subscription"&&Xt(E)}},ft=L=>{const E=L.id!==null&&o[L.id];if(E){if(E.callbacks.next?.(L),E.ws!==h&&A===h){const J=E.ws;E.ws=h,M(J)}"result"in L&&L.result.type==="stopped"&&A===h&&E.callbacks.complete()}};return A.addEventListener("message",({data:L})=>{const E=JSON.parse(L);"method"in E?de(E):ft(E),(A!==h||y==="closed")&&M(A)}),A.addEventListener("close",({code:L})=>{y==="open"&&a?.({code:L}),h===A&&k();for(const[E,J]of Object.entries(o))if(J.ws===A){if(y==="closed"){delete o[E],J.callbacks.complete?.();continue}J.type==="subscription"?Xt(J):(delete o[E],J.callbacks.error?.(Xr.TRPCClientError.from(new Bt("WebSocket closed prematurely"))))}}),A}function Kt(S,A){const{type:de,input:ft,path:L,id:E}=S,J={id:E,method:de,params:{input:ft,path:L}};return o[E]={ws:h,type:de,callbacks:A,op:S},i.push(J),T(),()=>{const Tn=o[E]?.callbacks;delete o[E],i=i.filter(kn=>kn.id!==E),Tn?.complete?.(),h.readyState===r.OPEN&&S.type==="subscription"&&(i.push({id:E,method:"subscription.stop"}),T())}}return{close:()=>{y="closed",a?.(),G(),M(h),clearTimeout(d),d=null},request:Kt,getConnection(){return h}}}class Bt extends Error{constructor(e){super(e),this.name="TRPCWebSocketClosedError",Object.setPrototypeOf(this,Bt.prototype)}}function Xs(t){return e=>{const{client:r}=t;return({op:n})=>Hs.observable(s=>{const{type:a,path:i,id:o,context:c}=n,u=e.transformer.serialize(n.input),d=r.request({type:a,path:i,input:u,id:o,context:c},{error(h){s.error(h),d()},complete(){s.complete()},next(h){const y=Gs.transformResult(h,e);if(!y.ok){s.error(Xr.TRPCClientError.from(y.error));return}s.next({result:y.result}),n.type!=="subscription"&&(d(),s.complete())}});return()=>{d()}})}}it.createWSClient=Ys;it.wsLink=Xs;Object.defineProperty(P,"__esModule",{value:!0});var hr=we,Qr=Wt,Kr=xe,mr=Ur,Ae=H,en=qt,Vt=at,Qs=zt,tn=it;class ot{$request({type:e,input:r,path:n,context:s={}}){return Qr.createChain({links:this.links,op:{id:++this.requestId,type:e,path:n,input:r,context:s}}).pipe(hr.share())}requestAsPromise(e){const r=this.$request(e),{promise:n,abort:s}=hr.observableToPromise(r);return new Promise((i,o)=>{e.signal?.addEventListener("abort",s),n.then(c=>{i(c.result.data)}).catch(c=>{o(Kr.TRPCClientError.from(c))})})}query(e,r,n){return this.requestAsPromise({type:"query",path:e,input:r,context:n?.context,signal:n?.signal})}mutation(e,r,n){return this.requestAsPromise({type:"mutation",path:e,input:r,context:n?.context,signal:n?.signal})}subscription(e,r,n){return this.$request({type:"subscription",path:e,input:r,context:n?.context}).subscribe({next(a){a.result.type==="started"?n.onStarted?.():a.result.type==="stopped"?n.onStopped?.():n.onData?.(a.result.data)},error(a){n.onError?.(a)},complete(){n.onComplete?.()}})}constructor(e){this.requestId=0;const r=(()=>{const n=e.transformer;return n?"input"in n?e.transformer:{input:n,output:n}:{input:{serialize:s=>s,deserialize:s=>s},output:{serialize:s=>s,deserialize:s=>s}}})();this.runtime={transformer:{serialize:n=>r.input.serialize(n),deserialize:n=>r.output.deserialize(n)},combinedTransformer:r},this.links=e.links.map(n=>n(this.runtime))}}function Ks(t){return new ot(t)}function ea(t){return new ot(t)}const ta={query:"query",mutate:"mutation",subscribe:"subscription"},rn=t=>ta[t];function nn(t){return mr.createFlatProxy(e=>t.hasOwnProperty(e)?t[e]:e==="__untypedClient"?t:mr.createRecursiveProxy(({path:r,args:n})=>{const s=[e,...r],a=rn(s.pop()),i=s.join(".");return t[a](i,...n)}))}function ra(t){const e=new ot(t);return nn(e)}function na(t){return t.__untypedClient}function sa(t){if(t)return t;if(typeof window<"u"&&window.TextDecoder)return new window.TextDecoder;if(typeof globalThis<"u"&&globalThis.TextDecoder)return new globalThis.TextDecoder;throw new Error("No TextDecoder implementation found")}async function aa(t){const e=t.parse??JSON.parse,r=n=>{if(t.signal?.aborted||!n||n==="}")return;const s=n.indexOf(":"),a=n.substring(2,s-1),i=n.substring(s+1);t.onSingle(Number(a),e(i))};await ia(t.readableStream,r,t.textDecoder)}async function ia(t,e,r){let n="";const s=a=>{const o=r.decode(a).split(`
`);if(o.length===1)n+=o[0];else if(o.length>1){e(n+o[0]);for(let c=1;c<o.length-1;c++)e(o[c]);n=o[o.length-1]}};"getReader"in t?await ca(t,s):await oa(t,s),e(n)}function oa(t,e){return new Promise(r=>{t.on("data",e),t.on("end",r)})}async function ca(t,e){const r=t.getReader();let n=await r.read();for(;!n.done;)e(n.value),n=await r.read()}const ua=(t,e)=>{const r=t.AbortController?new t.AbortController:null,n=Ae.fetchHTTPResponse({...t,contentTypeHeader:"application/json",batchModeHeader:"stream",getUrl:Ae.getUrl,getBody:Ae.getBody},r),s=()=>r?.abort(),a=n.then(async i=>{if(!i.body)throw new Error("Received response without body");const o={response:i};return aa({readableStream:i.body,onSingle:e,parse:c=>({json:JSON.parse(c),meta:o}),signal:r?.signal,textDecoder:t.textDecoder})});return{cancel:s,promise:a}},la=t=>{const e=sa(t.opts.textDecoder);return(r,n)=>{const s=r.map(c=>c.path).join(","),a=r.map(c=>c.input),{cancel:i,promise:o}=ua({...t,textDecoder:e,path:s,inputs:a,headers(){return t.opts.headers?typeof t.opts.headers=="function"?t.opts.headers({opList:r}):t.opts.headers:{}}},(c,u)=>{n(c,u)});return{promise:o.then(()=>[]),cancel:i}}},da=en.createHTTPBatchLink(la),fa=t=>{if("input"in t){if(!(t.input instanceof FormData))throw new Error("Input is not FormData");return t.input}},pa=t=>{if(t.type!=="mutation")throw new Error("We only handle mutations with formdata");return Ae.httpRequest({...t,getUrl(){return`${t.url}/${t.path}`},getBody:fa})},ha=Vt.httpLinkFactory({requester:pa});P.splitLink=Qr.splitLink;P.TRPCClientError=Kr.TRPCClientError;P.getFetch=Ae.getFetch;P.httpBatchLink=en.httpBatchLink;P.httpLink=Vt.httpLink;P.httpLinkFactory=Vt.httpLinkFactory;P.loggerLink=Qs.loggerLink;P.createWSClient=tn.createWSClient;P.wsLink=tn.wsLink;P.TRPCUntypedClient=ot;P.clientCallTypeToProcedureType=rn;P.createTRPCClient=ea;P.createTRPCClientProxy=nn;P.createTRPCProxyClient=ra;P.createTRPCUntypedClient=Ks;P.experimental_formDataLink=ha;P.getUntypedClient=na;P.unstable_httpBatchStreamLink=da;var se={},Ft={};function ma(t){return t}function ya(t){return t.length===0?ma:t.length===1?t[0]:function(r){return t.reduce((n,s)=>s(n),r)}}function ga(t){return typeof t=="object"&&t!==null&&"subscribe"in t}function _a(t){const e={subscribe(r){let n=null,s=!1,a=!1,i=!1;function o(){if(n===null){i=!0;return}a||(a=!0,typeof n=="function"?n():n&&n.unsubscribe())}return n=t({next(c){s||r.next?.(c)},error(c){s||(s=!0,r.error?.(c),o())},complete(){s||(s=!0,r.complete?.(),o())}}),i&&o(),{unsubscribe:o}},pipe(...r){return ya(r)(e)}};return e}Ft.isObservable=ga;Ft.observable=_a;Object.defineProperty(se,"__esModule",{value:!0});var sn=Ft;function va(t){return e=>{let r=0,n=null;const s=[];function a(){n||(n=e.subscribe({next(o){for(const c of s)c.next?.(o)},error(o){for(const c of s)c.error?.(o)},complete(){for(const o of s)o.complete?.()}}))}function i(){if(r===0&&n){const o=n;n=null,o.unsubscribe()}}return{subscribe(o){return r++,s.push(o),a(),{unsubscribe(){r--,i();const c=s.findIndex(u=>u===o);c>-1&&s.splice(c,1)}}}}}}function ba(t){return e=>({subscribe(r){let n=0;return e.subscribe({next(a){r.next?.(t(a,n++))},error(a){r.error?.(a)},complete(){r.complete?.()}})}})}function wa(t){return e=>({subscribe(r){return e.subscribe({next(n){t.next?.(n),r.next?.(n)},error(n){t.error?.(n),r.error?.(n)},complete(){t.complete?.(),r.complete?.()}})}})}class Ht extends Error{constructor(e){super(e),this.name="ObservableAbortError",Object.setPrototypeOf(this,Ht.prototype)}}function xa(t){let e;return{promise:new Promise((n,s)=>{let a=!1;function i(){a||(a=!0,s(new Ht("This operation was aborted.")),o.unsubscribe())}const o=t.subscribe({next(c){a=!0,n(c),i()},error(c){a=!0,s(c),i()},complete(){a=!0,i()}});e=i}),abort:e}}se.isObservable=sn.isObservable;se.observable=sn.observable;se.map=ba;se.observableToPromise=xa;se.share=va;se.tap=wa;var z={};Object.defineProperty(z,"__esModule",{value:!0});z.isTRPCRequestWithId=z.isTRPCRequest=z.isTRPCResponse=z.isTRPCMessage=void 0;function yr(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Ta(t){return t==null}function an(t){return!!(yr(t)&&"trpc"in t&&yr(t.trpc))}z.isTRPCMessage=an;function Gt(t){return an(t)&&"id"in t.trpc&&!Ta(t.trpc.id)}function ka(t){return Gt(t)&&("error"in t.trpc||"result"in t.trpc)}z.isTRPCResponse=ka;function on(t){return Gt(t)&&"method"in t.trpc}z.isTRPCRequest=on;function Ea(t){return on(t)&&Gt(t)}z.isTRPCRequestWithId=Ea;Object.defineProperty(be,"__esModule",{value:!0});be.createBaseLink=void 0;const vt=P,Ca=se,Ra=z,Sa=t=>e=>({op:r})=>(0,Ca.observable)(n=>{const s=[],{id:a,type:i,path:o}=r;try{const c=e.transformer.serialize(r.input),u=()=>{n.error(new vt.TRPCClientError("Port disconnected prematurely"))};t.addCloseListener(u),s.push(()=>t.removeCloseListener(u));const d=h=>{if(!(0,Ra.isTRPCResponse)(h))return;const{trpc:y}=h;if(a===y.id){if("error"in y)return n.error(vt.TRPCClientError.from(y));n.next({result:Object.assign(Object.assign({},y.result),(!y.result.type||y.result.type==="data")&&{type:"data",data:e.transformer.deserialize(y.result.data)})}),(i!=="subscription"||y.result.type==="stopped")&&n.complete()}};t.addMessageListener(d),s.push(()=>t.removeMessageListener(d)),t.postMessage({trpc:{id:a,jsonrpc:void 0,method:i,params:{path:o,input:c}}})}catch(c){n.error(new vt.TRPCClientError(c instanceof Error?c.message:"Unknown error"))}return()=>{i==="subscription"&&t.postMessage({trpc:{id:a,jsonrpc:void 0,method:"subscription.stop"}}),s.forEach(c=>c())}});be.createBaseLink=Sa;Object.defineProperty(st,"__esModule",{value:!0});st.chromeLink=void 0;const Oa=be,Pa=t=>(0,Oa.createBaseLink)({postMessage(e){t.port.postMessage(e)},addMessageListener(e){t.port.onMessage.addListener(e)},removeMessageListener(e){t.port.onMessage.removeListener(e)},addCloseListener(e){t.port.onDisconnect.addListener(e)},removeCloseListener(e){t.port.onDisconnect.removeListener(e)}});st.chromeLink=Pa;var ct={};Object.defineProperty(ct,"__esModule",{value:!0});ct.windowLink=void 0;const Aa=be,Na=t=>{var e;const r=new Map,n=t.window,s=(e=t.postWindow)!==null&&e!==void 0?e:n;return(0,Aa.createBaseLink)({postMessage(a){s.postMessage(a,{targetOrigin:t.postOrigin})},addMessageListener(a){const i=o=>{a(o.data)};r.set(a,i),n.addEventListener("message",i)},removeMessageListener(a){const i=r.get(a);i&&n.removeEventListener("message",i)},addCloseListener(a){n.addEventListener("beforeunload",a)},removeCloseListener(a){n.removeEventListener("beforeunload",a)}})};ct.windowLink=Na;var ut={},lt={};Object.defineProperty(lt,"__esModule",{value:!0});lt.TRPC_BROWSER_LOADED_EVENT=void 0;lt.TRPC_BROWSER_LOADED_EVENT="TRPC_BROWSER::POPUP_LOADED";Object.defineProperty(ut,"__esModule",{value:!0});ut.popupLink=void 0;const Ia=lt,ja=be,La=t=>{const e=new Map,r=new Set;let n=null;async function s(a){if(!n||n.closed){n=t.createPopup(),await Promise.race([new Promise(i=>{var o;try{(o=n?.addEventListener)===null||o===void 0||o.call(n,"load",i)}catch{}}),new Promise(i=>{a.addEventListener("message",o=>{o.data===Ia.TRPC_BROWSER_LOADED_EVENT&&i()})}),new Promise(i=>{console.warn("Could not detect if popup loading succeeded after 15s timeout, continuing anyway"),setTimeout(i,15e3)})]);try{if(!n.addEventListener)throw new Error("popupWindow.addEventListener is not a function");n.addEventListener("beforeunload",()=>{n=null})}catch{const o=setInterval(()=>{n&&n.closed&&(n=null,r.forEach(c=>{c()}),clearInterval(o))},1e3)}}return n}return(0,ja.createBaseLink)({async postMessage(a){return(await s(t.listenWindow)).postMessage(a,{targetOrigin:t.postOrigin})},addMessageListener(a){const i=o=>{a(o.data)};e.set(a,i),t.listenWindow.addEventListener("message",i)},removeMessageListener(a){const i=e.get(a);i&&t.listenWindow.removeEventListener("message",i)},addCloseListener(a){t.listenWindow.addEventListener("beforeunload",a),r.add(a)},removeCloseListener(a){t.listenWindow.removeEventListener("beforeunload",a),r.delete(a)}})};ut.popupLink=La;(function(t){var e=C.commonjsGlobal&&C.commonjsGlobal.__createBinding||(Object.create?function(n,s,a,i){i===void 0&&(i=a);var o=Object.getOwnPropertyDescriptor(s,a);(!o||("get"in o?!s.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return s[a]}}),Object.defineProperty(n,i,o)}:function(n,s,a,i){i===void 0&&(i=a),n[i]=s[a]}),r=C.commonjsGlobal&&C.commonjsGlobal.__exportStar||function(n,s){for(var a in n)a!=="default"&&!Object.prototype.hasOwnProperty.call(s,a)&&e(s,n,a)};Object.defineProperty(t,"__esModule",{value:!0}),r(st,t),r(ct,t),r(ut,t)})(kt);var x;(function(t){t.assertEqual=s=>s;function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},t.getValidEnumValues=s=>{const a=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return t.objectValues(i)},t.objectValues=s=>t.objectKeys(s).map(function(a){return s[a]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},t.find=(s,a)=>{for(const i of s)if(a(i))return i},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var Rt;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Rt||(Rt={}));const m=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),X=t=>{switch(typeof t){case"undefined":return m.undefined;case"string":return m.string;case"number":return isNaN(t)?m.nan:m.number;case"boolean":return m.boolean;case"function":return m.function;case"bigint":return m.bigint;case"symbol":return m.symbol;case"object":return Array.isArray(t)?m.array:t===null?m.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?m.promise:typeof Map<"u"&&t instanceof Map?m.map:typeof Set<"u"&&t instanceof Set?m.set:typeof Date<"u"&&t instanceof Date?m.date:m.object;default:return m.unknown}},f=x.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),$a=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class $ extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){const r=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let o=n,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(r(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(this),n}static assert(e){if(!(e instanceof $))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},n=[];for(const s of this.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}$.create=t=>new $(t);const ge=(t,e)=>{let r;switch(t.code){case f.invalid_type:t.received===m.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case f.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,x.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:r=`Unrecognized key(s) in object: ${x.joinValues(t.keys,", ")}`;break;case f.invalid_union:r="Invalid input";break;case f.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${x.joinValues(t.options)}`;break;case f.invalid_enum_value:r=`Invalid enum value. Expected ${x.joinValues(t.options)}, received '${t.received}'`;break;case f.invalid_arguments:r="Invalid function arguments";break;case f.invalid_return_type:r="Invalid function return type";break;case f.invalid_date:r="Invalid date";break;case f.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:x.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case f.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case f.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case f.custom:r="Invalid input";break;case f.invalid_intersection_types:r="Intersection results could not be merged";break;case f.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case f.not_finite:r="Number must be finite";break;default:r=e.defaultError,x.assertNever(t)}return{message:r}};let cn=ge;function Ma(t){cn=t}function Je(){return cn}const Ye=t=>{const{data:e,path:r,errorMaps:n,issueData:s}=t,a=[...r,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},Da=[];function p(t,e){const r=Je(),n=Ye({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===ge?void 0:ge].filter(s=>!!s)});t.common.issues.push(n)}class I{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const s of r){if(s.status==="aborted")return v;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const s of r){const a=await s.key,i=await s.value;n.push({key:a,value:i})}return I.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const s of r){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return v;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const v=Object.freeze({status:"aborted"}),he=t=>({status:"dirty",value:t}),j=t=>({status:"valid",value:t}),St=t=>t.status==="aborted",Ot=t=>t.status==="dirty",oe=t=>t.status==="valid",Ne=t=>typeof Promise<"u"&&t instanceof Promise;function Xe(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)}function un(t,e,r,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(t,r):s?s.value=r:e.set(t,r),r}var g;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(g||(g={}));var Re,Se;class V{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,.