@golproductions/voice-assistant 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,26 @@
1
- # Temporary Holding Version
1
+ # GOL Voice Assistant
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Talk to Claude Code from your phone. You speak, it types into Claude Code on your Windows PC, and the replies come back to your phone, read aloud.
4
+
5
+ ## Use it
6
+
7
+ 1. Get your GOL key at https://golproductions.com/console (the same key as Check).
8
+ 2. Install: `npm install -g @golproductions/voice-assistant`
9
+ 3. Switch it on: `gol-voice`
10
+ 4. Scan the QR code with your phone camera, and add the page to your home screen.
11
+
12
+ It runs only while that window is open. Keys: P new QR code, U unpair all phones, Q quit.
13
+
14
+ ## Price
15
+
16
+ Free. Optional Whisper listening (much better with natural speech): A$0.02 a minute of talking from your GOL credits. Hold the mic button on your phone to switch it on.
17
+
18
+ ## Good to know
19
+
20
+ - Windows and Claude Code only, for now. Tested with an iPhone.
21
+ - Messages pass through our server and are never stored.
22
+ - Your phone must keep its screen on while you talk.
23
+
24
+ https://golproductions.com/voice
25
+
26
+ © GOL Productions. All rights reserved.
@@ -0,0 +1,251 @@
1
+ GOL Voice Assistant includes the following open-source software, bundled into dist/gol-voice.js.
2
+
3
+ ================================================================
4
+ ws 8.22.1 (MIT)
5
+ ================================================================
6
+ Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
7
+ Copyright (c) 2013 Arnout Kazemier and contributors
8
+ Copyright (c) 2016 Luigi Pinca and contributors
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
11
+ this software and associated documentation files (the "Software"), to deal in
12
+ the Software without restriction, including without limitation the rights to
13
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
14
+ the Software, and to permit persons to whom the Software is furnished to do so,
15
+ subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
22
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
23
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+
27
+ ================================================================
28
+ qrcode-terminal 0.12.0 (undefined)
29
+ ================================================================
30
+
31
+ Apache License
32
+ Version 2.0, January 2004
33
+ http://www.apache.org/licenses/
34
+
35
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
36
+
37
+ 1. Definitions.
38
+
39
+ "License" shall mean the terms and conditions for use, reproduction,
40
+ and distribution as defined by Sections 1 through 9 of this document.
41
+
42
+ "Licensor" shall mean the copyright owner or entity authorized by
43
+ the copyright owner that is granting the License.
44
+
45
+ "Legal Entity" shall mean the union of the acting entity and all
46
+ other entities that control, are controlled by, or are under common
47
+ control with that entity. For the purposes of this definition,
48
+ "control" means (i) the power, direct or indirect, to cause the
49
+ direction or management of such entity, whether by contract or
50
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
51
+ outstanding shares, or (iii) beneficial ownership of such entity.
52
+
53
+ "You" (or "Your") shall mean an individual or Legal Entity
54
+ exercising permissions granted by this License.
55
+
56
+ "Source" form shall mean the preferred form for making modifications,
57
+ including but not limited to software source code, documentation
58
+ source, and configuration files.
59
+
60
+ "Object" form shall mean any form resulting from mechanical
61
+ transformation or translation of a Source form, including but
62
+ not limited to compiled object code, generated documentation,
63
+ and conversions to other media types.
64
+
65
+ "Work" shall mean the work of authorship, whether in Source or
66
+ Object form, made available under the License, as indicated by a
67
+ copyright notice that is included in or attached to the work
68
+ (an example is provided in the Appendix below).
69
+
70
+ "Derivative Works" shall mean any work, whether in Source or Object
71
+ form, that is based on (or derived from) the Work and for which the
72
+ editorial revisions, annotations, elaborations, or other modifications
73
+ represent, as a whole, an original work of authorship. For the purposes
74
+ of this License, Derivative Works shall not include works that remain
75
+ separable from, or merely link (or bind by name) to the interfaces of,
76
+ the Work and Derivative Works thereof.
77
+
78
+ "Contribution" shall mean any work of authorship, including
79
+ the original version of the Work and any modifications or additions
80
+ to that Work or Derivative Works thereof, that is intentionally
81
+ submitted to Licensor for inclusion in the Work by the copyright owner
82
+ or by an individual or Legal Entity authorized to submit on behalf of
83
+ the copyright owner. For the purposes of this definition, "submitted"
84
+ means any form of electronic, verbal, or written communication sent
85
+ to the Licensor or its representatives, including but not limited to
86
+ communication on electronic mailing lists, source code control systems,
87
+ and issue tracking systems that are managed by, or on behalf of, the
88
+ Licensor for the purpose of discussing and improving the Work, but
89
+ excluding communication that is conspicuously marked or otherwise
90
+ designated in writing by the copyright owner as "Not a Contribution."
91
+
92
+ "Contributor" shall mean Licensor and any individual or Legal Entity
93
+ on behalf of whom a Contribution has been received by Licensor and
94
+ subsequently incorporated within the Work.
95
+
96
+ 2. Grant of Copyright License. Subject to the terms and conditions of
97
+ this License, each Contributor hereby grants to You a perpetual,
98
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
99
+ copyright license to reproduce, prepare Derivative Works of,
100
+ publicly display, publicly perform, sublicense, and distribute the
101
+ Work and such Derivative Works in Source or Object form.
102
+
103
+ 3. Grant of Patent License. Subject to the terms and conditions of
104
+ this License, each Contributor hereby grants to You a perpetual,
105
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
106
+ (except as stated in this section) patent license to make, have made,
107
+ use, offer to sell, sell, import, and otherwise transfer the Work,
108
+ where such license applies only to those patent claims licensable
109
+ by such Contributor that are necessarily infringed by their
110
+ Contribution(s) alone or by combination of their Contribution(s)
111
+ with the Work to which such Contribution(s) was submitted. If You
112
+ institute patent litigation against any entity (including a
113
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
114
+ or a Contribution incorporated within the Work constitutes direct
115
+ or contributory patent infringement, then any patent licenses
116
+ granted to You under this License for that Work shall terminate
117
+ as of the date such litigation is filed.
118
+
119
+ 4. Redistribution. You may reproduce and distribute copies of the
120
+ Work or Derivative Works thereof in any medium, with or without
121
+ modifications, and in Source or Object form, provided that You
122
+ meet the following conditions:
123
+
124
+ (a) You must give any other recipients of the Work or
125
+ Derivative Works a copy of this License; and
126
+
127
+ (b) You must cause any modified files to carry prominent notices
128
+ stating that You changed the files; and
129
+
130
+ (c) You must retain, in the Source form of any Derivative Works
131
+ that You distribute, all copyright, patent, trademark, and
132
+ attribution notices from the Source form of the Work,
133
+ excluding those notices that do not pertain to any part of
134
+ the Derivative Works; and
135
+
136
+ (d) If the Work includes a "NOTICE" text file as part of its
137
+ distribution, then any Derivative Works that You distribute must
138
+ include a readable copy of the attribution notices contained
139
+ within such NOTICE file, excluding those notices that do not
140
+ pertain to any part of the Derivative Works, in at least one
141
+ of the following places: within a NOTICE text file distributed
142
+ as part of the Derivative Works; within the Source form or
143
+ documentation, if provided along with the Derivative Works; or,
144
+ within a display generated by the Derivative Works, if and
145
+ wherever such third-party notices normally appear. The contents
146
+ of the NOTICE file are for informational purposes only and
147
+ do not modify the License. You may add Your own attribution
148
+ notices within Derivative Works that You distribute, alongside
149
+ or as an addendum to the NOTICE text from the Work, provided
150
+ that such additional attribution notices cannot be construed
151
+ as modifying the License.
152
+
153
+ You may add Your own copyright statement to Your modifications and
154
+ may provide additional or different license terms and conditions
155
+ for use, reproduction, or distribution of Your modifications, or
156
+ for any such Derivative Works as a whole, provided Your use,
157
+ reproduction, and distribution of the Work otherwise complies with
158
+ the conditions stated in this License.
159
+
160
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
161
+ any Contribution intentionally submitted for inclusion in the Work
162
+ by You to the Licensor shall be under the terms and conditions of
163
+ this License, without any additional terms or conditions.
164
+ Notwithstanding the above, nothing herein shall supersede or modify
165
+ the terms of any separate license agreement you may have executed
166
+ with Licensor regarding such Contributions.
167
+
168
+ 6. Trademarks. This License does not grant permission to use the trade
169
+ names, trademarks, service marks, or product names of the Licensor,
170
+ except as required for reasonable and customary use in describing the
171
+ origin of the Work and reproducing the content of the NOTICE file.
172
+
173
+ 7. Disclaimer of Warranty. Unless required by applicable law or
174
+ agreed to in writing, Licensor provides the Work (and each
175
+ Contributor provides its Contributions) on an "AS IS" BASIS,
176
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
177
+ implied, including, without limitation, any warranties or conditions
178
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
179
+ PARTICULAR PURPOSE. You are solely responsible for determining the
180
+ appropriateness of using or redistributing the Work and assume any
181
+ risks associated with Your exercise of permissions under this License.
182
+
183
+ 8. Limitation of Liability. In no event and under no legal theory,
184
+ whether in tort (including negligence), contract, or otherwise,
185
+ unless required by applicable law (such as deliberate and grossly
186
+ negligent acts) or agreed to in writing, shall any Contributor be
187
+ liable to You for damages, including any direct, indirect, special,
188
+ incidental, or consequential damages of any character arising as a
189
+ result of this License or out of the use or inability to use the
190
+ Work (including but not limited to damages for loss of goodwill,
191
+ work stoppage, computer failure or malfunction, or any and all
192
+ other commercial damages or losses), even if such Contributor
193
+ has been advised of the possibility of such damages.
194
+
195
+ 9. Accepting Warranty or Additional Liability. While redistributing
196
+ the Work or Derivative Works thereof, You may choose to offer,
197
+ and charge a fee for, acceptance of support, warranty, indemnity,
198
+ or other liability obligations and/or rights consistent with this
199
+ License. However, in accepting such obligations, You may act only
200
+ on Your own behalf and on Your sole responsibility, not on behalf
201
+ of any other Contributor, and only if You agree to indemnify,
202
+ defend, and hold each Contributor harmless for any liability
203
+ incurred by, or claims asserted against, such Contributor by reason
204
+ of your accepting any such warranty or additional liability.
205
+
206
+ END OF TERMS AND CONDITIONS
207
+
208
+ APPENDIX: How to apply the Apache License to your work.
209
+
210
+ To apply the Apache License to your work, attach the following
211
+ boilerplate notice, with the fields enclosed by brackets "[]"
212
+ replaced with your own identifying information. (Don't include
213
+ the brackets!) The text should be enclosed in the appropriate
214
+ comment syntax for the file format. We also recommend that a
215
+ file or class name and description of purpose be included on the
216
+ same "printed page" as the copyright notice for easier
217
+ identification within third-party archives.
218
+
219
+ Copyright [yyyy] [name of copyright owner]
220
+
221
+ Licensed under the Apache License, Version 2.0 (the "License");
222
+ you may not use this file except in compliance with the License.
223
+ You may obtain a copy of the License at
224
+
225
+ http://www.apache.org/licenses/LICENSE-2.0
226
+
227
+ Unless required by applicable law or agreed to in writing, software
228
+ distributed under the License is distributed on an "AS IS" BASIS,
229
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
230
+ See the License for the specific language governing permissions and
231
+ limitations under the License.
232
+
233
+ ==============================================================
234
+ This product also include the following software:
235
+ ==============================================================
236
+
237
+ QRCode for JavaScript
238
+
239
+ Copyright (c) 2009 Kazuhiko Arase
240
+
241
+ URL: http://www.d-project.com/
242
+
243
+ Licensed under the MIT license:
244
+ http://www.opensource.org/licenses/mit-license.php
245
+
246
+ The word "QR Code" is registered trademark of
247
+ DENSO WAVE INCORPORATED
248
+ http://www.denso-wave.com/qrcode/faqpatent-e.html
249
+
250
+ Located in ./vendor/QRCode
251
+ - project has been modified to work in Node and some refactoring was done for code cleanup
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __cr } from 'module'; const require = __cr(import.meta.url);
3
+ var gs=Object.create;var kt=Object.defineProperty;var ys=Object.getOwnPropertyDescriptor;var Es=Object.getOwnPropertyNames;var vs=Object.getPrototypeOf,xs=Object.prototype.hasOwnProperty;var y=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var p=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}};var Ss=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Es(e))!xs.call(t,i)&&i!==r&&kt(t,i,{get:()=>e[i],enumerable:!(s=ys(e,i))||s.enumerable});return t};var U=(t,e,r)=>(r=t!=null?gs(vs(t)):{},Ss(e||!t||!t.__esModule?kt(r,"default",{value:t,enumerable:!0}):r,t));var F=p((cn,Bt)=>{"use strict";var Ct=["nodebuffer","arraybuffer","fragments"],Ot=typeof Blob<"u";Ot&&Ct.push("blob");Bt.exports={BINARY_TYPES:Ct,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:Ot,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var pe=p((dn,ne)=>{"use strict";var{websocketMask:Pt,websocketUnmask:ws}=y("http"),{EMPTY_BUFFER:Ts}=F(),$e=Buffer[Symbol.species];function bs(t,e){if(t.length===0)return Ts;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),s=0;for(let i=0;i<t.length;i++){let n=t[i];r.set(n,s),s+=n.length}return s<e?new $e(r.buffer,r.byteOffset,s):r}function je(t,e,r,s,i){for(let n=0;n<i;n++)r[s+n]=t[n]^e[n&3]}function He(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function Ls(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Ve(t){if(Ve.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new $e(t):ArrayBuffer.isView(t)?e=new $e(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Ve.readOnly=!1),e}ne.exports={concat:bs,mask:je,toArrayBuffer:Ls,toBuffer:Ve,unmask:He};if(Pt)ne.exports.mask=function(t,e,r,s,i){i<24?je(t,e,r,s,i):Pt(t,e,r,s,i)},ne.exports.unmask=function(t,e){t.length<24?He(t,e):ws(t,e)};else if(!process.env.WS_NO_BUFFER_UTIL)try{let t=y("bufferutil");ne.exports.mask=function(e,r,s,i,n){n<48?je(e,r,s,i,n):t.mask(e,r,s,i,n)},ne.exports.unmask=function(e,r){e.length<32?He(e,r):t.unmask(e,r)}}catch{}});var Rt=p((_n,At)=>{"use strict";var Nt=Symbol("kDone"),Ye=Symbol("kRun"),Ke=class{constructor(e){this[Nt]=()=>{this.pending--,this[Ye]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Ye]()}[Ye](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Nt])}}};At.exports=Ke});var fe=p((mn,Ut)=>{"use strict";var ge=y("zlib"),Dt=pe(),ks=Rt(),{kStatusCode:Mt}=F(),Cs=Buffer[Symbol.species],Os=Buffer.from([0,0,255,255]),Le=Symbol("permessage-deflate"),W=Symbol("total-length"),oe=Symbol("callback"),V=Symbol("buffers"),ae=Symbol("error"),be,ze=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!be){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;be=new ks(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[oe];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,s=e.find(i=>!(r.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>i.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&(typeof i.client_max_window_bits=="number"?r.clientMaxWindowBits>i.client_max_window_bits:!i.client_max_window_bits)));if(!s)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(s.server_no_context_takeover=!0),r.clientNoContextTakeover&&(s.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(s.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?s.client_max_window_bits=r.clientMaxWindowBits:(s.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete s.client_max_window_bits,s}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(s=>{let i=r[s];if(i.length>1)throw new Error(`Parameter "${s}" must have only a single value`);if(i=i[0],s==="client_max_window_bits"){if(i!==!0){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${s}": ${i}`);i=n}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${s}": ${i}`)}else if(s==="server_max_window_bits"){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${s}": ${i}`);i=n}else if(s==="client_no_context_takeover"||s==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${s}": ${i}`)}else throw new Error(`Unknown parameter "${s}"`);r[s]=i})}),e}decompress(e,r,s){be.add(i=>{this._decompress(e,r,(n,o)=>{i(),s(n,o)})})}compress(e,r,s){be.add(i=>{this._compress(e,r,(n,o)=>{i(),s(n,o)})})}_decompress(e,r,s){let i=this._isServer?"client":"server";if(!this._inflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?ge.Z_DEFAULT_WINDOWBITS:this.params[n];this._inflate=ge.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[Le]=this,this._inflate[W]=0,this._inflate[V]=[],this._inflate.on("error",Ps),this._inflate.on("data",It)}this._inflate[oe]=s,this._inflate.write(e),r&&this._inflate.write(Os),this._inflate.flush(()=>{let n=this._inflate[ae];if(n){this._inflate.close(),this._inflate=null,s(n);return}let o=Dt.concat(this._inflate[V],this._inflate[W]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[W]=0,this._inflate[V]=[],r&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),s(null,o)})}_compress(e,r,s){let i=this._isServer?"server":"client";if(!this._deflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?ge.Z_DEFAULT_WINDOWBITS:this.params[n];this._deflate=ge.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[W]=0,this._deflate[V]=[],this._deflate.on("data",Bs)}this._deflate[oe]=s,this._deflate.write(e),this._deflate.flush(ge.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let n=Dt.concat(this._deflate[V],this._deflate[W]);r&&(n=new Cs(n.buffer,n.byteOffset,n.length-4)),this._deflate[oe]=null,this._deflate[W]=0,this._deflate[V]=[],r&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),s(null,n)})}};Ut.exports=ze;function Bs(t){this[V].push(t),this[W]+=t.length}function It(t){if(this[W]+=t.length,this[Le]._maxPayload<1||this[W]<=this[Le]._maxPayload){this[V].push(t);return}this[ae]=new RangeError("Max payload size exceeded"),this[ae].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[ae][Mt]=1009,this.removeListener("data",It),this.reset()}function Ps(t){if(this[Le]._inflate=null,this[ae]){this[oe](this[ae]);return}t[Mt]=1007,this[oe](t)}});var le=p((pn,ke)=>{"use strict";var{isUtf8:Ft}=y("buffer"),{hasBlob:Ns}=F(),As=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function Rs(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Qe(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===0)r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function Ds(t){return Ns&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}ke.exports={isBlob:Ds,isValidStatusCode:Rs,isValidUTF8:Qe,tokenChars:As};if(Ft)ke.exports.isValidUTF8=function(t){return t.length<24?Qe(t):Ft(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=y("utf-8-validate");ke.exports.isValidUTF8=function(e){return e.length<32?Qe(e):t(e)}}catch{}});var tt=p((gn,Vt)=>{"use strict";var{Writable:Ms}=y("stream"),Wt=fe(),{BINARY_TYPES:Is,EMPTY_BUFFER:Gt,kStatusCode:Us,kWebSocket:Fs}=F(),{concat:Xe,toArrayBuffer:Ws,unmask:Gs}=pe(),{isValidStatusCode:qs,isValidUTF8:qt}=le(),Ce=Buffer[Symbol.species],b=0,$t=1,jt=2,Ht=3,Je=4,Ze=5,Oe=6,et=class extends Ms{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Is[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Fs]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=b}_write(e,r,s){if(this._opcode===8&&this._state==b)return s();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){s(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(s)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let s=this._buffers[0];return this._buffers[0]=new Ce(s.buffer,s.byteOffset+e,s.length-e),new Ce(s.buffer,s.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let s=this._buffers[0],i=r.length-e;e>=s.length?r.set(this._buffers.shift(),i):(r.set(new Uint8Array(s.buffer,s.byteOffset,e),i),this._buffers[0]=new Ce(s.buffer,s.byteOffset+e,s.length-e)),e-=s.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case b:this.getInfo(e);break;case $t:this.getPayloadLength16(e);break;case jt:this.getPayloadLength64(e);break;case Ht:this.getMask();break;case Je:this.getData(e);break;case Ze:case Oe:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let i=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(i);return}let s=(r[0]&64)===64;if(s&&!this._extensions[Wt.extensionName]){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(s){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(!this._fragmented){let i=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._compressed=s}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let i=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(i);return}if(s){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let i=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(i);return}}else{let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let i=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(i);return}}else if(this._masked){let i=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(i);return}this._payloadLength===126?this._state=$t:this._payloadLength===127?this._state=jt:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),s=r.readUInt32BE(0);if(s>Math.pow(2,21)-1){let i=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(i);return}this._payloadLength=s*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=Ht:this._state=Je}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Je}getData(e){let r=Gt;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&Gs(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){let s=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(s);return}if(this._compressed){this._state=Ze,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[Wt.extensionName].decompress(e,this._fin,(i,n)=>{if(i)return r(i);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(o);return}this._fragments.push(n)}this.dataMessage(r),this._state===b&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=b;return}let r=this._messageLength,s=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=Xe(s,r):this._binaryType==="arraybuffer"?i=Ws(Xe(s,r)):this._binaryType==="blob"?i=new Blob(s):i=s,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=b):(this._state=Oe,setImmediate(()=>{this.emit("message",i,!0),this._state=b,this.startLoop(e)}))}else{let i=Xe(s,r);if(!this._skipUTF8Validation&&!qt(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(n);return}this._state===Ze||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=b):(this._state=Oe,setImmediate(()=>{this.emit("message",i,!1),this._state=b,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Gt),this.end();else{let s=e.readUInt16BE(0);if(!qs(s)){let n=this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(n);return}let i=new Ce(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!qt(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(n);return}this._loop=!1,this.emit("conclude",s,i),this.end()}this._state=b;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=b):(this._state=Oe,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=b,this.startLoop(r)}))}createError(e,r,s,i,n){this._loop=!1,this._errored=!0;let o=new e(s?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(o,this.createError),o.code=n,o[Us]=i,o}};Vt.exports=et});var it=p((En,zt)=>{"use strict";var{Duplex:yn}=y("stream"),{randomFillSync:$s}=y("crypto"),{types:{isUint8Array:js}}=y("util"),Yt=fe(),{EMPTY_BUFFER:Hs,kWebSocket:Vs,NOOP:Ys}=F(),{isBlob:he,isValidStatusCode:Ks}=le(),{mask:Kt,toBuffer:J}=pe(),L=Symbol("kByteLength"),zs=Buffer.alloc(4),Be=8*1024,Z,ue=Be,O=0,Qs=1,Xs=2,rt=class t{constructor(e,r,s){this._extensions=r||{},s&&(this._generateMask=s,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=O,this.onerror=Ys,this[Vs]=void 0}static frame(e,r){let s,i=!1,n=2,o=!1;r.mask&&(s=r.maskBuffer||zs,r.generateMask?r.generateMask(s):(ue===Be&&(Z===void 0&&(Z=Buffer.alloc(Be)),$s(Z,0,Be),ue=0),s[0]=Z[ue++],s[1]=Z[ue++],s[2]=Z[ue++],s[3]=Z[ue++]),o=(s[0]|s[1]|s[2]|s[3])===0,n=6);let a;typeof e=="string"?(!r.mask||o)&&r[L]!==void 0?a=r[L]:(e=Buffer.from(e),a=e.length):(a=e.length,i=r.mask&&r.readOnly&&!o);let f=a;a>=65536?(n+=8,f=127):a>125&&(n+=2,f=126);let l=Buffer.allocUnsafe(i?a+n:n);return l[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(l[0]|=64),l[1]=f,f===126?l.writeUInt16BE(a,2):f===127&&(l[2]=l[3]=0,l.writeUIntBE(a,4,6)),r.mask?(l[1]|=128,l[n-4]=s[0],l[n-3]=s[1],l[n-2]=s[2],l[n-1]=s[3],a?o?[l,e]:i?(Kt(e,s,l,n,a),[l]):(Kt(e,s,e,0,a),[l,e]):[l]):a?[l,e]:[l]}close(e,r,s,i){let n;if(e===void 0)n=Hs;else{if(typeof e!="number"||!Ks(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)n=Buffer.allocUnsafe(2),n.writeUInt16BE(e,0);else{let a=Buffer.byteLength(r);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");if(n=Buffer.allocUnsafe(2+a),n.writeUInt16BE(e,0),typeof r=="string")n.write(r,2);else if(js(r))n.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let o={[L]:n.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==O?this.enqueue([this.dispatch,n,!1,o,i]):this.sendFrame(t.frame(n,o),i)}ping(e,r,s){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):he(e)?(i=e.size,n=!1):(e=J(e),i=e.length,n=J.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[L]:i,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:!1};he(e)?this._state!==O?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):this._state!==O?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(t.frame(e,o),s)}pong(e,r,s){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):he(e)?(i=e.size,n=!1):(e=J(e),i=e.length,n=J.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[L]:i,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:!1};he(e)?this._state!==O?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):this._state!==O?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(t.frame(e,o),s)}send(e,r,s){let i=this._extensions[Yt.extensionName],n=r.binary?2:1,o=r.compress,a,f;typeof e=="string"?(a=Buffer.byteLength(e),f=!1):he(e)?(a=e.size,f=!1):(e=J(e),a=e.length,f=J.readOnly),this._firstFragment?(this._firstFragment=!1,o&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=a>=i._threshold),this._compress=o):(o=!1,n=0),r.fin&&(this._firstFragment=!0);let l={[L]:a,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:f,rsv1:o};he(e)?this._state!==O?this.enqueue([this.getBlobData,e,this._compress,l,s]):this.getBlobData(e,this._compress,l,s):this._state!==O?this.enqueue([this.dispatch,e,this._compress,l,s]):this.dispatch(e,this._compress,l,s)}getBlobData(e,r,s,i){this._bufferedBytes+=s[L],this._state=Xs,e.arrayBuffer().then(n=>{if(this._socket.destroyed){let a=new Error("The socket was closed while the blob was being read");process.nextTick(st,this,a,i);return}this._bufferedBytes-=s[L];let o=J(n);r?this.dispatch(o,r,s,i):(this._state=O,this.sendFrame(t.frame(o,s),i),this.dequeue())}).catch(n=>{process.nextTick(Js,this,n,i)})}dispatch(e,r,s,i){if(!r){this.sendFrame(t.frame(e,s),i);return}let n=this._extensions[Yt.extensionName];this._bufferedBytes+=s[L],this._state=Qs,n.compress(e,s.fin,(o,a)=>{if(this._socket.destroyed){let f=new Error("The socket was closed while data was being compressed");st(this,f,i);return}this._bufferedBytes-=s[L],this._state=O,s.readOnly=!1,this.sendFrame(t.frame(a,s),i),this.dequeue()})}dequeue(){for(;this._state===O&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][L],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][L],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};zt.exports=rt;function st(t,e,r){typeof r=="function"&&r(e);for(let s=0;s<t._queue.length;s++){let i=t._queue[s],n=i[i.length-1];typeof n=="function"&&n(e)}}function Js(t,e,r){st(t,e,r),t.onerror(e)}});var ir=p((vn,sr)=>{"use strict";var{kForOnEventAttribute:ye,kListener:nt}=F(),Qt=Symbol("kCode"),Xt=Symbol("kData"),Jt=Symbol("kError"),Zt=Symbol("kMessage"),er=Symbol("kReason"),ce=Symbol("kTarget"),tr=Symbol("kType"),rr=Symbol("kWasClean"),G=class{constructor(e){this[ce]=null,this[tr]=e}get target(){return this[ce]}get type(){return this[tr]}};Object.defineProperty(G.prototype,"target",{enumerable:!0});Object.defineProperty(G.prototype,"type",{enumerable:!0});var ee=class extends G{constructor(e,r={}){super(e),this[Qt]=r.code===void 0?0:r.code,this[er]=r.reason===void 0?"":r.reason,this[rr]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Qt]}get reason(){return this[er]}get wasClean(){return this[rr]}};Object.defineProperty(ee.prototype,"code",{enumerable:!0});Object.defineProperty(ee.prototype,"reason",{enumerable:!0});Object.defineProperty(ee.prototype,"wasClean",{enumerable:!0});var de=class extends G{constructor(e,r={}){super(e),this[Jt]=r.error===void 0?null:r.error,this[Zt]=r.message===void 0?"":r.message}get error(){return this[Jt]}get message(){return this[Zt]}};Object.defineProperty(de.prototype,"error",{enumerable:!0});Object.defineProperty(de.prototype,"message",{enumerable:!0});var Ee=class extends G{constructor(e,r={}){super(e),this[Xt]=r.data===void 0?null:r.data}get data(){return this[Xt]}};Object.defineProperty(Ee.prototype,"data",{enumerable:!0});var Zs={addEventListener(t,e,r={}){for(let i of this.listeners(t))if(!r[ye]&&i[nt]===e&&!i[ye])return;let s;if(t==="message")s=function(n,o){let a=new Ee("message",{data:o?n:n.toString()});a[ce]=this,Pe(e,this,a)};else if(t==="close")s=function(n,o){let a=new ee("close",{code:n,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[ce]=this,Pe(e,this,a)};else if(t==="error")s=function(n){let o=new de("error",{error:n,message:n.message});o[ce]=this,Pe(e,this,o)};else if(t==="open")s=function(){let n=new G("open");n[ce]=this,Pe(e,this,n)};else return;s[ye]=!!r[ye],s[nt]=e,r.once?this.once(t,s):this.on(t,s)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[nt]===e&&!r[ye]){this.removeListener(t,r);break}}};sr.exports={CloseEvent:ee,ErrorEvent:de,Event:G,EventTarget:Zs,MessageEvent:Ee};function Pe(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var Ne=p((xn,nr)=>{"use strict";var{tokenChars:ve}=le();function R(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function ei(t){let e=Object.create(null),r=Object.create(null),s=!1,i=!1,n=!1,o,a,f=-1,l=-1,h=-1,u=0;for(;u<t.length;u++)if(l=t.charCodeAt(u),o===void 0)if(h===-1&&ve[l]===1)f===-1&&(f=u);else if(u!==0&&(l===32||l===9))h===-1&&f!==-1&&(h=u);else if(l===59||l===44){if(f===-1)throw new SyntaxError(`Unexpected character at index ${u}`);h===-1&&(h=u);let _=t.slice(f,h);l===44?(R(e,_,r),r=Object.create(null)):o=_,f=h=-1}else throw new SyntaxError(`Unexpected character at index ${u}`);else if(a===void 0)if(h===-1&&ve[l]===1)f===-1&&(f=u);else if(l===32||l===9)h===-1&&f!==-1&&(h=u);else if(l===59||l===44){if(f===-1)throw new SyntaxError(`Unexpected character at index ${u}`);h===-1&&(h=u),R(r,t.slice(f,h),!0),l===44&&(R(e,o,r),r=Object.create(null),o=void 0),f=h=-1}else if(l===61&&f!==-1&&h===-1)a=t.slice(f,u),f=h=-1;else throw new SyntaxError(`Unexpected character at index ${u}`);else if(i){if(ve[l]!==1)throw new SyntaxError(`Unexpected character at index ${u}`);f===-1?f=u:s||(s=!0),i=!1}else if(n)if(ve[l]===1)f===-1&&(f=u);else if(l===34&&f!==-1)n=!1,h=u;else if(l===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${u}`);else if(l===34&&t.charCodeAt(u-1)===61)n=!0;else if(h===-1&&ve[l]===1)f===-1&&(f=u);else if(f!==-1&&(l===32||l===9))h===-1&&(h=u);else if(l===59||l===44){if(f===-1)throw new SyntaxError(`Unexpected character at index ${u}`);h===-1&&(h=u);let _=t.slice(f,h);s&&(_=_.replace(/\\/g,""),s=!1),R(r,a,_),l===44&&(R(e,o,r),r=Object.create(null),o=void 0),a=void 0,f=h=-1}else throw new SyntaxError(`Unexpected character at index ${u}`);if(f===-1||n||l===32||l===9)throw new SyntaxError("Unexpected end of input");h===-1&&(h=u);let m=t.slice(f,h);return o===void 0?R(e,m,r):(a===void 0?R(r,m,!0):s?R(r,a,m.replace(/\\/g,"")):R(r,a,m),R(e,o,r)),e}function ti(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(s=>[e].concat(Object.keys(s).map(i=>{let n=s[i];return Array.isArray(n)||(n=[n]),n.map(o=>o===!0?i:`${i}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}nr.exports={format:ti,parse:ei}});var Me=p((Tn,gr)=>{"use strict";var ri=y("events"),si=y("https"),ii=y("http"),fr=y("net"),ni=y("tls"),{randomBytes:oi,createHash:ai}=y("crypto"),{Duplex:Sn,Readable:wn}=y("stream"),{URL:ot}=y("url"),Y=fe(),fi=tt(),li=it(),{isBlob:hi}=le(),{BINARY_TYPES:or,CLOSE_TIMEOUT:ui,EMPTY_BUFFER:Ae,GUID:ci,kForOnEventAttribute:at,kListener:di,kStatusCode:_i,kWebSocket:S,NOOP:lr}=F(),{EventTarget:{addEventListener:mi,removeEventListener:pi}}=ir(),{format:gi,parse:yi}=Ne(),{toBuffer:Ei}=pe(),hr=Symbol("kAborted"),ft=[8,13],q=["CONNECTING","OPEN","CLOSING","CLOSED"],vi=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,g=class t extends ri{constructor(e,r,s){super(),this._binaryType=or[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Ae,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?!s||s.protocols===void 0?r=[]:Array.isArray(s.protocols)?r=s.protocols:r=[s.protocols]:Array.isArray(r)||(typeof r=="object"&&r!==null?(s=r,s.protocols===void 0?r=[]:Array.isArray(s.protocols)?r=s.protocols:r=[s.protocols]):r=[r]),ur(this,e,r,s)):(this._autoPong=s.autoPong,this._closeTimeout=s.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){or.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,s){let i=new fi({allowSynchronousEvents:s.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:s.maxBufferedChunks,maxFragments:s.maxFragments,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation}),n=new li(e,this._extensions,s.generateMask);this._receiver=i,this._sender=n,this._socket=e,i[S]=this,n[S]=this,e[S]=this,i.on("conclude",wi),i.on("drain",Ti),i.on("error",bi),i.on("message",Li),i.on("ping",ki),i.on("pong",Ci),n.onerror=Oi,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",_r),e.on("data",De),e.on("end",mr),e.on("error",pr),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[Y.extensionName]&&this._extensions[Y.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){T(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._sender.close(e,r,!this._isServer,s=>{s||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),this._readyState=t.CLOSING,dr(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"&&(s=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){lt(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||Ae,r,s)}pong(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"&&(s=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){lt(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||Ae,r,s)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(s=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){lt(this,e,s);return}let i={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[Y.extensionName]||(i.compress=!1),this._sender.send(e||Ae,i,s)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){T(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(g,"CONNECTING",{enumerable:!0,value:q.indexOf("CONNECTING")});Object.defineProperty(g.prototype,"CONNECTING",{enumerable:!0,value:q.indexOf("CONNECTING")});Object.defineProperty(g,"OPEN",{enumerable:!0,value:q.indexOf("OPEN")});Object.defineProperty(g.prototype,"OPEN",{enumerable:!0,value:q.indexOf("OPEN")});Object.defineProperty(g,"CLOSING",{enumerable:!0,value:q.indexOf("CLOSING")});Object.defineProperty(g.prototype,"CLOSING",{enumerable:!0,value:q.indexOf("CLOSING")});Object.defineProperty(g,"CLOSED",{enumerable:!0,value:q.indexOf("CLOSED")});Object.defineProperty(g.prototype,"CLOSED",{enumerable:!0,value:q.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(g.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(g.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[at])return e[di];return null},set(e){for(let r of this.listeners(t))if(r[at]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[at]:!0})}})});g.prototype.addEventListener=mi;g.prototype.removeEventListener=pi;gr.exports=g;function ur(t,e,r,s){let i={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:ui,protocolVersion:ft[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...s,socketPath:void 0,hostname:void 0,protocol:void 0,protocols:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=i.autoPong,t._closeTimeout=i.closeTimeout,!ft.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${ft.join(", ")})`);let n;if(e instanceof ot)n=e;else try{n=new ot(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}n.protocol==="http:"?n.protocol="ws:":n.protocol==="https:"&&(n.protocol="wss:"),t._url=n.href;let o=n.protocol==="wss:",a=n.protocol==="ws+unix:",f;if(n.protocol!=="ws:"&&!o&&!a?f=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:a&&!n.pathname?f="The URL's pathname is empty":n.hash&&(f="The URL contains a fragment identifier"),f){let c=new SyntaxError(f);if(t._redirects===0)throw c;Re(t,c);return}let l=o?443:80,h=oi(16).toString("base64"),u=o?si.request:ii.request,m=new Set,_;if(i.createConnection=i.createConnection||(o?Si:xi),i.defaultPort=i.defaultPort||l,i.port=n.port||l,i.host=n.hostname.startsWith("[")?n.hostname.slice(1,-1):n.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":h,Connection:"Upgrade",Upgrade:"websocket"},i.path=n.pathname+n.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(_=new Y({...i.perMessageDeflate,isServer:!1,maxPayload:i.maxPayload}),i.headers["Sec-WebSocket-Extensions"]=gi({[Y.extensionName]:_.offer()})),r.length){for(let c of r){if(typeof c!="string"||!vi.test(c)||m.has(c))throw new SyntaxError("An invalid or duplicated subprotocol was specified");m.add(c)}i.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(n.username||n.password)&&(i.auth=`${n.username}:${n.password}`),a){let c=i.path.indexOf(":");c===-1?(i.socketPath=i.path,i.path=""):(i.socketPath=i.path.slice(0,c),i.path=i.path.slice(c+1))}let d;if(i.followRedirects){if(t._redirects===0){t._originalIpc=a,t._originalSecure=o,t._originalHostOrSocketPath=a?i.socketPath:n.host;let c=s&&s.headers;if(s={...s,headers:{}},c)for(let[E,N]of Object.entries(c))s.headers[E.toLowerCase()]=N}else if(t.listenerCount("redirect")===0){let c=a?t._originalIpc?i.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:n.host===t._originalHostOrSocketPath;(!c||t._originalSecure&&!o)&&(delete i.headers.authorization,delete i.headers.cookie,c||delete i.headers.host,i.auth=void 0)}i.auth&&!s.headers.authorization&&(s.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),d=t._req=u(i),t._redirects&&t.emit("redirect",t.url,d)}else d=t._req=u(i);i.timeout&&d.on("timeout",()=>{T(t,d,"Opening handshake has timed out")}),d.on("error",c=>{d===null||d[hr]||(d=t._req=null,Re(t,c))}),d.on("response",c=>{let E=c.headers.location,N=c.statusCode;if(E&&i.followRedirects&&N>=300&&N<400){if(++t._redirects>i.maxRedirects){T(t,d,"Maximum redirects exceeded");return}d.abort();let I;try{I=new ot(E,e)}catch{let C=new SyntaxError(`Invalid URL: ${E}`);Re(t,C);return}ur(t,I,r,s)}else t.emit("unexpected-response",d,c)||T(t,d,`Unexpected server response: ${c.statusCode}`)}),d.on("upgrade",(c,E,N)=>{if(t.emit("upgrade",c),t.readyState!==g.CONNECTING)return;d=t._req=null;let I=c.headers.upgrade;if(I===void 0||I.toLowerCase()!=="websocket"){T(t,E,"Invalid Upgrade header");return}let me=ai("sha1").update(h+ci).digest("base64");if(c.headers["sec-websocket-accept"]!==me){T(t,E,"Invalid Sec-WebSocket-Accept header");return}let C=c.headers["sec-websocket-protocol"],A;if(C!==void 0?m.size?m.has(C)||(A="Server sent an invalid subprotocol"):A="Server sent a subprotocol but none was requested":m.size&&(A="Server sent no subprotocol"),A){T(t,E,A);return}C&&(t._protocol=C);let X=c.headers["sec-websocket-extensions"];if(X!==void 0){if(!_){T(t,E,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let H;try{H=yi(X)}catch{T(t,E,"Invalid Sec-WebSocket-Extensions header");return}let Lt=Object.keys(H);if(Lt.length!==1||Lt[0]!==Y.extensionName){T(t,E,"Server indicated an extension that was not requested");return}try{_.accept(H[Y.extensionName])}catch{T(t,E,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[Y.extensionName]=_}t.setSocket(E,N,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxBufferedChunks:i.maxBufferedChunks,maxFragments:i.maxFragments,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(d,t):d.end()}function Re(t,e){t._readyState=g.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function xi(t){return t.path=t.socketPath,fr.connect(t)}function Si(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=fr.isIP(t.host)?"":t.host),ni.connect(t)}function T(t,e,r){t._readyState=g.CLOSING;let s=new Error(r);Error.captureStackTrace(s,T),e.setHeader?(e[hr]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Re,t,s)):(e.destroy(s),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function lt(t,e,r){if(e){let s=hi(e)?e.size:Ei(e).length;t._socket?t._sender._bufferedBytes+=s:t._bufferedAmount+=s}if(r){let s=new Error(`WebSocket is not open: readyState ${t.readyState} (${q[t.readyState]})`);process.nextTick(r,s)}}function wi(t,e){let r=this[S];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[S]!==void 0&&(r._socket.removeListener("data",De),process.nextTick(cr,r._socket),t===1005?r.close():r.close(t,e))}function Ti(){let t=this[S];t.isPaused||t._socket.resume()}function bi(t){let e=this[S];e._socket[S]!==void 0&&(e._socket.removeListener("data",De),process.nextTick(cr,e._socket),e.close(t[_i])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function ar(){this[S].emitClose()}function Li(t,e){this[S].emit("message",t,e)}function ki(t){let e=this[S];e._autoPong&&e.pong(t,!this._isServer,lr),e.emit("ping",t)}function Ci(t){this[S].emit("pong",t)}function cr(t){t.resume()}function Oi(t){let e=this[S];e.readyState!==g.CLOSED&&(e.readyState===g.OPEN&&(e._readyState=g.CLOSING,dr(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function dr(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function _r(){let t=this[S];if(this.removeListener("close",_r),this.removeListener("data",De),this.removeListener("end",mr),t._readyState=g.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[S]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",ar),t._receiver.on("finish",ar))}function De(t){this[S]._receiver.write(t)||this.pause()}function mr(){let t=this[S];t._readyState=g.CLOSING,t._receiver.end(),this.end()}function pr(){let t=this[S];this.removeListener("error",pr),this.on("error",lr),t&&(t._readyState=g.CLOSING,this.destroy())}});var xr=p((Ln,vr)=>{"use strict";var bn=Me(),{Duplex:Bi}=y("stream");function yr(t){t.emit("close")}function Pi(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Er(t){this.removeListener("error",Er),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function Ni(t,e){let r=!0,s=new Bi({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(n,o){let a=!o&&s._readableState.objectMode?n.toString():n;s.push(a)||t.pause()}),t.once("error",function(n){s.destroyed||(r=!1,s.destroy(n))}),t.once("close",function(){s.destroyed||s.push(null)}),s._destroy=function(i,n){if(t.readyState===t.CLOSED){n(i),process.nextTick(yr,s);return}let o=!1;t.once("error",function(f){o=!0,n(f)}),t.once("close",function(){o||n(i),process.nextTick(yr,s)}),r&&t.terminate()},s._final=function(i){if(t.readyState===t.CONNECTING){t.once("open",function(){s._final(i)});return}t._socket!==null&&(t._socket._writableState.finished?(i(),s._readableState.endEmitted&&s.destroy()):(t._socket.once("finish",function(){i()}),t.close()))},s._read=function(){t.isPaused&&t.resume()},s._write=function(i,n,o){if(t.readyState===t.CONNECTING){t.once("open",function(){s._write(i,n,o)});return}t.send(i,o)},s.on("end",Pi),s.on("error",Er),s}vr.exports=Ni});var ht=p((kn,Sr)=>{"use strict";var{tokenChars:Ai}=le();function Ri(t){let e=new Set,r=-1,s=-1,i=0;for(i;i<t.length;i++){let o=t.charCodeAt(i);if(s===-1&&Ai[o]===1)r===-1&&(r=i);else if(i!==0&&(o===32||o===9))s===-1&&r!==-1&&(s=i);else if(o===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${i}`);s===-1&&(s=i);let a=t.slice(r,s);if(e.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);e.add(a),r=s=-1}else throw new SyntaxError(`Unexpected character at index ${i}`)}if(r===-1||s!==-1)throw new SyntaxError("Unexpected end of input");let n=t.slice(r,i);if(e.has(n))throw new SyntaxError(`The "${n}" subprotocol is duplicated`);return e.add(n),e}Sr.exports={parse:Ri}});var Or=p((On,Cr)=>{"use strict";var Di=y("events"),Ie=y("http"),{Duplex:Cn}=y("stream"),{createHash:Mi}=y("crypto"),wr=Ne(),te=fe(),Ii=ht(),Ui=Me(),{CLOSE_TIMEOUT:Fi,GUID:Wi,kWebSocket:Gi}=F(),qi=/^[+/0-9A-Za-z]{22}==$/,Tr=0,br=1,kr=2,ut=class extends Di{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:Fi,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Ui,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=Ie.createServer((s,i)=>{let n=Ie.STATUS_CODES[426];i.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),i.end(n)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let s=this.emit.bind(this,"connection");this._removeListeners=$i(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,n,o)=>{this.handleUpgrade(i,n,o,s)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Tr}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===kr){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(xe,this);return}if(e&&this.once("close",e),this._state!==br)if(this._state=br,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(xe,this):process.nextTick(xe,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{xe(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,s,i){r.on("error",Lr);let n=e.headers["sec-websocket-key"],o=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!=="GET"){re(this,e,r,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){re(this,e,r,400,"Invalid Upgrade header");return}if(n===void 0||!qi.test(n)){re(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(a!==13&&a!==8){re(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Se(r,400);return}let f=e.headers["sec-websocket-protocol"],l=new Set;if(f!==void 0)try{l=Ii.parse(f)}catch{re(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let h=e.headers["sec-websocket-extensions"],u={};if(this.options.perMessageDeflate&&h!==void 0){let m=new te({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let _=wr.parse(h);_[te.extensionName]&&(m.accept(_[te.extensionName]),u[te.extensionName]=m)}catch{re(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let m={origin:e.headers[`${a===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(m,(_,d,c,E)=>{if(!_)return Se(r,d||401,c,E);this.completeUpgrade(u,n,l,e,r,s,i)});return}if(!this.options.verifyClient(m))return Se(r,401)}this.completeUpgrade(u,n,l,e,r,s,i)}completeUpgrade(e,r,s,i,n,o,a){if(!n.readable||!n.writable)return n.destroy();if(n[Gi])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Tr)return Se(n,503);let l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Mi("sha1").update(r+Wi).digest("base64")}`],h=new this.options.WebSocket(null,void 0,this.options);if(s.size){let u=this.options.handleProtocols?this.options.handleProtocols(s,i):s.values().next().value;u&&(l.push(`Sec-WebSocket-Protocol: ${u}`),h._protocol=u)}if(e[te.extensionName]){let u=e[te.extensionName].params,m=wr.format({[te.extensionName]:[u]});l.push(`Sec-WebSocket-Extensions: ${m}`),h._extensions=e}this.emit("headers",l,i),n.write(l.concat(`\r
4
+ `).join(`\r
5
+ `)),n.removeListener("error",Lr),h.setSocket(n,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(h),h.on("close",()=>{this.clients.delete(h),this._shouldEmitClose&&!this.clients.size&&process.nextTick(xe,this)})),a(h,i)}};Cr.exports=ut;function $i(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let s of Object.keys(e))t.removeListener(s,e[s])}}function xe(t){t._state=kr,t.emit("close")}function Lr(){this.destroy()}function Se(t,e,r,s){r=r||Ie.STATUS_CODES[e],s={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...s},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${Ie.STATUS_CODES[e]}\r
6
+ `+Object.keys(s).map(i=>`${i}: ${s[i]}`).join(`\r
7
+ `)+`\r
8
+ \r
9
+ `+r)}function re(t,e,r,s,i,n){if(t.listenerCount("wsClientError")){let o=new Error(i);Error.captureStackTrace(o,re),t.emit("wsClientError",o,r,e)}else Se(r,s,i,n)}});var ct=p((Pn,Nr)=>{Nr.exports={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8}});var Dr=p((Nn,Rr)=>{var Xi=ct();function Ar(t){this.mode=Xi.MODE_8BIT_BYTE,this.data=t}Ar.prototype={getLength:function(){return this.data.length},write:function(t){for(var e=0;e<this.data.length;e++)t.put(this.data.charCodeAt(e),8)}};Rr.exports=Ar});var dt=p((An,Mr)=>{var B={glog:function(t){if(t<1)throw new Error("glog("+t+")");return B.LOG_TABLE[t]},gexp:function(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return B.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)};for(v=0;v<8;v++)B.EXP_TABLE[v]=1<<v;var v;for(v=8;v<256;v++)B.EXP_TABLE[v]=B.EXP_TABLE[v-4]^B.EXP_TABLE[v-5]^B.EXP_TABLE[v-6]^B.EXP_TABLE[v-8];var v;for(v=0;v<255;v++)B.LOG_TABLE[B.EXP_TABLE[v]]=v;var v;Mr.exports=B});var _t=p((Rn,Ir)=>{var se=dt();function Ue(t,e){if(t.length===void 0)throw new Error(t.length+"/"+e);for(var r=0;r<t.length&&t[r]===0;)r++;this.num=new Array(t.length-r+e);for(var s=0;s<t.length-r;s++)this.num[s]=t[s+r]}Ue.prototype={get:function(t){return this.num[t]},getLength:function(){return this.num.length},multiply:function(t){for(var e=new Array(this.getLength()+t.getLength()-1),r=0;r<this.getLength();r++)for(var s=0;s<t.getLength();s++)e[r+s]^=se.gexp(se.glog(this.get(r))+se.glog(t.get(s)));return new Ue(e,0)},mod:function(t){if(this.getLength()-t.getLength()<0)return this;for(var e=se.glog(this.get(0))-se.glog(t.get(0)),r=new Array(this.getLength()),s=0;s<this.getLength();s++)r[s]=this.get(s);for(var i=0;i<t.getLength();i++)r[i]^=se.gexp(se.glog(t.get(i))+e);return new Ue(r,0).mod(t)}};Ir.exports=Ue});var Fr=p((Dn,Ur)=>{Ur.exports={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7}});var qr=p((Mn,Gr)=>{var k=ct(),Wr=_t(),Ji=dt(),K=Fr(),w={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(t){for(var e=t<<10;w.getBCHDigit(e)-w.getBCHDigit(w.G15)>=0;)e^=w.G15<<w.getBCHDigit(e)-w.getBCHDigit(w.G15);return(t<<10|e)^w.G15_MASK},getBCHTypeNumber:function(t){for(var e=t<<12;w.getBCHDigit(e)-w.getBCHDigit(w.G18)>=0;)e^=w.G18<<w.getBCHDigit(e)-w.getBCHDigit(w.G18);return t<<12|e},getBCHDigit:function(t){for(var e=0;t!==0;)e++,t>>>=1;return e},getPatternPosition:function(t){return w.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case K.PATTERN000:return(e+r)%2===0;case K.PATTERN001:return e%2===0;case K.PATTERN010:return r%3===0;case K.PATTERN011:return(e+r)%3===0;case K.PATTERN100:return(Math.floor(e/2)+Math.floor(r/3))%2===0;case K.PATTERN101:return e*r%2+e*r%3===0;case K.PATTERN110:return(e*r%2+e*r%3)%2===0;case K.PATTERN111:return(e*r%3+(e+r)%2)%2===0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new Wr([1],0),r=0;r<t;r++)e=e.multiply(new Wr([1,Ji.gexp(r)],0));return e},getLengthInBits:function(t,e){if(1<=e&&e<10)switch(t){case k.MODE_NUMBER:return 10;case k.MODE_ALPHA_NUM:return 9;case k.MODE_8BIT_BYTE:return 8;case k.MODE_KANJI:return 8;default:throw new Error("mode:"+t)}else if(e<27)switch(t){case k.MODE_NUMBER:return 12;case k.MODE_ALPHA_NUM:return 11;case k.MODE_8BIT_BYTE:return 16;case k.MODE_KANJI:return 10;default:throw new Error("mode:"+t)}else if(e<41)switch(t){case k.MODE_NUMBER:return 14;case k.MODE_ALPHA_NUM:return 13;case k.MODE_8BIT_BYTE:return 16;case k.MODE_KANJI:return 12;default:throw new Error("mode:"+t)}else throw new Error("type:"+e)},getLostPoint:function(t){var e=t.getModuleCount(),r=0,s=0,i=0;for(s=0;s<e;s++)for(i=0;i<e;i++){for(var n=0,o=t.isDark(s,i),a=-1;a<=1;a++)if(!(s+a<0||e<=s+a))for(var f=-1;f<=1;f++)i+f<0||e<=i+f||a===0&&f===0||o===t.isDark(s+a,i+f)&&n++;n>5&&(r+=3+n-5)}for(s=0;s<e-1;s++)for(i=0;i<e-1;i++){var l=0;t.isDark(s,i)&&l++,t.isDark(s+1,i)&&l++,t.isDark(s,i+1)&&l++,t.isDark(s+1,i+1)&&l++,(l===0||l===4)&&(r+=3)}for(s=0;s<e;s++)for(i=0;i<e-6;i++)t.isDark(s,i)&&!t.isDark(s,i+1)&&t.isDark(s,i+2)&&t.isDark(s,i+3)&&t.isDark(s,i+4)&&!t.isDark(s,i+5)&&t.isDark(s,i+6)&&(r+=40);for(i=0;i<e;i++)for(s=0;s<e-6;s++)t.isDark(s,i)&&!t.isDark(s+1,i)&&t.isDark(s+2,i)&&t.isDark(s+3,i)&&t.isDark(s+4,i)&&!t.isDark(s+5,i)&&t.isDark(s+6,i)&&(r+=40);var h=0;for(i=0;i<e;i++)for(s=0;s<e;s++)t.isDark(s,i)&&h++;var u=Math.abs(100*h/e/e-50)/5;return r+=u*10,r}};Gr.exports=w});var mt=p((In,$r)=>{$r.exports={L:1,M:0,Q:3,H:2}});var Hr=p((Un,jr)=>{var Fe=mt();function D(t,e){this.totalCount=t,this.dataCount=e}D.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]];D.getRSBlocks=function(t,e){var r=D.getRsBlockTable(t,e);if(r===void 0)throw new Error("bad rs block @ typeNumber:"+t+"/errorCorrectLevel:"+e);for(var s=r.length/3,i=[],n=0;n<s;n++)for(var o=r[n*3+0],a=r[n*3+1],f=r[n*3+2],l=0;l<o;l++)i.push(new D(a,f));return i};D.getRsBlockTable=function(t,e){switch(e){case Fe.L:return D.RS_BLOCK_TABLE[(t-1)*4+0];case Fe.M:return D.RS_BLOCK_TABLE[(t-1)*4+1];case Fe.Q:return D.RS_BLOCK_TABLE[(t-1)*4+2];case Fe.H:return D.RS_BLOCK_TABLE[(t-1)*4+3];default:return}};jr.exports=D});var Kr=p((Fn,Yr)=>{function Vr(){this.buffer=[],this.length=0}Vr.prototype={get:function(t){var e=Math.floor(t/8);return(this.buffer[e]>>>7-t%8&1)==1},put:function(t,e){for(var r=0;r<e;r++)this.putBit((t>>>e-r-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}};Yr.exports=Vr});var Jr=p((Wn,Xr)=>{var Zi=Dr(),z=qr(),en=_t(),zr=Hr(),Qr=Kr();function M(t,e){this.typeNumber=t,this.errorCorrectLevel=e,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}M.prototype={addData:function(t){var e=new Zi(t);this.dataList.push(e),this.dataCache=null},isDark:function(t,e){if(t<0||this.moduleCount<=t||e<0||this.moduleCount<=e)throw new Error(t+","+e);return this.modules[t][e]},getModuleCount:function(){return this.moduleCount},make:function(){if(this.typeNumber<1){var t=1;for(t=1;t<40;t++){for(var e=zr.getRSBlocks(t,this.errorCorrectLevel),r=new Qr,s=0,i=0;i<e.length;i++)s+=e[i].dataCount;for(var n=0;n<this.dataList.length;n++){var o=this.dataList[n];r.put(o.mode,4),r.put(o.getLength(),z.getLengthInBits(o.mode,t)),o.write(r)}if(r.getLengthInBits()<=s*8)break}this.typeNumber=t}this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(t,e){this.moduleCount=this.typeNumber*4+17,this.modules=new Array(this.moduleCount);for(var r=0;r<this.moduleCount;r++){this.modules[r]=new Array(this.moduleCount);for(var s=0;s<this.moduleCount;s++)this.modules[r][s]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(t,e),this.typeNumber>=7&&this.setupTypeNumber(t),this.dataCache===null&&(this.dataCache=M.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)},setupPositionProbePattern:function(t,e){for(var r=-1;r<=7;r++)if(!(t+r<=-1||this.moduleCount<=t+r))for(var s=-1;s<=7;s++)e+s<=-1||this.moduleCount<=e+s||(0<=r&&r<=6&&(s===0||s===6)||0<=s&&s<=6&&(r===0||r===6)||2<=r&&r<=4&&2<=s&&s<=4?this.modules[t+r][e+s]=!0:this.modules[t+r][e+s]=!1)},getBestMaskPattern:function(){for(var t=0,e=0,r=0;r<8;r++){this.makeImpl(!0,r);var s=z.getLostPoint(this);(r===0||t>s)&&(t=s,e=r)}return e},createMovieClip:function(t,e,r){var s=t.createEmptyMovieClip(e,r),i=1;this.make();for(var n=0;n<this.modules.length;n++)for(var o=n*i,a=0;a<this.modules[n].length;a++){var f=a*i,l=this.modules[n][a];l&&(s.beginFill(0,100),s.moveTo(f,o),s.lineTo(f+i,o),s.lineTo(f+i,o+i),s.lineTo(f,o+i),s.endFill())}return s},setupTimingPattern:function(){for(var t=8;t<this.moduleCount-8;t++)this.modules[t][6]===null&&(this.modules[t][6]=t%2===0);for(var e=8;e<this.moduleCount-8;e++)this.modules[6][e]===null&&(this.modules[6][e]=e%2===0)},setupPositionAdjustPattern:function(){for(var t=z.getPatternPosition(this.typeNumber),e=0;e<t.length;e++)for(var r=0;r<t.length;r++){var s=t[e],i=t[r];if(this.modules[s][i]===null)for(var n=-2;n<=2;n++)for(var o=-2;o<=2;o++)Math.abs(n)===2||Math.abs(o)===2||n===0&&o===0?this.modules[s+n][i+o]=!0:this.modules[s+n][i+o]=!1}},setupTypeNumber:function(t){for(var e=z.getBCHTypeNumber(this.typeNumber),r,s=0;s<18;s++)r=!t&&(e>>s&1)===1,this.modules[Math.floor(s/3)][s%3+this.moduleCount-8-3]=r;for(var i=0;i<18;i++)r=!t&&(e>>i&1)===1,this.modules[i%3+this.moduleCount-8-3][Math.floor(i/3)]=r},setupTypeInfo:function(t,e){for(var r=this.errorCorrectLevel<<3|e,s=z.getBCHTypeInfo(r),i,n=0;n<15;n++)i=!t&&(s>>n&1)===1,n<6?this.modules[n][8]=i:n<8?this.modules[n+1][8]=i:this.modules[this.moduleCount-15+n][8]=i;for(var o=0;o<15;o++)i=!t&&(s>>o&1)===1,o<8?this.modules[8][this.moduleCount-o-1]=i:o<9?this.modules[8][15-o-1+1]=i:this.modules[8][15-o-1]=i;this.modules[this.moduleCount-8][8]=!t},mapData:function(t,e){for(var r=-1,s=this.moduleCount-1,i=7,n=0,o=this.moduleCount-1;o>0;o-=2)for(o===6&&o--;;){for(var a=0;a<2;a++)if(this.modules[s][o-a]===null){var f=!1;n<t.length&&(f=(t[n]>>>i&1)===1);var l=z.getMask(e,s,o-a);l&&(f=!f),this.modules[s][o-a]=f,i--,i===-1&&(n++,i=7)}if(s+=r,s<0||this.moduleCount<=s){s-=r,r=-r;break}}}};M.PAD0=236;M.PAD1=17;M.createData=function(t,e,r){for(var s=zr.getRSBlocks(t,e),i=new Qr,n=0;n<r.length;n++){var o=r[n];i.put(o.mode,4),i.put(o.getLength(),z.getLengthInBits(o.mode,t)),o.write(i)}for(var a=0,f=0;f<s.length;f++)a+=s[f].dataCount;if(i.getLengthInBits()>a*8)throw new Error("code length overflow. ("+i.getLengthInBits()+">"+a*8+")");for(i.getLengthInBits()+4<=a*8&&i.put(0,4);i.getLengthInBits()%8!==0;)i.putBit(!1);for(;!(i.getLengthInBits()>=a*8||(i.put(M.PAD0,8),i.getLengthInBits()>=a*8));)i.put(M.PAD1,8);return M.createBytes(i,s)};M.createBytes=function(t,e){for(var r=0,s=0,i=0,n=new Array(e.length),o=new Array(e.length),a=0;a<e.length;a++){var f=e[a].dataCount,l=e[a].totalCount-f;s=Math.max(s,f),i=Math.max(i,l),n[a]=new Array(f);for(var h=0;h<n[a].length;h++)n[a][h]=255&t.buffer[h+r];r+=f;var u=z.getErrorCorrectPolynomial(l),m=new en(n[a],u.getLength()-1),_=m.mod(u);o[a]=new Array(u.getLength()-1);for(var d=0;d<o[a].length;d++){var c=d+_.getLength()-o[a].length;o[a][d]=c>=0?_.get(c):0}}for(var E=0,N=0;N<e.length;N++)E+=e[N].totalCount;for(var I=new Array(E),me=0,C=0;C<s;C++)for(var A=0;A<e.length;A++)C<n[A].length&&(I[me++]=n[A][C]);for(var X=0;X<i;X++)for(var H=0;H<e.length;H++)X<o[H].length&&(I[me++]=o[H][X]);return I};Xr.exports=M});var ts=p((Gn,es)=>{var tn=Jr(),Zr=mt(),rn="\x1B[40m \x1B[0m",We="\x1B[47m \x1B[0m",sn=function(t){return t?rn:We},pt=function(t){return{times:function(e){return new Array(e).join(t)}}},nn=function(t,e){for(var r=new Array(t),s=0;s<t;s++)r[s]=e;return r};es.exports={error:Zr.L,generate:function(t,e,r){typeof e=="function"&&(r=e,e={});var s=new tn(-1,this.error);s.addData(t),s.make();var i="";if(e&&e.small){var n=!0,o=!1,a=s.getModuleCount(),f=s.modules.slice(),l=a%2===1;l&&f.push(nn(a,o));var h={WHITE_ALL:"\u2588",WHITE_BLACK:"\u2580",BLACK_WHITE:"\u2584",BLACK_ALL:" "},u=pt(h.BLACK_WHITE).times(a+3),m=pt(h.WHITE_BLACK).times(a+3);i+=u+`
10
+ `;for(var _=0;_<a;_+=2){i+=h.WHITE_ALL;for(var d=0;d<a;d++)f[_][d]===o&&f[_+1][d]===o?i+=h.WHITE_ALL:f[_][d]===o&&f[_+1][d]===n?i+=h.WHITE_BLACK:f[_][d]===n&&f[_+1][d]===o?i+=h.BLACK_WHITE:i+=h.BLACK_ALL;i+=h.WHITE_ALL+`
11
+ `}l||(i+=m)}else{var c=pt(We).times(s.getModuleCount()+3);i+=c+`
12
+ `,s.modules.forEach(function(E){i+=We,i+=E.map(sn).join(""),i+=We+`
13
+ `}),i+=c}r?r(i):console.log(i)},setErrorLevel:function(t){this.error=Zr[t]||this.error}}});import x from"node:fs";import wt from"node:os";import P from"node:path";import on from"node:crypto";import ls from"node:readline";import{execFile as an}from"node:child_process";var ji=U(xr(),1),Hi=U(Ne(),1),Vi=U(fe(),1),Yi=U(tt(),1),Ki=U(it(),1),zi=U(ht(),1),Br=U(Me(),1),Qi=U(Or(),1);var Pr=Br.default;var hs=U(ts(),1),us=process.env.GOL_VOICE_RELAY||"voice.golproductions.com",Tt=wt.homedir(),_e=P.join(Tt,".gol"),rs=P.join(Tt,".claude","projects"),Q=t=>`\x1B[2m${t}\x1B[0m`,vt=t=>`\x1B[33m${t}\x1B[0m`,xt=t=>`\x1B[32m${t}\x1B[0m`,bt=t=>`\x1B[31m${t}\x1B[0m`;function ss(){let t=[];process.env.GOL_KEY&&t.push(process.env.GOL_KEY.trim());for(let e of[P.join(_e,"voice-key"),P.join(Tt,".check","key"),P.join(_e,"key")])try{let r=x.readFileSync(e,"utf8").trim();r.startsWith("gol_")&&!t.includes(r)&&t.push(r)}catch{}return t}async function is(){let t=ls.createInterface({input:process.stdin,output:process.stdout}),e=(await new Promise(r=>t.question("Paste your GOL key (from golproductions.com/console): ",r))).trim();t.close(),e.startsWith("gol_")||(console.log(bt("That doesn't look like a GOL key. They start with gol_.")),process.exit(1)),x.mkdirSync(_e,{recursive:!0}),x.writeFileSync(P.join(_e,"voice-key"),e,{mode:384}),console.log(xt("Saved. Now run: gol-voice"))}var cs=P.join(wt.tmpdir(),"gol-voice-type.ps1");x.writeFileSync(cs,`# \xA9 GOL Productions. All rights reserved.
14
+ # Types one phone message into the window running Claude Code: brings that
15
+ # window to the front, pastes the text, presses Enter, then puts your
16
+ # clipboard back.
17
+ param([string]$File, [string]$Key)
18
+
19
+ # -Key Escape: press one key instead of typing (Escape stops Claude mid-reply).
20
+ $text = $null
21
+ if ($File) {
22
+ $text = [IO.File]::ReadAllText($File, [Text.Encoding]::UTF8)
23
+ Remove-Item $File -ErrorAction SilentlyContinue
24
+ if (-not $text.Trim()) { exit 0 }
25
+ } elseif ($Key -ne "Escape") { exit 1 }
26
+
27
+ Add-Type -AssemblyName System.Windows.Forms
28
+ Add-Type @"
29
+ using System; using System.Runtime.InteropServices;
30
+ public class Win {
31
+ [DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr h);
32
+ [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr h, int c);
33
+ [DllImport("user32.dll")] public static extern bool IsIconic(IntPtr h);
34
+ [DllImport("user32.dll")] public static extern void keybd_event(byte vk, byte scan, uint flags, UIntPtr extra);
35
+ }
36
+ "@
37
+
38
+ # The window hosting Claude Code: from the newest claude.exe, walk up its
39
+ # parents to the first one that owns a window (Windows Terminal here).
40
+ $claude = Get-CimInstance Win32_Process -Filter "Name='claude.exe'" | Sort-Object CreationDate -Descending | Select-Object -First 1
41
+ if (-not $claude) { Write-Output "NO-CLAUDE"; exit 2 }
42
+ $hwnd = [IntPtr]::Zero; $p = $claude.ParentProcessId
43
+ for ($i = 0; $i -lt 12 -and $p; $i++) {
44
+ $g = Get-Process -Id $p -ErrorAction SilentlyContinue
45
+ if ($g -and $g.MainWindowHandle -ne 0) { $hwnd = $g.MainWindowHandle; break }
46
+ $p = (Get-CimInstance Win32_Process -Filter "ProcessId=$p").ParentProcessId
47
+ }
48
+ if ($hwnd -eq [IntPtr]::Zero) { Write-Output "NO-WINDOW"; exit 3 }
49
+
50
+ if (-not $text) {
51
+ if ([Win]::IsIconic($hwnd)) { [Win]::ShowWindow($hwnd, 9) | Out-Null }
52
+ [Win]::keybd_event(0x12, 0, 0, [UIntPtr]::Zero); [Win]::keybd_event(0x12, 0, 2, [UIntPtr]::Zero)
53
+ [Win]::SetForegroundWindow($hwnd) | Out-Null
54
+ Start-Sleep -Milliseconds 250
55
+ [System.Windows.Forms.SendKeys]::SendWait("{ESC}")
56
+ Write-Output "TYPED"; exit 0
57
+ }
58
+
59
+ $saved = $null
60
+ try { $saved = Get-Clipboard -Raw -ErrorAction Stop } catch {}
61
+
62
+ if ([Win]::IsIconic($hwnd)) { [Win]::ShowWindow($hwnd, 9) | Out-Null }
63
+ # Windows only lets the active app move focus; a tap of Alt allows it.
64
+ [Win]::keybd_event(0x12, 0, 0, [UIntPtr]::Zero); [Win]::keybd_event(0x12, 0, 2, [UIntPtr]::Zero)
65
+ [Win]::SetForegroundWindow($hwnd) | Out-Null
66
+ Start-Sleep -Milliseconds 250
67
+
68
+ Set-Clipboard -Value $text
69
+ [System.Windows.Forms.SendKeys]::SendWait("^v")
70
+ Start-Sleep -Milliseconds 400
71
+ [System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
72
+ Start-Sleep -Milliseconds 300
73
+
74
+ if ($null -ne $saved) { try { Set-Clipboard -Value $saved } catch {} }
75
+ Write-Output "TYPED"
76
+ `);var fn={"NO-CLAUDE":"Claude Code isn't open on the PC.","NO-WINDOW":"Couldn't find Claude Code's window."},ns=Promise.resolve();function os({text:t,key:e,id:r}){ns=ns.then(()=>new Promise(s=>{let i=["-NoProfile","-ExecutionPolicy","Bypass","-File",cs];if(e)i.push("-Key",e);else{let n=P.join(wt.tmpdir(),`gol-voice-${on.randomBytes(4).toString("hex")}.txt`);x.writeFileSync(n,t,"utf8"),i.push("-File",n)}an("powershell",i,{timeout:15e3,windowsHide:!0},(n,o)=>{let a=(o||"").trim()||"NO-ANSWER";ie({type:"typed",id:r,ok:a==="TYPED",why:fn[a]||"The PC didn't answer."}),s()})}))}function ds(){let t=null;try{for(let e of x.readdirSync(rs)){let r=P.join(rs,e);try{for(let s of x.readdirSync(r)){if(!s.endsWith(".jsonl"))continue;let i=P.join(r,s),n=x.statSync(i).mtimeMs;(!t||n>t.t)&&(t={p:i,t:n})}}catch{}}}catch{}return t&&t.p}function _s(t){let e=t?.message,r=e?.content,s=t.timestamp||null;if(e?.role==="assistant")return{role:"assistant",text:Array.isArray(r)?r.filter(o=>o.type==="text").map(o=>o.text).join(`
77
+ `).trim():typeof r=="string"?r.trim():"",time:s,done:e.stop_reason==="end_turn"};let i=t.attachment;if(t.type==="attachment"&&i?.type==="queued_command"&&i.origin?.kind==="human"&&typeof i.prompt=="string")return i.prompt.trim()?{role:"user",text:i.prompt.trim(),time:s}:null;if(t.type==="user"&&!t.isMeta&&e?.role==="user"){if(Array.isArray(r)&&r.some(o=>o.type==="tool_result"))return null;let n=(typeof r=="string"?r:Array.isArray(r)?r.filter(o=>o.type==="text").map(o=>o.text).join(`
78
+ `):"").trim();return!n||n.startsWith("<")||n.startsWith("[Request interrupted")?null:{role:"user",text:n,time:s}}return null}function ln(t,e){let r=x.statSync(t).size,s=Math.min(r,4<<20),i=Buffer.alloc(s),n=x.openSync(t,"r");x.readSync(n,i,0,s,r-s),x.closeSync(n);let o=i.toString("utf8").split(`
79
+ `).filter(h=>h.trim()),a=[],f=!1,l=!1;for(let h=o.length-1;h>=0&&a.length<e;h--){let u;try{u=_s(JSON.parse(o[h]))}catch{continue}u&&(l||(f=!(u.role==="assistant"&&u.done),l=!0),u.text&&a.unshift(u))}return{messages:a,working:f}}var j=ds(),we=j?x.statSync(j).size:0,gt="",as=Date.now();setInterval(()=>{if(Date.now()-as>1e4){as=Date.now();let i=ds();i&&i!==j&&(j=i,we=x.statSync(i).size,gt="",ms())}if(!j)return;let t;try{t=x.statSync(j)}catch{return}if(t.size<=we)return;let e=Buffer.alloc(t.size-we),r=x.openSync(j,"r");x.readSync(r,e,0,e.length,we),x.closeSync(r),we=t.size;let s=(gt+e.toString("utf8")).split(`
80
+ `);gt=s.pop();for(let i of s){let n;try{n=_s(JSON.parse(i))}catch{continue}n&&(n.text&&ie({type:"message",...n}),ie({type:"working",working:!(n.role==="assistant"&&n.done)}))}},500);function ms(){j&&ie({type:"history",...ln(j,40)})}var $=null,yt=null,Ge=1e3,ie=t=>{$&&$.readyState===1&&$.send(JSON.stringify(t))},Te=[],fs=0,Et=!1;function St(){let t=Te[fs];Et=!1,$=new Pr(`wss://${us}/pc`,{headers:{"X-GOL-CLIENT-ID":t}}),$.on("unexpected-response",(e,r)=>{if(r.statusCode===401||r.statusCode===403){if(Et=!0,++fs<Te.length)return St();console.log(bt("None of the GOL keys on this PC was accepted. Get a key at golproductions.com/console, then run: gol-voice login")),process.exit(1)}}),$.on("open",()=>{Ge=1e3,console.log(xt("\u25CF On.")+Q(" Your phone can talk to Claude Code while this window is open.")),ie({type:"pair"})}),$.on("message",e=>{let r;try{r=JSON.parse(e)}catch{return}if(r.type==="pair-code")hn(r);else if(r.type==="paired")yt=r.phones,console.log(xt("\u2713 Phone paired.")+Q(` ${yt} phone${yt===1?"":"s"} paired.`));else if(r.type==="phone-joined")console.log(Q("Phone connected.")),ms();else if(r.type==="chat"&&typeof r.text=="string"&&r.text.trim())console.log(vt("phone: ")+r.text.replace(/^\(voice\)\s*/i,"").slice(0,200)),os({text:r.text.slice(0,2e4),id:r.id});else if(r.type==="log"&&typeof r.text=="string")try{x.mkdirSync(_e,{recursive:!0}),x.appendFileSync(P.join(_e,"voice-debug.log"),`${new Date().toISOString()} ${r.text.slice(0,300)}
81
+ `)}catch{}else r.type==="key"&&r.key==="Escape"&&(console.log(vt("phone: ")+"Stop"),os({key:"Escape",id:r.id}))}),$.on("close",()=>{Et||(console.log(Q("Connection dropped. Reconnecting\u2026")),setTimeout(St,Ge),Ge=Math.min(Ge*2,3e4))}),$.on("error",()=>{})}function hn({code:t,minutes:e}){let r=`https://${us}/p/${t}`;console.log(`
82
+ To pair a phone, scan this with its camera:
83
+ `),hs.default.generate(r,{small:!0},s=>console.log(s)),console.log(Q(`Or open: ${r}`)),console.log(Q(`This code works once, for ${e} minutes. Already paired? Just open GOL Voice on your phone.`)),console.log(Q(`Keys: P new QR code U unpair all phones Q quit
84
+ `))}process.argv[2]==="login"?await is():(process.platform!=="win32"&&(console.log(bt("GOL Voice Assistant runs on Windows for now.")),process.exit(1)),Te=ss(),Te.length||(await is(),Te=ss()),console.log(vt(`
85
+ GOL Voice Assistant`)+Q(` \xB7 talk to Claude Code from your phone
86
+ `)),St(),process.stdin.isTTY&&(ls.emitKeypressEvents(process.stdin),process.stdin.setRawMode(!0),process.stdin.on("keypress",(t,e)=>{e.ctrl&&e.name==="c"&&process.exit(0),e.name==="q"&&process.exit(0),e.name==="p"&&ie({type:"pair"}),e.name==="u"&&ie({type:"unpair-all"})})));
package/package.json CHANGED
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "name": "@golproductions/voice-assistant",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Talk to Claude Code from your phone.",
5
+ "private": false,
6
+ "license": "UNLICENSED",
7
+ "type": "module",
8
+ "bin": {
9
+ "gol-voice": "dist/gol-voice.js"
10
+ },
11
+ "files": [
12
+ "dist/gol-voice.js",
13
+ "THIRD-PARTY-NOTICES.txt"
14
+ ],
15
+ "engines": {
16
+ "node": ">=18"
17
+ },
18
+ "os": [
19
+ "win32"
20
+ ],
21
+ "scripts": {
22
+ "build": "node build.mjs"
23
+ },
24
+ "devDependencies": {
25
+ "esbuild": "^0.28.2",
26
+ "qrcode-terminal": "^0.12.0",
27
+ "ws": "^8.22.1"
28
+ },
29
+ "homepage": "https://golproductions.com/voice",
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "keywords": [
34
+ "claude-code",
35
+ "voice",
36
+ "phone",
37
+ "remote",
38
+ "speech"
39
+ ]
40
+ }