@shumai-one/shumai 0.4.0 → 0.4.2
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/bin/{chunk-2xgvs3as.js → chunk-07h4b77v.js} +2 -2
- package/bin/{chunk-gazp5662.js → chunk-0t4n4d5w.js} +2 -2
- package/bin/{chunk-x9akgj7w.js → chunk-1611z9jg.js} +2 -2
- package/bin/{chunk-kvnfgr29.js → chunk-1phqxp6z.js} +1 -1
- package/bin/chunk-23hckrrz.js +2 -0
- package/bin/{chunk-ymr5ybxk.js → chunk-30z44j1g.js} +2 -2
- package/bin/{chunk-fcsfssar.js → chunk-3j463k1g.js} +1 -1
- package/bin/{chunk-zye42cfp.js → chunk-4181tdds.js} +1 -1
- package/bin/chunk-480jtqng.js +4 -0
- package/bin/{chunk-m8z8jvdq.js → chunk-4c3g146q.js} +2 -2
- package/bin/chunk-4ca0zt5e.js +1 -0
- package/bin/chunk-4d9bgmf2.js +2 -0
- package/bin/{chunk-fvbd5dk7.js → chunk-4ev56fss.js} +5 -5
- package/bin/{chunk-zmyawgth.js → chunk-4gk52tjq.js} +1 -1
- package/bin/chunk-4mdqkj4d.js +1 -0
- package/bin/{chunk-mhps85dd.js → chunk-4r91fggc.js} +1 -1
- package/bin/chunk-50fb1x3w.js +1 -0
- package/bin/chunk-59gj1njz.js +1 -0
- package/bin/{chunk-j04sztp3.js → chunk-5pr0t7fb.js} +1 -1
- package/bin/chunk-5vewxmz7.js +3 -0
- package/bin/chunk-62zx96pe.js +2 -0
- package/bin/chunk-63y0eb07.js +2 -0
- package/bin/chunk-6d5xrgfx.js +2 -0
- package/bin/{chunk-etprs58p.js → chunk-6gbtz5bf.js} +2 -2
- package/bin/{chunk-wrgwjg2g.js → chunk-6gjg5egq.js} +1 -1
- package/bin/{chunk-4q782s34.js → chunk-6m4jz9s1.js} +3 -3
- package/bin/{chunk-wehhpcm1.js → chunk-6s4x525w.js} +1 -1
- package/bin/{chunk-xzag8w1v.js → chunk-6w2wmvqs.js} +1 -1
- package/bin/{chunk-r2shjtte.js → chunk-77d23vcn.js} +2 -2
- package/bin/{chunk-vhcqazqf.js → chunk-77m5p188.js} +2 -2
- package/bin/chunk-7bvx087f.js +1 -0
- package/bin/chunk-7pfjfrjg.js +5 -0
- package/bin/{chunk-1qr0ajc8.js → chunk-7q10s127.js} +1 -1
- package/bin/{chunk-c3msq02x.js → chunk-7thx8ctx.js} +2 -2
- package/bin/{chunk-vvhs586e.js → chunk-8t4s91gh.js} +1 -1
- package/bin/{chunk-k3r97v7j.js → chunk-98ey5p2e.js} +1 -1
- package/bin/{chunk-44edgqvy.js → chunk-9amndcyh.js} +3 -3
- package/bin/chunk-9bk23g9x.js +1 -0
- package/bin/chunk-9mkcfy43.js +1 -0
- package/bin/{chunk-0h8rjeyj.js → chunk-9t3nsq5n.js} +2 -2
- package/bin/{chunk-j536e9nx.js → chunk-9tjq99ds.js} +2 -2
- package/bin/chunk-9wm9rwh1.js +2 -0
- package/bin/{chunk-nz2v1jmd.js → chunk-ab16fyg4.js} +2 -2
- package/bin/chunk-arv0g2av.js +1 -0
- package/bin/{chunk-hx2mvd20.js → chunk-aytj4zxg.js} +2 -2
- package/bin/{chunk-02afmyqy.js → chunk-b1ypjqgp.js} +2 -2
- package/bin/{chunk-93ecxcy4.js → chunk-bdjv0ykq.js} +1 -1
- package/bin/chunk-c1k86mfa.js +10 -0
- package/bin/{chunk-wy2f6mby.js → chunk-caa96dgd.js} +1 -1
- package/bin/chunk-ce4v2yjy.js +1 -0
- package/bin/{chunk-m2tbft2c.js → chunk-cqh60y54.js} +2 -2
- package/bin/chunk-cvq7zgw7.js +1 -0
- package/bin/{chunk-tcm57j8r.js → chunk-d9mjbtp2.js} +2 -2
- package/bin/{chunk-xkhwj8mw.js → chunk-dn7sbjws.js} +2 -2
- package/bin/{chunk-p49h5fxs.js → chunk-dxyq9h8n.js} +1 -1
- package/bin/{chunk-3twtxs5m.js → chunk-e3cabksx.js} +1 -1
- package/bin/{chunk-52dr035y.js → chunk-egcrbj94.js} +2 -2
- package/bin/chunk-ev17v1mv.js +2 -0
- package/bin/chunk-evtpwg71.js +2 -0
- package/bin/{chunk-2rbexbv0.js → chunk-f3e0nsv2.js} +1 -1
- package/bin/chunk-f40gjqpq.js +2 -0
- package/bin/chunk-fe7822ak.js +299 -0
- package/bin/{chunk-4b7jcpgv.js → chunk-g8tkhw9j.js} +2 -2
- package/bin/{chunk-mgnxa0vy.js → chunk-g9r0p4t8.js} +1 -1
- package/bin/chunk-gbjyh9ms.js +1 -0
- package/bin/{chunk-thbfw1ed.js → chunk-gtbsb39v.js} +1 -1
- package/bin/{chunk-zh752hw8.js → chunk-gytz1q13.js} +1 -1
- package/bin/chunk-h0fxysxs.js +7 -0
- package/bin/{chunk-aw5zkdma.js → chunk-h8bdvsqt.js} +2 -2
- package/bin/{chunk-76433x4d.js → chunk-hag024w8.js} +2 -2
- package/bin/chunk-hc6w5nw4.js +7 -0
- package/bin/chunk-j69dqc48.js +2 -0
- package/bin/{chunk-yfqz6f72.js → chunk-jbtw1zym.js} +1 -1
- package/bin/{chunk-9k76s3y6.js → chunk-jc1vb7rj.js} +2 -2
- package/bin/{chunk-41d9gkx7.js → chunk-jdv78w9r.js} +1 -1
- package/bin/{chunk-dag45evp.js → chunk-jjs70y9v.js} +1 -1
- package/bin/{chunk-ysvhtgve.js → chunk-jmdar2gz.js} +2 -2
- package/bin/chunk-jvwz10n4.js +2 -0
- package/bin/{chunk-ck6msfch.js → chunk-k47md1g4.js} +2 -2
- package/bin/{chunk-yyjx8nbq.js → chunk-k4v0brcb.js} +1 -1
- package/bin/chunk-k6n7c07e.js +1 -0
- package/bin/{chunk-kjjhvrk1.js → chunk-kk2cstsg.js} +1 -1
- package/bin/{chunk-3r33kewe.js → chunk-knz4h56q.js} +3 -3
- package/bin/{chunk-j5rx3x1q.js → chunk-kqqtt6bd.js} +1 -1
- package/bin/{chunk-ez6veng7.js → chunk-kvyp1t4j.js} +1 -1
- package/bin/{chunk-djx2r4nj.js → chunk-kxskpgsq.js} +2 -2
- package/bin/{chunk-3gjn4pyp.js → chunk-m6srbjcs.js} +2 -2
- package/bin/{chunk-8956rryj.js → chunk-mcc1scxs.js} +2 -2
- package/bin/{chunk-0bfqrx5q.js → chunk-mq83a0kk.js} +2 -2
- package/bin/chunk-mxm8g4q0.js +1 -0
- package/bin/{chunk-6m1k317a.js → chunk-nhpgdqq5.js} +2 -2
- package/bin/{chunk-pdjar480.js → chunk-nne496aa.js} +2 -2
- package/bin/{chunk-s73c0brj.js → chunk-nqpb0r9h.js} +1 -1
- package/bin/chunk-ns0zww9g.js +2 -0
- package/bin/{chunk-9cmvymm5.js → chunk-ps4xfp23.js} +1 -1
- package/bin/chunk-pz2ec6xt.js +2 -0
- package/bin/{chunk-vkgxrn1h.js → chunk-q163k309.js} +2 -2
- package/bin/chunk-q1da61ps.js +1 -0
- package/bin/{chunk-7x1vkftb.js → chunk-qrf0ady6.js} +2 -2
- package/bin/{chunk-d7en47eh.js → chunk-qy28f25e.js} +1 -1
- package/bin/{chunk-xjnghr99.js → chunk-r7s4ypw1.js} +1 -1
- package/bin/chunk-ran23vm9.js +1 -0
- package/bin/chunk-rfvdc4n0.js +2 -0
- package/bin/{chunk-8rcfhfq5.js → chunk-rgthkvgx.js} +1 -1
- package/bin/chunk-s39n3yw3.js +2 -0
- package/bin/{chunk-xv5h4dv1.js → chunk-s7wdd0g7.js} +1 -1
- package/bin/{chunk-n8gsjwht.js → chunk-s88ha5kx.js} +2 -2
- package/bin/chunk-sf91bt9m.js +2 -0
- package/bin/{chunk-2x46963w.js → chunk-sjwbjf9j.js} +1 -1
- package/bin/chunk-t62076pv.js +1 -0
- package/bin/{chunk-he1ywtxx.js → chunk-tbbwss3v.js} +1 -1
- package/bin/{chunk-06spnkta.js → chunk-tjcc7a6y.js} +1 -1
- package/bin/{chunk-qac5hr5h.js → chunk-tp6ab26e.js} +1 -1
- package/bin/{chunk-md12a1sf.js → chunk-v2wxk9p5.js} +2 -2
- package/bin/chunk-vbk6y4hk.js +2 -0
- package/bin/{chunk-vcf2qk9h.js → chunk-vfgfg5fk.js} +2 -2
- package/bin/{chunk-gjnrd32m.js → chunk-vm6c3xx9.js} +2 -2
- package/bin/{chunk-agabtxrc.js → chunk-vsx96mt6.js} +1 -1
- package/bin/{chunk-et0cewj7.js → chunk-wbyw1shz.js} +2 -2
- package/bin/chunk-whh2vh50.css +1 -0
- package/bin/{chunk-792t2653.js → chunk-wjkcq65s.js} +2 -2
- package/bin/{chunk-5yhn31rd.js → chunk-wkefwkfp.js} +1 -1
- package/bin/{chunk-gcc6pte2.js → chunk-x7bsnk1e.js} +2 -2
- package/bin/{chunk-tn67sjb2.js → chunk-xbhw6bpz.js} +2 -2
- package/bin/{chunk-34kaja59.js → chunk-xg5yrcj5.js} +2 -2
- package/bin/{chunk-wzmpvadf.js → chunk-xw2gpcsh.js} +1 -1
- package/bin/{chunk-sx6y697s.js → chunk-ycq8ank7.js} +1 -1
- package/bin/chunk-yp9hvkc5.js +73 -0
- package/bin/{chunk-dkjkn8t3.js → chunk-ytypyfkc.js} +2 -2
- package/bin/{chunk-62ebss6h.js → chunk-z1kjmf60.js} +2 -2
- package/bin/chunk-z36bx86r.js +2 -0
- package/bin/chunk-z7hdnecp.js +3 -0
- package/bin/chunk-zeby1cq7.js +2 -0
- package/bin/chunk-zs5e8z1w.js +1 -0
- package/bin/chunk-zxnyefg5.js +2 -0
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +312 -342
- package/package.json +7 -7
- package/prisma/schema.prisma +1 -1
- package/bin/chunk-045f1bw7.js +0 -2
- package/bin/chunk-0n1wfwcm.js +0 -2
- package/bin/chunk-1fwzepfn.js +0 -2
- package/bin/chunk-2xevs82j.js +0 -2
- package/bin/chunk-31y5j4hr.js +0 -1
- package/bin/chunk-34adtqqh.js +0 -1
- package/bin/chunk-4j8fbckp.js +0 -1
- package/bin/chunk-57s7yj35.js +0 -1
- package/bin/chunk-6tse78c7.js +0 -2
- package/bin/chunk-8nyve0cr.js +0 -7
- package/bin/chunk-ajndx51c.js +0 -2
- package/bin/chunk-bbyc2jfq.js +0 -1
- package/bin/chunk-br7d2qwc.js +0 -1
- package/bin/chunk-by6g0vye.js +0 -2
- package/bin/chunk-c24fvhm6.js +0 -1
- package/bin/chunk-c6aszz6p.js +0 -1
- package/bin/chunk-csqvmx1m.js +0 -2
- package/bin/chunk-dg8c91j5.js +0 -1
- package/bin/chunk-dk8vk17v.js +0 -2
- package/bin/chunk-ex2ym5pz.js +0 -2
- package/bin/chunk-f2zbsrc9.js +0 -2
- package/bin/chunk-gcpr2a24.js +0 -7
- package/bin/chunk-gpjkegdp.js +0 -1
- package/bin/chunk-jt6d0zb1.js +0 -2
- package/bin/chunk-jwgfkpek.js +0 -3
- package/bin/chunk-k2065y29.js +0 -2
- package/bin/chunk-k514bttd.js +0 -1
- package/bin/chunk-k7chm9a9.js +0 -2
- package/bin/chunk-kjgejwjp.css +0 -1
- package/bin/chunk-kqpzx5az.js +0 -73
- package/bin/chunk-kxr8fjsq.js +0 -2
- package/bin/chunk-mha3rsh7.js +0 -2
- package/bin/chunk-nn0px81k.js +0 -307
- package/bin/chunk-ns804tmv.js +0 -2
- package/bin/chunk-p1temt1j.js +0 -1
- package/bin/chunk-rkz6x3r0.js +0 -2
- package/bin/chunk-svz0ds0g.js +0 -1
- package/bin/chunk-t31basc5.js +0 -1
- package/bin/chunk-t6qdrw24.js +0 -1
- package/bin/chunk-wvwqgff4.js +0 -1
- package/bin/chunk-ww1cy08p.js +0 -1
- package/bin/chunk-xfp27ya9.js +0 -2
- package/bin/chunk-y0f4bc9f.js +0 -2
- package/bin/chunk-y2s0tjaa.js +0 -3
- package/bin/chunk-y3dy4pdt.js +0 -2
|
@@ -21,4 +21,4 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
|
21
21
|
new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
|
|
22
22
|
|
|
23
23
|
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
24
|
-
`);this.baseURL=z.baseURL,this.timeout=z.timeout??x2.DEFAULT_TIMEOUT,this.logger=z.logger??console;let N="warn";this.logLevel=N,this.logLevel=Z2(z.logLevel,"ClientOptions.logLevel",this)??Z2(a("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??N,this.fetchOptions=z.fetchOptions,this.maxRetries=z.maxRetries??2,this.fetch=z.fetch??b2(),E(this,m0,g2,"f"),this._options=z,this.apiKey=typeof Z==="string"?Z:"Missing Key",this.organization=Y,this.project=$,this.webhookSecret=G}withOptions(X){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...X})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:X,nulls:Z}){return}async authHeaders(X){return V([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(X){return n2(X)}getUserAgent(){return`${this.constructor.name}/JS ${NX}`}defaultIdempotencyKey(){return`stainless-node-retry-${u0()}`}makeStatusError(X,Z,Y,$){return f.generate(X,Z,Y,$)}async _callApiKey(){let X=this._options.apiKey;if(typeof X!=="function")return!1;let Z;try{Z=await X()}catch(Y){if(Y instanceof U)throw Y;throw new U(`Failed to get token from 'apiKey' function: ${Y.message}`,{cause:Y})}if(typeof Z!=="string"||!Z)throw new U(`Expected 'apiKey' function argument to return a string but it returned ${Z}`);return this.apiKey=Z,!0}buildURL(X,Z,Y){let $=!K(this,O2,"m",y3).call(this)&&Y||this.baseURL,G=C2(X)?new URL(X):new URL($+($.endsWith("/")&&X.startsWith("/")?X.slice(1):X)),W=this.defaultQuery();if(!D2(W))Z={...W,...Z};if(typeof Z==="object"&&Z&&!Array.isArray(Z))G.search=this.stringifyQuery(Z);return G.toString()}async prepareOptions(X){await this._callApiKey()}async prepareRequest(X,{url:Z,options:Y}){}get(X,Z){return this.methodRequest("get",X,Z)}post(X,Z){return this.methodRequest("post",X,Z)}patch(X,Z){return this.methodRequest("patch",X,Z)}put(X,Z){return this.methodRequest("put",X,Z)}delete(X,Z){return this.methodRequest("delete",X,Z)}methodRequest(X,Z,Y){return this.request(Promise.resolve(Y).then(($)=>{return{method:X,path:Z,...$}}))}request(X,Z=null){return new xX(this,this.makeRequest(X,Z,void 0))}async makeRequest(X,Z,Y){let $=await X,G=$.maxRetries??this.maxRetries;if(Z==null)Z=G;await this.prepareOptions($);let{req:W,url:z,timeout:N}=await this.buildRequest($,{retryCount:G-Z});await this.prepareRequest(W,{url:z,options:$});let w="log_"+(Math.random()*16777216|0).toString(16).padStart(6,"0"),F=Y===void 0?"":`, retryOf: ${Y}`,M=Date.now();if(S(this).debug(`[${w}] sending request`,GX({retryOfRequestLogID:Y,method:$.method,url:z,options:$,headers:W.headers})),$.signal?.aborted)throw new I;let H=new AbortController,B=await this.fetchWithTimeout(z,W,N,H).catch(wZ),q=Date.now();if(B instanceof globalThis.Error){let C=`retrying, ${Z} attempts remaining`;if($.signal?.aborted)throw new I;let P=VZ(B)||/timed? ?out/i.test(String(B)+("cause"in B?String(B.cause):""));if(Z)return S(this).info(`[${w}] connection ${P?"timed out":"failed"} - ${C}`),S(this).debug(`[${w}] connection ${P?"timed out":"failed"} (${C})`,GX({retryOfRequestLogID:Y,url:z,durationMs:q-M,message:B.message})),this.retryRequest($,Z,Y??w);if(S(this).info(`[${w}] connection ${P?"timed out":"failed"} - error; no more retries left`),S(this).debug(`[${w}] connection ${P?"timed out":"failed"} (error; no more retries left)`,GX({retryOfRequestLogID:Y,url:z,durationMs:q-M,message:B.message})),P)throw new OX;throw new LX({cause:B})}let T=[...B.headers.entries()].filter(([C])=>C==="x-request-id").map(([C,P])=>", "+C+": "+JSON.stringify(P)).join(""),D=`[${w}${F}${T}] ${W.method} ${z} ${B.ok?"succeeded":"failed"} with status ${B.status} in ${q-M}ms`;if(!B.ok){let C=await this.shouldRetry(B);if(Z&&C){let j=`retrying, ${Z} attempts remaining`;return await v2(B.body),S(this).info(`${D} - ${j}`),S(this).debug(`[${w}] response error (${j})`,GX({retryOfRequestLogID:Y,url:B.url,status:B.status,headers:B.headers,durationMs:q-M})),this.retryRequest($,Z,Y??w,B.headers)}let P=C?"error; no more retries left":"error; not retryable";S(this).info(`${D} - ${P}`);let x=await B.text().catch((j)=>wZ(j).message),_=S2(x),R=_?void 0:x;throw S(this).debug(`[${w}] response error (${P})`,GX({retryOfRequestLogID:Y,url:B.url,status:B.status,headers:B.headers,message:R,durationMs:Date.now()-M})),this.makeStatusError(B.status,_,R,B.headers)}return S(this).info(D),S(this).debug(`[${w}] response start`,GX({retryOfRequestLogID:Y,url:B.url,status:B.status,headers:B.headers,durationMs:q-M})),{response:B,options:$,controller:H,requestLogID:w,retryOfRequestLogID:Y,startTime:M}}getAPIList(X,Z,Y){return this.requestAPIList(Z,Y&&"then"in Y?Y.then(($)=>({method:"get",path:X,...$})):{method:"get",path:X,...Y})}requestAPIList(X,Z){let Y=this.makeRequest(Z,null,void 0);return new q0(this,Y,X)}async fetchWithTimeout(X,Z,Y,$){let{signal:G,method:W,...z}=Z||{},N=this._makeAbort($);if(G)G.addEventListener("abort",N,{once:!0});let w=setTimeout(N,Y),F=globalThis.ReadableStream&&z.body instanceof globalThis.ReadableStream||typeof z.body==="object"&&z.body!==null&&Symbol.asyncIterator in z.body,M={signal:$.signal,...F?{duplex:"half"}:{},method:"GET",...z};if(W)M.method=W.toUpperCase();try{return await this.fetch.call(void 0,X,M)}finally{clearTimeout(w)}}async shouldRetry(X){let Z=X.headers.get("x-should-retry");if(Z==="true")return!0;if(Z==="false")return!1;if(X.status===408)return!0;if(X.status===409)return!0;if(X.status===429)return!0;if(X.status>=500)return!0;return!1}async retryRequest(X,Z,Y,$){let G,W=$?.get("retry-after-ms");if(W){let N=parseFloat(W);if(!Number.isNaN(N))G=N}let z=$?.get("retry-after");if(z&&!G){let N=parseFloat(z);if(!Number.isNaN(N))G=N*1000;else G=Date.parse(z)-Date.now()}if(G===void 0){let N=X.maxRetries??this.maxRetries;G=this.calculateDefaultRetryTimeoutMillis(Z,N)}return await s(G),this.makeRequest(X,Z-1,Y)}calculateDefaultRetryTimeoutMillis(X,Z){let G=Z-X,W=Math.min(0.5*Math.pow(2,G),8),z=1-Math.random()*0.25;return W*z*1000}async buildRequest(X,{retryCount:Z=0}={}){let Y={...X},{method:$,path:G,query:W,defaultBaseURL:z}=Y,N=this.buildURL(G,W,z);if("timeout"in Y)R2("timeout",Y.timeout);Y.timeout=Y.timeout??this.timeout;let{bodyHeaders:w,body:F}=this.buildBody({options:Y}),M=await this.buildHeaders({options:X,method:$,bodyHeaders:w,retryCount:Z});return{req:{method:$,headers:M,...Y.signal&&{signal:Y.signal},...globalThis.ReadableStream&&F instanceof globalThis.ReadableStream&&{duplex:"half"},...F&&{body:F},...this.fetchOptions??{},...Y.fetchOptions??{}},url:N,timeout:Y.timeout}}async buildHeaders({options:X,method:Z,bodyHeaders:Y,retryCount:$}){let G={};if(this.idempotencyHeader&&Z!=="get"){if(!X.idempotencyKey)X.idempotencyKey=this.defaultIdempotencyKey();G[this.idempotencyHeader]=X.idempotencyKey}let W=V([G,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String($),...X.timeout?{"X-Stainless-Timeout":String(Math.trunc(X.timeout/1000))}:{},...y2(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(X),this._options.defaultHeaders,Y,X.headers]);return this.validateHeaders(W),W.values}_makeAbort(X){return()=>X.abort()}buildBody({options:{body:X,headers:Z}}){if(!X)return{bodyHeaders:void 0,body:void 0};let Y=V([Z]);if(ArrayBuffer.isView(X)||X instanceof ArrayBuffer||X instanceof DataView||typeof X==="string"&&Y.values.has("content-type")||globalThis.Blob&&X instanceof globalThis.Blob||X instanceof FormData||X instanceof URLSearchParams||globalThis.ReadableStream&&X instanceof globalThis.ReadableStream)return{bodyHeaders:void 0,body:X};else if(typeof X==="object"&&((Symbol.asyncIterator in X)||(Symbol.iterator in X)&&("next"in X)&&typeof X.next==="function"))return{bodyHeaders:void 0,body:w0(X)};else if(typeof X==="object"&&Y.values.get("content-type")==="application/x-www-form-urlencoded")return{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(X)};else return K(this,m0,"f").call(this,{body:X,headers:Y})}}x2=L,m0=new WeakMap,O2=new WeakSet,y3=function(){return this.baseURL!=="https://api.openai.com/v1"};L.OpenAI=x2;L.DEFAULT_TIMEOUT=600000;L.OpenAIError=U;L.APIError=f;L.APIConnectionError=LX;L.APIConnectionTimeoutError=OX;L.APIUserAbortError=I;L.NotFoundError=TZ;L.ConflictError=MZ;L.RateLimitError=qZ;L.BadRequestError=HZ;L.AuthenticationError=UZ;L.InternalServerError=LZ;L.PermissionDeniedError=FZ;L.UnprocessableEntityError=EZ;L.InvalidWebhookSignatureError=$X;L.toFile=O0;L.Completions=sX;L.Chat=CX;L.Embeddings=oX;L.Files=XZ;L.Images=GZ;L.Audio=QX;L.Moderations=KZ;L.Models=WZ;L.FineTuning=ZX;L.Graders=bX;L.VectorStores=qX;L.Webhooks=NZ;L.Beta=XX;L.Batches=nX;L.Uploads=vX;L.Responses=MX;L.Realtime=FX;L.Conversations=IX;L.Evals=yX;L.Containers=jX;L.Skills=EX;L.Videos=QZ;class b3 extends L{constructor({baseURL:X=a("OPENAI_BASE_URL"),apiKey:Z=a("AZURE_OPENAI_API_KEY"),apiVersion:Y=a("OPENAI_API_VERSION"),endpoint:$,deployment:G,azureADTokenProvider:W,dangerouslyAllowBrowser:z,...N}={}){if(!Y)throw new U("The OPENAI_API_VERSION environment variable is missing or empty; either provide it, or instantiate the AzureOpenAI client with an apiVersion option, like new AzureOpenAI({ apiVersion: 'My API Version' }).");if(typeof W==="function")z=!0;if(!W&&!Z)throw new U("Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.");if(W&&Z)throw new U("The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.");if(N.defaultQuery={...N.defaultQuery,"api-version":Y},!X){if(!$)$=process.env.AZURE_OPENAI_ENDPOINT;if(!$)throw new U("Must provide one of the `baseURL` or `endpoint` arguments, or the `AZURE_OPENAI_ENDPOINT` environment variable");X=`${$}/openai`}else if($)throw new U("baseURL and endpoint are mutually exclusive");super({apiKey:W??Z,baseURL:X,...N,...z!==void 0?{dangerouslyAllowBrowser:z}:{}});this.apiVersion="",this.apiVersion=Y,this.deploymentName=G}async buildRequest(X,Z={}){if(J8.has(X.path)&&X.method==="post"&&X.body!==void 0){if(!gX(X.body))throw Error("Expected request body to be an object");let Y=this.deploymentName||X.body.model||X.__metadata?.model;if(Y!==void 0&&!this.baseURL.includes("/deployments"))X.path=`/deployments/${Y}${X.path}`}return super.buildRequest(X,Z)}async authHeaders(X){if(typeof this._options.apiKey==="string")return V([{"api-key":this.apiKey}]);return super.authHeaders(X)}}var J8=new Set(["/completions","/chat/completions","/embeddings","/audio/transcriptions","/audio/translations","/audio/speech","/images/generations","/batches","/images/edits"]);export{L as wm,b3 as xm};
|
|
24
|
+
`);this.baseURL=z.baseURL,this.timeout=z.timeout??x2.DEFAULT_TIMEOUT,this.logger=z.logger??console;let N="warn";this.logLevel=N,this.logLevel=Z2(z.logLevel,"ClientOptions.logLevel",this)??Z2(a("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??N,this.fetchOptions=z.fetchOptions,this.maxRetries=z.maxRetries??2,this.fetch=z.fetch??b2(),E(this,m0,g2,"f"),this._options=z,this.apiKey=typeof Z==="string"?Z:"Missing Key",this.organization=Y,this.project=$,this.webhookSecret=G}withOptions(X){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...X})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:X,nulls:Z}){return}async authHeaders(X){return V([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(X){return n2(X)}getUserAgent(){return`${this.constructor.name}/JS ${NX}`}defaultIdempotencyKey(){return`stainless-node-retry-${u0()}`}makeStatusError(X,Z,Y,$){return f.generate(X,Z,Y,$)}async _callApiKey(){let X=this._options.apiKey;if(typeof X!=="function")return!1;let Z;try{Z=await X()}catch(Y){if(Y instanceof U)throw Y;throw new U(`Failed to get token from 'apiKey' function: ${Y.message}`,{cause:Y})}if(typeof Z!=="string"||!Z)throw new U(`Expected 'apiKey' function argument to return a string but it returned ${Z}`);return this.apiKey=Z,!0}buildURL(X,Z,Y){let $=!K(this,O2,"m",y3).call(this)&&Y||this.baseURL,G=C2(X)?new URL(X):new URL($+($.endsWith("/")&&X.startsWith("/")?X.slice(1):X)),W=this.defaultQuery();if(!D2(W))Z={...W,...Z};if(typeof Z==="object"&&Z&&!Array.isArray(Z))G.search=this.stringifyQuery(Z);return G.toString()}async prepareOptions(X){await this._callApiKey()}async prepareRequest(X,{url:Z,options:Y}){}get(X,Z){return this.methodRequest("get",X,Z)}post(X,Z){return this.methodRequest("post",X,Z)}patch(X,Z){return this.methodRequest("patch",X,Z)}put(X,Z){return this.methodRequest("put",X,Z)}delete(X,Z){return this.methodRequest("delete",X,Z)}methodRequest(X,Z,Y){return this.request(Promise.resolve(Y).then(($)=>{return{method:X,path:Z,...$}}))}request(X,Z=null){return new xX(this,this.makeRequest(X,Z,void 0))}async makeRequest(X,Z,Y){let $=await X,G=$.maxRetries??this.maxRetries;if(Z==null)Z=G;await this.prepareOptions($);let{req:W,url:z,timeout:N}=await this.buildRequest($,{retryCount:G-Z});await this.prepareRequest(W,{url:z,options:$});let w="log_"+(Math.random()*16777216|0).toString(16).padStart(6,"0"),F=Y===void 0?"":`, retryOf: ${Y}`,M=Date.now();if(S(this).debug(`[${w}] sending request`,GX({retryOfRequestLogID:Y,method:$.method,url:z,options:$,headers:W.headers})),$.signal?.aborted)throw new I;let H=new AbortController,B=await this.fetchWithTimeout(z,W,N,H).catch(wZ),q=Date.now();if(B instanceof globalThis.Error){let C=`retrying, ${Z} attempts remaining`;if($.signal?.aborted)throw new I;let P=VZ(B)||/timed? ?out/i.test(String(B)+("cause"in B?String(B.cause):""));if(Z)return S(this).info(`[${w}] connection ${P?"timed out":"failed"} - ${C}`),S(this).debug(`[${w}] connection ${P?"timed out":"failed"} (${C})`,GX({retryOfRequestLogID:Y,url:z,durationMs:q-M,message:B.message})),this.retryRequest($,Z,Y??w);if(S(this).info(`[${w}] connection ${P?"timed out":"failed"} - error; no more retries left`),S(this).debug(`[${w}] connection ${P?"timed out":"failed"} (error; no more retries left)`,GX({retryOfRequestLogID:Y,url:z,durationMs:q-M,message:B.message})),P)throw new OX;throw new LX({cause:B})}let T=[...B.headers.entries()].filter(([C])=>C==="x-request-id").map(([C,P])=>", "+C+": "+JSON.stringify(P)).join(""),D=`[${w}${F}${T}] ${W.method} ${z} ${B.ok?"succeeded":"failed"} with status ${B.status} in ${q-M}ms`;if(!B.ok){let C=await this.shouldRetry(B);if(Z&&C){let j=`retrying, ${Z} attempts remaining`;return await v2(B.body),S(this).info(`${D} - ${j}`),S(this).debug(`[${w}] response error (${j})`,GX({retryOfRequestLogID:Y,url:B.url,status:B.status,headers:B.headers,durationMs:q-M})),this.retryRequest($,Z,Y??w,B.headers)}let P=C?"error; no more retries left":"error; not retryable";S(this).info(`${D} - ${P}`);let x=await B.text().catch((j)=>wZ(j).message),_=S2(x),R=_?void 0:x;throw S(this).debug(`[${w}] response error (${P})`,GX({retryOfRequestLogID:Y,url:B.url,status:B.status,headers:B.headers,message:R,durationMs:Date.now()-M})),this.makeStatusError(B.status,_,R,B.headers)}return S(this).info(D),S(this).debug(`[${w}] response start`,GX({retryOfRequestLogID:Y,url:B.url,status:B.status,headers:B.headers,durationMs:q-M})),{response:B,options:$,controller:H,requestLogID:w,retryOfRequestLogID:Y,startTime:M}}getAPIList(X,Z,Y){return this.requestAPIList(Z,Y&&"then"in Y?Y.then(($)=>({method:"get",path:X,...$})):{method:"get",path:X,...Y})}requestAPIList(X,Z){let Y=this.makeRequest(Z,null,void 0);return new q0(this,Y,X)}async fetchWithTimeout(X,Z,Y,$){let{signal:G,method:W,...z}=Z||{},N=this._makeAbort($);if(G)G.addEventListener("abort",N,{once:!0});let w=setTimeout(N,Y),F=globalThis.ReadableStream&&z.body instanceof globalThis.ReadableStream||typeof z.body==="object"&&z.body!==null&&Symbol.asyncIterator in z.body,M={signal:$.signal,...F?{duplex:"half"}:{},method:"GET",...z};if(W)M.method=W.toUpperCase();try{return await this.fetch.call(void 0,X,M)}finally{clearTimeout(w)}}async shouldRetry(X){let Z=X.headers.get("x-should-retry");if(Z==="true")return!0;if(Z==="false")return!1;if(X.status===408)return!0;if(X.status===409)return!0;if(X.status===429)return!0;if(X.status>=500)return!0;return!1}async retryRequest(X,Z,Y,$){let G,W=$?.get("retry-after-ms");if(W){let N=parseFloat(W);if(!Number.isNaN(N))G=N}let z=$?.get("retry-after");if(z&&!G){let N=parseFloat(z);if(!Number.isNaN(N))G=N*1000;else G=Date.parse(z)-Date.now()}if(G===void 0){let N=X.maxRetries??this.maxRetries;G=this.calculateDefaultRetryTimeoutMillis(Z,N)}return await s(G),this.makeRequest(X,Z-1,Y)}calculateDefaultRetryTimeoutMillis(X,Z){let G=Z-X,W=Math.min(0.5*Math.pow(2,G),8),z=1-Math.random()*0.25;return W*z*1000}async buildRequest(X,{retryCount:Z=0}={}){let Y={...X},{method:$,path:G,query:W,defaultBaseURL:z}=Y,N=this.buildURL(G,W,z);if("timeout"in Y)R2("timeout",Y.timeout);Y.timeout=Y.timeout??this.timeout;let{bodyHeaders:w,body:F}=this.buildBody({options:Y}),M=await this.buildHeaders({options:X,method:$,bodyHeaders:w,retryCount:Z});return{req:{method:$,headers:M,...Y.signal&&{signal:Y.signal},...globalThis.ReadableStream&&F instanceof globalThis.ReadableStream&&{duplex:"half"},...F&&{body:F},...this.fetchOptions??{},...Y.fetchOptions??{}},url:N,timeout:Y.timeout}}async buildHeaders({options:X,method:Z,bodyHeaders:Y,retryCount:$}){let G={};if(this.idempotencyHeader&&Z!=="get"){if(!X.idempotencyKey)X.idempotencyKey=this.defaultIdempotencyKey();G[this.idempotencyHeader]=X.idempotencyKey}let W=V([G,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String($),...X.timeout?{"X-Stainless-Timeout":String(Math.trunc(X.timeout/1000))}:{},...y2(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(X),this._options.defaultHeaders,Y,X.headers]);return this.validateHeaders(W),W.values}_makeAbort(X){return()=>X.abort()}buildBody({options:{body:X,headers:Z}}){if(!X)return{bodyHeaders:void 0,body:void 0};let Y=V([Z]);if(ArrayBuffer.isView(X)||X instanceof ArrayBuffer||X instanceof DataView||typeof X==="string"&&Y.values.has("content-type")||globalThis.Blob&&X instanceof globalThis.Blob||X instanceof FormData||X instanceof URLSearchParams||globalThis.ReadableStream&&X instanceof globalThis.ReadableStream)return{bodyHeaders:void 0,body:X};else if(typeof X==="object"&&((Symbol.asyncIterator in X)||(Symbol.iterator in X)&&("next"in X)&&typeof X.next==="function"))return{bodyHeaders:void 0,body:w0(X)};else if(typeof X==="object"&&Y.values.get("content-type")==="application/x-www-form-urlencoded")return{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(X)};else return K(this,m0,"f").call(this,{body:X,headers:Y})}}x2=L,m0=new WeakMap,O2=new WeakSet,y3=function(){return this.baseURL!=="https://api.openai.com/v1"};L.OpenAI=x2;L.DEFAULT_TIMEOUT=600000;L.OpenAIError=U;L.APIError=f;L.APIConnectionError=LX;L.APIConnectionTimeoutError=OX;L.APIUserAbortError=I;L.NotFoundError=TZ;L.ConflictError=MZ;L.RateLimitError=qZ;L.BadRequestError=HZ;L.AuthenticationError=UZ;L.InternalServerError=LZ;L.PermissionDeniedError=FZ;L.UnprocessableEntityError=EZ;L.InvalidWebhookSignatureError=$X;L.toFile=O0;L.Completions=sX;L.Chat=CX;L.Embeddings=oX;L.Files=XZ;L.Images=GZ;L.Audio=QX;L.Moderations=KZ;L.Models=WZ;L.FineTuning=ZX;L.Graders=bX;L.VectorStores=qX;L.Webhooks=NZ;L.Beta=XX;L.Batches=nX;L.Uploads=vX;L.Responses=MX;L.Realtime=FX;L.Conversations=IX;L.Evals=yX;L.Containers=jX;L.Skills=EX;L.Videos=QZ;class b3 extends L{constructor({baseURL:X=a("OPENAI_BASE_URL"),apiKey:Z=a("AZURE_OPENAI_API_KEY"),apiVersion:Y=a("OPENAI_API_VERSION"),endpoint:$,deployment:G,azureADTokenProvider:W,dangerouslyAllowBrowser:z,...N}={}){if(!Y)throw new U("The OPENAI_API_VERSION environment variable is missing or empty; either provide it, or instantiate the AzureOpenAI client with an apiVersion option, like new AzureOpenAI({ apiVersion: 'My API Version' }).");if(typeof W==="function")z=!0;if(!W&&!Z)throw new U("Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.");if(W&&Z)throw new U("The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.");if(N.defaultQuery={...N.defaultQuery,"api-version":Y},!X){if(!$)$=process.env.AZURE_OPENAI_ENDPOINT;if(!$)throw new U("Must provide one of the `baseURL` or `endpoint` arguments, or the `AZURE_OPENAI_ENDPOINT` environment variable");X=`${$}/openai`}else if($)throw new U("baseURL and endpoint are mutually exclusive");super({apiKey:W??Z,baseURL:X,...N,...z!==void 0?{dangerouslyAllowBrowser:z}:{}});this.apiVersion="",this.apiVersion=Y,this.deploymentName=G}async buildRequest(X,Z={}){if(J8.has(X.path)&&X.method==="post"&&X.body!==void 0){if(!gX(X.body))throw Error("Expected request body to be an object");let Y=this.deploymentName||X.body.model||X.__metadata?.model;if(Y!==void 0&&!this.baseURL.includes("/deployments"))X.path=`/deployments/${Y}${X.path}`}return super.buildRequest(X,Z)}async authHeaders(X){if(typeof this._options.apiKey==="string")return V([{"api-key":this.apiKey}]);return super.authHeaders(X)}}var J8=new Set(["/completions","/chat/completions","/embeddings","/audio/transcriptions","/audio/translations","/audio/speech","/images/generations","/batches","/images/edits"]);export{L as Em,b3 as Fm};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Sb as P,Tb as J}from"./chunk-s88ha5kx.js";import{Gc as V,Hc as W,Ic as X}from"./chunk-rgthkvgx.js";import"./chunk-dxyq9h8n.js";var Y=class{get supportsCreateIfNotExists(){return!0}get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(){}async releaseMigrationLock(){}get supportsOutput(){return!0}},Z=class{#h;#j=new k;#z;#H;constructor(h){this.#h={...h}}async init(){if(this.#z=this.#h.database,this.#H=new $(this.#z),this.#h.onCreateConnection)await this.#h.onCreateConnection(this.#H)}async acquireConnection(){return await this.#j.lock(),this.#H}async beginTransaction(h){await h.executeQuery(J.raw("begin"))}async commitTransaction(h){await h.executeQuery(J.raw("commit"))}async rollbackTransaction(h){await h.executeQuery(J.raw("rollback"))}async releaseConnection(){this.#j.unlock()}async destroy(){this.#z?.close()}},$=class{#h;constructor(h){this.#h=h}executeQuery(h){let{sql:z,parameters:H}=h,j=this.#h.prepare(z).all(...H);return Promise.resolve({rows:j})}async*streamQuery(){throw Error("Streaming query is not supported by SQLite driver.")}},k=class{#h;#j;async lock(){while(this.#h!==void 0)await this.#h;this.#h=new Promise((h)=>{this.#j=h})}unlock(){let h=this.#j;this.#h=void 0,this.#j=void 0,h?.()}},w=class{#h;constructor(h){this.#h=h}async getSchemas(){return[]}async getTables(h={withInternalKyselyTables:!1}){let z=this.#h.selectFrom("sqlite_schema").where("type","=","table").where("name","not like","sqlite_%").select("name").$castTo();if(!h.withInternalKyselyTables)z=z.where("name","!=",W).where("name","!=",X);let H=await z.execute();return Promise.all(H.map(({name:j})=>this.#j(j)))}async getMetadata(h){return{tables:await this.getTables(h)}}async#j(h){let z=this.#h,H=(await z.selectFrom("sqlite_master").where("name","=",h).select("sql").$castTo().execute())[0]?.sql?.split(/[\(\),]/)?.find((j)=>j.toLowerCase().includes("autoincrement"))?.split(/\s+/)?.[0]?.replace(/["`]/g,"");return{name:h,columns:(await z.selectFrom(P`pragma_table_info(${h})`.as("table_info")).select(["name","type","notnull","dflt_value"]).execute()).map((j)=>({name:j.name,dataType:j.type,isNullable:!j.notnull,isAutoIncrementing:j.name===H,hasDefaultValue:j.dflt_value!=null})),isView:!0}}},K=class extends V{getCurrentParameterPlaceholder(){return"?"}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}},F=class{#h;constructor(h){this.#h={...h}}createDriver(){return new Z(this.#h)}createQueryCompiler(){return new K}createAdapter(){return new Y}createIntrospector(h){return new w(h)}};export{F as NodeSqliteDialect};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$c as
|
|
2
|
+
import{$c as N,Mc as JG,Nc as r,Oc as u,Sc as H,Yc as W,Zc as l,ad as k,dd as E,fd as J,hd as I,kd as V,md as X,pd as _}from"./chunk-6gbtz5bf.js";function q(G,Q){let Y={};if(!Object.keys(Q).length)return Y=G,Y;for(let[K,B]of Object.entries(G)){let O=Q[K];if(O===null)continue;Y[O??K]=B}return Y}function UG(G){let Q={};for(let[Y,K]of Object.entries(G))if(typeof K<"u")Q[Y]=K;return Q}class C extends Error{rawValue;rawMessage;static[Symbol.hasInstance](G){if(!(G instanceof Error))return!1;if(!("rawValue"in G))return!1;if(!("rawMessage"in G))return!1;if(!("pretty"in G))return!1;if(typeof G.pretty!=="function")return!1;return!0}constructor(G,Q,Y){super(`${G}: ${Q}`);this.name="SDKValidationError",this.cause=Q,this.rawValue=Y,this.rawMessage=G}pretty(){if(this.cause instanceof r)return`${this.rawMessage}
|
|
3
3
|
${yG(this.cause)}`;else return this.toString()}}function yG(G){return u(G)}function t(G){return{ok:!0,value:G}}function s(G){return{ok:!1,error:G}}async function vG(G){let Q=await G;if(!Q.ok)throw Q.error;return Q.value}function i(G,Q,Y){try{return t(Q(G))}catch(K){return s(new C(Y,K,G))}}var o=J({prompt_tokens:W().default(0),completion_tokens:W().default(0),total_tokens:W().default(0),prompt_audio_seconds:_(W()).optional()}).catchall(N()).transform((G)=>{return q(G,{prompt_tokens:"promptTokens",completion_tokens:"completionTokens",total_tokens:"totalTokens",prompt_audio_seconds:"promptAudioSeconds"})}),hG=J({promptTokens:W().default(0),completionTokens:W().default(0),totalTokens:W().default(0),promptAudioSeconds:_(W()).optional()}).catchall(N()).transform((G)=>{return{...q(G,{promptTokens:"prompt_tokens",completionTokens:"completion_tokens",totalTokens:"total_tokens",promptAudioSeconds:"prompt_audio_seconds"})}});function j(G){return z++,G}var z=0,a=0;function P(){a++;let G=z;return{end:(Q)=>{let Y=z-G;if(z=G+(Q??Y),--a===0)z=0;return Y}}}function M(G){let Q=Object.values(G);return I([...Q.map((Y)=>X(Y)),H().transform((Y)=>j(Y))])}function lG(G){let Q=Object.values(G).filter((Y)=>typeof Y==="number");return I([...Q.map((Y)=>X(Y)),W().transform((Y)=>j(Y))])}function f(G){return H()}function cG(G){return W()}var e=Symbol("UNKNOWN");function n(G){return typeof G==="object"&&G!==null&&e in G}function GG(G,Q,Y={}){let{unknownValue:K="UNKNOWN",outputPropertyName:B}=Y;return k().transform((O)=>{let w=Object.defineProperties({raw:O,[B??G]:K,isUnknown:!0},{[e]:{value:!0,enumerable:!1,configurable:!1}});if(!(typeof O==="object"&&O!==null))return w;let F=O[G];if(typeof F!=="string")return w;if(!(F in Q))return w;let $=Q[F];if(!$)return w;let T=P(),y=$.safeParse(O);if(!y.success)return T.end(0),w;if(T.end(),B)y.data[B]=F;return y.data})}var HG=/^\d{4}-\d{2}-\d{2}$/;class v{serialized;static today(){return new v(new Date)}constructor(G){if(typeof G==="string"&&!HG.test(G))throw RangeError("RFCDate: date strings must be in the format YYYY-MM-DD: "+G);let Q=new Date(G);if(isNaN(+Q))throw RangeError("RFCDate: invalid date provided: "+G);if(this.serialized=Q.toISOString().slice(0,10),!HG.test(this.serialized))throw TypeError(`RFCDate: failed to build valid date with given value: ${G} serialized to ${this.serialized}`)}toJSON(){return this.toString()}toString(){return this.serialized}}function Z(G){return k().transform((Q,Y)=>{let K=[],B=G.map(()=>[]),O=P();for(let[D,F]of G.entries()){let $=P(),T=F.safeParse(Q),y=$.end(),xG=0;if(T.success){K.push({data:T.data,inexactCount:y,zeroDefaultCount:0,fieldCount:-1});continue}B[D].push(...T.error.issues)}if(K.length===0)return O.end(0),Y.addIssue({input:Q,code:"invalid_union",errors:B}),JG;let w=K[0];for(let D of K){if(K.length>1)D.fieldCount=PG(D.data);w=zG(D,w)}return O.end(w.inexactCount),w.data})}function zG(G,Q){let Y=G.inexactCount===0,K=Q.inexactCount===0;if(Y!==K)return Y?G:Q;let B=G.fieldCount-G.zeroDefaultCount,O=Q.fieldCount-Q.zeroDefaultCount;if(B!==O)return B>O?G:Q;return G.inexactCount<Q.inexactCount?G:Q}function PG(G){let Q=0,Y=[G],K=0;while(K<Y.length){let B=Y[K++];if(B===void 0||n(B))continue;let O=typeof B;if(B===null||O==="number"||O==="string"||O==="boolean"||O==="bigint"||B instanceof Date||B instanceof v){Q++;continue}if(Array.isArray(B)){Y.push(...B);continue}if(O==="object")Y.push(...Object.values(B))}return Q}var QG=J({type:X("input_audio"),input_audio:H()}).transform((G)=>{return q(G,{input_audio:"inputAudio"})}),XG=J({type:X("input_audio"),inputAudio:H()}).transform((G)=>{return q(G,{inputAudio:"input_audio"})});var YG=J({type:X("document_url").default("document_url"),document_url:H(),document_name:_(H()).optional()}).transform((G)=>{return q(G,{document_url:"documentUrl",document_name:"documentName"})}),_G=J({type:X("document_url").default("document_url"),documentUrl:H(),documentName:_(H()).optional()}).transform((G)=>{return q(G,{documentUrl:"document_url",documentName:"document_name"})});var ZG=J({type:X("file").default("file"),file_id:H()}).transform((G)=>{return q(G,{file_id:"fileId"})}),WG=J({type:X("file").default("file"),fileId:H()}).transform((G)=>{return q(G,{fileId:"file_id"})});var qG={Low:"low",Auto:"auto",High:"high"},BG=M(qG),KG=f(qG);var b=J({url:H(),detail:_(BG).optional()}),p=J({url:H(),detail:_(KG).optional()});var BH=Z([b,H()]),KH=Z([p,H()]);var OG=J({type:X("image_url").default("image_url"),image_url:Z([b,H()])}).transform((G)=>{return q(G,{image_url:"imageUrl"})}),AG=J({type:X("image_url").default("image_url"),imageUrl:Z([p,H()])}).transform((G)=>{return q(G,{imageUrl:"image_url"})});var wH=Z([W(),H()]),NH=Z([W(),H()]);var L=J({type:X("reference").default("reference"),reference_ids:E(Z([W(),H()]))}).transform((G)=>{return q(G,{reference_ids:"referenceIds"})}),R=J({type:X("reference").default("reference"),referenceIds:E(Z([W(),H()]))}).transform((G)=>{return q(G,{referenceIds:"reference_ids"})});var x=J({type:X("text").default("text"),text:H()}),U=J({type:X("text").default("text"),text:H()});var EG={WebSearch:"web_search",WebSearchPremium:"web_search_premium",CodeInterpreter:"code_interpreter",ImageGeneration:"image_generation",DocumentLibrary:"document_library"},h=M(EG),g=f(EG);var yH=Z([h,H()]),zH=Z([g,H()]);var d=J({type:X("tool_reference").default("tool_reference"),tool:Z([h,H()]),title:H(),url:_(H()).optional(),favicon:_(H()).optional(),description:_(H()).optional()}),m=J({type:X("tool_reference").default("tool_reference"),tool:Z([g,H()]),title:H(),url:_(H()).optional(),favicon:_(H()).optional(),description:_(H()).optional()});var UH=Z([d,x,L]),$H=Z([m,U,R]);var wG=J({type:X("thinking").default("thinking"),thinking:E(Z([d,x,L])),signature:_(H()).optional(),closed:l().optional()}),NG=J({type:X("thinking").default("thinking"),thinking:E(Z([m,U,R])),signature:_(H()).optional(),closed:l().optional()});var c=GG("type",{image_url:OG.and(J({type:X("image_url")})),document_url:YG.and(J({type:X("document_url")})),text:x.and(J({type:X("text")})),reference:L.and(J({type:X("reference")})),file:ZG.and(J({type:X("file")})),thinking:wG.and(J({type:X("thinking")})),input_audio:QG}),gH=I([AG.and(J({type:X("image_url")})),_G.and(J({type:X("document_url")})),U.and(J({type:X("text")})),R.and(J({type:X("reference")})),WG.and(J({type:X("file")})),NG.and(J({type:X("thinking")})),XG]);var lH=Z([V(H(),N()),H()]),cH=Z([V(H(),N()),H()]);var VG=J({name:H(),arguments:Z([V(H(),N()),H()])}),DG=J({name:H(),arguments:Z([V(H(),N()),H()])});var FG=J({id:H().default("null"),type:H().optional(),function:VG,index:W().default(0)}),tH=J({id:H().default("null"),type:H().optional(),function:DG,index:W().default(0)});var nH=Z([H(),E(c)]);var TG=J({role:_(H()).optional(),content:_(Z([H(),E(c)])).optional(),tool_calls:_(E(FG)).optional(),tool_call_id:_(H()).optional(),index:_(W()).optional(),metadata:_(V(H(),N())).optional()}).transform((G)=>{return q(G,{tool_calls:"toolCalls",tool_call_id:"toolCallId"})});var IG={Stop:"stop",Length:"length",Error:"error",ToolCalls:"tool_calls"},LG=M(IG),MG=J({index:W(),delta:TG,finish_reason:_(LG)}).transform((G)=>{return q(G,{finish_reason:"finishReason"})});var RG=J({id:H(),object:H().optional(),created:W().optional(),model:H(),usage:o.optional(),choices:E(MG)});function ZJ(G){return i(G,(Q)=>RG.parse(JSON.parse(Q)),"Failed to parse 'CompletionChunk' from JSON")}
|
|
4
|
-
export{yG as
|
|
4
|
+
export{yG as fa,t as ga,s as ha,vG as ia,i as ja,q as ka,UG as la,M as ma,lG as na,f as oa,cG as pa,GG as qa,Z as ra,YG as sa,_G as ta,WG as ua,OG as va,AG as wa,x as xa,U as ya,h as za,g as Aa,d as Ba,m as Ca,wG as Da,NG as Ea,c as Fa,gH as Ga,FG as Ha,tH as Ia,TG as Ja,o as Ka,hG as La,RG as Ma,ZJ as Na};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Pe as cf}from"./chunk-jmdar2gz.js";import{hf as uf}from"./chunk-23hckrrz.js";import{wf as df}from"./chunk-bdjv0ykq.js";import{Kf as wf}from"./chunk-30z44j1g.js";import{$f as lf,ag as xf}from"./chunk-5vewxmz7.js";import{og as If}from"./chunk-63y0eb07.js";import{qh as Tf,rh as Af,sh as pf,th as Df,uh as kf,xh as af}from"./chunk-mq83a0kk.js";import{Ch as Of,Dh as gf,Eh as vf,Fh as yf}from"./chunk-hag024w8.js";import{ei as Rf,fi as zf,gi as Uf,hi as Hf,ii as C,li as Ff,mi as D,ni as Jf,oi as Wf,pi as Xf,ri as Pf}from"./chunk-b1ypjqgp.js";import{Bi as qf,Gi as j,xi as Gf}from"./chunk-h0fxysxs.js";import{Gk as Vf,Jj as Ef,Nk as bf,Tk as hf,Xl as Sf,Yj as Kf,Zk as t,aj as fN,bj as A,bk as Lf,cj as f,ck as Mf,dj as R,ij as Qf,kj as p,rm as k,sk as Bf,um as Y,zj as Cf}from"./chunk-yp9hvkc5.js";import{sn as sf}from"./chunk-dxyq9h8n.js";var Yf=sf(fN(),1);var d=qf((z)=>({isMobileMenuOpen:!1,activeItem:null,activeItemId:null,openMobileMenu:(N=null)=>z({isMobileMenuOpen:!0,activeItemId:typeof N==="string"?N:null,activeItem:typeof N==="number"?N:null}),closeMobileMenu:()=>z({isMobileMenuOpen:!1,activeItem:null,activeItemId:null}),toggleMobileMenu:()=>z((N)=>({isMobileMenuOpen:!N.isMobileMenuOpen,activeItem:N.isMobileMenuOpen?null:N.activeItem,activeItemId:N.isMobileMenuOpen?null:N.activeItemId})),setActiveItem:(N)=>z({activeItem:N,activeItemId:null}),setActiveItemId:(N)=>z({activeItemId:N})}));function mf({teamId:z,projectId:N,projectName:g,ancestorFolders:K,currentAsset:J,isRootFolder:v,customTerminalBreadcrumb:q,displayStyle:y,onDisplayStyleChange:F,isLeftSidebarCollapsed:u,onLeftSidebarToggle:c,isRightSidebarCollapsed:B,onRightSidebarToggle:m,isChatbotOpen:L=!1,onChatbotToggle:l,isPublic:H=!1,onFolderClick:V,onRename:i,onDelete:a,fileId:W,shareId:b,allowDownload:r=!0,downloadInfo:G,versions:E,compareMode:X=!1,canCompareVersions:I=!1,onCompareVersions:_}){let h=Qf(),{canEdit:P}=Pf(N),{openMobileMenu:n}=d(),[o,w]=Yf.useState(!1),[x,e]=Yf.useState(!1),Q=W||J.id,jf=J.name==="Recently Deleted",tf=J.name==="All Collections",s=!H&&!v&&!jf&&!tf&&!X&&!!Q,{data:Zf}=Gf({queryKey:["teams",z,"kanban","assets",Q,"tasks"],queryFn:async()=>{if(!z||!Q)return{data:[],total:0};let S=await j.api.teams[":teamId"].kanban.assets[":assetId"].tasks.$get({param:{teamId:z,assetId:Q}});if(!S.ok)return{data:[],total:0};return await S.json()},enabled:!!z&&!!Q&&s}),_f=Zf?.total??Zf?.data?.length??0,SN=!1,rf=(S)=>{if(!W)return;if(H&&b){h({to:"/share/$shareId/files/$fileId",params:{shareId:b,fileId:W},search:(U)=>({...U,version:S})});return}if(!N)return;h({to:"/projects/$projectId/files/$fileId",params:{projectId:N,fileId:W},search:(U)=>({...U,version:S})})},ff=async(S)=>{if(!W)return;try{let U=b?await j.api.shares[":shareId"].files[":fileId"]["download-url"].$post({param:{shareId:b,fileId:W},json:{key:S}}):await j.api.files["download-url"].$post({json:{key:S,assetId:W}});if(!U.ok)return;let{url:Z}=await U.json(),$=document.createElement("a");$.href=Z,$.download="",document.body.appendChild($),$.click(),document.body.removeChild($)}catch{}},nf=J.proxyType!=="audio"&&(G?.videoTranscodes?.length??0)>0,O=Boolean(q||!v&&!X),M={name:g,path:H?void 0:`/projects/${N}`,id:"root"},T=K.slice().reverse().map((S)=>({name:S.name||"",path:H?void 0:`/projects/${N}/folders/${S.id}`,id:S.id})),Nf=O?T:T.slice(0,-1),$f=!O&&T.length>0?T[T.length-1]:null,of=()=>{if(q)return f("span",{className:"truncate rounded px-2 py-1 text-sm font-medium text-foreground",children:q});if(!v&&!X){if(J.type==="folder")return f("span",{className:"truncate rounded px-2 py-1 text-sm font-medium text-foreground",children:J.name});return R(Rf,{modal:!1,children:[R(Uf,{className:"flex items-center gap-1 truncate rounded px-2 py-1 text-sm font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground",children:[f("span",{className:"truncate",children:J.name}),J.version!==void 0&&R(wf,{variant:"outline",className:"px-1 py-0 text-xs shrink-0",children:["v",J.version]}),f(Mf,{className:"h-4 w-4 shrink-0"})]}),R(Hf,{className:"w-56",align:"start",children:[r&&(nf?R(Jf,{children:[f(Wf,{className:"flex items-center gap-2",children:f("span",{children:Y.download()})}),f(zf,{children:R(Xf,{className:"w-48",children:[f(Ff,{children:Y.download()}),G?.videoTranscodes?.map((S)=>{let U=Math.max(S.width,S.height),Z=`${S.height}p`;if(U>=3840)Z="2160p";else if(U>=1920)Z="1080p";else if(U>=1280)Z="720p";else if(U>=960)Z="540p";else if(U>=640)Z="360p";else if(U>=320)Z="180p";return R(C,{onClick:()=>ff(S.key),className:"flex items-center justify-between",children:[f("span",{children:Z}),f("span",{className:"text-xs text-muted-foreground",children:"MP4"})]},Z)}),G?.originalKey&&R(A,{children:[f(D,{}),R(C,{onClick:()=>ff(G.originalKey),className:"flex items-center justify-between",children:[f("span",{children:"Original"}),f("span",{className:"text-xs text-muted-foreground",children:J.name?.split(".").pop()?.toUpperCase()||"RAW"})]})]})]})})]}):f(C,{onClick:()=>G?.originalKey&&ff(G.originalKey),disabled:!G?.originalKey,children:Y.download()})),P&&i&&f(C,{onClick:i,children:Y.rename()}),P&&a&&f(C,{onClick:a,className:"text-destructive focus:text-destructive",children:Y.delete()}),I&&_&&R(A,{children:[f(D,{}),R(C,{onClick:()=>_(),children:[f(Cf,{className:"h-4 w-4"}),f("span",{children:Y.compare_versions()})]})]}),E&&E.length>0&&R(A,{children:[f(D,{}),R(Jf,{children:[R(Wf,{className:"flex items-center gap-2",children:[f(Vf,{className:"h-4 w-4"}),f("span",{children:"Versions"})]}),f(zf,{children:R(Xf,{className:"w-80 p-1",children:[f("div",{className:"flex flex-col gap-1 max-h-96 overflow-y-auto",children:E.map((S)=>{let U=J.version===S.version;return R(C,{onClick:()=>rf(S.id),className:"flex items-center gap-3 py-2 px-3 rounded-md cursor-pointer focus:bg-accent focus:text-accent-foreground",children:[R("div",{className:"flex-shrink-0 flex items-center justify-center bg-muted dark:bg-muted-foreground/20 text-muted-foreground dark:text-muted-foreground rounded-full px-2 py-0.5 text-xs font-semibold select-none min-w-[2rem]",children:["v",S.version]}),f("div",{className:"h-10 w-16 flex-shrink-0 overflow-hidden rounded-md border border-border bg-muted flex items-center justify-center",children:S.previewUrl?f("img",{src:S.previewUrl,alt:S.name||void 0,className:"h-full w-full object-cover"}):f(Bf,{className:"h-4 w-4 text-muted-foreground"})}),R("div",{className:"flex flex-col flex-1 min-w-0 text-left",children:[f("span",{className:"truncate text-sm font-semibold text-foreground",children:S.name}),f("span",{className:"truncate text-xs text-muted-foreground",children:S.creator?.name||"Unknown"})]}),U&&f(Lf,{className:"h-4 w-4 text-primary ml-auto flex-shrink-0"})]},S.id)})}),f(D,{}),f("div",{className:"p-1",children:f("button",{className:"w-full text-center text-xs font-medium py-2 px-3 rounded-md bg-muted/80 hover:bg-muted text-foreground transition-colors cursor-pointer",onClick:()=>w(!0),children:Y.manage_versions()})})]})})]})]})]})]})}return null};return R("div",{className:"flex h-14 flex-nowrap items-center justify-between gap-2 border-b border-border bg-card px-4 py-2 overflow-hidden",children:[R("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden",children:[!H&&f(k,{variant:"ghost",size:"icon",onClick:()=>n(),className:"md:hidden h-8 w-8 text-foreground hover:bg-accent shrink-0 -ml-2 mr-1","aria-label":"Open navigation menu",children:f(t,{className:"h-5 w-5"})}),!H&&R("div",{className:"hidden md:flex items-center gap-1 shrink-0",children:[f(p,{to:`/teams/${z}`,className:"truncate rounded px-2 py-1 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground text-muted-foreground",children:Y.all_projects()}),f("span",{className:"text-muted-foreground",children:"/"})]}),O||K.length>0?M.path?f(p,{to:M.path,className:"min-w-0 max-w-[45%] md:max-w-none truncate rounded px-1.5 md:px-2 py-1 text-sm font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground shrink",children:M.name}):f("button",{onClick:()=>M.id&&V?.(M.id),className:"min-w-0 max-w-[45%] md:max-w-none truncate rounded px-1.5 md:px-2 py-1 text-sm font-medium text-foreground transition-colors hover:bg-accent hover:text-accent-foreground text-left shrink cursor-pointer",children:M.name}):f("span",{className:"min-w-0 flex-1 truncate rounded px-1.5 md:px-2 py-1 text-sm font-medium text-foreground",children:M.name}),Nf.length>0&&R("div",{className:"flex md:hidden items-center gap-1 shrink-0",children:[f("span",{className:"text-muted-foreground shrink-0",children:"/"}),R(Rf,{modal:!1,children:[f(Uf,{asChild:!0,children:f("button",{className:"text-muted-foreground hover:text-foreground text-sm font-medium px-1.5 py-0.5 rounded hover:bg-accent shrink-0 cursor-pointer","aria-label":"Show omitted folders",children:"..."})}),f(Hf,{align:"start",children:Nf.map((S,U)=>f(C,{asChild:!0,children:S.path?f(p,{to:S.path,className:"cursor-pointer",children:S.name}):f("button",{onClick:()=>S.id&&V?.(S.id),className:"cursor-pointer w-full text-left",children:S.name})},U))})]}),f("span",{className:"text-muted-foreground shrink-0",children:"/"})]}),K.slice().reverse().map((S)=>{let U=H?void 0:`/projects/${N}/folders/${S.id}`;return R("div",{className:"hidden md:flex items-center gap-1",children:[f("span",{className:"text-muted-foreground",children:"/"}),U?f(p,{to:U,className:"truncate rounded px-2 py-1 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground text-foreground",children:S.name}):f("button",{onClick:()=>S.id&&V?.(S.id),className:"truncate rounded px-2 py-1 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground text-foreground",children:S.name})]},S.id)}),(O||!O&&K.length>0)&&R("div",{className:"flex items-center gap-1 min-w-0 shrink overflow-hidden",children:[f("span",{className:Sf("text-muted-foreground shrink-0",Nf.length>0?"hidden md:inline":"inline"),children:"/"}),O?of():$f&&f("span",{className:"min-w-0 truncate rounded px-2 py-1 text-sm font-medium text-foreground",children:$f.name})]}),s&&R(k,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs gap-1.5 text-muted-foreground hover:text-foreground hover:bg-muted ml-1 cursor-pointer shrink-0",onClick:()=>e(!0),title:Y.linked_tasks(),children:[f(Ef,{className:"w-4 h-4"}),_f>0&&f("span",{className:"inline-flex items-center justify-center px-1.5 py-0.2 text-[10px] font-semibold rounded-full bg-muted-foreground/15 text-foreground",children:_f})]})]}),s&&x&&Q&&f(cf,{teamId:z,assetId:Q,assetName:J.name,isOpen:x,onClose:()=>e(!1)}),W&&E&&E.length>0&&f(uf,{open:o,onOpenChange:w,stackId:W,canEdit:P,onStackDissolved:(S)=>{w(!1),h({to:"/projects/$projectId/files/$fileId",params:{projectId:N,fileId:S}})},onVersionRemoved:(S,U)=>{if((J.version?E.find(($)=>$.version===J.version)?.id:void 0)===S){let $=U[0];if($)h({to:"/projects/$projectId/files/$fileId",params:{projectId:N,fileId:W},search:(ef)=>({...ef,version:$.id})})}}}),R("div",{className:"hidden md:flex items-center gap-2",children:[R("div",{className:"flex flex-shrink-0 items-center gap-1 rounded-md border border-border bg-background p-1",children:[!W&&!H&&c&&f("button",{onClick:c,className:"rounded p-1.5 text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",title:u?"Show Left Sidebar":"Hide Left Sidebar",children:u?f(Tf,{className:"h-4 w-4"}):f(pf,{className:"h-4 w-4 fill-primary stroke-0"})}),!W&&!H&&y&&F&&R(A,{children:[f("button",{onClick:()=>F("card"),className:`rounded p-1.5 transition-colors ${y==="card"?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"}`,title:"Card View",children:f(bf,{className:"h-4 w-4"})}),f("button",{onClick:()=>F("list"),className:`rounded p-1.5 transition-colors ${y==="list"?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"}`,title:"List View",children:f(hf,{className:"h-4 w-4"})})]}),f("button",{onClick:m,className:`rounded p-1.5 transition-colors ${!B&&!L?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"}`,title:B?"Show Right Sidebar":"Hide Right Sidebar",children:!B&&!L?f(Df,{className:"h-4 w-4 fill-primary stroke-0"}):f(Af,{className:"h-4 w-4"})})]}),!H&&l&&f(Of,{children:R(gf,{children:[f(vf,{asChild:!0,children:f("span",{children:f("button",{disabled:!1,onClick:l,className:Sf("h-9 w-9 flex items-center justify-center rounded-full border border-border bg-background transition-colors",L?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground",!1),children:L?f(kf,{className:"h-6 w-6 text-primary transition-colors"}):f(Kf,{className:"h-6 w-6 text-muted-foreground transition-colors"})})})}),f(yf,{children:f("p",{children:L?Y.hide_chatbot():Y.show_chatbot()})})]})})]})]})}function yN(){let{projectState:z}=lf(),N=If(),{isChatbotOpen:g,setIsChatbotOpen:K}=xf();if(df()&&z?.fileId)return null;if(!z)return f(NN,{});let{teamId:v,projectId:q,projectName:y,ancestorFolders:F,currentAsset:u,isRootFolder:c,customTerminalBreadcrumb:B,fileId:m,downloadInfo:L,versions:l,isPublic:H,shareId:V,allowDownload:i,onFolderClick:a,onRename:W,onDelete:b,compareMode:r,canCompareVersions:G,onCompareVersions:E}=z,X=!!m,I=!!B,_=!!V&&!X,h=X?N.fileViewLeftSidebarCollapsed:_?N.shareConfigLeftSidebarCollapsed:N.fileListLeftSidebarCollapsed,P=H?void 0:()=>X?N.setFileViewLeftSidebarCollapsed(!N.fileViewLeftSidebarCollapsed):_?N.setShareConfigLeftSidebarCollapsed(!N.shareConfigLeftSidebarCollapsed):N.setFileListLeftSidebarCollapsed(!N.fileListLeftSidebarCollapsed),n=H&&z.isRightSidebarCollapsed!==void 0?z.isRightSidebarCollapsed:X?N.fileViewRightSidebarCollapsed:_?N.shareConfigRightSidebarCollapsed:N.fileListRightSidebarCollapsed,o=H&&z.onRightSidebarToggle?z.onRightSidebarToggle:()=>{if(!H&&g)if(K(!1),X)N.setFileViewRightSidebarCollapsed(!1);else if(_)N.setShareConfigRightSidebarCollapsed(!1);else N.setFileListRightSidebarCollapsed(!1);else if(X)N.setFileViewRightSidebarCollapsed(!N.fileViewRightSidebarCollapsed);else if(_)N.setShareConfigRightSidebarCollapsed(!N.shareConfigRightSidebarCollapsed);else N.setFileListRightSidebarCollapsed(!N.fileListRightSidebarCollapsed)},w=H?void 0:()=>{K(!g)},x=q?N.viewModes[q]??"card":"card";return f(mf,{teamId:v,projectId:q,projectName:y,ancestorFolders:F,currentAsset:u,isRootFolder:c,customTerminalBreadcrumb:B,displayStyle:X||_||I?void 0:x,onDisplayStyleChange:X||_||I?void 0:H?void 0:(Q)=>{if(q)N.setViewMode(q,Q)},isLeftSidebarCollapsed:h,onLeftSidebarToggle:P,isRightSidebarCollapsed:n,onRightSidebarToggle:o,isChatbotOpen:!H&&g,onChatbotToggle:w,isPublic:H,shareId:V,allowDownload:i,fileId:m,downloadInfo:L,versions:l,onFolderClick:a,onRename:W,onDelete:b,compareMode:r,canCompareVersions:G,onCompareVersions:E})}function NN(){let{toggleMobileMenu:z}=d();return R("div",{className:"flex h-14 items-center justify-between border-b border-border bg-card px-4 py-2 flex-shrink-0",children:[f(k,{variant:"ghost",size:"icon",onClick:z,className:"md:hidden text-foreground hover:bg-accent -ml-2","aria-label":"Open navigation menu",children:f(t,{className:"h-5 w-5"})}),f("div",{className:"flex flex-1 items-center justify-center",children:f(af,{className:"w-10 h-10 text-orange-600"})}),f("div",{className:"w-9 md:hidden"})]})}
|
|
2
|
+
export{d as Ne,yN as Oe};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{B as
|
|
1
|
+
import{pg as A}from"./chunk-63y0eb07.js";import{Gi as z}from"./chunk-h0fxysxs.js";import{cj as v,mj as w}from"./chunk-yp9hvkc5.js";var B=(b)=>({queryKey:["projects",b],queryFn:async()=>{let h=await z.api.projects[":projectId"].$get({param:{projectId:b}});if(!h.ok)throw Error("Failed to fetch project");return await h.json()}}),H=w("/projects/$projectId/recents")({loader:({context:{queryClient:b},params:{projectId:h}})=>b.ensureQueryData(B(h)),pendingComponent:()=>v(A,{})});
|
|
2
|
+
export{B as xe,H as ye};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{B as
|
|
1
|
+
import{pg as A}from"./chunk-63y0eb07.js";import{Gi as z}from"./chunk-h0fxysxs.js";import{cj as v,mj as w}from"./chunk-yp9hvkc5.js";var B=(b)=>({queryKey:["projects",b],queryFn:async()=>{let h=await z.api.projects[":projectId"].$get({param:{projectId:b}});if(!h.ok)throw Error("Failed to fetch project");return await h.json()}}),H=w("/projects/$projectId/shares/")({loader:({context:{queryClient:b},params:{projectId:h}})=>b.ensureQueryData(B(h)),pendingComponent:()=>v(A,{})});
|
|
2
|
+
export{B as De,H as Ee};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
function k(q,J,H){let Q=J[H];if(typeof Q!=="string")throw Error(`Grammar tool call "${q}" requires argument "${H}" to be a string.`);return Q}function d(q,J,H,Q){if(q.closed){if(Q&&H===q.input)return;throw Error(`grammar tool input for property "${J}" changed after it was closed`)}if(!H.startsWith(q.input))throw Error(`grammar tool input for property "${J}" changed non-monotonically`);let V=H.slice(q.input.length);if(!Q&&V.length===0)return;let Z="";if(!q.started)Z+=`{${JSON.stringify(J)}:"`,q.started=!0;if(Z+=JSON.stringify(V).slice(1,-1),q.input=H,Q)Z+='"}',q.closed=!0;return Z}function P(q){let J=q.parameters;if(J.type!=="object")throw Error("grammar constrained sampling requires an object parameter schema");if(!Array.isArray(J.required)||J.required.length!==1||typeof J.required[0]!=="string")throw Error("grammar constrained sampling requires exactly one required string property");let H=J.required[0];if(!J.properties?.[H])throw Error(`grammar constrained sampling requires a properties entry for ${H}`);if(J.properties[H]?.type!=="string")throw Error(`grammar constrained sampling property ${H} must have type string`);return H}function u(q,J){let H=q.constrainedSampling;if(!H||H.type!=="json_schema")return;if(J)return!0;if(H.strict==="require")throw Error(`Tool "${q.name}" requires JSON-schema constrained sampling, but strict tools are unsupported.`);return}function C(q,J){let H=q.constrainedSampling;if(!H||H.type!=="grammar")return;if(!J)return;let Q=H.variants.openai_lark,V=H.variants.openai_regex,Z=typeof Q==="string"&&Q.trim().length>0,E=typeof V==="string"&&V.trim().length>0;if(!Z&&!E)throw Error(`Tool "${q.name}" cannot use grammar constrained sampling: no supported grammar variant was provided.`);try{return{format:Z?"lark":"regex",definition:Z?Q:V,inputProperty:P(q)}}catch(Y){let j=Y instanceof Error?Y.message:String(Y);throw Error(`Tool "${q.name}" cannot use grammar constrained sampling: ${j}.`)}}function c(q,J){let H=new Map;for(let Q of q??[]){let V=C(Q,J);if(V)H.set(Q.name,V.inputProperty)}return H}function R(q){return q.totalTokens||q.input+q.output+q.cacheRead+q.cacheWrite}function v(q){try{return JSON.stringify(q)??"undefined"}catch{return"[unserializable]"}}function h(q){if(typeof q==="string")return q.length;let J=0;for(let H of q)J+=H.type==="text"?H.text.length:4800;return J}function D(q){return Math.ceil(q.length/4)}function O(q){return Math.ceil(h(q)/4)}function _(q){let J=0;if(q.role==="user")return O(q.content);if(q.role==="toolResult")return O(q.content);for(let H of q.content)if(H.type==="text")J+=H.text.length;else if(H.type==="thinking")J+=H.thinking.length;else J+=H.name.length+v(H.arguments).length;return Math.ceil(J/4)}function M(q){let J=Number.NEGATIVE_INFINITY,H;for(let Q=0;Q<q.length;Q++){let V=q[Q];if(V.role==="assistant"){let Z=V;if(Z.timestamp>=J&&Z.stopReason!=="aborted"&&Z.stopReason!=="error"&&R(Z.usage)>0)H={usage:Z.usage,index:Q}}J=Math.max(J,V.timestamp)}return H}function A(q){let J=M(q);if(J){let Q=R(J.usage),V=0;for(let Z=J.index+1;Z<q.length;Z++)V+=_(q[Z]);return{tokens:Q+V,usageTokens:Q,trailingTokens:V,lastUsageIndex:J.index}}let H=0;for(let Q of q)H+=_(Q);return{tokens:H,usageTokens:0,trailingTokens:H,lastUsageIndex:null}}function N(q){if(!q||q.length===0)return 0;return D(v(q))}function I(q){return Array.isArray(q)}function z(q){if(I(q))return A(q);let J=A(q.messages);if(J.lastUsageIndex!==null){let Q=new Set(q.messages.slice(J.lastUsageIndex+1).filter((Z)=>Z.role==="toolResult").flatMap((Z)=>Z.addedToolNames??[])),V=N(q.tools?.filter((Z)=>Q.has(Z.name)));return{tokens:J.tokens+V,usageTokens:J.usageTokens,trailingTokens:J.trailingTokens+V,lastUsageIndex:J.lastUsageIndex}}let H=(q.systemPrompt?D(q.systemPrompt):0)+N(q.tools);return{tokens:J.tokens+H,usageTokens:J.usageTokens,trailingTokens:J.trailingTokens+H,lastUsageIndex:J.lastUsageIndex}}var b=4096,S=1;function x(q,J,H){if(q.contextWindow<=0)return Math.max(S,H);let Q=q.contextWindow-z(J).tokens-b;return Math.min(H,Math.max(S,Q))}function m(q,J,H,Q){return{temperature:H?.temperature,maxTokens:x(q,J,H?.maxTokens??q.maxTokens),signal:H?.signal,apiKey:Q||H?.apiKey,transport:H?.transport,cacheRetention:H?.cacheRetention,sessionId:H?.sessionId,headers:H?.headers,onPayload:H?.onPayload,onResponse:H?.onResponse,timeoutMs:H?.timeoutMs,websocketConnectTimeoutMs:H?.websocketConnectTimeoutMs,maxRetries:H?.maxRetries,maxRetryDelayMs:H?.maxRetryDelayMs,metadata:H?.metadata,env:H?.env}}function T(q){return q==="xhigh"||q==="max"?"high":q}function i(q,J,H,Q){let Z={...{minimal:1024,low:2048,medium:8192,high:16384},...Q},E=1024,Y=T(H),j=Z[Y],X=q===void 0?J:Math.min(q+j,J);if(X<=j)j=Math.max(0,X-1024);return{maxTokens:X,thinkingBudget:j}}function y(q,J){let H=[],Q=!1;for(let V of q){if(V.type==="image"){if(!Q)H.push({type:"text",text:J});Q=!0;continue}H.push(V),Q=V.text===J}return H}function f(q,J){if(J.input.includes("image"))return q;return q.map((H)=>{if(H.role==="user"&&Array.isArray(H.content))return{...H,content:y(H.content,"(image omitted: model does not support images)")};if(H.role==="toolResult")return{...H,content:y(H.content,"(tool image omitted: model does not support images)")};return H})}function l(q,J,H){let Q=new Map,V=q.map(($)=>$.content==null?{...$,content:[]}:$),E=f(V,J).map(($)=>{if($.role==="user")return $;if($.role==="toolResult"){let w=Q.get($.toolCallId);if(w&&w!==$.toolCallId)return{...$,toolCallId:w};return $}if($.role==="assistant"){let w=$,U=w.provider===J.provider&&w.api===J.api&&w.model===J.id,B=w.content.flatMap((F)=>{if(F.type==="thinking"){if(F.redacted)return U?F:[];if(U&&F.thinkingSignature)return F;if(!F.thinking||F.thinking.trim()==="")return[];if(U)return F;return{type:"text",text:F.thinking}}if(F.type==="text"){if(U)return F;return{type:"text",text:F.text}}if(F.type==="toolCall"){let K=F,W=K;if(!U&&K.thoughtSignature)W={...K},delete W.thoughtSignature;if(!U&&H){let L=H(K.id,J,w);if(L!==K.id)Q.set(K.id,L),W={...W,id:L}}return W}return F});return{...w,content:B}}return $}),Y=[],j=[],X=new Set,G=()=>{if(j.length>0){for(let $ of j)if(!X.has($.id))Y.push({role:"toolResult",toolCallId:$.id,toolName:$.name,content:[{type:"text",text:"No result provided"}],isError:!0,timestamp:Date.now()});j=[],X=new Set}};for(let $=0;$<E.length;$++){let w=E[$];if(w.role==="assistant"){G();let U=w;if(U.stopReason==="error"||U.stopReason==="aborted")continue;let B=U.content.filter((F)=>F.type==="toolCall");if(B.length>0)j=B,X=new Set;Y.push(w)}else if(w.role==="toolResult")X.add(w.toolCallId),Y.push(w);else if(w.role==="user")G(),Y.push(w);else Y.push(w)}return G(),Y}
|
|
3
|
-
export{k as
|
|
3
|
+
export{k as Ym,d as Zm,u as _m,C as $m,c as an,x as bn,m as cn,i as dn,l as en};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{mn as pt}from"./chunk-p49h5fxs.js";var Fe={};pt(Fe,{encode:()=>y,decode:()=>W});var X=new TextEncoder,C=new TextDecoder;function g(...e){let t=e.reduce((i,{length:a})=>i+a,0),r=new Uint8Array(t),n=0;for(let i of e)r.set(i,n),n+=i.length;return r}function Ge(e,t,r){if(t<0||t>=4294967296)throw RangeError(`value must be >= 0 and <= 4294967295. Received ${t}`);e.set([t>>>24,t>>>16,t>>>8,t&255],r)}function Ve(e){let t=Math.floor(e/4294967296),r=e%4294967296,n=new Uint8Array(8);return Ge(n,t,0),Ge(n,r,4),n}function Ce(e){let t=new Uint8Array(4);return Ge(t,e),t}function w(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n>127)throw TypeError("non-ASCII string encountered in encode()");t[r]=n}return t}function de(e){if(Uint8Array.prototype.toBase64)return e.toBase64();let t=32768,r=[];for(let n=0;n<e.length;n+=t)r.push(String.fromCharCode.apply(null,e.subarray(n,n+t)));return btoa(r.join(""))}function xe(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function W(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof e==="string"?e:C.decode(e),{alphabet:"base64url"});let t=e;if(t instanceof Uint8Array)t=C.decode(t);t=t.replace(/-/g,"+").replace(/_/g,"/");try{return xe(t)}catch{throw TypeError("The input to be decoded is not correctly encoded.")}}function y(e){let t=e;if(typeof t==="string")t=X.encode(t);if(Uint8Array.prototype.toBase64)return t.toBase64({alphabet:"base64url",omitPadding:!0});return de(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var v=(e,t="algorithm.name")=>TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`),N=(e,t)=>e.name===t;function mr(e){return parseInt(e.name.slice(4),10)}function Pe(e,t){if(mr(e.hash)!==t)throw v(`SHA-${t}`,"algorithm.hash")}function yr(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw Error("unreachable")}}function ut(e,t){if(t&&!e.usages.includes(t))throw TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)}function dt(e,t,r){switch(t){case"HS256":case"HS384":case"HS512":{if(!N(e.algorithm,"HMAC"))throw v("HMAC");Pe(e.algorithm,parseInt(t.slice(2),10));break}case"RS256":case"RS384":case"RS512":{if(!N(e.algorithm,"RSASSA-PKCS1-v1_5"))throw v("RSASSA-PKCS1-v1_5");Pe(e.algorithm,parseInt(t.slice(2),10));break}case"PS256":case"PS384":case"PS512":{if(!N(e.algorithm,"RSA-PSS"))throw v("RSA-PSS");Pe(e.algorithm,parseInt(t.slice(2),10));break}case"Ed25519":case"EdDSA":{if(!N(e.algorithm,"Ed25519"))throw v("Ed25519");break}case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":{if(!N(e.algorithm,t))throw v(t);break}case"ES256":case"ES384":case"ES512":{if(!N(e.algorithm,"ECDSA"))throw v("ECDSA");let n=yr(t);if(e.algorithm.namedCurve!==n)throw v(n,"algorithm.namedCurve");break}default:throw TypeError("CryptoKey does not support this operation")}ut(e,r)}function J(e,t,r){switch(t){case"A128GCM":case"A192GCM":case"A256GCM":{if(!N(e.algorithm,"AES-GCM"))throw v("AES-GCM");let n=parseInt(t.slice(1,4),10);if(e.algorithm.length!==n)throw v(n,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if(!N(e.algorithm,"AES-KW"))throw v("AES-KW");let n=parseInt(t.slice(1,4),10);if(e.algorithm.length!==n)throw v(n,"algorithm.length");break}case"ECDH":{switch(e.algorithm.name){case"ECDH":case"X25519":break;default:throw v("ECDH or X25519")}break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if(!N(e.algorithm,"PBKDF2"))throw v("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{if(!N(e.algorithm,"RSA-OAEP"))throw v("RSA-OAEP");Pe(e.algorithm,parseInt(t.slice(9),10)||1);break}default:throw TypeError("CryptoKey does not support this operation")}ut(e,r)}function ft(e,t,...r){if(r=r.filter(Boolean),r.length>2){let n=r.pop();e+=`one of type ${r.join(", ")}, or ${n}.`}else if(r.length===2)e+=`one of type ${r[0]} or ${r[1]}.`;else e+=`of type ${r[0]}.`;if(t==null)e+=` Received ${t}`;else if(typeof t==="function"&&t.name)e+=` Received function ${t.name}`;else if(typeof t==="object"&&t!=null){if(t.constructor?.name)e+=` Received an instance of ${t.constructor.name}`}return e}var D=(e,...t)=>ft("Key must be ",e,...t),ze=(e,t,...r)=>ft(`Key for the ${e} algorithm must be `,t,...r);var ht={};pt(ht,{JWTInvalid:()=>K,JWTExpired:()=>fe,JWTClaimValidationFailed:()=>H,JWSSignatureVerificationFailed:()=>ne,JWSInvalid:()=>h,JWKSTimeout:()=>Te,JWKSNoMatchingKey:()=>re,JWKSMultipleMatchingKeys:()=>He,JWKSInvalid:()=>he,JWKInvalid:()=>We,JWEInvalid:()=>c,JWEDecryptionFailed:()=>V,JOSENotSupported:()=>d,JOSEError:()=>x,JOSEAlgNotAllowed:()=>Y});class x extends Error{static code="ERR_JOSE_GENERIC";code="ERR_JOSE_GENERIC";constructor(e,t){super(e,t);this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}class H extends x{static code="ERR_JWT_CLAIM_VALIDATION_FAILED";code="ERR_JWT_CLAIM_VALIDATION_FAILED";claim;reason;payload;constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}});this.claim=r,this.reason=n,this.payload=t}}class fe extends x{static code="ERR_JWT_EXPIRED";code="ERR_JWT_EXPIRED";claim;reason;payload;constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}});this.claim=r,this.reason=n,this.payload=t}}class Y extends x{static code="ERR_JOSE_ALG_NOT_ALLOWED";code="ERR_JOSE_ALG_NOT_ALLOWED"}class d extends x{static code="ERR_JOSE_NOT_SUPPORTED";code="ERR_JOSE_NOT_SUPPORTED"}class V extends x{static code="ERR_JWE_DECRYPTION_FAILED";code="ERR_JWE_DECRYPTION_FAILED";constructor(e="decryption operation failed",t){super(e,t)}}class c extends x{static code="ERR_JWE_INVALID";code="ERR_JWE_INVALID"}class h extends x{static code="ERR_JWS_INVALID";code="ERR_JWS_INVALID"}class K extends x{static code="ERR_JWT_INVALID";code="ERR_JWT_INVALID"}class We extends x{static code="ERR_JWK_INVALID";code="ERR_JWK_INVALID"}class he extends x{static code="ERR_JWKS_INVALID";code="ERR_JWKS_INVALID"}class re extends x{static code="ERR_JWKS_NO_MATCHING_KEY";code="ERR_JWKS_NO_MATCHING_KEY";constructor(e="no applicable key found in the JSON Web Key Set",t){super(e,t)}}class He extends x{[Symbol.asyncIterator];static code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";constructor(e="multiple matching keys found in the JSON Web Key Set",t){super(e,t)}}class Te extends x{static code="ERR_JWKS_TIMEOUT";code="ERR_JWKS_TIMEOUT";constructor(e="request timed out",t){super(e,t)}}class ne extends x{static code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";constructor(e="signature verification failed",t){super(e,t)}}function ie(e){if(!M(e))throw Error("CryptoKey instance expected")}var M=(e)=>{if(e?.[Symbol.toStringTag]==="CryptoKey")return!0;try{return e instanceof CryptoKey}catch{return!1}},q=(e)=>e?.[Symbol.toStringTag]==="KeyObject",me=(e)=>M(e)||q(e);function Ie(e){switch(e){case"A128GCM":return 128;case"A192GCM":return 192;case"A256GCM":case"A128CBC-HS256":return 256;case"A192CBC-HS384":return 384;case"A256CBC-HS512":return 512;default:throw new d(`Unsupported JWE Algorithm: ${e}`)}}var _=(e)=>crypto.getRandomValues(new Uint8Array(Ie(e)>>3));function ve(e,t){let r=e.byteLength<<3;if(r!==t)throw new c(`Invalid Content Encryption Key length. Expected ${t} bits, got ${r} bits`)}function mt(e){switch(e){case"A128GCM":case"A128GCMKW":case"A192GCM":case"A192GCMKW":case"A256GCM":case"A256GCMKW":return 96;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return 128;default:throw new d(`Unsupported JWE Algorithm: ${e}`)}}var lr=(e)=>crypto.getRandomValues(new Uint8Array(mt(e)>>3));function yt(e,t){if(t.length<<3!==mt(e))throw new c("Invalid Initialization Vector length")}async function lt(e,t,r){if(!(t instanceof Uint8Array))throw TypeError(D(t,"Uint8Array"));let n=parseInt(e.slice(1,4),10),i=await crypto.subtle.importKey("raw",t.subarray(n>>3),"AES-CBC",!1,[r]),a=await crypto.subtle.importKey("raw",t.subarray(0,n>>3),{hash:`SHA-${n<<1}`,name:"HMAC"},!1,["sign"]);return{encKey:i,macKey:a,keySize:n}}async function St(e,t,r){return new Uint8Array((await crypto.subtle.sign("HMAC",e,t)).slice(0,r>>3))}async function Sr(e,t,r,n,i){let{encKey:a,macKey:s,keySize:o}=await lt(e,r,"encrypt"),p=new Uint8Array(await crypto.subtle.encrypt({iv:n,name:"AES-CBC"},a,t)),u=g(i,n,p,Ve(i.length<<3)),f=await St(s,u,o);return{ciphertext:p,tag:f,iv:n}}async function wr(e,t){if(!(e instanceof Uint8Array))throw TypeError("First argument must be a buffer");if(!(t instanceof Uint8Array))throw TypeError("Second argument must be a buffer");let r={name:"HMAC",hash:"SHA-256"},n=await crypto.subtle.generateKey(r,!1,["sign"]),i=new Uint8Array(await crypto.subtle.sign(r,n,e)),a=new Uint8Array(await crypto.subtle.sign(r,n,t)),s=0,o=-1;while(++o<32)s|=i[o]^a[o];return s===0}async function Ar(e,t,r,n,i,a){let{encKey:s,macKey:o,keySize:p}=await lt(e,t,"decrypt"),u=g(a,n,r,Ve(a.length<<3)),f=await St(o,u,p),l;try{l=await wr(i,f)}catch{}if(!l)throw new V;let E;try{E=new Uint8Array(await crypto.subtle.decrypt({iv:n,name:"AES-CBC"},s,r))}catch{}if(!E)throw new V;return E}async function Er(e,t,r,n,i){let a;if(r instanceof Uint8Array)a=await crypto.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]);else J(r,e,"encrypt"),a=r;let s=new Uint8Array(await crypto.subtle.encrypt({additionalData:i,iv:n,name:"AES-GCM",tagLength:128},a,t)),o=s.slice(-16);return{ciphertext:s.slice(0,-16),tag:o,iv:n}}async function br(e,t,r,n,i,a){let s;if(t instanceof Uint8Array)s=await crypto.subtle.importKey("raw",t,"AES-GCM",!1,["decrypt"]);else J(t,e,"decrypt"),s=t;try{return new Uint8Array(await crypto.subtle.decrypt({additionalData:a,iv:n,name:"AES-GCM",tagLength:128},s,g(r,i)))}catch{throw new V}}var wt="Unsupported JWE Content Encryption Algorithm";async function Je(e,t,r,n,i){if(!M(r)&&!(r instanceof Uint8Array))throw TypeError(D(r,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(n)yt(e,n);else n=lr(e);switch(e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":if(r instanceof Uint8Array)ve(r,parseInt(e.slice(-3),10));return Sr(e,t,r,n,i);case"A128GCM":case"A192GCM":case"A256GCM":if(r instanceof Uint8Array)ve(r,parseInt(e.slice(1,4),10));return Er(e,t,r,n,i);default:throw new d(wt)}}async function Re(e,t,r,n,i,a){if(!M(t)&&!(t instanceof Uint8Array))throw TypeError(D(t,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(!n)throw new c("JWE Initialization Vector missing");if(!i)throw new c("JWE Authentication Tag missing");switch(yt(e,n),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":if(t instanceof Uint8Array)ve(t,parseInt(e.slice(-3),10));return Ar(e,t,r,n,i,a);case"A128GCM":case"A192GCM":case"A256GCM":if(t instanceof Uint8Array)ve(t,parseInt(e.slice(1,4),10));return br(e,t,r,n,i,a);default:throw new d(wt)}}var De=Symbol();function S(e,t){if(e)throw TypeError(`${t} can only be called once`)}function I(e,t,r){try{return W(e)}catch{throw new r(`Failed to base64url decode the ${t}`)}}async function Ue(e,t){let r=`SHA-${e.slice(-3)}`;return new Uint8Array(await crypto.subtle.digest(r,t))}var gr=(e)=>typeof e==="object"&&e!==null;function m(e){if(!gr(e)||Object.prototype.toString.call(e)!=="[object Object]")return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;while(Object.getPrototypeOf(t)!==null)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function L(...e){let t=e.filter(Boolean);if(t.length===0||t.length===1)return!0;let r;for(let n of t){let i=Object.keys(n);if(!r||r.size===0){r=new Set(i);continue}for(let a of i){if(r.has(a))return!1;r.add(a)}}return!0}var Q=(e)=>m(e)&&typeof e.kty==="string",At=(e)=>e.kty!=="oct"&&(e.kty==="AKP"&&typeof e.priv==="string"||typeof e.d==="string"),Et=(e)=>e.kty!=="oct"&&e.d===void 0&&e.priv===void 0,bt=(e)=>e.kty==="oct"&&typeof e.k==="string";function gt(e,t){if(e.algorithm.length!==parseInt(t.slice(1,4),10))throw TypeError(`Invalid key size for alg: ${t}`)}function Kt(e,t,r){if(e instanceof Uint8Array)return crypto.subtle.importKey("raw",e,"AES-KW",!0,[r]);return J(e,t,r),e}async function ye(e,t,r){let n=await Kt(t,e,"wrapKey");gt(n,e);let i=await crypto.subtle.importKey("raw",r,{hash:"SHA-256",name:"HMAC"},!0,["sign"]);return new Uint8Array(await crypto.subtle.wrapKey("raw",i,n,"AES-KW"))}async function le(e,t,r){let n=await Kt(t,e,"unwrapKey");gt(n,e);let i=await crypto.subtle.unwrapKey("raw",r,n,"AES-KW",{hash:"SHA-256",name:"HMAC"},!0,["sign"]);return new Uint8Array(await crypto.subtle.exportKey("raw",i))}function Xe(e){return g(Ce(e.length),e)}async function Cr(e,t,r){let n=t>>3,i=32,a=Math.ceil(n/32),s=new Uint8Array(a*32);for(let o=1;o<=a;o++){let p=new Uint8Array(4+e.length+r.length);p.set(Ce(o),0),p.set(e,4),p.set(r,4+e.length);let u=await Ue("sha256",p);s.set(u,(o-1)*32)}return s.slice(0,n)}async function Ye(e,t,r,n,i=new Uint8Array,a=new Uint8Array){J(e,"ECDH"),J(t,"ECDH","deriveBits");let s=Xe(w(r)),o=Xe(i),p=Xe(a),u=Ce(n),f=new Uint8Array,l=g(s,o,p,u,f),E=new Uint8Array(await crypto.subtle.deriveBits({name:e.algorithm.name,public:e},t,xr(e)));return Cr(E,n,l)}function xr(e){if(e.algorithm.name==="X25519")return 256;return Math.ceil(parseInt(e.algorithm.namedCurve.slice(-3),10)/8)<<3}function qe(e){switch(e.algorithm.namedCurve){case"P-256":case"P-384":case"P-521":return!0;default:return e.algorithm.name==="X25519"}}function Wr(e,t){if(e instanceof Uint8Array)return crypto.subtle.importKey("raw",e,"PBKDF2",!1,["deriveBits"]);return J(e,t,"deriveBits"),e}var Hr=(e,t)=>g(w(e),Uint8Array.of(0),t);async function xt(e,t,r,n){if(!(e instanceof Uint8Array)||e.length<8)throw new c("PBES2 Salt Input must be 8 or more octets");if(!Number.isSafeInteger(r)||Math.sign(r)!==1)throw new c("PBES2 Count Input must be a positive integer");let i=Hr(t,e),a=parseInt(t.slice(13,16),10),s={hash:`SHA-${t.slice(8,11)}`,iterations:r,name:"PBKDF2",salt:i},o=await Wr(n,t);return new Uint8Array(await crypto.subtle.deriveBits(s,o,a))}async function Pt(e,t,r,n=2048,i=crypto.getRandomValues(new Uint8Array(16))){let a=await xt(i,e,n,t);return{encryptedKey:await ye(e.slice(-6),a,r),p2c:n,p2s:y(i)}}async function Wt(e,t,r,n,i){let a=await xt(i,e,n,t);return le(e.slice(-6),a,r)}function Se(e,t){if(e.startsWith("RS")||e.startsWith("PS")){let{modulusLength:r}=t.algorithm;if(typeof r!=="number"||r<2048)throw TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}}function Ht(e,t){let r=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:parseInt(e.slice(-3),10)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:t.namedCurve};case"Ed25519":case"EdDSA":return{name:"Ed25519"};case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":return{name:e};default:throw new d(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}async function Tt(e,t,r){if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw TypeError(D(t,"CryptoKey","KeyObject","JSON Web Key"));return crypto.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[r])}return dt(t,e,r),t}async function vt(e,t,r){let n=await Tt(e,t,"sign");Se(e,n);let i=await crypto.subtle.sign(Ht(e,n.algorithm),n,r);return new Uint8Array(i)}async function It(e,t,r,n){let i=await Tt(e,t,"verify");Se(e,i);let a=Ht(e,i.algorithm);try{return await crypto.subtle.verify(a,i,r,n)}catch{return!1}}var Jt=(e)=>{switch(e){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new d(`alg ${e} is not supported either by JOSE or your javascript runtime`)}};async function Rt(e,t,r){return J(t,e,"encrypt"),Se(e,t),new Uint8Array(await crypto.subtle.encrypt(Jt(e),t,r))}async function Dt(e,t,r){return J(t,e,"decrypt"),Se(e,t),new Uint8Array(await crypto.subtle.decrypt(Jt(e),t,r))}var Me='Invalid or unsupported JWK "alg" (Algorithm) Parameter value';function Ir(e){let t,r;switch(e.kty){case"AKP":{switch(e.alg){case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":t={name:e.alg},r=e.priv?["sign"]:["verify"];break;default:throw new d(Me)}break}case"RSA":{switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},r=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new d(Me)}break}case"EC":{switch(e.alg){case"ES256":case"ES384":case"ES512":t={name:"ECDSA",namedCurve:{ES256:"P-256",ES384:"P-384",ES512:"P-521"}[e.alg]},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new d(Me)}break}case"OKP":{switch(e.alg){case"Ed25519":case"EdDSA":t={name:"Ed25519"},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new d(Me)}break}default:throw new d('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:r}}async function ae(e){if(!e.alg)throw TypeError('"alg" argument is required when "jwk.alg" is not present');let{algorithm:t,keyUsages:r}=Ir(e),n={...e};if(n.kty!=="AKP")delete n.alg;return delete n.use,crypto.subtle.importKey("jwk",n,t,e.ext??(e.d||e.priv?!1:!0),e.key_ops??r)}var se="given KeyObject instance cannot be used for this algorithm",oe,Ut=async(e,t,r,n=!1)=>{oe||=new WeakMap;let i=oe.get(e);if(i?.[r])return i[r];let a=await ae({...t,alg:r});if(n)Object.freeze(e);if(!i)oe.set(e,{[r]:a});else i[r]=a;return a},Jr=(e,t)=>{oe||=new WeakMap;let r=oe.get(e);if(r?.[t])return r[t];let n=e.type==="public",i=n?!0:!1,a;if(e.asymmetricKeyType==="x25519"){switch(t){case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":break;default:throw TypeError(se)}a=e.toCryptoKey(e.asymmetricKeyType,i,n?[]:["deriveBits"])}if(e.asymmetricKeyType==="ed25519"){if(t!=="EdDSA"&&t!=="Ed25519")throw TypeError(se);a=e.toCryptoKey(e.asymmetricKeyType,i,[n?"verify":"sign"])}switch(e.asymmetricKeyType){case"ml-dsa-44":case"ml-dsa-65":case"ml-dsa-87":{if(t!==e.asymmetricKeyType.toUpperCase())throw TypeError(se);a=e.toCryptoKey(e.asymmetricKeyType,i,[n?"verify":"sign"])}}if(e.asymmetricKeyType==="rsa"){let s;switch(t){case"RSA-OAEP":s="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":s="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":s="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":s="SHA-512";break;default:throw TypeError(se)}if(t.startsWith("RSA-OAEP"))return e.toCryptoKey({name:"RSA-OAEP",hash:s},i,n?["encrypt"]:["decrypt"]);a=e.toCryptoKey({name:t.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:s},i,[n?"verify":"sign"])}if(e.asymmetricKeyType==="ec"){let o=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get(e.asymmetricKeyDetails?.namedCurve);if(!o)throw TypeError(se);let p={ES256:"P-256",ES384:"P-384",ES512:"P-521"};if(p[t]&&o===p[t])a=e.toCryptoKey({name:"ECDSA",namedCurve:o},i,[n?"verify":"sign"]);if(t.startsWith("ECDH-ES"))a=e.toCryptoKey({name:"ECDH",namedCurve:o},i,n?[]:["deriveBits"])}if(!a)throw TypeError(se);if(!r)oe.set(e,{[t]:a});else r[t]=a;return a};async function U(e,t){if(e instanceof Uint8Array)return e;if(M(e))return e;if(q(e)){if(e.type==="secret")return e.export();if("toCryptoKey"in e&&typeof e.toCryptoKey==="function")try{return Jr(e,t)}catch(n){if(n instanceof TypeError)throw n}let r=e.export({format:"jwk"});return Ut(e,r,t)}if(Q(e)){if(e.k)return W(e.k);return Ut(e,e,t,!0)}throw Error("unreachable")}var Mt=(e,t)=>{let r=(e.match(/.{1,64}/g)||[]).join(`
|
|
2
|
+
import{un as pt}from"./chunk-dxyq9h8n.js";var Fe={};pt(Fe,{encode:()=>y,decode:()=>W});var X=new TextEncoder,C=new TextDecoder;function g(...e){let t=e.reduce((i,{length:a})=>i+a,0),r=new Uint8Array(t),n=0;for(let i of e)r.set(i,n),n+=i.length;return r}function Ge(e,t,r){if(t<0||t>=4294967296)throw RangeError(`value must be >= 0 and <= 4294967295. Received ${t}`);e.set([t>>>24,t>>>16,t>>>8,t&255],r)}function Ve(e){let t=Math.floor(e/4294967296),r=e%4294967296,n=new Uint8Array(8);return Ge(n,t,0),Ge(n,r,4),n}function Ce(e){let t=new Uint8Array(4);return Ge(t,e),t}function w(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n>127)throw TypeError("non-ASCII string encountered in encode()");t[r]=n}return t}function de(e){if(Uint8Array.prototype.toBase64)return e.toBase64();let t=32768,r=[];for(let n=0;n<e.length;n+=t)r.push(String.fromCharCode.apply(null,e.subarray(n,n+t)));return btoa(r.join(""))}function xe(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function W(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof e==="string"?e:C.decode(e),{alphabet:"base64url"});let t=e;if(t instanceof Uint8Array)t=C.decode(t);t=t.replace(/-/g,"+").replace(/_/g,"/");try{return xe(t)}catch{throw TypeError("The input to be decoded is not correctly encoded.")}}function y(e){let t=e;if(typeof t==="string")t=X.encode(t);if(Uint8Array.prototype.toBase64)return t.toBase64({alphabet:"base64url",omitPadding:!0});return de(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var v=(e,t="algorithm.name")=>TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`),N=(e,t)=>e.name===t;function mr(e){return parseInt(e.name.slice(4),10)}function Pe(e,t){if(mr(e.hash)!==t)throw v(`SHA-${t}`,"algorithm.hash")}function yr(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw Error("unreachable")}}function ut(e,t){if(t&&!e.usages.includes(t))throw TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)}function dt(e,t,r){switch(t){case"HS256":case"HS384":case"HS512":{if(!N(e.algorithm,"HMAC"))throw v("HMAC");Pe(e.algorithm,parseInt(t.slice(2),10));break}case"RS256":case"RS384":case"RS512":{if(!N(e.algorithm,"RSASSA-PKCS1-v1_5"))throw v("RSASSA-PKCS1-v1_5");Pe(e.algorithm,parseInt(t.slice(2),10));break}case"PS256":case"PS384":case"PS512":{if(!N(e.algorithm,"RSA-PSS"))throw v("RSA-PSS");Pe(e.algorithm,parseInt(t.slice(2),10));break}case"Ed25519":case"EdDSA":{if(!N(e.algorithm,"Ed25519"))throw v("Ed25519");break}case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":{if(!N(e.algorithm,t))throw v(t);break}case"ES256":case"ES384":case"ES512":{if(!N(e.algorithm,"ECDSA"))throw v("ECDSA");let n=yr(t);if(e.algorithm.namedCurve!==n)throw v(n,"algorithm.namedCurve");break}default:throw TypeError("CryptoKey does not support this operation")}ut(e,r)}function J(e,t,r){switch(t){case"A128GCM":case"A192GCM":case"A256GCM":{if(!N(e.algorithm,"AES-GCM"))throw v("AES-GCM");let n=parseInt(t.slice(1,4),10);if(e.algorithm.length!==n)throw v(n,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if(!N(e.algorithm,"AES-KW"))throw v("AES-KW");let n=parseInt(t.slice(1,4),10);if(e.algorithm.length!==n)throw v(n,"algorithm.length");break}case"ECDH":{switch(e.algorithm.name){case"ECDH":case"X25519":break;default:throw v("ECDH or X25519")}break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if(!N(e.algorithm,"PBKDF2"))throw v("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{if(!N(e.algorithm,"RSA-OAEP"))throw v("RSA-OAEP");Pe(e.algorithm,parseInt(t.slice(9),10)||1);break}default:throw TypeError("CryptoKey does not support this operation")}ut(e,r)}function ft(e,t,...r){if(r=r.filter(Boolean),r.length>2){let n=r.pop();e+=`one of type ${r.join(", ")}, or ${n}.`}else if(r.length===2)e+=`one of type ${r[0]} or ${r[1]}.`;else e+=`of type ${r[0]}.`;if(t==null)e+=` Received ${t}`;else if(typeof t==="function"&&t.name)e+=` Received function ${t.name}`;else if(typeof t==="object"&&t!=null){if(t.constructor?.name)e+=` Received an instance of ${t.constructor.name}`}return e}var D=(e,...t)=>ft("Key must be ",e,...t),ze=(e,t,...r)=>ft(`Key for the ${e} algorithm must be `,t,...r);var ht={};pt(ht,{JWTInvalid:()=>K,JWTExpired:()=>fe,JWTClaimValidationFailed:()=>H,JWSSignatureVerificationFailed:()=>ne,JWSInvalid:()=>h,JWKSTimeout:()=>Te,JWKSNoMatchingKey:()=>re,JWKSMultipleMatchingKeys:()=>He,JWKSInvalid:()=>he,JWKInvalid:()=>We,JWEInvalid:()=>c,JWEDecryptionFailed:()=>V,JOSENotSupported:()=>d,JOSEError:()=>x,JOSEAlgNotAllowed:()=>Y});class x extends Error{static code="ERR_JOSE_GENERIC";code="ERR_JOSE_GENERIC";constructor(e,t){super(e,t);this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}class H extends x{static code="ERR_JWT_CLAIM_VALIDATION_FAILED";code="ERR_JWT_CLAIM_VALIDATION_FAILED";claim;reason;payload;constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}});this.claim=r,this.reason=n,this.payload=t}}class fe extends x{static code="ERR_JWT_EXPIRED";code="ERR_JWT_EXPIRED";claim;reason;payload;constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}});this.claim=r,this.reason=n,this.payload=t}}class Y extends x{static code="ERR_JOSE_ALG_NOT_ALLOWED";code="ERR_JOSE_ALG_NOT_ALLOWED"}class d extends x{static code="ERR_JOSE_NOT_SUPPORTED";code="ERR_JOSE_NOT_SUPPORTED"}class V extends x{static code="ERR_JWE_DECRYPTION_FAILED";code="ERR_JWE_DECRYPTION_FAILED";constructor(e="decryption operation failed",t){super(e,t)}}class c extends x{static code="ERR_JWE_INVALID";code="ERR_JWE_INVALID"}class h extends x{static code="ERR_JWS_INVALID";code="ERR_JWS_INVALID"}class K extends x{static code="ERR_JWT_INVALID";code="ERR_JWT_INVALID"}class We extends x{static code="ERR_JWK_INVALID";code="ERR_JWK_INVALID"}class he extends x{static code="ERR_JWKS_INVALID";code="ERR_JWKS_INVALID"}class re extends x{static code="ERR_JWKS_NO_MATCHING_KEY";code="ERR_JWKS_NO_MATCHING_KEY";constructor(e="no applicable key found in the JSON Web Key Set",t){super(e,t)}}class He extends x{[Symbol.asyncIterator];static code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";constructor(e="multiple matching keys found in the JSON Web Key Set",t){super(e,t)}}class Te extends x{static code="ERR_JWKS_TIMEOUT";code="ERR_JWKS_TIMEOUT";constructor(e="request timed out",t){super(e,t)}}class ne extends x{static code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";constructor(e="signature verification failed",t){super(e,t)}}function ie(e){if(!M(e))throw Error("CryptoKey instance expected")}var M=(e)=>{if(e?.[Symbol.toStringTag]==="CryptoKey")return!0;try{return e instanceof CryptoKey}catch{return!1}},q=(e)=>e?.[Symbol.toStringTag]==="KeyObject",me=(e)=>M(e)||q(e);function Ie(e){switch(e){case"A128GCM":return 128;case"A192GCM":return 192;case"A256GCM":case"A128CBC-HS256":return 256;case"A192CBC-HS384":return 384;case"A256CBC-HS512":return 512;default:throw new d(`Unsupported JWE Algorithm: ${e}`)}}var _=(e)=>crypto.getRandomValues(new Uint8Array(Ie(e)>>3));function ve(e,t){let r=e.byteLength<<3;if(r!==t)throw new c(`Invalid Content Encryption Key length. Expected ${t} bits, got ${r} bits`)}function mt(e){switch(e){case"A128GCM":case"A128GCMKW":case"A192GCM":case"A192GCMKW":case"A256GCM":case"A256GCMKW":return 96;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return 128;default:throw new d(`Unsupported JWE Algorithm: ${e}`)}}var lr=(e)=>crypto.getRandomValues(new Uint8Array(mt(e)>>3));function yt(e,t){if(t.length<<3!==mt(e))throw new c("Invalid Initialization Vector length")}async function lt(e,t,r){if(!(t instanceof Uint8Array))throw TypeError(D(t,"Uint8Array"));let n=parseInt(e.slice(1,4),10),i=await crypto.subtle.importKey("raw",t.subarray(n>>3),"AES-CBC",!1,[r]),a=await crypto.subtle.importKey("raw",t.subarray(0,n>>3),{hash:`SHA-${n<<1}`,name:"HMAC"},!1,["sign"]);return{encKey:i,macKey:a,keySize:n}}async function St(e,t,r){return new Uint8Array((await crypto.subtle.sign("HMAC",e,t)).slice(0,r>>3))}async function Sr(e,t,r,n,i){let{encKey:a,macKey:s,keySize:o}=await lt(e,r,"encrypt"),p=new Uint8Array(await crypto.subtle.encrypt({iv:n,name:"AES-CBC"},a,t)),u=g(i,n,p,Ve(i.length<<3)),f=await St(s,u,o);return{ciphertext:p,tag:f,iv:n}}async function wr(e,t){if(!(e instanceof Uint8Array))throw TypeError("First argument must be a buffer");if(!(t instanceof Uint8Array))throw TypeError("Second argument must be a buffer");let r={name:"HMAC",hash:"SHA-256"},n=await crypto.subtle.generateKey(r,!1,["sign"]),i=new Uint8Array(await crypto.subtle.sign(r,n,e)),a=new Uint8Array(await crypto.subtle.sign(r,n,t)),s=0,o=-1;while(++o<32)s|=i[o]^a[o];return s===0}async function Ar(e,t,r,n,i,a){let{encKey:s,macKey:o,keySize:p}=await lt(e,t,"decrypt"),u=g(a,n,r,Ve(a.length<<3)),f=await St(o,u,p),l;try{l=await wr(i,f)}catch{}if(!l)throw new V;let E;try{E=new Uint8Array(await crypto.subtle.decrypt({iv:n,name:"AES-CBC"},s,r))}catch{}if(!E)throw new V;return E}async function Er(e,t,r,n,i){let a;if(r instanceof Uint8Array)a=await crypto.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]);else J(r,e,"encrypt"),a=r;let s=new Uint8Array(await crypto.subtle.encrypt({additionalData:i,iv:n,name:"AES-GCM",tagLength:128},a,t)),o=s.slice(-16);return{ciphertext:s.slice(0,-16),tag:o,iv:n}}async function br(e,t,r,n,i,a){let s;if(t instanceof Uint8Array)s=await crypto.subtle.importKey("raw",t,"AES-GCM",!1,["decrypt"]);else J(t,e,"decrypt"),s=t;try{return new Uint8Array(await crypto.subtle.decrypt({additionalData:a,iv:n,name:"AES-GCM",tagLength:128},s,g(r,i)))}catch{throw new V}}var wt="Unsupported JWE Content Encryption Algorithm";async function Je(e,t,r,n,i){if(!M(r)&&!(r instanceof Uint8Array))throw TypeError(D(r,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(n)yt(e,n);else n=lr(e);switch(e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":if(r instanceof Uint8Array)ve(r,parseInt(e.slice(-3),10));return Sr(e,t,r,n,i);case"A128GCM":case"A192GCM":case"A256GCM":if(r instanceof Uint8Array)ve(r,parseInt(e.slice(1,4),10));return Er(e,t,r,n,i);default:throw new d(wt)}}async function Re(e,t,r,n,i,a){if(!M(t)&&!(t instanceof Uint8Array))throw TypeError(D(t,"CryptoKey","KeyObject","Uint8Array","JSON Web Key"));if(!n)throw new c("JWE Initialization Vector missing");if(!i)throw new c("JWE Authentication Tag missing");switch(yt(e,n),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":if(t instanceof Uint8Array)ve(t,parseInt(e.slice(-3),10));return Ar(e,t,r,n,i,a);case"A128GCM":case"A192GCM":case"A256GCM":if(t instanceof Uint8Array)ve(t,parseInt(e.slice(1,4),10));return br(e,t,r,n,i,a);default:throw new d(wt)}}var De=Symbol();function S(e,t){if(e)throw TypeError(`${t} can only be called once`)}function I(e,t,r){try{return W(e)}catch{throw new r(`Failed to base64url decode the ${t}`)}}async function Ue(e,t){let r=`SHA-${e.slice(-3)}`;return new Uint8Array(await crypto.subtle.digest(r,t))}var gr=(e)=>typeof e==="object"&&e!==null;function m(e){if(!gr(e)||Object.prototype.toString.call(e)!=="[object Object]")return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;while(Object.getPrototypeOf(t)!==null)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function L(...e){let t=e.filter(Boolean);if(t.length===0||t.length===1)return!0;let r;for(let n of t){let i=Object.keys(n);if(!r||r.size===0){r=new Set(i);continue}for(let a of i){if(r.has(a))return!1;r.add(a)}}return!0}var Q=(e)=>m(e)&&typeof e.kty==="string",At=(e)=>e.kty!=="oct"&&(e.kty==="AKP"&&typeof e.priv==="string"||typeof e.d==="string"),Et=(e)=>e.kty!=="oct"&&e.d===void 0&&e.priv===void 0,bt=(e)=>e.kty==="oct"&&typeof e.k==="string";function gt(e,t){if(e.algorithm.length!==parseInt(t.slice(1,4),10))throw TypeError(`Invalid key size for alg: ${t}`)}function Kt(e,t,r){if(e instanceof Uint8Array)return crypto.subtle.importKey("raw",e,"AES-KW",!0,[r]);return J(e,t,r),e}async function ye(e,t,r){let n=await Kt(t,e,"wrapKey");gt(n,e);let i=await crypto.subtle.importKey("raw",r,{hash:"SHA-256",name:"HMAC"},!0,["sign"]);return new Uint8Array(await crypto.subtle.wrapKey("raw",i,n,"AES-KW"))}async function le(e,t,r){let n=await Kt(t,e,"unwrapKey");gt(n,e);let i=await crypto.subtle.unwrapKey("raw",r,n,"AES-KW",{hash:"SHA-256",name:"HMAC"},!0,["sign"]);return new Uint8Array(await crypto.subtle.exportKey("raw",i))}function Xe(e){return g(Ce(e.length),e)}async function Cr(e,t,r){let n=t>>3,i=32,a=Math.ceil(n/32),s=new Uint8Array(a*32);for(let o=1;o<=a;o++){let p=new Uint8Array(4+e.length+r.length);p.set(Ce(o),0),p.set(e,4),p.set(r,4+e.length);let u=await Ue("sha256",p);s.set(u,(o-1)*32)}return s.slice(0,n)}async function Ye(e,t,r,n,i=new Uint8Array,a=new Uint8Array){J(e,"ECDH"),J(t,"ECDH","deriveBits");let s=Xe(w(r)),o=Xe(i),p=Xe(a),u=Ce(n),f=new Uint8Array,l=g(s,o,p,u,f),E=new Uint8Array(await crypto.subtle.deriveBits({name:e.algorithm.name,public:e},t,xr(e)));return Cr(E,n,l)}function xr(e){if(e.algorithm.name==="X25519")return 256;return Math.ceil(parseInt(e.algorithm.namedCurve.slice(-3),10)/8)<<3}function qe(e){switch(e.algorithm.namedCurve){case"P-256":case"P-384":case"P-521":return!0;default:return e.algorithm.name==="X25519"}}function Wr(e,t){if(e instanceof Uint8Array)return crypto.subtle.importKey("raw",e,"PBKDF2",!1,["deriveBits"]);return J(e,t,"deriveBits"),e}var Hr=(e,t)=>g(w(e),Uint8Array.of(0),t);async function xt(e,t,r,n){if(!(e instanceof Uint8Array)||e.length<8)throw new c("PBES2 Salt Input must be 8 or more octets");if(!Number.isSafeInteger(r)||Math.sign(r)!==1)throw new c("PBES2 Count Input must be a positive integer");let i=Hr(t,e),a=parseInt(t.slice(13,16),10),s={hash:`SHA-${t.slice(8,11)}`,iterations:r,name:"PBKDF2",salt:i},o=await Wr(n,t);return new Uint8Array(await crypto.subtle.deriveBits(s,o,a))}async function Pt(e,t,r,n=2048,i=crypto.getRandomValues(new Uint8Array(16))){let a=await xt(i,e,n,t);return{encryptedKey:await ye(e.slice(-6),a,r),p2c:n,p2s:y(i)}}async function Wt(e,t,r,n,i){let a=await xt(i,e,n,t);return le(e.slice(-6),a,r)}function Se(e,t){if(e.startsWith("RS")||e.startsWith("PS")){let{modulusLength:r}=t.algorithm;if(typeof r!=="number"||r<2048)throw TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}}function Ht(e,t){let r=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:parseInt(e.slice(-3),10)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:t.namedCurve};case"Ed25519":case"EdDSA":return{name:"Ed25519"};case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":return{name:e};default:throw new d(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}async function Tt(e,t,r){if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw TypeError(D(t,"CryptoKey","KeyObject","JSON Web Key"));return crypto.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[r])}return dt(t,e,r),t}async function vt(e,t,r){let n=await Tt(e,t,"sign");Se(e,n);let i=await crypto.subtle.sign(Ht(e,n.algorithm),n,r);return new Uint8Array(i)}async function It(e,t,r,n){let i=await Tt(e,t,"verify");Se(e,i);let a=Ht(e,i.algorithm);try{return await crypto.subtle.verify(a,i,r,n)}catch{return!1}}var Jt=(e)=>{switch(e){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new d(`alg ${e} is not supported either by JOSE or your javascript runtime`)}};async function Rt(e,t,r){return J(t,e,"encrypt"),Se(e,t),new Uint8Array(await crypto.subtle.encrypt(Jt(e),t,r))}async function Dt(e,t,r){return J(t,e,"decrypt"),Se(e,t),new Uint8Array(await crypto.subtle.decrypt(Jt(e),t,r))}var Me='Invalid or unsupported JWK "alg" (Algorithm) Parameter value';function Ir(e){let t,r;switch(e.kty){case"AKP":{switch(e.alg){case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":t={name:e.alg},r=e.priv?["sign"]:["verify"];break;default:throw new d(Me)}break}case"RSA":{switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},r=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new d(Me)}break}case"EC":{switch(e.alg){case"ES256":case"ES384":case"ES512":t={name:"ECDSA",namedCurve:{ES256:"P-256",ES384:"P-384",ES512:"P-521"}[e.alg]},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new d(Me)}break}case"OKP":{switch(e.alg){case"Ed25519":case"EdDSA":t={name:"Ed25519"},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new d(Me)}break}default:throw new d('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:r}}async function ae(e){if(!e.alg)throw TypeError('"alg" argument is required when "jwk.alg" is not present');let{algorithm:t,keyUsages:r}=Ir(e),n={...e};if(n.kty!=="AKP")delete n.alg;return delete n.use,crypto.subtle.importKey("jwk",n,t,e.ext??(e.d||e.priv?!1:!0),e.key_ops??r)}var se="given KeyObject instance cannot be used for this algorithm",oe,Ut=async(e,t,r,n=!1)=>{oe||=new WeakMap;let i=oe.get(e);if(i?.[r])return i[r];let a=await ae({...t,alg:r});if(n)Object.freeze(e);if(!i)oe.set(e,{[r]:a});else i[r]=a;return a},Jr=(e,t)=>{oe||=new WeakMap;let r=oe.get(e);if(r?.[t])return r[t];let n=e.type==="public",i=n?!0:!1,a;if(e.asymmetricKeyType==="x25519"){switch(t){case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":break;default:throw TypeError(se)}a=e.toCryptoKey(e.asymmetricKeyType,i,n?[]:["deriveBits"])}if(e.asymmetricKeyType==="ed25519"){if(t!=="EdDSA"&&t!=="Ed25519")throw TypeError(se);a=e.toCryptoKey(e.asymmetricKeyType,i,[n?"verify":"sign"])}switch(e.asymmetricKeyType){case"ml-dsa-44":case"ml-dsa-65":case"ml-dsa-87":{if(t!==e.asymmetricKeyType.toUpperCase())throw TypeError(se);a=e.toCryptoKey(e.asymmetricKeyType,i,[n?"verify":"sign"])}}if(e.asymmetricKeyType==="rsa"){let s;switch(t){case"RSA-OAEP":s="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":s="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":s="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":s="SHA-512";break;default:throw TypeError(se)}if(t.startsWith("RSA-OAEP"))return e.toCryptoKey({name:"RSA-OAEP",hash:s},i,n?["encrypt"]:["decrypt"]);a=e.toCryptoKey({name:t.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:s},i,[n?"verify":"sign"])}if(e.asymmetricKeyType==="ec"){let o=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get(e.asymmetricKeyDetails?.namedCurve);if(!o)throw TypeError(se);let p={ES256:"P-256",ES384:"P-384",ES512:"P-521"};if(p[t]&&o===p[t])a=e.toCryptoKey({name:"ECDSA",namedCurve:o},i,[n?"verify":"sign"]);if(t.startsWith("ECDH-ES"))a=e.toCryptoKey({name:"ECDH",namedCurve:o},i,n?[]:["deriveBits"])}if(!a)throw TypeError(se);if(!r)oe.set(e,{[t]:a});else r[t]=a;return a};async function U(e,t){if(e instanceof Uint8Array)return e;if(M(e))return e;if(q(e)){if(e.type==="secret")return e.export();if("toCryptoKey"in e&&typeof e.toCryptoKey==="function")try{return Jr(e,t)}catch(n){if(n instanceof TypeError)throw n}let r=e.export({format:"jwk"});return Ut(e,r,t)}if(Q(e)){if(e.k)return W(e.k);return Ut(e,e,t,!0)}throw Error("unreachable")}var Mt=(e,t)=>{let r=(e.match(/.{1,64}/g)||[]).join(`
|
|
3
3
|
`);return`-----BEGIN ${t}-----
|
|
4
4
|
${r}
|
|
5
5
|
-----END ${t}-----`},Ot=async(e,t,r)=>{if(q(r)){if(r.type!==e)throw TypeError(`key is not a ${e} key`);return r.export({format:"pem",type:t})}if(!M(r))throw TypeError(D(r,"CryptoKey","KeyObject"));if(!r.extractable)throw TypeError("CryptoKey is not extractable");if(r.type!==e)throw TypeError(`key is not a ${e} key`);return Mt(de(new Uint8Array(await crypto.subtle.exportKey(t,r))),`${e.toUpperCase()} KEY`)},Nt=(e)=>Ot("public","spki",e),_t=(e)=>Ot("private","pkcs8",e),Qe=(e,t)=>{if(e.byteLength!==t.length)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0},je=(e)=>({data:e,pos:0}),O=(e)=>{let t=e.data[e.pos++];if(t&128){let r=t&127,n=0;for(let i=0;i<r;i++)n=n<<8|e.data[e.pos++];return n}return t},Ze=(e,t=1)=>{if(t<=0)return;e.pos++;let r=O(e);if(e.pos+=r,t>1)Ze(e,t-1)},B=(e,t,r)=>{if(e.data[e.pos++]!==t)throw Error(r)},Lt=(e,t)=>{let r=e.data.subarray(e.pos,e.pos+t);return e.pos+=t,r},Rr=(e)=>{B(e,6,"Expected algorithm OID");let t=O(e);return Lt(e,t)};function Dr(e){B(e,48,"Invalid PKCS#8 structure"),O(e),B(e,2,"Expected version field");let t=O(e);e.pos+=t,B(e,48,"Expected algorithm identifier");let r=O(e);return{algIdStart:e.pos,algIdLength:r}}function Ur(e){B(e,48,"Invalid SPKI structure"),O(e),B(e,48,"Expected algorithm identifier");let t=O(e);return{algIdStart:e.pos,algIdLength:t}}var Bt=(e)=>{let t=Rr(e);if(Qe(t,[43,101,110]))return"X25519";if(!Qe(t,[42,134,72,206,61,2,1]))throw Error("Unsupported key algorithm");B(e,6,"Expected curve OID");let r=O(e),n=Lt(e,r);for(let{name:i,oid:a}of[{name:"P-256",oid:[42,134,72,206,61,3,1,7]},{name:"P-384",oid:[43,129,4,0,34]},{name:"P-521",oid:[43,129,4,0,35]}])if(Qe(n,a))return i;throw Error("Unsupported named curve")},kt=async(e,t,r,n)=>{let i,a,s=e==="spki",o=()=>s?["verify"]:["sign"],p=()=>s?["encrypt","wrapKey"]:["decrypt","unwrapKey"];switch(r){case"PS256":case"PS384":case"PS512":i={name:"RSA-PSS",hash:`SHA-${r.slice(-3)}`},a=o();break;case"RS256":case"RS384":case"RS512":i={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${r.slice(-3)}`},a=o();break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":i={name:"RSA-OAEP",hash:`SHA-${parseInt(r.slice(-3),10)||1}`},a=p();break;case"ES256":case"ES384":case"ES512":{i={name:"ECDSA",namedCurve:{ES256:"P-256",ES384:"P-384",ES512:"P-521"}[r]},a=o();break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{try{let u=n.getNamedCurve(t);i=u==="X25519"?{name:"X25519"}:{name:"ECDH",namedCurve:u}}catch(u){throw new d("Invalid or unsupported key format")}a=s?[]:["deriveBits"];break}case"Ed25519":case"EdDSA":i={name:"Ed25519"},a=o();break;case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":i={name:r},a=o();break;default:throw new d('Invalid or unsupported "alg" (Algorithm) value')}return crypto.subtle.importKey(e,t,i,n?.extractable??(s?!0:!1),a)},et=(e,t)=>{return xe(e.replace(t,""))},$t=(e,t,r)=>{let n=et(e,/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g),i=r;if(t?.startsWith?.("ECDH-ES"))i||={},i.getNamedCurve=(a)=>{let s=je(a);return Dr(s),Bt(s)};return kt("pkcs8",n,t,i)},tt=(e,t,r)=>{let n=et(e,/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g),i=r;if(t?.startsWith?.("ECDH-ES"))i||={},i.getNamedCurve=(a)=>{let s=je(a);return Ur(s),Bt(s)};return kt("spki",n,t,i)};function Mr(e){let t=je(e);if(B(t,48,"Invalid certificate structure"),O(t),B(t,48,"Invalid tbsCertificate structure"),O(t),e[t.pos]===160)Ze(t,6);else Ze(t,5);let r=t.pos;B(t,48,"Invalid SPKI structure");let n=O(t);return e.subarray(r,r+n+(t.pos-r))}function Or(e){let t=et(e,/(?:-----(?:BEGIN|END) CERTIFICATE-----|\s)/g);return Mr(t)}var Gt=(e,t,r)=>{let n;try{n=Or(e)}catch(i){throw TypeError("Failed to parse the X.509 certificate",{cause:i})}return tt(Mt(de(n),"PUBLIC KEY"),t,r)};async function Nr(e,t,r){if(typeof e!=="string"||e.indexOf("-----BEGIN PUBLIC KEY-----")!==0)throw TypeError('"spki" must be SPKI formatted string');return tt(e,t,r)}async function _r(e,t,r){if(typeof e!=="string"||e.indexOf("-----BEGIN CERTIFICATE-----")!==0)throw TypeError('"x509" must be X.509 formatted string');return Gt(e,t,r)}async function Lr(e,t,r){if(typeof e!=="string"||e.indexOf("-----BEGIN PRIVATE KEY-----")!==0)throw TypeError('"pkcs8" must be PKCS#8 formatted string');return $t(e,t,r)}async function Z(e,t,r){if(!m(e))throw TypeError("JWK must be an object");let n;switch(t??=e.alg,n??=r?.extractable??e.ext,e.kty){case"oct":if(typeof e.k!=="string"||!e.k)throw TypeError('missing "k" (Key Value) Parameter value');return W(e.k);case"RSA":if("oth"in e&&e.oth!==void 0)throw new d('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');return ae({...e,alg:t,ext:n});case"AKP":{if(typeof e.alg!=="string"||!e.alg)throw TypeError('missing "alg" (Algorithm) Parameter value');if(t!==void 0&&t!==e.alg)throw TypeError("JWK alg and alg option value mismatch");return ae({...e,ext:n})}case"EC":case"OKP":return ae({...e,alg:t,ext:n});default:throw new d('Unsupported "kty" (Key Type) Parameter value')}}async function Vt(e){if(q(e))if(e.type==="secret")e=e.export();else return e.export({format:"jwk"});if(e instanceof Uint8Array)return{kty:"oct",k:y(e)};if(!M(e))throw TypeError(D(e,"CryptoKey","KeyObject","Uint8Array"));if(!e.extractable)throw TypeError("non-extractable CryptoKey cannot be exported as a JWK");let{ext:t,key_ops:r,alg:n,use:i,...a}=await crypto.subtle.exportKey("jwk",e);if(a.kty==="AKP")a.alg=n;return a}async function Br(e){return Nt(e)}async function kr(e){return _t(e)}async function we(e){return Vt(e)}async function Ft(e,t,r,n){let i=e.slice(0,7),a=await Je(i,r,t,n,new Uint8Array);return{encryptedKey:a.ciphertext,iv:y(a.iv),tag:y(a.tag)}}async function zt(e,t,r,n,i){let a=e.slice(0,7);return Re(a,t,r,n,i,new Uint8Array)}var Xt='Invalid or unsupported "alg" (JWE Algorithm) header value';function Ae(e){if(e===void 0)throw new c("JWE Encrypted Key missing")}async function Yt(e,t,r,n,i){switch(e){case"dir":{if(r!==void 0)throw new c("Encountered unexpected JWE Encrypted Key");return t}case"ECDH-ES":if(r!==void 0)throw new c("Encountered unexpected JWE Encrypted Key");case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(!m(n.epk))throw new c('JOSE Header "epk" (Ephemeral Public Key) missing or invalid');if(ie(t),!qe(t))throw new d("ECDH with the provided key is not allowed or not supported by your javascript runtime");let a=await Z(n.epk,e);ie(a);let s,o;if(n.apu!==void 0){if(typeof n.apu!=="string")throw new c('JOSE Header "apu" (Agreement PartyUInfo) invalid');s=I(n.apu,"apu",c)}if(n.apv!==void 0){if(typeof n.apv!=="string")throw new c('JOSE Header "apv" (Agreement PartyVInfo) invalid');o=I(n.apv,"apv",c)}let p=await Ye(a,t,e==="ECDH-ES"?n.enc:e,e==="ECDH-ES"?Ie(n.enc):parseInt(e.slice(-5,-2),10),s,o);if(e==="ECDH-ES")return p;return Ae(r),le(e.slice(-6),p,r)}case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return Ae(r),ie(t),Dt(e,t,r);case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{if(Ae(r),typeof n.p2c!=="number")throw new c('JOSE Header "p2c" (PBES2 Count) missing or invalid');let a=i?.maxPBES2Count||1e4;if(n.p2c>a)throw new c('JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds');if(typeof n.p2s!=="string")throw new c('JOSE Header "p2s" (PBES2 Salt) missing or invalid');let s;return s=I(n.p2s,"p2s",c),Wt(e,t,r,n.p2c,s)}case"A128KW":case"A192KW":case"A256KW":return Ae(r),le(e,t,r);case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{if(Ae(r),typeof n.iv!=="string")throw new c('JOSE Header "iv" (Initialization Vector) missing or invalid');if(typeof n.tag!=="string")throw new c('JOSE Header "tag" (Authentication Tag) missing or invalid');let a;a=I(n.iv,"iv",c);let s;return s=I(n.tag,"tag",c),zt(e,t,r,a,s)}default:throw new d(Xt)}}async function Oe(e,t,r,n,i={}){let a,s,o;switch(e){case"dir":{o=r;break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(ie(r),!qe(r))throw new d("ECDH with the provided key is not allowed or not supported by your javascript runtime");let{apu:p,apv:u}=i,f;if(i.epk)f=await U(i.epk,e);else f=(await crypto.subtle.generateKey(r.algorithm,!0,["deriveBits"])).privateKey;let{x:l,y:E,crv:T,kty:b}=await we(f),A=await Ye(r,f,e==="ECDH-ES"?t:e,e==="ECDH-ES"?Ie(t):parseInt(e.slice(-5,-2),10),p,u);if(s={epk:{x:l,crv:T,kty:b}},b==="EC")s.epk.y=E;if(p)s.apu=y(p);if(u)s.apv=y(u);if(e==="ECDH-ES"){o=A;break}o=n||_(t);let P=e.slice(-6);a=await ye(P,A,o);break}case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{o=n||_(t),ie(r),a=await Rt(e,r,o);break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{o=n||_(t);let{p2c:p,p2s:u}=i;({encryptedKey:a,...s}=await Pt(e,r,o,p,u));break}case"A128KW":case"A192KW":case"A256KW":{o=n||_(t),a=await ye(e,r,o);break}case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{o=n||_(t);let{iv:p}=i;({encryptedKey:a,...s}=await Ft(e,r,o,p));break}default:throw new d(Xt)}return{cek:o,encryptedKey:a,parameters:s}}function k(e,t,r,n,i){if(i.crit!==void 0&&n?.crit===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||n.crit===void 0)return new Set;if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some((s)=>typeof s!=="string"||s.length===0))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let a;if(r!==void 0)a=new Map([...Object.entries(r),...t.entries()]);else a=t;for(let s of n.crit){if(!a.has(s))throw new d(`Extension Header Parameter "${s}" is not recognized`);if(i[s]===void 0)throw new e(`Extension Header Parameter "${s}" is missing`);if(a.get(s)&&n[s]===void 0)throw new e(`Extension Header Parameter "${s}" MUST be integrity protected`)}return new Set(n.crit)}function Ee(e,t){if(t!==void 0&&(!Array.isArray(t)||t.some((r)=>typeof r!=="string")))throw TypeError(`"${e}" option must be an array of strings`);if(!t)return;return new Set(t)}var ce=(e)=>e?.[Symbol.toStringTag],rt=(e,t,r)=>{if(t.use!==void 0){let n;switch(r){case"sign":case"verify":n="sig";break;case"encrypt":case"decrypt":n="enc";break}if(t.use!==n)throw TypeError(`Invalid key for this operation, its "use" must be "${n}" when present`)}if(t.alg!==void 0&&t.alg!==e)throw TypeError(`Invalid key for this operation, its "alg" must be "${e}" when present`);if(Array.isArray(t.key_ops)){let n;switch(!0){case(r==="sign"||r==="verify"):case e==="dir":case e.includes("CBC-HS"):n=r;break;case e.startsWith("PBES2"):n="deriveBits";break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(e):if(!e.includes("GCM")&&e.endsWith("KW"))n=r==="encrypt"?"wrapKey":"unwrapKey";else n=r;break;case(r==="encrypt"&&e.startsWith("RSA")):n="wrapKey";break;case r==="decrypt":n=e.startsWith("RSA")?"unwrapKey":"deriveBits";break}if(n&&t.key_ops?.includes?.(n)===!1)throw TypeError(`Invalid key for this operation, its "key_ops" must include "${n}" when present`)}return!0},$r=(e,t,r)=>{if(t instanceof Uint8Array)return;if(Q(t)){if(bt(t)&&rt(e,t,r))return;throw TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!me(t))throw TypeError(ze(e,t,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"));if(t.type!=="secret")throw TypeError(`${ce(t)} instances for symmetric algorithms must be of type "secret"`)},Gr=(e,t,r)=>{if(Q(t))switch(r){case"decrypt":case"sign":if(At(t)&&rt(e,t,r))return;throw TypeError("JSON Web Key for this operation must be a private JWK");case"encrypt":case"verify":if(Et(t)&&rt(e,t,r))return;throw TypeError("JSON Web Key for this operation must be a public JWK")}if(!me(t))throw TypeError(ze(e,t,"CryptoKey","KeyObject","JSON Web Key"));if(t.type==="secret")throw TypeError(`${ce(t)} instances for asymmetric algorithms must not be of type "secret"`);if(t.type==="public")switch(r){case"sign":throw TypeError(`${ce(t)} instances for asymmetric algorithm signing must be of type "private"`);case"decrypt":throw TypeError(`${ce(t)} instances for asymmetric algorithm decryption must be of type "private"`)}if(t.type==="private")switch(r){case"verify":throw TypeError(`${ce(t)} instances for asymmetric algorithm verifying must be of type "public"`);case"encrypt":throw TypeError(`${ce(t)} instances for asymmetric algorithm encryption must be of type "public"`)}};function $(e,t,r){switch(e.substring(0,2)){case"A1":case"A2":case"di":case"HS":case"PB":$r(e,t,r);break;default:Gr(e,t,r)}}function qt(e){if(typeof globalThis[e]>"u")throw new d(`JWE "zip" (Compression Algorithm) Header Parameter requires the ${e} API.`)}async function Qt(e){qt("CompressionStream");let t=new CompressionStream("deflate-raw"),r=t.writable.getWriter();r.write(e).catch(()=>{}),r.close().catch(()=>{});let n=[],i=t.readable.getReader();for(;;){let{value:a,done:s}=await i.read();if(s)break;n.push(a)}return g(...n)}async function Zt(e,t){qt("DecompressionStream");let r=new DecompressionStream("deflate-raw"),n=r.writable.getWriter();n.write(e).catch(()=>{}),n.close().catch(()=>{});let i=[],a=0,s=r.readable.getReader();for(;;){let{value:o,done:p}=await s.read();if(p)break;if(i.push(o),a+=o.byteLength,t!==1/0&&a>t)throw new c("Decompressed plaintext exceeded the configured limit")}return g(...i)}async function be(e,t,r){if(!m(e))throw new c("Flattened JWE must be an object");if(e.protected===void 0&&e.header===void 0&&e.unprotected===void 0)throw new c("JOSE Header missing");if(e.iv!==void 0&&typeof e.iv!=="string")throw new c("JWE Initialization Vector incorrect type");if(typeof e.ciphertext!=="string")throw new c("JWE Ciphertext missing or incorrect type");if(e.tag!==void 0&&typeof e.tag!=="string")throw new c("JWE Authentication Tag incorrect type");if(e.protected!==void 0&&typeof e.protected!=="string")throw new c("JWE Protected Header incorrect type");if(e.encrypted_key!==void 0&&typeof e.encrypted_key!=="string")throw new c("JWE Encrypted Key incorrect type");if(e.aad!==void 0&&typeof e.aad!=="string")throw new c("JWE AAD incorrect type");if(e.header!==void 0&&!m(e.header))throw new c("JWE Shared Unprotected Header incorrect type");if(e.unprotected!==void 0&&!m(e.unprotected))throw new c("JWE Per-Recipient Unprotected Header incorrect type");let n;if(e.protected)try{let R=W(e.protected);n=JSON.parse(C.decode(R))}catch{throw new c("JWE Protected Header is invalid")}if(!L(n,e.header,e.unprotected))throw new c("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint");let i={...n,...e.header,...e.unprotected};if(k(c,new Map,r?.crit,n,i),i.zip!==void 0&&i.zip!=="DEF")throw new d('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(i.zip!==void 0&&!n?.zip)throw new c('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.');let{alg:a,enc:s}=i;if(typeof a!=="string"||!a)throw new c("missing JWE Algorithm (alg) in JWE Header");if(typeof s!=="string"||!s)throw new c("missing JWE Encryption Algorithm (enc) in JWE Header");let o=r&&Ee("keyManagementAlgorithms",r.keyManagementAlgorithms),p=r&&Ee("contentEncryptionAlgorithms",r.contentEncryptionAlgorithms);if(o&&!o.has(a)||!o&&a.startsWith("PBES2"))throw new Y('"alg" (Algorithm) Header Parameter value not allowed');if(p&&!p.has(s))throw new Y('"enc" (Encryption Algorithm) Header Parameter value not allowed');let u;if(e.encrypted_key!==void 0)u=I(e.encrypted_key,"encrypted_key",c);let f=!1;if(typeof t==="function")t=await t(n,e),f=!0;$(a==="dir"?s:a,t,"decrypt");let l=await U(t,a),E;try{E=await Yt(a,l,u,i,r)}catch(R){if(R instanceof TypeError||R instanceof c||R instanceof d)throw R;E=_(s)}let T,b;if(e.iv!==void 0)T=I(e.iv,"iv",c);if(e.tag!==void 0)b=I(e.tag,"tag",c);let A=e.protected!==void 0?w(e.protected):new Uint8Array,P;if(e.aad!==void 0)P=g(A,w("."),w(e.aad));else P=A;let ke=I(e.ciphertext,"ciphertext",c),ct=await Re(s,E,ke,T,b,P),z={plaintext:ct};if(i.zip==="DEF"){let R=r?.maxDecompressedLength??250000;if(R===0)throw new d('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');if(R!==1/0&&(!Number.isSafeInteger(R)||R<1))throw TypeError("maxDecompressedLength must be 0, a positive safe integer, or Infinity");z.plaintext=await Zt(ct,R).catch(($e)=>{if($e instanceof c)throw $e;throw new c("Failed to decompress plaintext",{cause:$e})})}if(e.protected!==void 0)z.protectedHeader=n;if(e.aad!==void 0)z.additionalAuthenticatedData=I(e.aad,"aad",c);if(e.unprotected!==void 0)z.sharedUnprotectedHeader=e.unprotected;if(e.header!==void 0)z.unprotectedHeader=e.header;if(f)return{...z,key:l};return z}async function nt(e,t,r){if(e instanceof Uint8Array)e=C.decode(e);if(typeof e!=="string")throw new c("Compact JWE must be a string or Uint8Array");let{0:n,1:i,2:a,3:s,4:o,length:p}=e.split(".");if(p!==5)throw new c("Invalid Compact JWE");let u=await be({ciphertext:s,iv:a||void 0,protected:n,tag:o||void 0,encrypted_key:i||void 0},t,r),f={plaintext:u.plaintext,protectedHeader:u.protectedHeader};if(typeof t==="function")return{...f,key:u.key};return f}async function Vr(e,t,r){if(!m(e))throw new c("General JWE must be an object");if(!Array.isArray(e.recipients)||!e.recipients.every(m))throw new c("JWE Recipients missing or incorrect type");if(!e.recipients.length)throw new c("JWE Recipients has no members");for(let n of e.recipients)try{return await be({aad:e.aad,ciphertext:e.ciphertext,encrypted_key:n.encrypted_key,header:n.header,iv:e.iv,protected:e.protected,tag:e.tag,unprotected:e.unprotected},t,r)}catch{}throw new V}class j{#e;#t;#r;#n;#a;#s;#o;#i;constructor(e){if(!(e instanceof Uint8Array))throw TypeError("plaintext must be an instance of Uint8Array");this.#e=e}setKeyManagementParameters(e){return S(this.#i,"setKeyManagementParameters"),this.#i=e,this}setProtectedHeader(e){return S(this.#t,"setProtectedHeader"),this.#t=e,this}setSharedUnprotectedHeader(e){return S(this.#r,"setSharedUnprotectedHeader"),this.#r=e,this}setUnprotectedHeader(e){return S(this.#n,"setUnprotectedHeader"),this.#n=e,this}setAdditionalAuthenticatedData(e){return this.#a=e,this}setContentEncryptionKey(e){return S(this.#s,"setContentEncryptionKey"),this.#s=e,this}setInitializationVector(e){return S(this.#o,"setInitializationVector"),this.#o=e,this}async encrypt(e,t){if(!this.#t&&!this.#n&&!this.#r)throw new c("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!L(this.#t,this.#n,this.#r))throw new c("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");let r={...this.#t,...this.#n,...this.#r};if(k(c,new Map,t?.crit,this.#t,r),r.zip!==void 0&&r.zip!=="DEF")throw new d('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(r.zip!==void 0&&!this.#t?.zip)throw new c('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.');let{alg:n,enc:i}=r;if(typeof n!=="string"||!n)throw new c('JWE "alg" (Algorithm) Header Parameter missing or invalid');if(typeof i!=="string"||!i)throw new c('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');let a;if(this.#s&&(n==="dir"||n==="ECDH-ES"))throw TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${n}`);$(n==="dir"?i:n,e,"encrypt");let s;{let P,ke=await U(e,n);if({cek:s,encryptedKey:a,parameters:P}=await Oe(n,i,ke,this.#s,this.#i),P)if(t&&De in t)if(!this.#n)this.setUnprotectedHeader(P);else this.#n={...this.#n,...P};else if(!this.#t)this.setProtectedHeader(P);else this.#t={...this.#t,...P}}let o,p,u,f;if(this.#t)p=y(JSON.stringify(this.#t)),u=w(p);else p="",u=new Uint8Array;if(this.#a){f=y(this.#a);let P=w(f);o=g(u,w("."),P)}else o=u;let l=this.#e;if(r.zip==="DEF")l=await Qt(l).catch((P)=>{throw new c("Failed to compress plaintext",{cause:P})});let{ciphertext:E,tag:T,iv:b}=await Je(i,l,s,this.#o,o),A={ciphertext:y(E)};if(b)A.iv=y(b);if(T)A.tag=y(T);if(a)A.encrypted_key=y(a);if(f)A.aad=f;if(this.#t)A.protected=p;if(this.#r)A.unprotected=this.#r;if(this.#n)A.header=this.#n;return A}}class jt{#e;unprotectedHeader;keyManagementParameters;key;options;constructor(e,t,r){this.#e=e,this.key=t,this.options=r}setUnprotectedHeader(e){return S(this.unprotectedHeader,"setUnprotectedHeader"),this.unprotectedHeader=e,this}setKeyManagementParameters(e){return S(this.keyManagementParameters,"setKeyManagementParameters"),this.keyManagementParameters=e,this}addRecipient(...e){return this.#e.addRecipient(...e)}encrypt(...e){return this.#e.encrypt(...e)}done(){return this.#e}}class er{#e;#t=[];#r;#n;#a;constructor(e){this.#e=e}addRecipient(e,t){let r=new jt(this,e,{crit:t?.crit});return this.#t.push(r),r}setProtectedHeader(e){return S(this.#r,"setProtectedHeader"),this.#r=e,this}setSharedUnprotectedHeader(e){return S(this.#n,"setSharedUnprotectedHeader"),this.#n=e,this}setAdditionalAuthenticatedData(e){return this.#a=e,this}async encrypt(){if(!this.#t.length)throw new c("at least one recipient must be added");if(this.#t.length===1){let[n]=this.#t,i=await new j(this.#e).setAdditionalAuthenticatedData(this.#a).setProtectedHeader(this.#r).setSharedUnprotectedHeader(this.#n).setUnprotectedHeader(n.unprotectedHeader).encrypt(n.key,{...n.options}),a={ciphertext:i.ciphertext,iv:i.iv,recipients:[{}],tag:i.tag};if(i.aad)a.aad=i.aad;if(i.protected)a.protected=i.protected;if(i.unprotected)a.unprotected=i.unprotected;if(i.encrypted_key)a.recipients[0].encrypted_key=i.encrypted_key;if(i.header)a.recipients[0].header=i.header;return a}let e;for(let n=0;n<this.#t.length;n++){let i=this.#t[n];if(!L(this.#r,this.#n,i.unprotectedHeader))throw new c("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");let a={...this.#r,...this.#n,...i.unprotectedHeader},{alg:s}=a;if(typeof s!=="string"||!s)throw new c('JWE "alg" (Algorithm) Header Parameter missing or invalid');if(s==="dir"||s==="ECDH-ES")throw new c('"dir" and "ECDH-ES" alg may only be used with a single recipient');if(typeof a.enc!=="string"||!a.enc)throw new c('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');if(!e)e=a.enc;else if(e!==a.enc)throw new c('JWE "enc" (Encryption Algorithm) Header Parameter must be the same for all recipients');if(k(c,new Map,i.options.crit,this.#r,a),a.zip!==void 0&&a.zip!=="DEF")throw new d('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value.');if(a.zip!==void 0&&!this.#r?.zip)throw new c('JWE "zip" (Compression Algorithm) Header Parameter MUST be in a protected header.')}let t=_(e),r={ciphertext:"",recipients:[]};for(let n=0;n<this.#t.length;n++){let i=this.#t[n],a={};if(r.recipients.push(a),n===0){let f=await new j(this.#e).setAdditionalAuthenticatedData(this.#a).setContentEncryptionKey(t).setProtectedHeader(this.#r).setSharedUnprotectedHeader(this.#n).setUnprotectedHeader(i.unprotectedHeader).setKeyManagementParameters(i.keyManagementParameters).encrypt(i.key,{...i.options,[De]:!0});if(r.ciphertext=f.ciphertext,r.iv=f.iv,r.tag=f.tag,f.aad)r.aad=f.aad;if(f.protected)r.protected=f.protected;if(f.unprotected)r.unprotected=f.unprotected;if(a.encrypted_key=f.encrypted_key,f.header)a.header=f.header;continue}let s=i.unprotectedHeader?.alg||this.#r?.alg||this.#n?.alg;$(s==="dir"?e:s,i.key,"encrypt");let o=await U(i.key,s),{encryptedKey:p,parameters:u}=await Oe(s,e,o,t,i.keyManagementParameters);if(a.encrypted_key=y(p),i.unprotectedHeader||u)a.header={...i.unprotectedHeader,...u}}return r}}async function ge(e,t,r){if(!m(e))throw new h("Flattened JWS must be an object");if(e.protected===void 0&&e.header===void 0)throw new h('Flattened JWS must have either of the "protected" or "header" members');if(e.protected!==void 0&&typeof e.protected!=="string")throw new h("JWS Protected Header incorrect type");if(e.payload===void 0)throw new h("JWS Payload missing");if(typeof e.signature!=="string")throw new h("JWS Signature missing or incorrect type");if(e.header!==void 0&&!m(e.header))throw new h("JWS Unprotected Header incorrect type");let n={};if(e.protected)try{let P=W(e.protected);n=JSON.parse(C.decode(P))}catch{throw new h("JWS Protected Header is invalid")}if(!L(n,e.header))throw new h("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let i={...n,...e.header},a=k(h,new Map([["b64",!0]]),r?.crit,n,i),s=!0;if(a.has("b64")){if(s=n.b64,typeof s!=="boolean")throw new h('The "b64" (base64url-encode payload) Header Parameter must be a boolean')}let{alg:o}=i;if(typeof o!=="string"||!o)throw new h('JWS "alg" (Algorithm) Header Parameter missing or invalid');let p=r&&Ee("algorithms",r.algorithms);if(p&&!p.has(o))throw new Y('"alg" (Algorithm) Header Parameter value not allowed');if(s){if(typeof e.payload!=="string")throw new h("JWS Payload must be a string")}else if(typeof e.payload!=="string"&&!(e.payload instanceof Uint8Array))throw new h("JWS Payload must be a string or an Uint8Array instance");let u=!1;if(typeof t==="function")t=await t(n,e),u=!0;$(o,t,"verify");let f=g(e.protected!==void 0?w(e.protected):new Uint8Array,w("."),typeof e.payload==="string"?s?w(e.payload):X.encode(e.payload):e.payload),l=I(e.signature,"signature",h),E=await U(t,o);if(!await It(o,E,l,f))throw new ne;let b;if(s)b=I(e.payload,"payload",h);else if(typeof e.payload==="string")b=X.encode(e.payload);else b=e.payload;let A={payload:b};if(e.protected!==void 0)A.protectedHeader=n;if(e.header!==void 0)A.unprotectedHeader=e.header;if(u)return{...A,key:E};return A}async function it(e,t,r){if(e instanceof Uint8Array)e=C.decode(e);if(typeof e!=="string")throw new h("Compact JWS must be a string or Uint8Array");let{0:n,1:i,2:a,length:s}=e.split(".");if(s!==3)throw new h("Invalid Compact JWS");let o=await ge({payload:i,protected:n,signature:a},t,r),p={payload:o.payload,protectedHeader:o.protectedHeader};if(typeof t==="function")return{...p,key:o.key};return p}async function Fr(e,t,r){if(!m(e))throw new h("General JWS must be an object");if(!Array.isArray(e.signatures)||!e.signatures.every(m))throw new h("JWS Signatures missing or incorrect type");for(let n of e.signatures)try{return await ge({header:n.header,payload:e.payload,protected:n.protected,signature:n.signature},t,r)}catch{}throw new ne}var F=(e)=>Math.floor(e.getTime()/1000),rr=60,nr=rr*60,at=nr*24,zr=at*7,Xr=at*365.25,Yr=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function Ke(e){let t=Yr.exec(e);if(!t||t[4]&&t[1])throw TypeError("Invalid time period format");let r=parseFloat(t[2]),n=t[3].toLowerCase(),i;switch(n){case"sec":case"secs":case"second":case"seconds":case"s":i=Math.round(r);break;case"minute":case"minutes":case"min":case"mins":case"m":i=Math.round(r*rr);break;case"hour":case"hours":case"hr":case"hrs":case"h":i=Math.round(r*nr);break;case"day":case"days":case"d":i=Math.round(r*at);break;case"week":case"weeks":case"w":i=Math.round(r*zr);break;default:i=Math.round(r*Xr);break}if(t[1]==="-"||t[4]==="ago")return-i;return i}function ee(e,t){if(!Number.isFinite(t))throw TypeError(`Invalid ${e} input`);return t}var tr=(e)=>{if(e.includes("/"))return e.toLowerCase();return`application/${e.toLowerCase()}`},qr=(e,t)=>{if(typeof e==="string")return t.includes(e);if(Array.isArray(e))return t.some(Set.prototype.has.bind(new Set(e)));return!1};function pe(e,t,r={}){let n;try{n=JSON.parse(C.decode(t))}catch{}if(!m(n))throw new K("JWT Claims Set must be a top-level JSON object");let{typ:i}=r;if(i&&(typeof e.typ!=="string"||tr(e.typ)!==tr(i)))throw new H('unexpected "typ" JWT header value',n,"typ","check_failed");let{requiredClaims:a=[],issuer:s,subject:o,audience:p,maxTokenAge:u}=r,f=[...a];if(u!==void 0)f.push("iat");if(p!==void 0)f.push("aud");if(o!==void 0)f.push("sub");if(s!==void 0)f.push("iss");for(let b of new Set(f.reverse()))if(!(b in n))throw new H(`missing required "${b}" claim`,n,b,"missing");if(s&&!(Array.isArray(s)?s:[s]).includes(n.iss))throw new H('unexpected "iss" claim value',n,"iss","check_failed");if(o&&n.sub!==o)throw new H('unexpected "sub" claim value',n,"sub","check_failed");if(p&&!qr(n.aud,typeof p==="string"?[p]:p))throw new H('unexpected "aud" claim value',n,"aud","check_failed");let l;switch(typeof r.clockTolerance){case"string":l=Ke(r.clockTolerance);break;case"number":l=r.clockTolerance;break;case"undefined":l=0;break;default:throw TypeError("Invalid clockTolerance option type")}let{currentDate:E}=r,T=F(E||new Date);if((n.iat!==void 0||u)&&typeof n.iat!=="number")throw new H('"iat" claim must be a number',n,"iat","invalid");if(n.nbf!==void 0){if(typeof n.nbf!=="number")throw new H('"nbf" claim must be a number',n,"nbf","invalid");if(n.nbf>T+l)throw new H('"nbf" claim timestamp check failed',n,"nbf","check_failed")}if(n.exp!==void 0){if(typeof n.exp!=="number")throw new H('"exp" claim must be a number',n,"exp","invalid");if(n.exp<=T-l)throw new fe('"exp" claim timestamp check failed',n,"exp","check_failed")}if(u){let b=T-n.iat,A=typeof u==="number"?u:Ke(u);if(b-l>A)throw new fe('"iat" claim timestamp check failed (too far in the past)',n,"iat","check_failed");if(b<0-l)throw new H('"iat" claim timestamp check failed (it should be in the past)',n,"iat","check_failed")}return n}class te{#e;constructor(e){if(!m(e))throw TypeError("JWT Claims Set MUST be an object");this.#e=structuredClone(e)}data(){return X.encode(JSON.stringify(this.#e))}get iss(){return this.#e.iss}set iss(e){this.#e.iss=e}get sub(){return this.#e.sub}set sub(e){this.#e.sub=e}get aud(){return this.#e.aud}set aud(e){this.#e.aud=e}set jti(e){this.#e.jti=e}set nbf(e){if(typeof e==="number")this.#e.nbf=ee("setNotBefore",e);else if(e instanceof Date)this.#e.nbf=ee("setNotBefore",F(e));else this.#e.nbf=F(new Date)+Ke(e)}set exp(e){if(typeof e==="number")this.#e.exp=ee("setExpirationTime",e);else if(e instanceof Date)this.#e.exp=ee("setExpirationTime",F(e));else this.#e.exp=F(new Date)+Ke(e)}set iat(e){if(e===void 0)this.#e.iat=F(new Date);else if(e instanceof Date)this.#e.iat=ee("setIssuedAt",F(e));else if(typeof e==="string")this.#e.iat=ee("setIssuedAt",F(new Date)+Ke(e));else this.#e.iat=ee("setIssuedAt",e)}}async function Qr(e,t,r){let n=await it(e,t,r);if(n.protectedHeader.crit?.includes("b64")&&n.protectedHeader.b64===!1)throw new K("JWTs MUST NOT use unencoded payload");let a={payload:pe(n.protectedHeader,n.payload,r),protectedHeader:n.protectedHeader};if(typeof t==="function")return{...a,key:n.key};return a}async function Zr(e,t,r){let n=await nt(e,t,r),i=pe(n.protectedHeader,n.plaintext,r),{protectedHeader:a}=n;if(a.iss!==void 0&&a.iss!==i.iss)throw new H('replicated "iss" claim header parameter mismatch',i,"iss","mismatch");if(a.sub!==void 0&&a.sub!==i.sub)throw new H('replicated "sub" claim header parameter mismatch',i,"sub","mismatch");if(a.aud!==void 0&&JSON.stringify(a.aud)!==JSON.stringify(i.aud))throw new H('replicated "aud" claim header parameter mismatch',i,"aud","mismatch");let s={payload:i,protectedHeader:a};if(typeof t==="function")return{...s,key:n.key};return s}class Ne{#e;constructor(e){this.#e=new j(e)}setContentEncryptionKey(e){return this.#e.setContentEncryptionKey(e),this}setInitializationVector(e){return this.#e.setInitializationVector(e),this}setProtectedHeader(e){return this.#e.setProtectedHeader(e),this}setKeyManagementParameters(e){return this.#e.setKeyManagementParameters(e),this}async encrypt(e,t){let r=await this.#e.encrypt(e,t);return[r.protected,r.encrypted_key,r.iv,r.ciphertext,r.tag].join(".")}}class ue{#e;#t;#r;constructor(e){if(!(e instanceof Uint8Array))throw TypeError("payload must be an instance of Uint8Array");this.#e=e}setProtectedHeader(e){return S(this.#t,"setProtectedHeader"),this.#t=e,this}setUnprotectedHeader(e){return S(this.#r,"setUnprotectedHeader"),this.#r=e,this}async sign(e,t){if(!this.#t&&!this.#r)throw new h("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!L(this.#t,this.#r))throw new h("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let r={...this.#t,...this.#r},n=k(h,new Map([["b64",!0]]),t?.crit,this.#t,r),i=!0;if(n.has("b64")){if(i=this.#t.b64,typeof i!=="boolean")throw new h('The "b64" (base64url-encode payload) Header Parameter must be a boolean')}let{alg:a}=r;if(typeof a!=="string"||!a)throw new h('JWS "alg" (Algorithm) Header Parameter missing or invalid');$(a,e,"sign");let s,o;if(i)s=y(this.#e),o=w(s);else o=this.#e,s="";let p,u;if(this.#t)p=y(JSON.stringify(this.#t)),u=w(p);else p="",u=new Uint8Array;let f=g(u,w("."),o),l=await U(e,a),E=await vt(a,l,f),T={signature:y(E),payload:s};if(this.#r)T.header=this.#r;if(this.#t)T.protected=p;return T}}class _e{#e;constructor(e){this.#e=new ue(e)}setProtectedHeader(e){return this.#e.setProtectedHeader(e),this}async sign(e,t){let r=await this.#e.sign(e,t);if(r.payload===void 0)throw TypeError("use the flattened module for creating JWS with b64: false");return`${r.protected}.${r.payload}.${r.signature}`}}class ir{#e;protectedHeader;unprotectedHeader;options;key;constructor(e,t,r){this.#e=e,this.key=t,this.options=r}setProtectedHeader(e){return S(this.protectedHeader,"setProtectedHeader"),this.protectedHeader=e,this}setUnprotectedHeader(e){return S(this.unprotectedHeader,"setUnprotectedHeader"),this.unprotectedHeader=e,this}addSignature(...e){return this.#e.addSignature(...e)}sign(...e){return this.#e.sign(...e)}done(){return this.#e}}class ar{#e;#t=[];constructor(e){this.#e=e}addSignature(e,t){let r=new ir(this,e,t);return this.#t.push(r),r}async sign(){if(!this.#t.length)throw new h("at least one signature must be added");let e={signatures:[],payload:""};for(let t=0;t<this.#t.length;t++){let r=this.#t[t],n=new ue(this.#e);n.setProtectedHeader(r.protectedHeader),n.setUnprotectedHeader(r.unprotectedHeader);let{payload:i,...a}=await n.sign(r.key,r.options);if(t===0)e.payload=i;else if(e.payload!==i)throw new h("inconsistent use of JWS Unencoded Payload (RFC7797)");e.signatures.push(a)}return e}}class sr{#e;#t;constructor(e={}){this.#t=new te(e)}setIssuer(e){return this.#t.iss=e,this}setSubject(e){return this.#t.sub=e,this}setAudience(e){return this.#t.aud=e,this}setJti(e){return this.#t.jti=e,this}setNotBefore(e){return this.#t.nbf=e,this}setExpirationTime(e){return this.#t.exp=e,this}setIssuedAt(e){return this.#t.iat=e,this}setProtectedHeader(e){return this.#e=e,this}async sign(e,t){let r=new _e(this.#t.data());if(r.setProtectedHeader(this.#e),Array.isArray(this.#e?.crit)&&this.#e.crit.includes("b64")&&this.#e.b64===!1)throw new K("JWTs MUST NOT use unencoded payload");return r.sign(e,t)}}class or{#e;#t;#r;#n;#a;#s;#o;#i;constructor(e={}){this.#i=new te(e)}setIssuer(e){return this.#i.iss=e,this}setSubject(e){return this.#i.sub=e,this}setAudience(e){return this.#i.aud=e,this}setJti(e){return this.#i.jti=e,this}setNotBefore(e){return this.#i.nbf=e,this}setExpirationTime(e){return this.#i.exp=e,this}setIssuedAt(e){return this.#i.iat=e,this}setProtectedHeader(e){return S(this.#n,"setProtectedHeader"),this.#n=e,this}setKeyManagementParameters(e){return S(this.#r,"setKeyManagementParameters"),this.#r=e,this}setContentEncryptionKey(e){return S(this.#e,"setContentEncryptionKey"),this.#e=e,this}setInitializationVector(e){return S(this.#t,"setInitializationVector"),this.#t=e,this}replicateIssuerAsHeader(){return this.#a=!0,this}replicateSubjectAsHeader(){return this.#s=!0,this}replicateAudienceAsHeader(){return this.#o=!0,this}async encrypt(e,t){let r=new Ne(this.#i.data());if(this.#n&&(this.#a||this.#s||this.#o))this.#n={...this.#n,iss:this.#a?this.#i.iss:void 0,sub:this.#s?this.#i.sub:void 0,aud:this.#o?this.#i.aud:void 0};if(r.setProtectedHeader(this.#n),this.#t)r.setInitializationVector(this.#t);if(this.#e)r.setContentEncryptionKey(this.#e);if(this.#r)r.setKeyManagementParameters(this.#r);return r.encrypt(e,t)}}var G=(e,t)=>{if(typeof e!=="string"||!e)throw new We(`${t} missing or invalid`)};async function cr(e,t){let r;if(Q(e))r=e;else if(me(e))r=await we(e);else throw TypeError(D(e,"CryptoKey","KeyObject","JSON Web Key"));if(t??="sha256",t!=="sha256"&&t!=="sha384"&&t!=="sha512")throw TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"');let n;switch(r.kty){case"AKP":G(r.alg,'"alg" (Algorithm) Parameter'),G(r.pub,'"pub" (Public key) Parameter'),n={alg:r.alg,kty:r.kty,pub:r.pub};break;case"EC":G(r.crv,'"crv" (Curve) Parameter'),G(r.x,'"x" (X Coordinate) Parameter'),G(r.y,'"y" (Y Coordinate) Parameter'),n={crv:r.crv,kty:r.kty,x:r.x,y:r.y};break;case"OKP":G(r.crv,'"crv" (Subtype of Key Pair) Parameter'),G(r.x,'"x" (Public Key) Parameter'),n={crv:r.crv,kty:r.kty,x:r.x};break;case"RSA":G(r.e,'"e" (Exponent) Parameter'),G(r.n,'"n" (Modulus) Parameter'),n={e:r.e,kty:r.kty,n:r.n};break;case"oct":G(r.k,'"k" (Key Value) Parameter'),n={k:r.k,kty:r.kty};break;default:throw new d('"kty" (Key Type) Parameter missing or unsupported')}let i=w(JSON.stringify(n));return y(await Ue(t,i))}async function jr(e,t){t??="sha256";let r=await cr(e,t);return`urn:ietf:params:oauth:jwk-thumbprint:sha-${t.slice(-3)}:${r}`}async function en(e,t){let r={...e,...t?.header};if(!m(r.jwk))throw new h('"jwk" (JSON Web Key) Header Parameter must be a JSON object');let n=await Z({...r.jwk,ext:!0},r.alg);if(n instanceof Uint8Array||n.type!=="public")throw new h('"jwk" (JSON Web Key) Header Parameter must be a public key');return n}function tn(e){switch(typeof e==="string"&&e.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";case"ML":return"AKP";default:throw new d('Unsupported "alg" value for a JSON Web Key Set')}}function rn(e){return e&&typeof e==="object"&&Array.isArray(e.keys)&&e.keys.every(nn)}function nn(e){return m(e)}class ur{#e;#t=new WeakMap;constructor(e){if(!rn(e))throw new he("JSON Web Key Set malformed");this.#e=structuredClone(e)}jwks(){return this.#e}async getKey(e,t){let{alg:r,kid:n}={...e,...t?.header},i=tn(r),a=this.#e.keys.filter((p)=>{let u=i===p.kty;if(u&&typeof n==="string")u=n===p.kid;if(u&&(typeof p.alg==="string"||i==="AKP"))u=r===p.alg;if(u&&typeof p.use==="string")u=p.use==="sig";if(u&&Array.isArray(p.key_ops))u=p.key_ops.includes("verify");if(u)switch(r){case"ES256":u=p.crv==="P-256";break;case"ES384":u=p.crv==="P-384";break;case"ES512":u=p.crv==="P-521";break;case"Ed25519":case"EdDSA":u=p.crv==="Ed25519";break}return u}),{0:s,length:o}=a;if(o===0)throw new re;if(o!==1){let p=new He,u=this.#t;throw p[Symbol.asyncIterator]=async function*(){for(let f of a)try{yield await pr(u,f,r)}catch{}},p}return pr(this.#t,s,r)}}async function pr(e,t,r){let n=e.get(t)||e.set(t,{}).get(t);if(n[r]===void 0){let i=await Z({...t,ext:!0},r);if(i instanceof Uint8Array||i.type!=="public")throw new he("JSON Web Key Set members must be public keys");n[r]=i}return n[r]}function Le(e){let t=new ur(e),r=async(n,i)=>t.getKey(n,i);return Object.defineProperties(r,{jwks:{value:()=>structuredClone(t.jwks()),enumerable:!1,configurable:!1,writable:!1}}),r}function an(){return typeof WebSocketPair<"u"||typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"||typeof EdgeRuntime<"u"&&EdgeRuntime==="vercel"}var st;if(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))st="jose/v6.2.3";var dr=Symbol();async function sn(e,t,r,n=fetch){let i=await n(e,{method:"GET",signal:r,redirect:"manual",headers:t}).catch((a)=>{if(a.name==="TimeoutError")throw new Te;throw a});if(i.status!==200)throw new x("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await i.json()}catch{throw new x("Failed to parse the JSON Web Key Set HTTP response as JSON")}}var Be=Symbol();function on(e,t){if(typeof e!=="object"||e===null)return!1;if(!("uat"in e)||typeof e.uat!=="number"||Date.now()-e.uat>=t)return!1;if(!("jwks"in e)||!m(e.jwks)||!Array.isArray(e.jwks.keys)||!Array.prototype.every.call(e.jwks.keys,m))return!1;return!0}class fr{#e;#t;#r;#n;#a;#s;#o;#i;#c;#p;constructor(e,t){if(!(e instanceof URL))throw TypeError("url must be an instance of URL");if(this.#e=new URL(e.href),this.#t=typeof t?.timeoutDuration==="number"?t?.timeoutDuration:5000,this.#r=typeof t?.cooldownDuration==="number"?t?.cooldownDuration:30000,this.#n=typeof t?.cacheMaxAge==="number"?t?.cacheMaxAge:600000,this.#o=new Headers(t?.headers),st&&!this.#o.has("User-Agent"))this.#o.set("User-Agent",st);if(!this.#o.has("accept"))this.#o.set("accept","application/json"),this.#o.append("accept","application/jwk-set+json");if(this.#i=t?.[dr],t?.[Be]!==void 0){if(this.#p=t?.[Be],on(t?.[Be],this.#n))this.#a=this.#p.uat,this.#c=Le(this.#p.jwks)}}pendingFetch(){return!!this.#s}coolingDown(){return typeof this.#a==="number"?Date.now()<this.#a+this.#r:!1}fresh(){return typeof this.#a==="number"?Date.now()<this.#a+this.#n:!1}jwks(){return this.#c?.jwks()}async getKey(e,t){if(!this.#c||!this.fresh())await this.reload();try{return await this.#c(e,t)}catch(r){if(r instanceof re){if(this.coolingDown()===!1)return await this.reload(),this.#c(e,t)}throw r}}async reload(){if(this.#s&&an())this.#s=void 0;this.#s||=sn(this.#e.href,this.#o,AbortSignal.timeout(this.#t),this.#i).then((e)=>{if(this.#c=Le(e),this.#p)this.#p.uat=Date.now(),this.#p.jwks=e;this.#a=Date.now(),this.#s=void 0}).catch((e)=>{throw this.#s=void 0,e}),await this.#s}}function cn(e,t){let r=new fr(e,t),n=async(i,a)=>r.getKey(i,a);return Object.defineProperties(n,{coolingDown:{get:()=>r.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>r.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>r.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>r.pendingFetch(),enumerable:!0,configurable:!1},jwks:{value:()=>r.jwks(),enumerable:!0,configurable:!1,writable:!1}}),n}class hr{#e;constructor(e={}){this.#e=new te(e)}encode(){let e=y(JSON.stringify({alg:"none"})),t=y(this.#e.data());return`${e}.${t}.`}setIssuer(e){return this.#e.iss=e,this}setSubject(e){return this.#e.sub=e,this}setAudience(e){return this.#e.aud=e,this}setJti(e){return this.#e.jti=e,this}setNotBefore(e){return this.#e.nbf=e,this}setExpirationTime(e){return this.#e.exp=e,this}setIssuedAt(e){return this.#e.iat=e,this}static decode(e,t){if(typeof e!=="string")throw new K("Unsecured JWT must be a string");let{0:r,1:n,2:i,length:a}=e.split(".");if(a!==3||i!=="")throw new K("Invalid Unsecured JWT");let s;try{if(s=JSON.parse(C.decode(W(r))),s.alg!=="none")throw Error()}catch{throw new K("Invalid Unsecured JWT")}return{payload:pe(s,W(n),t),header:s}}}function pn(e){let t;if(typeof e==="string"){let r=e.split(".");if(r.length===3||r.length===5)[t]=r}else if(typeof e==="object"&&e)if("protected"in e)t=e.protected;else throw TypeError("Token does not contain a Protected Header");try{if(typeof t!=="string"||!t)throw Error();let r=JSON.parse(C.decode(W(t)));if(!m(r))throw Error();return r}catch{throw TypeError("Invalid Token or Protected Header formatting")}}function un(e){if(typeof e!=="string")throw new K("JWTs must use Compact JWS serialization, JWT must be a string");let{1:t,length:r}=e.split(".");if(r===5)throw new K("Only JWTs using Compact JWS serialization can be decoded");if(r!==3)throw new K("Invalid JWT");if(!t)throw new K("JWTs must contain a payload");let n;try{n=W(t)}catch{throw new K("Failed to base64url decode the payload")}let i;try{i=JSON.parse(C.decode(n))}catch{throw new K("Failed to parse the decoded payload as JSON")}if(!m(i))throw new K("Invalid JWT Claims Set");return i}function ot(e){let t=e?.modulusLength??2048;if(typeof t!=="number"||t<2048)throw new d("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");return t}async function dn(e,t){let r,n;switch(e){case"PS256":case"PS384":case"PS512":r={name:"RSA-PSS",hash:`SHA-${e.slice(-3)}`,publicExponent:Uint8Array.of(1,0,1),modulusLength:ot(t)},n=["sign","verify"];break;case"RS256":case"RS384":case"RS512":r={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.slice(-3)}`,publicExponent:Uint8Array.of(1,0,1),modulusLength:ot(t)},n=["sign","verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":r={name:"RSA-OAEP",hash:`SHA-${parseInt(e.slice(-3),10)||1}`,publicExponent:Uint8Array.of(1,0,1),modulusLength:ot(t)},n=["decrypt","unwrapKey","encrypt","wrapKey"];break;case"ES256":r={name:"ECDSA",namedCurve:"P-256"},n=["sign","verify"];break;case"ES384":r={name:"ECDSA",namedCurve:"P-384"},n=["sign","verify"];break;case"ES512":r={name:"ECDSA",namedCurve:"P-521"},n=["sign","verify"];break;case"Ed25519":case"EdDSA":{n=["sign","verify"],r={name:"Ed25519"};break}case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":{n=["sign","verify"],r={name:e};break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{n=["deriveBits"];let i=t?.crv??"P-256";switch(i){case"P-256":case"P-384":case"P-521":{r={name:"ECDH",namedCurve:i};break}case"X25519":r={name:"X25519"};break;default:throw new d("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, and X25519")}break}default:throw new d('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return crypto.subtle.generateKey(r,t?.extractable??!1,n)}async function fn(e,t){let r,n,i;switch(e){case"HS256":case"HS384":case"HS512":r=parseInt(e.slice(-3),10),n={name:"HMAC",hash:`SHA-${r}`,length:r},i=["sign","verify"];break;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r=parseInt(e.slice(-3),10),crypto.getRandomValues(new Uint8Array(r>>3));case"A128KW":case"A192KW":case"A256KW":r=parseInt(e.slice(1,4),10),n={name:"AES-KW",length:r},i=["wrapKey","unwrapKey"];break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":case"A128GCM":case"A192GCM":case"A256GCM":r=parseInt(e.slice(1,4),10),n={name:"AES-GCM",length:r},i=["encrypt","decrypt"];break;default:throw new d('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return crypto.subtle.generateKey(n,t?.extractable??!1,i)}var wo="WebCryptoAPI";
|
|
6
|
-
export{Fe as
|
|
6
|
+
export{Fe as yd,fe as zd,ht as Ad,Nr as Bd,_r as Cd,Lr as Dd,Z as Ed,Br as Fd,kr as Gd,we as Hd,be as Id,nt as Jd,Vr as Kd,j as Ld,er as Md,ge as Nd,it as Od,Fr as Pd,Qr as Qd,Zr as Rd,Ne as Sd,ue as Td,_e as Ud,ar as Vd,sr as Wd,or as Xd,cr as Yd,jr as Zd,en as _d,Le as $d,dr as ae,Be as be,cn as ce,hr as de,pn as ee,un as fe,dn as ge,fn as he,wo as ie};
|