@opencode/console 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chunk-0752rr1w.js +1 -0
- package/chunk-11wqcgnn.js +2 -0
- package/{chunk-b02r286p.js → chunk-1z17cm3w.js} +2 -2
- package/chunk-38zs2jre.js +1 -0
- package/chunk-3p7x3f0s.js +1 -0
- package/chunk-5a8bvcgq.js +15 -0
- package/chunk-6fqhbptf.js +1 -0
- package/chunk-6hmr86q5.js +3 -0
- package/{chunk-wd4mfvqy.js → chunk-6xs4y82y.js} +2 -2
- package/{chunk-rx6cjbq2.js → chunk-7qa618ad.js} +55 -55
- package/chunk-82p6vmpy.js +1 -0
- package/chunk-9dgq3xc0.js +32 -0
- package/chunk-9zpe1ry1.js +2 -0
- package/chunk-b4fde357.js +2 -0
- package/chunk-b6azftzw.js +254 -0
- package/chunk-bcmj4f7y.js +2 -0
- package/chunk-cd4h496v.js +2 -0
- package/chunk-g9f1r3v3.js +1 -0
- package/chunk-gcqbk8bn.js +149 -0
- package/chunk-ghvsrvdw.js +1 -0
- package/chunk-jpqmm6pm.js +2 -0
- package/chunk-jxh84gfh.js +1 -0
- package/chunk-kd1hjfpe.js +1 -0
- package/{chunk-dnepb5ke.js → chunk-m3m5harb.js} +2 -2
- package/chunk-mnjk01tj.js +1 -0
- package/chunk-nqk8n93s.js +1 -0
- package/chunk-qp7a49b3.js +1 -0
- package/chunk-r1adn0ka.js +11 -0
- package/chunk-tamzaefd.js +1 -0
- package/chunk-x65p26st.js +2 -0
- package/chunk-yb3fn5r1.js +2 -0
- package/{chunk-jem7z938.js → chunk-z5mqjw9r.js} +2 -2
- package/dsh-plugin.js +1 -1
- package/index.js +50 -50
- package/package.json +1 -1
- package/pi-extension.js +2 -2
- package/chunk-0067hzw7.js +0 -11
- package/chunk-0trayd9n.js +0 -2
- package/chunk-37whdg3n.js +0 -1
- package/chunk-6bc9ezw6.js +0 -1
- package/chunk-71rwyxw2.js +0 -2
- package/chunk-78cwb109.js +0 -162
- package/chunk-7k3ymrp6.js +0 -254
- package/chunk-83pr45e8.js +0 -1
- package/chunk-96f5c0tj.js +0 -2
- package/chunk-ak1n0cs7.js +0 -2
- package/chunk-cdc5arvh.js +0 -1
- package/chunk-et9y1sb5.js +0 -2
- package/chunk-g9bke322.js +0 -1
- package/chunk-gvywgb0d.js +0 -1
- package/chunk-gxedprvk.js +0 -32
- package/chunk-kpp48ne0.js +0 -1
- package/chunk-ktx666b5.js +0 -2
- package/chunk-m3n97pxp.js +0 -1
- package/chunk-n5bt7jzp.js +0 -3
- package/chunk-px1nqkzb.js +0 -2
- package/chunk-sbkpkav3.js +0 -1
- package/chunk-t8p1svd4.js +0 -1
- package/chunk-tx5wws16.js +0 -2
- package/chunk-vy3ahcaj.js +0 -2
- package/chunk-w6kmmxmz.js +0 -1
- package/chunk-wkrya350.js +0 -1
- package/chunk-ysgtje2z.js +0 -1
- package/chunk-zgcspk2g.js +0 -1
package/chunk-7k3ymrp6.js
DELETED
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import"./chunk-dnepb5ke.js";import"./chunk-gvywgb0d.js";import{Ot,ao,As}from"./chunk-0trayd9n.js";import{ke,J,be,W}from"./chunk-wd4mfvqy.js";import{ye,Be}from"./chunk-tx5wws16.js";import{ur,yt,bt,pr,$n,Qe,fn,At,_,fr,je,Xe,It,Tt,dn}from"./chunk-78cwb109.js";import"./chunk-px1nqkzb.js";import{ar,cs,no}from"./chunk-rx6cjbq2.js";import{hr}from"./chunk-ktx666b5.js";import{$e}from"./chunk-71rwyxw2.js";import{Ct,lr}from"./chunk-96f5c0tj.js";import{le}from"./chunk-ak1n0cs7.js";import{k,F,Dt,Ce,I,g,D,z,S,e,V,v,n,x,u,Ze,Z}from"./chunk-gxedprvk.js";var he={};k(he,{Codex:()=>he,PROVIDER:()=>Q,hookArgs:()=>ce,manifest:()=>ne,manifestFile:()=>ee,models:()=>Pe,paths:()=>kn,refresh:()=>An,remove:()=>Cn,rules:()=>Je,trustHash:()=>ze});import{createHash as Re}from"node:crypto";import{existsSync as pe,realpathSync as gn,rmSync as yn}from"node:fs";import bn from"node:os";import C from"node:path";/*!
|
|
2
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
3
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
4
|
-
*
|
|
5
|
-
* Redistribution and use in source and binary forms, with or without
|
|
6
|
-
* modification, are permitted provided that the following conditions are met:
|
|
7
|
-
*
|
|
8
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
-
* list of conditions and the following disclaimer.
|
|
10
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
-
* this list of conditions and the following disclaimer in the
|
|
12
|
-
* documentation and/or other materials provided with the distribution.
|
|
13
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
14
|
-
* may be used to endorse or promote products derived from this software without
|
|
15
|
-
* specific prior written permission.
|
|
16
|
-
*
|
|
17
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
18
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
19
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
20
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
21
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
23
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
24
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
25
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
26
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
-
*/function He(r,t){let i=r.slice(0,t).split(/\r?\n/);return[i.length,i.pop().length+1]}function qe(r,t,i){let s=r.split(/\r?\n/),l="",a=(Math.log10(t+1)|0)+1;for(let o=t-1;o<=t+1;o++){let f=s[o-1];if(!f)continue;if(l+=o.toString().padEnd(a," "),l+=": ",l+=f,l+=`
|
|
28
|
-
`,o===t)l+=" ".repeat(a+i+2),l+=`^
|
|
29
|
-
`}return l}class h extends Error{line;column;codeblock;constructor(r,t){let[i,s]=He(t.toml,t.ptr),l=qe(t.toml,i,s);super(`Invalid TOML document: ${r}
|
|
30
|
-
|
|
31
|
-
${l}`,t);this.line=i,this.column=s,this.codeblock=l}static x(r,t,i){throw new h(r,{toml:t.s,ptr:i??t.p})}}/*!
|
|
32
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
33
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
34
|
-
*
|
|
35
|
-
* Redistribution and use in source and binary forms, with or without
|
|
36
|
-
* modification, are permitted provided that the following conditions are met:
|
|
37
|
-
*
|
|
38
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
39
|
-
* list of conditions and the following disclaimer.
|
|
40
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
41
|
-
* this list of conditions and the following disclaimer in the
|
|
42
|
-
* documentation and/or other materials provided with the distribution.
|
|
43
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
44
|
-
* may be used to endorse or promote products derived from this software without
|
|
45
|
-
* specific prior written permission.
|
|
46
|
-
*
|
|
47
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
48
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
49
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
50
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
51
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
52
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
53
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
54
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
55
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
56
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
57
|
-
*/function K(r){let t=r.p,i=r.s.charCodeAt(r.p++),s=i,l=i===39,a=i===r.s.charCodeAt(r.p)&&i===r.s.charCodeAt(r.p+1);if(a){if((i=r.s.charCodeAt(r.p+=2))===10)r.p++;else if(i===13&&r.s.charCodeAt(r.p+1)===10)r.p+=2}let o="",f=r.p,c=0;for(;r.p<r.s.length;r.p++)if(i=r.s.charCodeAt(r.p),a&&(i===10||i===13&&r.s.charCodeAt(r.p+1)===10))c=c&&3;else if(i<32&&i!==9||i===127)h.x("control characters are not allowed in strings",r);else if((!c||c===3)&&i===s&&(!a||r.s.charCodeAt(r.p+1)===s&&r.s.charCodeAt(r.p+2)===s)){if(a){if(r.s.charCodeAt(r.p+3)===s)r.p++;if(r.s.charCodeAt(r.p+3)===s)r.p++}if(!c){let p=r.s.slice(f,r.p);o=o?o+p:p}return r.p+=a?3:1,o}else if(!c){if(!l&&i===92)o+=r.s.slice(f,f=r.p),c=1}else if(c===1)if(i===120||i===117||i===85){let p=r.p++-1,m=0,y=i===120?2:i===117?4:8;for(let O=0;O<y;O++,r.p++){let b=r.s.charCodeAt(r.p),w=b>=48&&b<=57?b-48:b>=65&&b<=70?b-65+10:b>=97&&b<=102?b-97+10:-1;if(w<0)h.x("invalid non-hex character in unicode escape",r);m=m<<4|w}if(m<0||m>1114111||m>=55296&&m<=57343)h.x("invalid unicode escape",r,p);o+=String.fromCodePoint(m),f=r.p--,c=0}else if(a&&(i===32||i===9))c=2;else{if(i===98)o+="\b";else if(i===116)o+="\t";else if(i===110)o+=`
|
|
58
|
-
`;else if(i===102)o+="\f";else if(i===114)o+="\r";else if(i===101)o+="\x1B";else if(i===34)o+='"';else if(i===92)o+="\\";else h.x("unrecognised escape sequence",r);f=r.p+1,c=0}else if(i!==32&&i!==9){if(c===2)h.x("invalid escape: only line-ending whitespace may be escaped",r,f);c=!l&&i===92?1:0,f=r.p}h.x("unfinished string",r,t)}/*!
|
|
59
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
60
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
-
*
|
|
62
|
-
* Redistribution and use in source and binary forms, with or without
|
|
63
|
-
* modification, are permitted provided that the following conditions are met:
|
|
64
|
-
*
|
|
65
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
66
|
-
* list of conditions and the following disclaimer.
|
|
67
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
68
|
-
* this list of conditions and the following disclaimer in the
|
|
69
|
-
* documentation and/or other materials provided with the distribution.
|
|
70
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
71
|
-
* may be used to endorse or promote products derived from this software without
|
|
72
|
-
* specific prior written permission.
|
|
73
|
-
*
|
|
74
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
75
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
76
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
77
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
78
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
79
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
80
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
81
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
82
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
83
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
84
|
-
*/var Ye=/^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i;class j extends Date{#n=!1;#r=!1;#e=null;constructor(r,t,i){let s=!0,l=!0,a="Z",o;if(typeof r==="string")if(t)e:{if(t<3){if(+r.slice(11,13)>23){r="";break e}if(t===2)a=null,r+="Z";else if((o=r.charCodeAt(r.length-1))!==90&&o!==122)a=r.slice(r.length-6);if(i)r=r.slice(0,10)+"T"+r.slice(11)}else if(t===4)r=+r.slice(0,2)>23?"":`0000-01-01T${r}Z`;s=t!==4,l=t!==3}else{let f=r.match(Ye);if(f){if(!f[1])s=!1,r=`0000-01-01T${r}`;if(l=!!f[2],l&&r[10]===" "&&(r=r.replace(" ","T")),f[2]&&+f[2]>23)r="";else if(a=f[3]||null,!a&&l)r+="Z"}else r=""}super(r);if(!isNaN(this.getTime()))this.#n=s,this.#r=l,this.#e=a}isDateTime(){return this.#n&&this.#r}isLocal(){return!this.#n||!this.#r||!this.#e}isDate(){return this.#n&&!this.#r}isTime(){return this.#r&&!this.#n}isValid(){return this.#n||this.#r}toISOString(){let r=super.toISOString();if(this.isDate())return r.slice(0,10);if(this.isTime())return r.slice(11,23);if(this.#e===null)return r.slice(0,-1);if(this.#e==="Z"||this.#e==="z")return r;let t=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return t=this.#e[0]==="-"?t:-t,new Date(this.getTime()-t*60000).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(r,t="Z"){let i=new j(r);return i.#e=t,i}static wrapAsLocalDateTime(r){let t=new j(r);return t.#e=null,t}static wrapAsLocalDate(r){let t=new j(r);return t.#r=!1,t.#e=null,t}static wrapAsLocalTime(r){let t=new j(r);return t.#n=!1,t.#e=null,t}}/*!
|
|
85
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
86
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
87
|
-
*
|
|
88
|
-
* Redistribution and use in source and binary forms, with or without
|
|
89
|
-
* modification, are permitted provided that the following conditions are met:
|
|
90
|
-
*
|
|
91
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
92
|
-
* list of conditions and the following disclaimer.
|
|
93
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
94
|
-
* this list of conditions and the following disclaimer in the
|
|
95
|
-
* documentation and/or other materials provided with the distribution.
|
|
96
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
97
|
-
* may be used to endorse or promote products derived from this software without
|
|
98
|
-
* specific prior written permission.
|
|
99
|
-
*
|
|
100
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
101
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
102
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
103
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
104
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
105
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
106
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
107
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
108
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
109
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
110
|
-
*/function A(r,t=10){return t===16?r>47&&r<58||r>64&&r<71||r>96&&r<103:r>47&&r<48+t}function fe(r,t){return r===32||r===9||r===10||r===13||t&&(r===t||r===44)||r===35}function P(r,t){let i=r.p,s=r.s.charCodeAt(r.p);if(s===91||s===123){r.d--||h.x("document contains excessively nested structures. aborting.",r);let l=s===91?ve(r):Oe(r);return r.d++,l}if(s===34||s===39)return K(r);if(s===116){if(r.s.charCodeAt(++r.p)!==114||r.s.charCodeAt(++r.p)!==117||r.s.charCodeAt(++r.p)!==101)h.x("invalid value",r,i);return r.p++,!0}if(s===102){if(r.s.charCodeAt(++r.p)!==97||r.s.charCodeAt(++r.p)!==108||r.s.charCodeAt(++r.p)!==115||r.s.charCodeAt(++r.p)!==101)h.x("invalid value",r,i);return r.p++,!1}if(s===43||s===45)return G(r,r.p,r.s.charCodeAt(++r.p),44-s,t);if(r.s.charCodeAt(r.p+4)===45&&r.s.charCodeAt(r.p+7)===45)return en(r,s,t);if(r.s.charCodeAt(r.p+2)===58)return nn(r,s,t);return G(r,r.p,s,0,t)}function G(r,t,i,s,l){let a=i,o=0,f=!1;if(a===105){if(r.s.charCodeAt(++r.p)!==110||r.s.charCodeAt(++r.p)!==102)h.x("invalid value",r,t);return r.p++,(s||1)/0}if(a===110){if(r.s.charCodeAt(++r.p)!==97||r.s.charCodeAt(++r.p)!==110)h.x("invalid value",r,t);return r.p++,NaN}if(a===48){if(++r.p>=r.s.length||fe(a=r.s.charCodeAt(r.p),l))return r.bi===!0?0n:0;if(!s){if(a===120)return ae(r,t,16,l);else if(a===98)return ae(r,t,2,l);else if(a===111)return ae(r,t,8,l)}if(a===46)o=2;else if(a===101||a===69)o=4;else h.x("illegal leading zero",r,t)}else if(!A(a))h.x("invalid value",r,t);while(++r.p<r.s.length&&(a=r.s.charCodeAt(r.p),!fe(a,l))){if(!o)o=1;if(a===95){if(!(o&1))h.x("illegal underscore",r);o+=11,f=!0}else if(o===1&&a===46)o=2;else if((o===1||o===3)&&(a===101||a===69))o=4;else if(o===4&&(a===43||a===45))o=6;else if(!A(a))h.x("illegal character in numeric literal",r);else if(o>9)o-=11;else if(!(o&1))o++}if(!o){let p=(i-48)*(s||1);return r.bi===!0?BigInt(p):p}if(!(o&1))h.x("unfinished numeric value",r,t);let c=r.s.slice(t,r.p);if(f)c=c.replaceAll("_","");return o>1?parseFloat(c):Te(r,c,10,t)}function ae(r,t,i,s){let l,a=1;while(++r.p<r.s.length&&(l=r.s.charCodeAt(r.p),!fe(l,s)))if(l===95){if(a&1)h.x("illegal underscore",r);a=3}else if(!A(l,i))h.x("illegal character in numeric literal",r);else if(a&1)a--;if(a&1)h.x("unfinished numeric value",r);let o=r.s.slice(t+2,r.p);if(a)o=o.replaceAll("_","");return Te(r,o,i,t)}function Te(r,t,i,s){if(r.bi!==!0)e:{let l=parseInt(t,i);if(!Number.isSafeInteger(l)){if(r.bi)break e;h.x("integer value cannot be represented losslessly",r,s)}return l}return i===10?BigInt(t):BigInt((i===2?"0b":i===8?"0o":"0x")+t)}function en(r,t,i){let s=r.p++,l;if(!A(t)||!A(r.s.charCodeAt(r.p++))||!A(r.s.charCodeAt(r.p++))||!A(r.s.charCodeAt(r.p++)))return G(r,r.p=s,t,0,i);if(r.p+=5,!A(r.s.charCodeAt(r.p++)))h.x("invalid date-time: date part is malformed",r,s);if(r.p>=r.s.length||((t=r.s.charCodeAt(r.p))!==32||(l=!0,!A(r.s.charCodeAt(r.p+1))))&&t!==84&&t!==116){let o=r.s.slice(s,r.p);return L(r,o,3,!1,s)}if(r.s.charCodeAt(r.p+=3)!==58)h.x("invalid date-time: time part is malformed",r,s);if(r.s.charCodeAt(r.p+=3)===58)r.p+=3;if(r.s.charCodeAt(r.p)===46)while(A(r.s.charCodeAt(++r.p)));if(t=r.s.charCodeAt(r.p)){if(t===90||t===122){let o=r.s.slice(s,++r.p);return L(r,o,1,l,s,"[+00:00]")}if(t===43||t===45){let o=r.s.slice(s,r.p+=6);return L(r,o,1,l,s,!r.ld&&"["+r.s.slice(r.p-6,r.p)+"]")}}let a=r.s.slice(s,r.p);return L(r,a,2,l,s)}function nn(r,t,i){let s=r.p;if(!A(t)||!A(r.s.charCodeAt(++r.p)))return G(r,--r.p,t,0,i);if(r.s.charCodeAt(r.p+=4)===58)r.p+=3;if(r.s.charCodeAt(r.p)===46)while(A(r.s.charCodeAt(++r.p)));let l=r.s.slice(s,r.p);return L(r,l,4,!1,s)}function L(r,t,i,s,l,a){if(r.ld){let o=new j(t,i,s);if(!o.isValid())h.x("invalid date",r,l);return o}try{if(a)t+=a;switch(i){case 1:return Temporal.ZonedDateTime.from(t);case 2:return Temporal.PlainDateTime.from(t);case 3:return Temporal.PlainDate.from(t);case 4:return Temporal.PlainTime.from(t)}}catch(o){h.x(o instanceof Error?o.message:""+o,r,l)}}/*!
|
|
111
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
112
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
113
|
-
*
|
|
114
|
-
* Redistribution and use in source and binary forms, with or without
|
|
115
|
-
* modification, are permitted provided that the following conditions are met:
|
|
116
|
-
*
|
|
117
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
118
|
-
* list of conditions and the following disclaimer.
|
|
119
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
120
|
-
* this list of conditions and the following disclaimer in the
|
|
121
|
-
* documentation and/or other materials provided with the distribution.
|
|
122
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
123
|
-
* may be used to endorse or promote products derived from this software without
|
|
124
|
-
* specific prior written permission.
|
|
125
|
-
*
|
|
126
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
127
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
128
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
129
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
130
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
131
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
132
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
133
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
134
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
135
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
136
|
-
*/function rn(r){for(;r.p<r.s.length;r.p++){let t=r.s.charCodeAt(r.p);if(t===10)break;if(t===13&&r.s.charCodeAt(r.p+1)===10){r.p++;break}if(t<32&&t!==9||t===127)h.x("control characters are not allowed in comments",r)}}function T(r,t,i){let s;while(r.p<r.s.length){while(r.p<r.s.length&&((s=r.s.charCodeAt(r.p))===32||s===9||!t&&(s===10||s===13&&r.s.charCodeAt(r.p+1)===10)))r.p++;if(i||s!==35)break;rn(r)}}/*!
|
|
137
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
138
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
139
|
-
*
|
|
140
|
-
* Redistribution and use in source and binary forms, with or without
|
|
141
|
-
* modification, are permitted provided that the following conditions are met:
|
|
142
|
-
*
|
|
143
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
144
|
-
* list of conditions and the following disclaimer.
|
|
145
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
146
|
-
* this list of conditions and the following disclaimer in the
|
|
147
|
-
* documentation and/or other materials provided with the distribution.
|
|
148
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
149
|
-
* may be used to endorse or promote products derived from this software without
|
|
150
|
-
* specific prior written permission.
|
|
151
|
-
*
|
|
152
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
153
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
154
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
155
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
156
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
157
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
158
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
159
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
160
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
161
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
162
|
-
*/function H(r,t=61){let i,s=0,l=[],a,o=r.s.charCodeAt(i=r.p);do if(o===t){if(!s)h.x("unexpected end of key",r);if(s===1)l.push(r.s.slice(a,r.p));return r.p++,l}else if(o===46){if(!s)h.x("illegal empty bare key",r);if(s===1)l.push(r.s.slice(a,r.p));s=0}else if(!s&&(o===34||o===39)){if(o===r.s.charCodeAt(r.p+1)&&o===r.s.charCodeAt(r.p+2))h.x("illegal quoted key: multiline strings are not allowed",r);l.push(K(r)),s=2,r.p--}else if(o===32||o===9){if(s===1)l.push(r.s.slice(a,r.p)),s=2}else if(s===2||o<48&&o!==45||o>57&&o<65||o>90&&o<97&&o!==95||o>122)h.x("illegal character in key",r);else if(!s)s=1,a=r.p;while(o=r.s.charCodeAt(++r.p));h.x("incomplete key-value: cannot find end of key",r,i)}function Oe(r){let t=r.p++,i=Object.create(null),s=new Set,l;while(r.p<r.s.length){if(T(r),(l=r.s.charCodeAt(r.p))===125)return r.p++,i;let a,o=i,f=!1,c=r.p,p=H(r);for(let y=0;y<p.length;y++){if(y)o=f?o[a]:o[a]=Object.create(null);if(a=p[y],(f=Object.hasOwn(o,a))&&(typeof o[a]!=="object"||s.has(o[a])))h.x("trying to redefine an already defined value",r,c);let O=a==="__proto__";if(r.uk&&(O||a==="constructor")){o=r.uk!==1&&h.x("document contains an unsafe property",r,c);break}if(!f&&O)Object.defineProperty(o,a,{enumerable:!0,configurable:!0,writable:!0})}if(f)h.x("trying to redefine an already defined value",r,c);T(r,!0,!0);let m=P(r,125);if(o&&typeof(o[a]=m)==="object")s.add(m);if(T(r),(l=r.s.charCodeAt(r.p++))===125)return i;if(l!==44)h.x("expected comma or end of structure",r,r.p-1)}h.x("unfinished table",r,t)}function ve(r){let t=r.p++,i=[],s;while(r.p<r.s.length){if(T(r),(s=r.s.charCodeAt(r.p))===93)return r.p++,i;if(i.push(P(r,93)),T(r),(s=r.s.charCodeAt(r.p++))===93)return i;if(s!==44)h.x("expected comma or end of structure",r,r.p-1)}h.x("unfinished array",r,t)}/*!
|
|
163
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
164
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
165
|
-
*
|
|
166
|
-
* Redistribution and use in source and binary forms, with or without
|
|
167
|
-
* modification, are permitted provided that the following conditions are met:
|
|
168
|
-
*
|
|
169
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
170
|
-
* list of conditions and the following disclaimer.
|
|
171
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
172
|
-
* this list of conditions and the following disclaimer in the
|
|
173
|
-
* documentation and/or other materials provided with the distribution.
|
|
174
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
175
|
-
* may be used to endorse or promote products derived from this software without
|
|
176
|
-
* specific prior written permission.
|
|
177
|
-
*
|
|
178
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
179
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
180
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
181
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
182
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
183
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
184
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
185
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
186
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
187
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
188
|
-
*/function Ee(r,t,i,s,l){let a=i,o=s,f,c=!1,p;for(let m=0;m<t.length;m++){if(m){if(a=c?a[f]:a[f]=Object.create(null),o=(p=o[f]).c,l===0&&(p.t===1||p.t===2))return null;if(p.t===2){let y=a.length-1;a=a[y],o=o[y].c}}if(f=t[m],(c=Object.hasOwn(a,f))&&o[f]?.t===0&&o[f]?.d)return null;if(!c){let y=f==="__proto__";if(r.uk&&(y||f==="constructor"))return!1;if(y)Object.defineProperty(a,f,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(o,f,{enumerable:!0,configurable:!0,writable:!0});o[f]={t:m<t.length-1&&l===2?3:l,d:!1,i:0,c:Object.create(null)}}}if(p=o[f],p.t!==l&&!(l===1&&p.t===3))return null;if(l===2){if(!p.d)p.d=!0,a[f]=[];a[f].push(a=Object.create(null)),p.c[p.i++]=p={t:1,d:!1,i:0,c:Object.create(null)}}if(p.d)return null;if(p.d=!0,l===1)a=c?a[f]:a[f]=Object.create(null);else if(l===0&&c)return null;return[f,a,p.c]}function Ie(r,t,i){if(t===null||r.uk===2)h.x(t===null?"trying to redefine an already defined table or value":"document contains an unsafe property",r,i)}function ue(r,t={}){let i={s:r,p:0,d:t.maxDepth??1000,bi:t.integersAsBigInt??!1,ld:t.useLegacyDate??!0,uk:t.unsafeKeyBehaviour==="throw"?2:t.unsafeKeyBehaviour==="drop"?1:0},s=Object.create(null),l=Object.create(null),a,o=!1,f=s,c=l;if(r.charCodeAt(0)===65279)i.p++;T(i);while(i.p<r.length){if(r.charCodeAt(i.p)===91){let p=r.charCodeAt(++i.p)===91;a=i.p+=+p,o=!1;let m=H(i,93);if(p){if(r.charCodeAt(i.p)!==93)h.x("expected end of table array declaration",i);i.p++}let y=Ee(i,m,s,l,p?2:1);if(!y)Ie(i,y,a),o=!0;else c=y[2],f=y[1]}else{a=i.p;let p=H(i),m=Ee(i,p,f,c,0);if(!m&&!o)Ie(i,m,a);T(i,!0,!0);let y=P(i,void 0);if(m&&!o)m[1][m[0]]=y}if(T(i,!0),i.p<r.length&&(a=r.charCodeAt(i.p))!==10&&(a!==13||r.charCodeAt(i.p+1)!==10))h.x("each key-value declaration must be followed by an end-of-line",i);T(i)}return s}/*!
|
|
189
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
190
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
191
|
-
*
|
|
192
|
-
* Redistribution and use in source and binary forms, with or without
|
|
193
|
-
* modification, are permitted provided that the following conditions are met:
|
|
194
|
-
*
|
|
195
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
196
|
-
* list of conditions and the following disclaimer.
|
|
197
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
198
|
-
* this list of conditions and the following disclaimer in the
|
|
199
|
-
* documentation and/or other materials provided with the distribution.
|
|
200
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
201
|
-
* may be used to endorse or promote products derived from this software without
|
|
202
|
-
* specific prior written permission.
|
|
203
|
-
*
|
|
204
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
205
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
206
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
207
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
208
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
209
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
210
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
211
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
212
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
213
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
214
|
-
*/var Xn=!!"".isWellFormed;/*!
|
|
215
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
216
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
217
|
-
*
|
|
218
|
-
* Redistribution and use in source and binary forms, with or without
|
|
219
|
-
* modification, are permitted provided that the following conditions are met:
|
|
220
|
-
*
|
|
221
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
222
|
-
* list of conditions and the following disclaimer.
|
|
223
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
224
|
-
* this list of conditions and the following disclaimer in the
|
|
225
|
-
* documentation and/or other materials provided with the distribution.
|
|
226
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
227
|
-
* may be used to endorse or promote products derived from this software without
|
|
228
|
-
* specific prior written permission.
|
|
229
|
-
*
|
|
230
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
231
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
232
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
233
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
234
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
235
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
236
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
237
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
238
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
239
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
240
|
-
*/function Ne(r){let t=J(r);if(t===void 0||t.trim()==="")return;let i=R(t);if(!i)throw Error(`${r} isn't valid TOML, so it was left alone. Fix it and run setup again.`);return{text:t,value:i}}function _e(r,t,i){let s=R(t)??{},l=De(s),a=i.reduce((c,p)=>{if(p.type==="key"){if(p.value===void 0)delete l[p.key];else l[p.key]=p.value;return on(c,p.key,p.value)}if(p.type==="remove")return mn(l,p.path),an(c,p.path);return hn(l,p.path,p.entries),ln(c,p.path,p.entries)},t),o=/^\s*\n/.test(t)?a:a.replace(/^\s*\n/,""),f=R(o);if(!f||X(f)!==X(l))throw Error(`${r} couldn't be updated without changing settings setup doesn't own, so it was left alone.`);return o}function U(r,t){return t.reduce((i,s)=>E(i)?i[s]:void 0,r)}function q(r){if(typeof r==="string")return JSON.stringify(r);if(typeof r==="number"||typeof r==="boolean")return String(r);if(Array.isArray(r))return`[${r.map(q).join(", ")}]`;if(E(r))return`{ ${Object.entries(r).filter(([,t])=>t!==void 0).map(([t,i])=>`${Y(t)} = ${q(i)}`).join(", ")} }`;throw Error(`Can't write ${String(r)} as TOML`)}function Y(r){return/^[A-Za-z0-9_-]+$/.test(r)?r:JSON.stringify(r)}function E(r){return typeof r==="object"&&r!==null&&!Array.isArray(r)&&!(r instanceof Date)}function R(r){try{return ue(r)}catch{return}}function on(r,t,i){let s=r.split(`
|
|
241
|
-
`),l=s.findIndex(de),a=l===-1?s.length:l,o=s.slice(0,a).findIndex((p)=>un(p)===t),f=i===void 0?[]:[`${Y(t)} = ${q(i)}`];if(o!==-1)return[...s.slice(0,o),...f.map((p)=>`${p}${sn(s[o])}`),...s.slice(o+1)].join(`
|
|
242
|
-
`);if(i===void 0)return r;let c=s.slice(0,a).findLastIndex((p)=>p.trim()!==""&&!p.trim().startsWith("#"));return[...s.slice(0,c+1),...f,...s.slice(c+1)].join(`
|
|
243
|
-
`)}function sn(r){let t=[...r.matchAll(/#/g)].map((i)=>i.index).find((i)=>R(r.slice(0,i))!==void 0);return t===void 0?"":r.slice(r.slice(0,t).trimEnd().length)}function an(r,t){let i=r.split(`
|
|
244
|
-
`),s=i.findIndex((c)=>de(c)&&!c.trim().startsWith("[[")&&cn(pn(c),t));if(s===-1)return r;let l=i.slice(s+1).findIndex(de),a=l===-1?i.length:s+1+l,o=i.slice(0,a).findLastIndex((c)=>c.trim()!=="")+1,f=i.slice(0,s).findLastIndex((c)=>c.trim()!=="")+1;return[...i.slice(0,f),...i.slice(o)].join(`
|
|
245
|
-
`)}function ln(r,t,i){let s=Object.entries(i).filter(([,a])=>a!==void 0).map(([a,o])=>`${Y(a)} = ${q(o)}`),l=r.replace(/\s*$/,"");return`${l===""?"":`${l}
|
|
246
|
-
|
|
247
|
-
`}[${t.map(Y).join(".")}]
|
|
248
|
-
${s.join(`
|
|
249
|
-
`)}
|
|
250
|
-
`}function de(r){return/^\s*\[/.test(r)}function un(r){let t=r.match(/^\s*(?:([A-Za-z0-9_-]+)|"((?:[^"\\]|\\.)*)"|'([^']*)')\s*=/);if(!t)return;let i=t[2]===void 0?void 0:R(`k = "${t[2]}"`)?.k;return t[1]??t[3]??(typeof i==="string"?i:void 0)}function pn(r){let t=R(`${r}
|
|
251
|
-
`),i=[],s=t;while(E(s)&&Object.keys(s).length===1){let l=Object.keys(s)[0];i.push(l),s=s[l]}return i}function De(r){return Object.fromEntries(Object.entries(r).map(([t,i])=>[t,xe(i)]))}function xe(r){if(Array.isArray(r))return r.map(xe);if(E(r))return De(r);return r}function cn(r,t){return r.length===t.length&&r.every((i,s)=>i===t[s])}function hn(r,t,i){let s=t.slice(0,-1).reduce((l,a)=>{let o=l[a];if(E(o))return o;let f={};return l[a]=f,f},r);s[t.at(-1)]=Object.fromEntries(Object.entries(i).filter(([,l])=>l!==void 0))}function mn(r,t){let i=U(r,t.slice(0,-1));if(E(i))delete i[t.at(-1)]}function X(r){if(Array.isArray(r))return`[${r.map(X).join(",")}]`;if(r instanceof Date)return JSON.stringify(r.toISOString());if(E(r))return`{${Object.keys(r).toSorted().map((t)=>[t,X(r[t])]).filter(([,t])=>t!=="{}").map(([t,i])=>`${JSON.stringify(t)}:${i}`).join(",")}}`;return JSON.stringify(r)}function kn(r=process.env,t=bn.homedir()){let i=r.CODEX_HOME?.trim(),s=i?Le(C.resolve(i)):C.join(t,".codex"),l=C.join(s,"AGENTS.override.md");return{home:s,config:C.join(s,"config.toml"),hooks:C.join(s,"hooks.json"),rules:C.join(s,"rules","opencode-console.rules"),skills:C.join(s,"skills"),memory:(J(l)?.trim()??"")===""?C.join(s,"AGENTS.md"):l}}function Le(r){if(pe(r))return gn(r);let t=C.dirname(r);return t===r?r:C.join(Le(t),C.basename(r))}function Pe(r,t,i){let s=lr(Ct(r)),l=t.models[0];if(s===void 0||l===void 0)return;return{baseURL:`${s}/openai/v1`,catalogURL:`${i}${ao}`,model:l.slug,count:t.models.length}}function Je(r){return r.flatMap((t,i)=>{if(t.action!=="tool.use"||t.effect!=="deny"||!t.resource.startsWith("shell:"))return[];let s=t.resource.slice(6).match(/^([^*?]+)\*$/)?.[1]?.trim(),l=s?.split(/\s+/)??[];if(!s||l.some((o)=>!/^[\w@%+=:,./-]+$/.test(o)))return[];if(r.slice(i+1).some((o)=>o.action==="tool.use"&&o.effect==="allow"&&no(o.resource,`shell:${s}`)))return[];let a=[...t.message].map((o)=>o<" "||o===""?" ":o).join("");return[`prefix_rule(pattern = ${JSON.stringify(l)}, decision = "forbidden", justification = ${JSON.stringify(a)})`]})}var wn=n({baseURL:e,catalogURL:e,model:e,count:V}),Ue=n({paths:n({home:e,config:e,hooks:e,rules:e,skills:e,memory:e}),command:u(e),harness:S(e),environment:x(e,e),...ur,tables:u(u(e)),servers:u(e),skills:x(e,e),memoryCreated:v,created:n({config:v,hooks:v}),providers:S(e),models:S(Ze(wn))}),ee=(r)=>C.join(r.data,"codex.json");function ne(r){let t=ee(r),i=J(t);if(i===void 0)return;let s=F(z(Z(Ue))(i));if(!s)throw Error(`${t} can't be read, so Codex was left as it is. Delete it and run setup again.`);return s}var Q="opencode-console",ce=["hook","codex"],An=D("Codex.refresh")(function*(r,t){let i=ne(r),s=t??i;if(!s)return;let l=yield*Be(r),a=l&&$e(r,ye(l));if(!l||!a?.config)return;let o=a.config,f=je(o),c=Re("sha256").update(JSON.stringify(o.providers??null)).digest("hex"),m=!t&&i?.providers===c&&i.models!==void 0?i.models??void 0:yield*Dt([Ot(l),As(l)],{concurrency:2}).pipe(g(([w,N])=>Pe(w,N,l.server))),y=yield*It(l,s.paths.skills,f.skills,i?.skills??{}),O=hr(l,a),b=yield*Ce([{action:"websearch:",resources:["*"],truncated:!0},{action:"websearch.use",resources:["openai"]}],(w)=>ar(O,w));return yield*ke(r,I(()=>Sn(r,{paths:s.paths,command:s.command,harness:t?t.harness:i?.harness,environment:t?t.environment??{}:i?.environment??{},models:m,servers:Object.fromEntries(Object.entries(Xe(o)).map(([w,N])=>[w,{url:N.url,gateway:N.headers!==void 0}])),instructions:f.instructions,skills:f.skills,bundles:y,rules:Je(cs(O)??[]),searchOff:b.some((w)=>w.effect==="deny"),providers:c,explicit:t!==void 0})))});function Cn(r){let t=ne(r);if(!t)return!1;let i=Ne(t.paths.config),s=yt(t.paths.hooks),l=J(t.paths.memory),a=i&&_e(t.paths.config,i.text,[...Object.keys(t.originals).flatMap((o)=>{let f={...i.value};return $n(f,o,t),JSON.stringify(f[o])===JSON.stringify(i.value[o])?[]:[{type:"key",key:o,value:f[o]}]}),...t.tables.filter((o)=>U(i.value,o)!==void 0).map((o)=>({type:"remove",path:o}))]);if(i&&a!==void 0){if(a.trim()===""&&t.created.config)W(t.paths.config);else if(a!==i.text)At(t.paths.config,a)}if(s)if(Fe(s),Object.keys(s).length===0&&t.created.hooks)W(t.paths.hooks);else bt(t.paths.hooks,s);return W(t.paths.rules),Object.keys(t.skills).forEach((o)=>yn(C.join(t.paths.skills,o),{recursive:!0,force:!0})),dn(t.paths.memory,l,[],t.memoryCreated),[t.paths.config,t.paths.hooks].forEach((o)=>W(Qe(o))),W(ee(r)),!0}function Sn(r,t){let i=ne(r),s=pe(t.paths.config),l=pe(t.paths.hooks),a=Ne(t.paths.config)??{text:"",value:{}},o=yt(t.paths.hooks)??{},f=J(t.paths.memory),c=i?.created??{config:!s,hooks:!l},p=[];Fe(o);let m=_(o.hooks),y=[...t.command,...t.harness===void 0?[]:["--harness",t.harness]],O=vn(y).map(([d,M])=>{let Se=[...Array.isArray(m[d])?m[d]:[],M];return m[d]=Se,{event:d,group:M,index:Se.length-1}});o.hooks=m;let b={...a.value},{originals:w,written:N}=pr(b,Tn(t),i,t.explicit),Ve=[...new Set([...Object.keys(i?.originals??{}),...Object.keys(w)])].flatMap((d)=>JSON.stringify(b[d])===JSON.stringify(a.value[d])?[]:[{type:"key",key:d,value:b[d]}]),re=new Map((i?.tables??[]).map((d)=>[JSON.stringify(d),d])),te=(d)=>!re.has(JSON.stringify(d))&&U(a.value,d)!==void 0,me=["model_providers",Q];if(t.models&&te(me))throw Error(`${t.paths.config} already has a model provider named ${Q}, so Codex was left as it is. Rename it and run setup again.`);let ie=Object.entries(t.servers).flatMap(([d,M])=>{if(M.url===void 0||!/^[a-z0-9_-]+$/i.test(d))return[];if(te(["mcp_servers",d]))return p.push(d),[];return[{name:d,url:M.url,gateway:M.gateway}]}),ge=O.map((d)=>({path:["hooks","state",`${t.paths.hooks}:${We(d.event)}:${d.index}:0`],hash:ze(d.event,d.group)})),oe=[...t.models?[{path:[...me],entries:On(t)}]:[],...ie.map((d)=>({path:["mcp_servers",d.name],entries:{url:d.url,...d.gateway?{http_headers_helper:fr([...En(t.environment),...y,"mcp-headers",d.name])}:{}}})),...ge.map((d)=>({path:d.path,entries:{trusted_hash:d.hash}}))],Ke=(d)=>re.has(JSON.stringify(d.path))&&B(U(a.value,d.path))===B(d.entries),we=new Set(oe.filter(Ke).map((d)=>JSON.stringify(d.path))),Ae=_e(t.paths.config,a.text,[...Ve,...[...re].filter(([d])=>!we.has(d)).map(([,d])=>d).filter((d)=>U(a.value,d)!==void 0).map((d)=>({type:"remove",path:d})),...ge.filter((d)=>te(d.path)).map((d)=>({type:"remove",path:d.path})),...oe.filter((d)=>!we.has(JSON.stringify(d.path))).map((d)=>({type:"table",path:d.path,entries:d.entries}))]);if(!i)[t.paths.config,t.paths.hooks].forEach(fn);if(Ae!==a.text)At(t.paths.config,Ae,384);if(bt(t.paths.hooks,o,384),t.rules.length>0)In(t.paths.rules,`# Written by OpenCode Console from the workspace's policies; \`npx @opencode/console sync\` rewrites it.
|
|
252
|
-
${t.rules.join(`
|
|
253
|
-
`)}
|
|
254
|
-
`);else W(t.paths.rules);let se=Tt(t.paths.skills,t.skills,t.bundles,i?.skills??{});p.push(...se.skipped);let Ge=dn(t.paths.memory,f,t.instructions,i?.memoryCreated??!1);return be(ee(r),JSON.stringify(Ue.make({paths:t.paths,command:[...t.command],...t.harness===void 0?{}:{harness:t.harness},environment:{...t.environment},originals:w,written:N,tables:oe.map((d)=>d.path),servers:ie.map((d)=>d.name),skills:se.skills,memoryCreated:Ge,created:c,providers:t.providers,models:t.models??null}))),{models:t.models,servers:ie.map((d)=>d.name),skills:Object.keys(se.skills),instructions:t.instructions.length,rules:t.rules.length,searchOff:t.searchOff,skipped:p}}function Tn(r){return{...r.models?{model_provider:Q,model:r.models.model}:{},...r.searchOff?{web_search:"disabled"}:{}}}function On(r){let t=r.models;return{name:"OpenCode Console",base_url:t.baseURL,wire_api:"responses",model_catalog_url:t.catalogURL,http_headers:{"x-opencode-plugin":`opencode-console/${le}`},auth:{command:r.command[0],args:[...r.command.slice(1),"token"],refresh_interval_ms:240000,timeout_ms:15000}}}function vn(r){let t=fr([...r,...ce]);return[["PreToolUse",{matcher:"*",hooks:[{type:"command",command:t,timeout:30}]}],["UserPromptSubmit",{hooks:[{type:"command",command:t,timeout:30}]}],["SessionStart",{hooks:[{type:"command",command:t,timeout:10}]}]]}function ze(r,t){let i=t.hooks[0],s={event_name:We(r),..."matcher"in t?{matcher:t.matcher}:{},hooks:[{type:i.type,command:i.command,timeout:i.timeout,async:!1}]};return`sha256:${Re("sha256").update(B(s)).digest("hex")}`}function We(r){return r.replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase()}function B(r){if(Array.isArray(r))return`[${r.map(B).join(",")}]`;if(E(r))return`{${Object.keys(r).toSorted().map((t)=>`${JSON.stringify(t)}:${B(r[t])}`).join(",")}}`;return JSON.stringify(r)}function Fe(r){let t=_(r.hooks);if(Object.entries(t).forEach(([i,s])=>{if(!Array.isArray(s))return;let l=s.flatMap((a)=>{let o=_(a).hooks;if(!Array.isArray(o))return[a];let f=o.filter((c)=>!jn(c));if(f.length===o.length)return[a];return f.length===0?[]:[{..._(a),hooks:f}]});if(l.length===0)delete t[i];else t[i]=l}),Object.keys(t).length===0)delete r.hooks;else r.hooks=t}function jn(r){let t=_(r).command;return typeof t==="string"&&t.endsWith(` ${ce.join(" ")}`)}function En(r){let t=Object.entries(r);if(t.length===0||process.platform==="win32")return[];return["env",...t.map(([i,s])=>`${i}=${s}`)]}function In(r,t){if(J(r)!==t)At(r,t)}export{he as Codex,Q as PROVIDER,ce as hookArgs,ne as manifest,ee as manifestFile,Pe as models,kn as paths,An as refresh,Cn as remove,Je as rules,ze as trustHash};
|
package/chunk-83pr45e8.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ha,zo,Ko,Zr,Wo,Jo,Go,Yr,Dn,Qr,Vo,ga,xa,Zo,Yo,Qo}from"./chunk-vy3ahcaj.js";import"./chunk-et9y1sb5.js";import"./chunk-rx6cjbq2.js";import"./chunk-96f5c0tj.js";import"./chunk-71rwyxw2.js";import"./chunk-78cwb109.js";import"./chunk-ktx666b5.js";import"./chunk-tx5wws16.js";import"./chunk-px1nqkzb.js";import"./chunk-0trayd9n.js";import"./chunk-gvywgb0d.js";import"./chunk-wd4mfvqy.js";import"./chunk-dnepb5ke.js";export{Qo as Pi,Zr as Unreadable,Wo as checks,Ko as defaultModel,Dn as directory,Vo as manifest,Yr as manifestFile,Zo as models,Qr as modelsFile,ha as paths,zo as providers,xa as remove,ga as setup,Go as skillCommand,Yo as skills,Jo as userBash};
|
package/chunk-96f5c0tj.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{_,at}from"./chunk-78cwb109.js";function Ct(t){return Object.entries(t).toSorted(([e],[o])=>i(e)-i(o)).flatMap(([e,o])=>Object.entries(o.models).flatMap(([n,r])=>s(r)?[{provider:e,providerName:o.name,id:n,entry:r}]:[]))}function cr(t,...e){let o=(n)=>t.filter((r)=>r.id.toLowerCase().includes("claude")&&r.id.toLowerCase().includes(n)).toSorted((r,a)=>i(r.provider)-i(a.provider)||d(a).localeCompare(d(r)))[0];return e.map(o).find((n)=>n!==void 0)??t[0]}function lr(t){return t.flatMap((e)=>Object.values(_(e.entry.api))).flatMap((e)=>at(_(e).base_url)??[]).map((e)=>e.match(/^(https?:\/\/.+?)\/(?:go\/)?(?:anthropic\/v1|openai\/v1|google\/v1beta|v1)\/?$/)?.[1]??e.match(/^(https?:\/\/.+?)\/custom\/[^/]+(?:\/.*)?$/)?.[1]).find((e)=>e!==void 0)}function s(t){let e=_(_(t.capabilities).tools).supported,o=_(t.modalities).output;return(t.type??"chat")==="chat"&&e!==!1&&(!Array.isArray(o)||o.includes("text")&&!o.includes("audio"))}function d(t){return at(t.entry.release_date)??""}function i(t){return t==="opencode"?0:t==="opencode-go"?1:2}
|
|
2
|
-
export{Ct,cr,lr};
|
package/chunk-ak1n0cs7.js
DELETED
package/chunk-cdc5arvh.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./chunk-dnepb5ke.js";import{Pt}from"./chunk-wd4mfvqy.js";import{k,F,z,e,n,Z}from"./chunk-gxedprvk.js";var u={};k(u,{CliInstall:()=>u,directory:()=>m,install:()=>I,packageName:()=>b,uninstall:()=>D});import{randomUUID as S}from"node:crypto";import{chmodSync as g,copyFileSync as j,cpSync as v,existsSync as c,readFileSync as C,realpathSync as f,renameSync as h,rmSync as l}from"node:fs";import t from"node:path";var b="@opencode/console",m=(r)=>t.join(r.data,"cli");function I(r,o){let s=m(r);if(o.entry===void 0){let a=t.join(s,t.basename(o.execPath));return x(s,(p)=>{Pt(p);let y=t.join(p,t.basename(o.execPath));j(o.execPath,y),g(y,493)}),[a]}let i=f(o.entry),d=t.dirname(i);if(!O(d))return[o.execPath,i];return x(s,(a)=>v(d,a,{recursive:!0})),[U(o.execPath,o.path),t.join(s,t.basename(i))]}function U(r,o){if(!c(r))return r;let s=f(r);return(o??"").split(t.delimiter).filter((i)=>t.isAbsolute(i)).map((i)=>t.join(i,t.basename(r))).find((i)=>c(i)&&f(i)===s)??r}function D(r){l(m(r),{recursive:!0,force:!0})}function O(r){let o=t.join(r,"package.json");if(!c(o))return!1;let s=z(Z(n({name:e})))(C(o,"utf8"));return F(s)?.name===b}function x(r,o){Pt(t.dirname(r));let s=`${r}.${S()}.tmp`,i=`${r}.${S()}.old`;try{if(o(s),c(r))h(r,i);h(s,r)}finally{l(s,{recursive:!0,force:!0}),l(i,{recursive:!0,force:!0})}}export{u as CliInstall,m as directory,I as install,b as packageName,D as uninstall};
|
package/chunk-et9y1sb5.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{_t,po}from"./chunk-gvywgb0d.js";import{vr,Ms,Ns,be}from"./chunk-wd4mfvqy.js";import{Ee,ye}from"./chunk-tx5wws16.js";import{ar}from"./chunk-rx6cjbq2.js";import{mr,hr}from"./chunk-ktx666b5.js";import{us,ps,$e}from"./chunk-71rwyxw2.js";import{le}from"./chunk-ak1n0cs7.js";import{k,vn,Ce,Rr,Ae,Tn}from"./chunk-gxedprvk.js";var as={};k(as,{InProcess:()=>as,config:()=>Le,decide:()=>xt,decisions:()=>ir,refresh:()=>is,refreshStale:()=>fi,session:()=>sr});function sr(e={}){let r=us({version:le,harness:e.harness}).pipe(vn(po)),o=e.fetch;return{store:e.store??vr(),run:(n)=>Tn(o?n.pipe(Rr(r),Ae(_t,o)):n.pipe(Rr(r)))}}var i=new WeakMap;function is(e){let r=i.get(e);if(r)return r;let o=e.run(ps(e.store)).finally(()=>i.delete(e));return i.set(e,o),o}async function xt(e,r){return(await ir(e,r)).find((o)=>o.effect==="deny")}async function ir(e,r){let o=Ee(e.store),n=hr(o,o&&await Le(e));return Tn(Ce(r,(t)=>ar(n,t)))}async function Le(e){let r=Ee(e.store);if(!r)return;let o=ye(r),n=$e(e.store,o);if(!n)await new Promise((t)=>{let s=setTimeout(t,3000);s.unref?.(),is(e).catch(()=>{return}).finally(()=>{clearTimeout(s),t()})});else if(mr(n,Date.now()))fi(e);return $e(e.store,o)}function fi(e){let r=Ms(e.store),o=Ns(r);if(o!==void 0&&Date.now()-o<30000)return!1;return be(r,""),is(e).catch(()=>{return}),!0}
|
|
2
|
-
export{sr,is,xt,ir,Le,fi,as};
|
package/chunk-g9bke322.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{us,di,ps,$e,fs}from"./chunk-71rwyxw2.js";import"./chunk-ktx666b5.js";import"./chunk-tx5wws16.js";import"./chunk-px1nqkzb.js";import"./chunk-0trayd9n.js";import"./chunk-gvywgb0d.js";import"./chunk-wd4mfvqy.js";import"./chunk-dnepb5ke.js";export{fs as WorkspaceSync,$e as current,us as identify,ps as sync,di as userAgent};
|
package/chunk-gvywgb0d.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{k,C,t,c,ee,De,Jt,ho,s,Fi,Pe,f,R,te,Us,Re,oe,Se,i,a,A,U,H,Me,wr,F,M,ue,xn,Zt,T,y,ze,E,P,K,yn,he,ve,we,Mt,Er,Wn,N,Jn,bn,yo,bo,qs,Sn,Ft,pe,Ui,se,Cr,Ar,wn,En,Ir,lt,ge,r,O,I,Ut,o,ut,L,Tr,Cn,l,An,Je,g,pt,nt,Or,zs,rt,_r,Eo,Ks,ko,Lt,Ws,Js,tn,Yn,Qn,Gs,Ys,rn,Et,Co,Ao,Io,$t,Qs,Xs,ei,Ie,fe,Nr,Dr,Hi,$r,dt,Po,zi,Ki,Ro,Mo,_n,Wi,on,Ji,Gi,jt,No,oi,Fo,Vi,sn,Zi,ot,qr,Yi,Qi,Xi,ea,ta,an,Do,Bt,tr,cn,j,h,Z,ci,un,it,ua,Gr,Bo,Fn,pa,qo,fa,Ho,da,ma,gt}from"./chunk-gxedprvk.js";var Oi={};k(Oi,{Fetch:()=>_t,RequestInit:()=>uo,StreamBodyFallback:()=>pn,layer:()=>po});var Rs={};k(Rs,{HttpClient:()=>_e,SpanNameGenerator:()=>Ko,TracerDisabledWhen:()=>Qo,TracerHeaderFilter:()=>Yo,TracerPropagationEnabled:()=>Zo,catch:()=>Ms,catchTag:()=>ks,catchTags:()=>_s,circuitBreakerClassifier:()=>jo,del:()=>As,execute:()=>Hs,filterOrElse:()=>Fs,filterOrFail:()=>Ns,filterStatus:()=>Ls,filterStatusOk:()=>Ai,followRedirects:()=>Ra,get:()=>Cs,head:()=>ws,isHttpClient:()=>$o,isTransientError:()=>pr,isTransientResponse:()=>mr,layerMergedContext:()=>dr,make:()=>ur,makeWith:()=>tt,mapRequest:()=>Ii,mapRequestEffect:()=>js,mapRequestInput:()=>Vs,mapRequestInputEffect:()=>Zs,options:()=>Ds,patch:()=>Os,post:()=>Is,put:()=>Bs,query:()=>Ts,retry:()=>ra,retryTransient:()=>oa,tap:()=>Sa,tapError:()=>ba,tapRequest:()=>Ha,timeout:()=>na,transform:()=>ne,transformResponse:()=>Fe,withCircuitBreaker:()=>aa,withCookiesRef:()=>Ca,withRateLimiter:()=>sa,withScope:()=>Ti});var co={};k(co,{accept:()=>er,acceptJson:()=>Sr,appendUrl:()=>Gn,appendUrlParam:()=>Kn,appendUrlParams:()=>Xn,basicAuth:()=>$n,bearerToken:()=>ki,bodyFile:()=>fs,bodyFormData:()=>is,bodyFormDataRecord:()=>cs,bodyJson:()=>ns,bodyJsonUnsafe:()=>Ci,bodyStream:()=>ps,bodyText:()=>os,bodyUint8Array:()=>rs,bodyUrlParams:()=>as,compressBody:()=>es,delete:()=>Nn,empty:()=>so,fromWeb:()=>us,get:()=>Ps,head:()=>Ln,isHttpClientRequest:()=>qt,make:()=>Q,makeWith:()=>D,modify:()=>Xe,options:()=>vn,patch:()=>Mn,post:()=>Ei,prependUrl:()=>zn,put:()=>kn,query:()=>Dn,removeHash:()=>ts,removeHeader:()=>yt,schemaBodyJson:()=>ss,setBody:()=>W,setHash:()=>go,setHeader:()=>Wt,setHeaders:()=>mn,setMethod:()=>He,setUrl:()=>io,setUrlParam:()=>Zn,setUrlParams:()=>mo,toUrl:()=>Xt,toWeb:()=>ls,toWebResult:()=>xo,trace:()=>qn,updateHeaders:()=>ao,updateUrl:()=>Vn,upgrade:()=>jn});var lo={};k(lo,{TypeId:()=>xt,filterStatus:()=>nr,filterStatusOk:()=>hn,fromWeb:()=>or,matchStatus:()=>xs,schemaBodyJson:()=>et,schemaBodyUrlParams:()=>So,schemaHeaders:()=>To,schemaJson:()=>gs,schemaNoBody:()=>Es,stream:()=>ys,toWeb:()=>hs});var dn="~effect/Ref",Aa={[dn]:{_A:c},...Se,toJSON(){return{_id:"Ref",ref:this.ref}}};var xr=(e)=>I(()=>e.ref.current);var br=t(2,(e,n)=>I(()=>{e.ref.current=n(e.ref.current)}));var Ne="~effect/http/HttpBody";var Hr="~effect/http/HttpBody/HttpBodyError";class qe extends N("HttpBodyError"){[Hr]=Hr}class It{[Ne];constructor(){this[Ne]=Ne}[R](){return this.toJSON()}toString(){return f(this,{ignoreToString:!0})}}class Mr extends It{_tag="Empty";toJSON(){return{_id:"effect/HttpBody",_tag:"Empty"}}}var Ot=new Mr;class kr extends It{_tag="Raw";body;contentType;contentLength;constructor(e,n,p){super();this.body=e,this.contentType=n,this.contentLength=p}toJSON(){return{_id:"effect/HttpBody",_tag:"Raw",body:this.body,contentType:this.contentType,contentLength:this.contentLength}}}var Fr=(e,n)=>new kr(e,n?.contentType,n?.contentLength);class ie extends It{_tag="Uint8Array";contentType;contentLength;text;_body;constructor(e,n,p,u){super();this._body=e,this.text=u,this.contentType=n,this.contentLength=p}get body(){return this._body??=gn(this.text)}toJSON(){return{_id:"effect/HttpBody",_tag:"Uint8Array",body:this.contentType.startsWith("text/")||this.contentType.endsWith("json")?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}}var me=(e,n)=>new ie(e,n??"application/octet-stream",e.length),Lr=new TextEncoder,ce=globalThis.Buffer,gn=ce!==void 0?(e)=>ce.from(e,"utf8"):(e)=>Lr.encode(e),Vt=(e,n)=>{if(typeof e!=="string")e=e===void 0?"":String(e);if(ce!==void 0)return new ie(void 0,n??"text/plain",ce.byteLength(e,"utf8"),e);let p=Lr.encode(e);return new ie(p,n??"text/plain",p.length,e)},vr=(e,n)=>Vt(JSON.stringify(e),n??"application/json"),We=(e,n)=>L({try:()=>Vt(JSON.stringify(e),n??"application/json"),catch:(p)=>new qe({reason:{_tag:"JsonError"},cause:p})}),Jr=(e,n)=>{let p=Bt(un(e));return(u,d)=>p(u,n).pipe(rt((m)=>new qe({reason:{_tag:"SchemaError",issue:m},cause:m})),l((m)=>We(m,d)))},Wr=(e,n)=>Vt(ta(ot(e)),n??"application/x-www-form-urlencoded");class jr extends It{_tag="FormData";contentType=void 0;contentLength=void 0;formData;constructor(e){super();this.formData=e}toJSON(){return{_id:"effect/HttpBody",_tag:"FormData",formData:this.formData}}}var $e=(e)=>new jr(e),Rr=(e,n,p)=>{if(p==null)return;if(typeof p==="object"){e.append(n,p);return}e.append(n,String(p))},zr=(e)=>{let n=new globalThis.FormData;for(let[p,u]of Object.entries(e))if(Array.isArray(u))for(let d of u)Rr(n,p,d);else Rr(n,p,u);return $e(n)};class Vr extends It{_tag="Stream";stream;contentType;contentLength;constructor(e,n,p){super();this.stream=e,this.contentType=n,this.contentLength=p}toJSON(){return{_id:"effect/HttpBody",_tag:"Stream",contentType:this.contentType,contentLength:this.contentLength}}}var Qt=(e,n,p)=>new Vr(e,n??"application/octet-stream",p),Ur=(e,n,p)=>{let u=$r(e);return U(u)?r(u.value):o(it({module:"HttpBody",method:p,description:`Invalid ${n}: ${e}`}))},Hn=fe(function*(e,n,p){let u=p?.offset===void 0?Hi:yield*Ur(p.offset,"offset",n),d=p?.bytesToRead===void 0?void 0:yield*Ur(p.bytesToRead,"bytesToRead",n),m=u>=e?BigInt("0"):e-u,x=d===void 0||d>m?m:d;if(x>BigInt(Number.MAX_SAFE_INTEGER))return yield*o(it({module:"HttpBody",method:n,description:`Content length exceeds Number.MAX_SAFE_INTEGER: ${x}`}));return Number(x)}),Qr=(e,n)=>l(gt,(p)=>l(p.stat(e),(u)=>g(Hn(u.size,"file",n),(d)=>Qt(p.stream(e,n),n?.contentType,d))));var je="~effect/http/HttpClientError",Yt=(e)=>s(e,je);class _ extends N("HttpClientError"){constructor(e){if("cause"in e.reason)super({...e,cause:e.reason.cause});else super(e)}[je]=je;get request(){return this.reason.request}get response(){return"response"in this.reason?this.reason.response:void 0}get message(){return this.reason.message}}var At=(e)=>e.endsWith("Error")?e.slice(0,-5):e,Dt=(e,n,p)=>n?`${e}: ${n} (${p})`:`${e} error (${p})`,kt=(e)=>`${e.method} ${an(e.url)}`,Nt=(e,n)=>({...n,request:{_id:"HttpClientRequest",method:e.request.method,url:an(e.request.url)},..."response"in e?{response:{_id:"HttpClientResponse",status:e.response.status}}:void 0});class vt extends N("TransportError"){get methodAndUrl(){return kt(this.request)}get message(){return Dt(At(this._tag),this.description,this.methodAndUrl)}toJSON(){return Nt(this,super.toJSON())}}class Ee extends N("EncodeError"){get methodAndUrl(){return kt(this.request)}get message(){return Dt(At(this._tag),this.description,this.methodAndUrl)}toJSON(){return Nt(this,super.toJSON())}}class Ge extends N("InvalidUrlError"){get methodAndUrl(){return kt(this.request)}get message(){return Dt(At(this._tag),this.description,this.methodAndUrl)}toJSON(){return Nt(this,super.toJSON())}}class bt extends N("StatusCodeError"){get methodAndUrl(){return kt(this.request)}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return Dt(At(this._tag),this.description,e)}toJSON(){return Nt(this,super.toJSON())}}class Ht extends N("DecodeError"){get methodAndUrl(){return kt(this.request)}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return Dt(At(this._tag),this.description,e)}toJSON(){return Nt(this,super.toJSON())}}class Ve extends N("EmptyBodyError"){get methodAndUrl(){return kt(this.request)}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return Dt(At(this._tag),this.description,e)}toJSON(){return Nt(this,super.toJSON())}}function Qe(e){return e!=="GET"&&e!=="HEAD"&&e!=="OPTIONS"&&e!=="TRACE"}var Yr=[["GET","get"],["POST","post"],["PUT","put"],["DELETE","del"],["PATCH","patch"],["HEAD","head"],["OPTIONS","options"],["TRACE","trace"],["QUERY","query"]];var Kr=(e)=>(n)=>n.pipeThrough(new CompressionStream(e)),Rn=(e)=>new ReadableStream({start(n){n.enqueue(e),n.close()}}),Xr=(e,n,p)=>{if(e._tag!=="Uint8Array"&&e._tag!=="Stream")return r(e);if(e.contentLength!==void 0&&e.contentLength<(p?.minSize??1024))return r(e);if(e._tag==="Uint8Array")return g(lt(()=>new globalThis.Response(Kr(n)(Rn(e.body))).arrayBuffer()),(u)=>me(new Uint8Array(u),e.contentType));return r(Qt(Bo({evaluate:()=>Kr(n)(da(e.stream)),onError:c}),e.contentType))};var to=(e,n)=>{if(n._tag==="Empty"||n._tag==="FormData")return jt(jt(e,"content-type"),"content-length");return e=n.contentType===void 0?jt(e,"content-type"):on(e,"content-type",n.contentType),Ye(e,n)},Ye=(e,n)=>{let p=n._tag==="Empty"||n._tag==="FormData"?void 0:n.contentLength;return p===void 0?jt(e,"content-length"):on(e,"content-length",p.toString())},eo=(e)=>{if(e===null||e===void 0||!/^\d+$/.test(e))return;let n=Number(e);return Number.isSafeInteger(n)?n:void 0};class be extends N("UrlError"){}var Kt=(e,n,p)=>ze({try:()=>{let u=new URL(e,On());for(let d=0;d<n.params.length;d++){let[m,x]=n.params[d];if(x!==void 0)u.searchParams.append(m,sn(x))}if(p!==void 0)u.hash=p;return u},catch:(u)=>new be({cause:u})}),On=()=>{if("location"in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0){let e=location.origin+location.pathname;try{return new URL(e).href}catch{return}}return},oo=(e,n)=>ze({try:()=>new URL(e,n),catch:()=>new Sn(`Invalid URL: "${e}"${n!==void 0?` with base "${n}"`:""}`)});var Ke="~effect/http/HttpClientRequest",qt=(e)=>s(e,Ke),Bn={[Ke]:Ke,...te,toJSON(){return{_id:"HttpClientRequest",method:this.method,url:an(this.url),urlParams:this.urlParams,hash:this.hash,headers:Pe(this.headers),body:this.body.toJSON()}},pipe(){return C(this,arguments)}};function D(e,n,p,u,d,m){let x=Object.create(Bn);return x.method=e,x.url=n,x.urlParams=p,x.hash=u,x.headers=d,x.body=m,x}var so=D("GET","",qr,i(),Mo,Ot),Q=(e)=>(n,p)=>Xe(so,{method:e,url:n,...p??void 0}),Ps=Q("GET"),Dn=Q("QUERY"),Ei=Q("POST"),Mn=Q("PATCH"),kn=Q("PUT"),Nn=Q("DELETE");var Ln=Q("HEAD"),vn=Q("OPTIONS"),qn=Q("TRACE"),Xe=t(2,(e,n)=>{let p=e;if(n.method)p=He(p,n.method);if(n.url)p=io(p,n.url);if(n.headers)p=mn(p,n.headers);if(n.urlParams)p=mo(p,n.urlParams);if(n.hash)p=go(p,n.hash);if(n.body)p=W(p,n.body);if(n.accept)p=er(p,n.accept);if(n.acceptJson)p=Sr(p);return p}),He=t(2,(e,n)=>D(n,e.url,e.urlParams,e.hash,e.headers,e.body)),Wt=t(3,(e,n,p)=>D(e.method,e.url,e.urlParams,e.hash,on(e.headers,n,p),e.body)),mn=t(2,(e,n)=>D(e.method,e.url,e.urlParams,e.hash,Ji(e.headers,n),e.body)),ao=t(2,(e,n)=>D(e.method,e.url,e.urlParams,e.hash,n(e.headers),e.body)),yt=t(2,(e,n)=>ao(e,jt(n))),$n=t(3,(e,n,p)=>Wt(e,"Authorization",`Basic ${dt(`${Ro(n)}:${Ro(p)}`)}`)),ki=t(2,(e,n)=>Wt(e,"Authorization",`Bearer ${Ro(n)}`)),er=t(2,(e,n)=>Wt(e,"Accept",n)),Sr=er("application/json"),jn=t(2,(e,n)=>D(e.method,e.url,e.urlParams,e.hash,on(on(e.headers,"connection","Upgrade"),"upgrade",n),e.body)),io=t(2,(e,n)=>{if(typeof n==="string")return D(e.method,n,e.urlParams,e.hash,e.headers,e.body);let p=new URL(n.toString()),u=ot(p.searchParams),d=Me(p.hash===""?void 0:p.hash.slice(1));return p.search="",p.hash="",D(e.method,p.toString(),u,d,e.headers,e.body)}),zn=t(2,(e,n)=>{if(n==="")return e;return D(e.method,fo(n,e.url),e.urlParams,e.hash,e.headers,e.body)}),Gn=t(2,(e,n)=>{if(n==="")return e;return D(e.method,fo(e.url,n),e.urlParams,e.hash,e.headers,e.body)}),fo=(e,n)=>{let p=e.endsWith("/"),u=n.startsWith("/");return p&&u?e+n.slice(1):!p&&!u?e+"/"+n:e+n},Vn=t(2,(e,n)=>D(e.method,n(e.url),e.urlParams,e.hash,e.headers,e.body)),Zn=t(3,(e,n,p)=>D(e.method,e.url,Yi(e.urlParams,n,p),e.hash,e.headers,e.body)),mo=t(2,(e,n)=>D(e.method,e.url,Qi(e.urlParams,n),e.hash,e.headers,e.body)),Kn=t(3,(e,n,p)=>D(e.method,e.url,Xi(e.urlParams,n,p),e.hash,e.headers,e.body)),Xn=t(2,(e,n)=>D(e.method,e.url,ea(e.urlParams,n),e.hash,e.headers,e.body)),go=t(2,(e,n)=>D(e.method,e.url,e.urlParams,a(n),e.headers,e.body)),ts=(e)=>D(e.method,e.url,e.urlParams,i(),e.headers,e.body),W=t(2,(e,n)=>D(e.method,e.url,e.urlParams,e.hash,to(e.headers,n),n)),es=t((e)=>qt(e[0]),(e,n,p)=>{if(e.headers["content-encoding"]!==void 0)return r(e);return g(Xr(e.body,n,p),(u)=>u===e.body?e:D(e.method,e.url,e.urlParams,e.hash,on(Ye(e.headers,u),"content-encoding",n),u))}),rs=t((e)=>qt(e[0]),(e,n,p)=>W(e,me(n,p))),os=t((e)=>qt(e[0]),(e,n,p)=>W(e,Vt(n,p))),ns=t(2,(e,n)=>g(We(n),(p)=>W(e,p))),Ci=t(2,(e,n)=>W(e,vr(n))),ss=(e,n)=>{let p=Jr(e,n);return t(2,(u,d)=>g(p(d),(m)=>W(u,m)))},as=t(2,(e,n)=>W(e,Wr(ot(n)))),is=t(2,(e,n)=>W(e,$e(n))),cs=t(2,(e,n)=>W(e,zr(n))),ps=t((e)=>qt(e[0]),(e,n,p)=>W(e,Qt(n,p?.contentType,p?.contentLength))),fs=t((e)=>qt(e[0]),(e,n,p)=>g(Qr(n,p),(u)=>W(e,u)));function Xt(e){let n=Kt(e.url,e.urlParams,F(e.hash));if(P(n))return a(n.success);return i()}var us=(e)=>{let n=e.method.toUpperCase();return Xe(D(n,"",qr,i(),Mo,Ot),{url:new URL(e.url),headers:e.headers,body:ds(e,n)})},ds=(e,n)=>{if(!Qe(n)||e.body===null)return Ot;return Fr(e.body,{contentType:e.headers.get("content-type")??void 0,contentLength:eo(e.headers.get("content-length"))})},xo=(e,n)=>{let p=Kt(e.url,e.urlParams,F(e.hash));if(E(p))return y(p.failure);let u={method:e.method,headers:e.headers};if(n?.signal)u.signal=n.signal;if(Qe(e.method))switch(e.body._tag){case"Empty":break;case"Raw":{if(u.body=e.body.body,ms(e.body.body))u.duplex="half";break}case"Uint8Array":{u.body=e.body.body;break}case"FormData":{u.body=e.body.formData;break}case"Stream":{u.body=Ho(e.body.stream,n?.context??ue()),u.duplex="half";break}}return ze({try:()=>new Request(p.success,u),catch:(d)=>new be({cause:d})})},ms=(e)=>typeof ReadableStream<"u"&&e instanceof ReadableStream,ls=(e,n)=>Qn((p)=>Cn(xo(e,{context:p,signal:n?.signal})));var Rt="~effect/http/HttpIncomingMessage";var et=(e,n)=>{let p=cn(un(e)),u=n?.reviver===void 0?void 0:cn(Z(un(e),n));return(d)=>u===void 0?l(d.json,(m)=>p(m,n)):l(d.text,(m)=>m===""?l(d.json,(x)=>p(x,n)):u(m,n))},So=(e,n)=>{let p=ci.pipe(h(e),cn);return(u)=>l(u.urlParamsBody,(d)=>p(d,n))},To=(e,n)=>{let p=tr(e);return(u)=>p(u.headers,n)};var wo=(e,n)=>({...n,headers:Pe(e.headers),remoteAddress:e.remoteAddress});var Ce="~effect/http/HttpClientResponse/WebSource",Te=(e)=>e["~effect/http/HttpClientResponse/WebSource"]?.();var xt="~effect/http/HttpClientResponse",or=(e,n)=>new Oo(e,n),hs=(e)=>wr(Te(e)),gs=(e,n)=>{let p=cn(un(e),n),u=et(j,n);return(d)=>l(u(d),(m)=>p({status:d.status,headers:d.headers,body:m}))},Es=(e,n)=>{let p=cn(e,n);return(u)=>p({status:u.status,headers:u.headers})},ys=(e)=>Fn(g(e,(n)=>n.stream)),xs=t(2,(e,n)=>{let p=e.status;if(n[p])return n[p](e);else if(p>=200&&p<300&&n["2xx"])return n["2xx"](e);else if(p>=300&&p<400&&n["3xx"])return n["3xx"](e);else if(p>=400&&p<500&&n["4xx"])return n["4xx"](e);else if(p>=500&&p<600&&n["5xx"])return n["5xx"](e);return n.orElse(e)}),nr=t(2,(e,n)=>O(()=>n(e.status)?r(e):o(new _({reason:new bt({response:e,request:e.request,description:"invalid status code"})})))),hn=(e)=>e.status>=200&&e.status<300?r(e):o(new _({reason:new bt({response:e,request:e.request,description:"non 2xx status code"})}));class Oo extends Us{[Rt];[xt];request;source;constructor(e,n){super();this.request=e,this.source=n,this[Rt]=Rt,this[xt]=xt}toJSON(){return wo(this,{_id:"HttpClientResponse",request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get url(){if(this.source.url)return this.source.url.split("#")[0];let e=Xt(this.request);if(A(e))return"";return e.value.hash="",e.value.href}get headers(){return _n(this.source.headers)}cachedCookies;get cookies(){if(this.cachedCookies)return this.cachedCookies;return this.cachedCookies=Po(this.source.headers.getSetCookie?.()??[])}get remoteAddress(){return i()}[Ce](){return this.source}get stream(){return this.source.body?Bo({evaluate:()=>this.source.body,onError:(e)=>new _({reason:new Ht({request:this.request,response:this,cause:e})})}):Gr(new _({reason:new Ve({request:this.request,response:this,description:"can not create stream from empty body"})}))}get json(){return l(this.text,(e)=>L({try:()=>e===""?null:JSON.parse(e),catch:(n)=>new _({reason:new Ht({request:this.request,response:this,cause:n})})}))}textBody;get text(){return this.textBody??=g(this.arrayBuffer,(e)=>new TextDecoder().decode(e))}get urlParamsBody(){return l(this.arrayBuffer,(e)=>L({try:()=>ot(Zi(e)),catch:(n)=>new _({reason:new Ht({request:this.request,response:this,cause:n})})}))}formDataBody;get formData(){return this.formDataBody??=ge({try:()=>this.source.formData(),catch:(e)=>new _({reason:new Ht({request:this.request,response:this,cause:e})})}).pipe(Co,Ie)}arrayBufferBody;get arrayBuffer(){if(this.arrayBufferBody)return this.arrayBufferBody;return this.arrayBufferBody=ge({try:()=>this.source.arrayBuffer(),catch:(e)=>new _({reason:new Ht({request:this.request,response:this,cause:e})})}).pipe(Co,Ie),this.arrayBufferBody}get upgrade(){return o(new _({reason:new bt({request:this.request,response:this,description:"fetch cannot hand over the connection of an HTTP upgrade"})}))}pipe(){return C(this,arguments)}}var _o=(e)=>Wi({b3:`${e.traceId}-${e.spanId}-${e.sampled?"1":"0"}${H(e.parent,{onNone:()=>"",onSome:(n)=>`-${n.spanId}`})}`,traceparent:`00-${e.traceId.padStart(32,"0")}-${e.spanId}-${e.sampled?"01":"00"}`});var Ss={"http:":80,"https:":443,"ws:":80,"wss:":443},vo=(e,n,p)=>{let u=an(n.search,p).slice(1);if(e.attribute("url.full",an(n.href,p)),e.attribute("url.path",n.pathname),u!=="")e.attribute("url.query",u);if(e.attribute("url.scheme",n.protocol.slice(0,-1)),n.hostname!==""){e.attribute("server.address",n.hostname.startsWith("[")?n.hostname.slice(1,-1):n.hostname);let d=n.port===""?Ss[n.protocol]:Number(n.port);if(d!==void 0)e.attribute("server.port",d)}},Jo=(e,n)=>{let p=e.params.filter(([,u])=>typeof u!=="string").map(([u])=>u);return p.length===0?n:[...n,...new URLSearchParams(p.map((u)=>[u,""])).keys()]},sr=(e,n,p,u,d)=>{for(let m in p){if(!u(m,n))continue;e.attribute(`http.${n}.header.${m}`,No(m,d)?"<redacted>":p[m])}};var ir="~effect/http/HttpClient",$o=(e)=>s(e,ir),_e=M("effect/HttpClient"),ft=(e)=>(...n)=>l(_e,(p)=>p[e](...n)),Hs=ft("execute"),Cs=ft("get"),Ts=ft("query"),ws=ft("head"),Is=ft("post"),Os=ft("patch"),Bs=ft("put"),As=ft("del"),Ds=ft("options"),ne=t(2,(e,n)=>tt(l((p)=>n(e.postprocess(r(p)),p)),e.preprocess)),Fe=t(2,(e,n)=>tt((p)=>n(e.postprocess(p)),e.preprocess)),Ms=t(2,(e,n)=>Fe(e,nt(n)));var ks=t(3,(e,n,p)=>Fe(e,(u)=>Or(u,n,p))),_s=t(2,(e,n)=>Fe(e,zs(n))),Fs=t(3,(e,n,p)=>Fe(e,Ws(n,p))),Ns=t(3,(e,n,p)=>Fe(e,Js(n,p))),Ls=t(2,(e,n)=>Fe(e,l(nr(n)))),Ai=Fe(l(hn)),tt=(e,n)=>{let p=Object.create(vs);return p.preprocess=n,p.postprocess=e,p.execute=function(u){return e(n(u))},p},vs={[ir]:ir,pipe(){return C(this,arguments)},...te,toJSON(){return{_id:"effect/HttpClient"}},...Object.fromEntries(Yr.map(([e,n])=>[n,function(p,u){return this.execute(Q(e)(p,u))}]))},ur=(e)=>tt((n)=>l(n,(p)=>Tr((u)=>{let d=Oe.get(p),m=d??new AbortController,x=Kt(p.url,p.urlParams,F(p.hash));if(E(x))return o(new _({reason:new Ge({request:p,cause:x.failure})}));let b=x.success;if(u.getRef(Jn)||u.getRef(Qo)(p)){let w=e(p,b,m.signal,u);if(d)return g(w,(B)=>ar(B,m,!0));return $t((B)=>tn(B(w),{onSuccess(S){return r(ar(S,m,!1))},onFailure(S){if(yo(S))m.abort();return ut(S)}}))}return Xs(u.getRef(Ko)(p),{kind:"client"},(w)=>{w.attribute("http.request.method",p.method);let B=u.getRef(oi);vo(w,b,Jo(p.urlParams,u.getRef(Do)));let S=u.getRef(Yo);return sr(w,"request",p.headers,S,B),p=u.getRef(Zo)?mn(p,_o(w)):p,$t((z)=>z(e(p,b,m.signal,u)).pipe(ei(w,{captureStackTrace:!1}),tn({onSuccess:(v)=>{if(w.attribute("http.response.status_code",v.status),sr(w,"response",v.headers,S,B),v.status>=400&&v.status<600)w.attribute("error.type",String(v.status)),$s(u,w,p,v);return r(ar(v,m,d!==void 0))},onFailure(v){if(!d&&yo(v))m.abort();return ut(v)}})))})})),r),$s=(e,n,p,u)=>{let d=Re();oe(0);let m;try{m=Ft(new _({reason:new bt({request:p,response:u})}))}finally{oe(d)}n.end(e.getRef(Ui)?e.getRef(Cr).currentTimeNanosUnsafe():BigInt(0),m)},Ii=t(2,(e,n)=>tt(e.postprocess,(p)=>g(e.preprocess(p),n))),js=t(2,(e,n)=>tt(e.postprocess,(p)=>l(e.preprocess(p),n))),Vs=t(2,(e,n)=>tt(e.postprocess,(p)=>e.preprocess(n(p)))),Zs=t(2,(e,n)=>tt(e.postprocess,(p)=>l(n(p),e.preprocess))),ra=t(2,(e,n)=>Fe(e,Eo(n))),oa=t(2,(e,n)=>{let p=Ar(n),u=p?"errors-and-responses":n.retryOn??"errors-and-responses",d=wa(p?n:n.schedule??Ir),m=p?void 0:n.times;return Fe(e,ho(u==="errors-only"?c:Qs({schedule:d,times:m,while:mr}),u==="response-only"?c:Eo({while:p||n.while===void 0?pr:Fi(pr,n.while),schedule:d,times:m})))}),na=t(2,(e,n)=>{let p=K(n),u=`timed out after ${Wn(p)}`;return ne(e,(d,m)=>Ks(d,{duration:p,orElse:()=>o(new _({reason:new vt({request:m,cause:new qs(`Operation ${u}`),description:u})}))}))}),sa=t(2,(e,n)=>{let p={initial:!0,limit:n.limit,window:Mt(K(n.window),he(1))},u=new Map,d=n.key,m=typeof d==="function"?d:ee(d),x=n.tokens,b=typeof x==="function"?x:ee(x??1),V=!n.disableAdaptiveLearning,w=ha(n.responseHeaders),B=(G)=>{let q=u.get(G);if(q!==void 0)return q;return u.set(G,p),p},S=new Map,z=(G)=>{let q=S.get(G);if(q===void 0)q={sent:0,observed:0,remaining:0,resetAt:0},S.set(G,q);return q},v=n.disableResponseInspection?void 0:(G,q,at,Tt,Ae)=>{let mt=B(q),st=ga(mt,G,at,Tt,w);if(st.limit!==mt.limit||!Er(st.window,mt.window))u.set(q,st);let ct=Go(at,w),Y=z(q);if(ct===void 0||Ae<=Y.observed)return;let zt=cr(G,at,w);if(Y.observed=Ae,Y.remaining=ct,zt!==void 0)Y.resetAt=G.currentTimeMillisUnsafe()+we(zt)};return ne(e,function G(q,at,Tt=0){let mt=Dr().getRef(Cr),st=m(at),ct=Math.max(b(at),1),Y=z(st),zt=mt.currentTimeMillisUnsafe();if(Y.resetAt>zt&&Y.remaining-(Y.sent-Y.observed)<ct)return l(Lt(Y.resetAt-zt),()=>G(q,at,Tt));let fn=Y.sent+=ct,ae=B(st),lr=n.times===void 0||Tt<n.times;function hr(X){return X?l(Lt(X),()=>G(q,at,Tt+1)):G(q,at,Tt+1)}let gr=(X,wt)=>{if(v?.(mt,st,X.headers,ct,fn),n.disableResponseInspection||X.status!==429)return r(void 0);let Gt=Vo(mt.currentTimeMillisUnsafe(),re(X.headers,...w.retryAfter));if(Gt===void 0)return r(void 0);let J=cr(mt,X.headers,w)??Gt;if(wt===void 0)return r(J);return pt(n.limiter.adaptiveFeedback({key:st,epoch:wt.epoch,tokens:ct,status:X.status,retryAfter:J}),J)};return l(n.limiter.consume({algorithm:n.algorithm,onExceeded:"delay",key:st,limit:ae.limit,window:ae.window,tokens:ct}),({delay:X})=>{let wt=()=>{let Gt=(J)=>{let yr=Yn(q,{onSuccess(ht){return l(gr(ht,J),(ke)=>{if(ht.status!==429||!lr)return r(ht);return hr(ke)})},onFailure(ht){if(Ua(ht))return l(gr(ht.reason.response,J),(ke)=>lr?hr(ke):o(ht));return o(ht)}});return J===void 0||yn(J.delay)?yr:ko(yr,J.delay)};if(!V)return Gt(void 0);return l(n.limiter.adaptiveConsume({key:st,tokens:ct,fallbackLimit:ae.limit,fallbackWindow:ae.window}),(J)=>{if(!yn(J.delay)&&J.phase==="cooldown")return l(Lt(J.delay),wt);return Gt(J)})};return yn(X)?wt():l(Lt(X),wt)})})}),aa=t(2,(e,n)=>{let p=n.key,u=typeof p==="function"?p:p===void 0?ia:ee(p),d=n.classify??jo;return ne(e,(m,x)=>n.breaker.execute(m,{key:u(x),classify:d}))}),ia=(e)=>H(Xt(e),{onNone:()=>e.url,onSome:(n)=>n.origin}),jo=(e)=>Nr((n)=>r(ca(e,n.currentTimeMillisUnsafe()))),ca=(e,n)=>{if(pe(e)){let m=zo(e.value.status);return m==="Failure"?Wo(fr(e.value,n)):{_tag:m}}let p=!1,u=!1,d;for(let m of e.cause.reasons){if(!bn(m))continue;let x=la(m.error);if(x==="Failure"){p=!0;let b=fr(m.error,n);if(b!==void 0)d=d===void 0?b:Mt(d,b)}else if(x==="Success")u=!0}return p?Wo(d):{_tag:u?"Success":"Ignored"}},Wo=(e)=>({_tag:"Failure",retryAfter:e}),la=(e)=>{if(bo(e))return"Failure";if(!Yt(e))return"Ignored";switch(e.reason._tag){case"TransportError":return"Failure";case"StatusCodeError":return zo(e.reason.response.status);default:return"Ignored"}},zo=(e)=>e===429?"Ignored":e===408||e===500||e===502||e===503||e===504?"Failure":"Success",ha=(e)=>({limit:e?.limit===void 0?["ratelimit-limit","x-ratelimit-limit"]:[e.limit.toLowerCase()],remaining:e?.remaining===void 0?["ratelimit-remaining","x-ratelimit-remaining"]:[e.remaining.toLowerCase()],reset:e?.reset===void 0?["ratelimit-reset","x-ratelimit-reset"]:[e.reset.toLowerCase()],resetAfter:e?.resetAfter===void 0?["ratelimit-reset-after","x-ratelimit-reset-after"]:[e.resetAfter.toLowerCase()],retryAfter:e?.retryAfter===void 0?["retry-after"]:[e.retryAfter.toLowerCase()]}),ga=(e,n,p,u,d)=>{let m=Ea(e,p,u,d)??e.limit,x=cr(n,p,d)??e.window;if(m===e.limit&&Er(x,e.window))return e;return{limit:m,window:x,initial:!1}},Ea=(e,n,p,u)=>{let d=re(n,...u.limit),m=Be(d);if(m!==void 0&&m>0)return m;let x=Go(n,u);if(x===void 0)return;return e.initial?x+p:Math.max(x+p,e.limit)},Go=(e,n)=>{let p=re(e,...n.remaining),u=Be(p);return u!==void 0&&u>=0?u:void 0},cr=(e,n,p)=>{let u=ya(re(n,...p.resetAfter));if(u!==void 0)return u;return xa(e,re(n,...p.reset))},Vo=(e,n)=>{if(n===void 0)return;let p=Fo(n);return P(p)?Mt(Vi(p.success,e),he(1)):void 0},ya=(e)=>{let n=Be(e);if(n===void 0||n<=0)return;return Mt(ve(n),he(1))},xa=(e,n)=>{let p=Be(n);if(p===void 0||p<=0)return;let u=e.currentTimeMillisUnsafe();if(p>1000000000000)return he(Math.max(p-u,1));if(p>1e9)return he(Math.max(p*1000-u,1));return Mt(ve(p),he(1))},Be=(e)=>{if(e===void 0)return;let n=/-?\d+(?:\.\d+)?/.exec(e);if(n===null)return;let p=Number(n[0]);return Number.isFinite(p)?p:void 0},re=(e,...n)=>{for(let p=0;p<n.length;p++){let u=e[n[p]];if(u!==void 0)return u}return},Sa=t(2,(e,n)=>Fe(e,Je(n))),ba=t(2,(e,n)=>Fe(e,_r(n))),Ha=t(2,(e,n)=>tt(e.postprocess,(p)=>Je(e.preprocess(p),n))),Ca=t(2,(e,n)=>{let p=()=>Dr().getRef(Cr).currentTimeMillisUnsafe(),u=(d)=>g(xr(n),(m)=>{let x=Ki(m,d.url,p());if(x===void 0)return d;let b=Wt(d,"cookie",x),V=Oe.get(d);if(V!==void 0)Oe.set(b,V);return b});return tt((d)=>Je(e.postprocess(l(d,u)),(m)=>br(n,zi(m.url,m.cookies,p()))),e.preprocess)}),Ti=(e)=>ne(e,(n,p)=>{let u=new AbortController;return Oe.set(p,u),An(Ys(()=>I(()=>u.abort())),n)}),Ra=t((e)=>$o(e[0]),(e,n)=>tt((p)=>{let u=(d,m)=>O(()=>{let x;return l(e.postprocess(g(d,(b)=>(x=b,b))),(b)=>{if(b.status<300||b.status>=400||!b.headers.location||m>=(n??10))return r(b);let V=oo(b.headers.location,b.request.url);if(E(V))return r(b);let w=V.success,B=x??b.request,S=B;if((b.status===301||b.status===302)&&B.method==="POST"||b.status===303&&B.method!=="GET"&&B.method!=="HEAD")S=He(S,"GET"),S=W(S,Ot),S=yt(S,"content-encoding"),S=yt(S,"content-language"),S=yt(S,"content-location");if(w.origin!==new URL(b.request.url).origin)S=yt(S,"authorization"),S=yt(S,"proxy-authorization"),S=yt(S,"cookie");let z=w.hash===""?i():a(w.hash.slice(1));return w.hash="",S=D(S.method,w.href,qr,z,S.headers,S.body),An(I(()=>Xo.get(b)?.abort()),u(r(S),m+1))})});return u(p,0)},e.preprocess)),Qo=T("effect/http/HttpClient/TracerDisabledWhen",{defaultValue:()=>Jt}),Yo=T("effect/http/HttpClient/TracerHeaderFilter",{defaultValue:()=>Jt}),Zo=T("effect/http/HttpClient/TracerPropagationEnabled",{defaultValue:De}),Ko=T("effect/http/HttpClient/SpanNameGenerator",{defaultValue:()=>(e)=>e.method}),dr=(e)=>se(_e)(Qn((n)=>g(e,(p)=>Fe(p,Gs((u)=>Zt(n,u)))))),Ue=(()=>{if("FinalizationRegistry"in globalThis&&globalThis.FinalizationRegistry){let n=new FinalizationRegistry((p)=>{try{p.abort()}catch{}});return{register(p,u){n.register(p,u,p)},unregister(p){n.unregister(p)}}}let e=new WeakMap;return{register(n,p){e.set(n,setTimeout(()=>p.abort(),5000))},unregister(n){let p=e.get(n);if(p===void 0)return;clearTimeout(p),e.delete(n)}}})(),Oe=new WeakMap,Xo=new WeakMap,ar=(e,n,p)=>{if(!p)Ue.register(e,n),e=new en(e,n);return Xo.set(e,n),e};class en{original;controller;constructor(e,n){this.original=e,this.controller=n}[xt]=xt;[Rt]=Rt;applyInterrupt(e){return O(()=>(Ue.unregister(this.original),Io(e,()=>I(()=>{this.controller.abort()}))))}get request(){return this.original.request}get url(){return this.original.url}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get upgrade(){return this.applyInterrupt(this.original.upgrade)}[Ce](){let e=Te(this.original);if(e!==void 0)Ue.unregister(this.original);return e}get stream(){return ua(()=>(Ue.unregister(this.original),qo(this.original.stream,I(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[R](){return this.original[R]()}pipe(){return C(this,arguments)}}var pr=(e)=>bo(e)||Ta(e),Ta=(e)=>Yt(e)&&(e.reason._tag==="TransportError"||e.reason._tag==="StatusCodeError"&&mr(e.reason.response)),fr=(e,n)=>{let p=Yt(e)?e.response:s(e,xt)?e:void 0;return Vo(n,p?.headers["retry-after"])},wa=(e)=>wn(g(En(e),(n)=>(p,u)=>{let d=fr(u,p);if(d===void 0)return n(p,u);return g(n(p,u),([m,x])=>[m,Mt(x,d)])})),Ua=(e)=>Yt(e)&&e.reason._tag==="StatusCodeError"&&e.reason.response.status===429,mr=(e)=>e.status===408||e.status===429||e.status===500||e.status===502||e.status===503||e.status===504;var _t=T("effect/http/FetchHttpClient/Fetch",{defaultValue:()=>globalThis.fetch}),pn=T("effect/http/FetchHttpClient/StreamBodyFallback",{defaultValue:()=>"error"});class uo extends M()("effect/http/FetchHttpClient/RequestInit"){}var nn,Pa=()=>{try{let e=!1,n=new ReadableStream,p=new Request("https://example.com",{method:"POST",body:n,get duplex(){return e=!0,"half"}});return(e||p.body===n)&&!p.headers.has("Content-Type")}catch{return!1}},Ia=ur((e,n,p,u)=>{if(e.headers.upgrade!==void 0)return o(new _({reason:new vt({request:e,description:"fetch cannot send an HTTP upgrade request"})}));let d=u.getRef(_t),m=xn(u.context,uo)??{},x=m.headers?Gi(_n(m.headers),e.headers):e.headers;if(x["content-length"])x=jt(x,"content-length");let b,V=I(()=>b?.abort()),w=(B)=>g(ge({try:()=>d(n,{...m,method:e.method,headers:x,body:B,duplex:typeof ReadableStream<"u"&&B instanceof ReadableStream?"half":void 0,signal:b?AbortSignal.any([p,b.signal]):p}),catch:(S)=>new _({reason:new vt({request:e,cause:S})})}),(S)=>{let z=or(e,S);if(!b)return z;if(S.body===null)b.abort();return Object.create(z,{...Object.fromEntries(["arrayBuffer","text","json","formData","urlParamsBody"].map((v)=>[v,{get:()=>rn(z[v],V)}])),stream:{get:()=>qo(z.stream,V)}})}).pipe(Et(()=>V));switch(e.body._tag){case"Raw":case"Uint8Array":return w(e.body.body);case"FormData":return w(e.body.formData);case"Stream":{if(nn??=Pa(),nn){b=new AbortController;let B=AbortSignal.any([p,b.signal]),S=Ut((z)=>{let v=()=>z(Ao);if(B.aborted){v();return}return B.addEventListener("abort",v,{once:!0}),I(()=>B.removeEventListener("abort",v))});return l(ma(pa(e.body.stream,S)),w)}if(u.getRef(pn)==="error")return o(new _({reason:new Ee({request:e,description:"Streaming request bodies are not supported in this runtime"})}));return fa(e.body.stream).pipe(rt((B)=>new _({reason:new Ee({request:e,cause:B})})),l(w))}}return w(void 0)}),po=dr(r(Ia));export{Ps,Ei,mn,ki,Sr,Ci,co,et,hn,lo,_e,Fe,Ai,Ii,Ti,Rs,_t,uo,po,Oi};
|