stellavault 0.1.0 → 0.2.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.
@@ -1,49 +1,93 @@
1
- // Federation: Sharing Control
2
- // 노드별 공유 범위 관리 태그/폴더/문서 단위로 공개/비공개 설정
1
+ // Federation: Sharing Control v2 — Level-based sharing system
2
+ // Level 0: 차단 (검색 됨)
3
+ // Level 1: 제목 + 유사도만
4
+ // Level 2: Level 1 + 50자 스니펫
5
+ // Level 3: Level 2 + 요청 시 전문 (피어 승인)
6
+ // Level 4: Level 3 + 전문 자동 공개
7
+ //
8
+ // 상호 매칭: 내 공개 레벨이 높을수록 남의 것도 더 많이 볼 수 있음
3
9
 
4
10
  import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
5
11
  import { join } from 'node:path';
6
12
  import { homedir } from 'node:os';
7
13
 
8
- export interface SharingConfig {
9
- mode: 'whitelist' | 'blacklist'; // whitelist=명시적 공개만, blacklist=명시적 비공개만
14
+ export type SharingLevel = 0 | 1 | 2 | 3 | 4;
10
15
 
11
- // 태그 기반
12
- allowedTags: string[]; // whitelist 모드: 이 태그가 있는 문서만 공개
13
- blockedTags: string[]; // blacklist 모드: 이 태그가 있는 문서 제외
16
+ export const LEVEL_LABELS: Record<SharingLevel, string> = {
17
+ 0: 'Blocked (not searchable)',
18
+ 1: 'Title + similarity only',
19
+ 2: 'Title + snippet (50 chars)',
20
+ 3: 'Full text on request (approval needed)',
21
+ 4: 'Full text auto-shared',
22
+ };
14
23
 
15
- // 폴더 기반
16
- allowedFolders: string[]; // whitelist 모드: 폴더만 공개
17
- blockedFolders: string[]; // blacklist 모드: 이 폴더 제외
24
+ export const LEVEL_ICONS: Record<SharingLevel, string> = {
25
+ 0: '🚫', 1: '📌', 2: '📝', 3: '📖', 4: '🌐',
26
+ };
27
+
28
+ export interface SharingRule {
29
+ pattern: string; // 태그명, 폴더명, 또는 문서ID
30
+ type: 'tag' | 'folder' | 'doc';
31
+ level: SharingLevel;
32
+ }
18
33
 
19
- // 문서 단위
20
- blockedDocIds: string[]; // 개별 문서 ID 차단 (둘 다 적용)
34
+ export interface SharingConfig {
35
+ defaultLevel: SharingLevel; // 규칙에 걸리는 문서의 기본 레벨
36
+ myNodeLevel: SharingLevel; // 내 노드의 전체 공개 레벨 (상호 매칭용)
37
+ rules: SharingRule[]; // 태그/폴더/문서별 레벨 규칙
38
+ blockedDocIds: string[]; // 개별 문서 강제 차단 (Level 0)
39
+ blockSensitivePatterns: boolean;
40
+ pendingRequests: FullTextRequest[]; // 전문 열람 요청 대기열
41
+ }
21
42
 
22
- // 콘텐츠 필터
23
- blockSensitivePatterns: boolean; // 이메일, 전화번호, API키 패턴 자동 감지→차단
43
+ export interface FullTextRequest {
44
+ requestId: string;
45
+ fromPeerId: string;
46
+ fromName: string;
47
+ documentTitle: string;
48
+ documentId: string;
49
+ requestedAt: string;
50
+ status: 'pending' | 'approved' | 'denied';
24
51
  }
25
52
 
53
+ // 크레딧 보너스 (레벨별)
54
+ export const LEVEL_CREDIT_MULTIPLIER: Record<SharingLevel, number> = {
55
+ 0: 0, 1: 1, 2: 2, 3: 5, 4: 10,
56
+ };
57
+
26
58
  const SHARING_FILE = join(homedir(), '.stellavault', 'federation', 'sharing.json');
27
59
 
60
+ const SENSITIVE_PATTERNS = [
61
+ /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/,
62
+ /\b\d{3}[-.]?\d{4}[-.]?\d{4}\b/,
63
+ /\b(sk-|pk-|api[_-]?key|token|secret)[a-zA-Z0-9_-]{10,}\b/i,
64
+ /\bpassword\s*[:=]\s*\S+/i,
65
+ /\b\d{6}[-]\d{7}\b/,
66
+ ];
67
+
28
68
  const DEFAULT_CONFIG: SharingConfig = {
29
- mode: 'blacklist',
30
- allowedTags: [],
31
- blockedTags: ['personal', 'private', 'secret', 'diary', 'salary', 'password', 'credential'],
32
- allowedFolders: [],
33
- blockedFolders: ['03_Daily', '06_Archive', '.obsidian'],
69
+ defaultLevel: 2, // 기본: 스니펫까지
70
+ myNodeLevel: 2, // 내 노드 기본: 스니펫까지
71
+ rules: [
72
+ // 기본 규칙
73
+ { pattern: 'public', type: 'tag', level: 4 },
74
+ { pattern: 'opensource', type: 'tag', level: 4 },
75
+ { pattern: 'personal', type: 'tag', level: 1 },
76
+ { pattern: 'private', type: 'tag', level: 0 },
77
+ { pattern: 'secret', type: 'tag', level: 0 },
78
+ { pattern: 'diary', type: 'tag', level: 0 },
79
+ { pattern: 'salary', type: 'tag', level: 0 },
80
+ { pattern: 'password', type: 'tag', level: 0 },
81
+ { pattern: 'credential', type: 'tag', level: 0 },
82
+ { pattern: '03_Daily', type: 'folder', level: 1 },
83
+ { pattern: '06_Archive', type: 'folder', level: 1 },
84
+ { pattern: '.obsidian', type: 'folder', level: 0 },
85
+ ],
34
86
  blockedDocIds: [],
35
87
  blockSensitivePatterns: true,
88
+ pendingRequests: [],
36
89
  };
37
90
 
38
- // 민감 패턴
39
- const SENSITIVE_PATTERNS = [
40
- /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/, // 이메일
41
- /\b\d{3}[-.]?\d{4}[-.]?\d{4}\b/, // 전화번호
42
- /\b(sk-|pk-|api[_-]?key|token|secret)[a-zA-Z0-9_-]{10,}\b/i, // API 키
43
- /\bpassword\s*[:=]\s*\S+/i, // password=xxx
44
- /\b\d{6}[-]\d{7}\b/, // 주민번호 패턴
45
- ];
46
-
47
91
  export function loadSharingConfig(): SharingConfig {
48
92
  if (existsSync(SHARING_FILE)) {
49
93
  const raw = JSON.parse(readFileSync(SHARING_FILE, 'utf-8'));
@@ -57,51 +101,144 @@ export function saveSharingConfig(config: SharingConfig): void {
57
101
  writeFileSync(SHARING_FILE, JSON.stringify(config, null, 2), 'utf-8');
58
102
  }
59
103
 
60
- // 문서가 공유 가능한지 확인
61
- export function isDocumentShareable(
104
+ // 문서의 공유 레벨 결정
105
+ export function getDocumentLevel(
62
106
  doc: { tags: string[]; filePath: string; id: string; content: string },
63
107
  config?: SharingConfig,
64
- ): boolean {
108
+ ): SharingLevel {
65
109
  const cfg = config ?? loadSharingConfig();
66
110
 
67
- // 1. 개별 차단 확인
68
- if (cfg.blockedDocIds.includes(doc.id)) return false;
111
+ // 1. 개별 차단
112
+ if (cfg.blockedDocIds.includes(doc.id)) return 0;
69
113
 
70
- // 2. 폴더 기반 필터
71
- const folder = doc.filePath.split('/')[0] ?? '';
72
- if (cfg.mode === 'whitelist') {
73
- if (cfg.allowedFolders.length > 0 && !cfg.allowedFolders.some(f => doc.filePath.startsWith(f))) {
74
- return false;
114
+ // 2. 민감 패턴 감지 → Level 0
115
+ if (cfg.blockSensitivePatterns) {
116
+ for (const pattern of SENSITIVE_PATTERNS) {
117
+ if (pattern.test(doc.content)) return 0;
75
118
  }
76
- } else {
77
- if (cfg.blockedFolders.some(f => doc.filePath.startsWith(f))) {
78
- return false;
119
+ }
120
+
121
+ // 3. 규칙 매칭 (가장 구체적인 규칙 우선)
122
+ let matchedLevel: SharingLevel | null = null;
123
+
124
+ // 문서ID 규칙 (가장 구체적)
125
+ for (const rule of cfg.rules) {
126
+ if (rule.type === 'doc' && rule.pattern === doc.id) {
127
+ return rule.level;
79
128
  }
80
129
  }
81
130
 
82
- // 3. 태그 기반 필터
131
+ // 태그 규칙 (가장 제한적인 것 적용)
83
132
  const docTags = doc.tags.map(t => t.toLowerCase());
84
- if (cfg.mode === 'whitelist') {
85
- if (cfg.allowedTags.length > 0 && !cfg.allowedTags.some(t => docTags.includes(t.toLowerCase()))) {
86
- return false;
87
- }
88
- } else {
89
- if (cfg.blockedTags.some(t => docTags.includes(t.toLowerCase()))) {
90
- return false;
133
+ for (const rule of cfg.rules) {
134
+ if (rule.type === 'tag' && docTags.includes(rule.pattern.toLowerCase())) {
135
+ if (matchedLevel === null || rule.level < matchedLevel) {
136
+ matchedLevel = rule.level;
137
+ }
91
138
  }
92
139
  }
93
140
 
94
- // 4. 민감 패턴 감지
95
- if (cfg.blockSensitivePatterns) {
96
- for (const pattern of SENSITIVE_PATTERNS) {
97
- if (pattern.test(doc.content)) return false;
141
+ // 폴더 규칙
142
+ for (const rule of cfg.rules) {
143
+ if (rule.type === 'folder' && doc.filePath.startsWith(rule.pattern)) {
144
+ if (matchedLevel === null || rule.level < matchedLevel) {
145
+ matchedLevel = rule.level;
146
+ }
98
147
  }
99
148
  }
100
149
 
150
+ return matchedLevel ?? cfg.defaultLevel;
151
+ }
152
+
153
+ // 이전 API 호환: isDocumentShareable = Level > 0
154
+ export function isDocumentShareable(
155
+ doc: { tags: string[]; filePath: string; id: string; content: string },
156
+ config?: SharingConfig,
157
+ ): boolean {
158
+ return getDocumentLevel(doc, config) > 0;
159
+ }
160
+
161
+ // 상호 매칭: 내 레벨에 따라 상대 문서를 어디까지 볼 수 있는가
162
+ export function getAccessibleLevel(myLevel: SharingLevel, docLevel: SharingLevel): SharingLevel {
163
+ // 내 공개 레벨이 상대 문서 레벨 이상이어야 열람 가능
164
+ // 단, 상대가 공개한 범위를 넘을 수는 없음
165
+ return Math.min(myLevel, docLevel) as SharingLevel;
166
+ }
167
+
168
+ // 검색 결과에 레벨 정보 추가
169
+ export interface LeveledSearchResult {
170
+ title: string;
171
+ similarity: number;
172
+ snippet?: string; // Level 2+ only
173
+ fullTextAvailable: boolean; // Level 3+ → 요청 가능, Level 4 → 자동
174
+ autoShare: boolean; // Level 4 → true
175
+ level: SharingLevel;
176
+ }
177
+
178
+ export function buildLeveledResult(
179
+ doc: { title: string; content: string; tags: string[]; filePath: string; id: string },
180
+ similarity: number,
181
+ requesterNodeLevel: SharingLevel,
182
+ config?: SharingConfig,
183
+ ): LeveledSearchResult | null {
184
+ const docLevel = getDocumentLevel(doc, config);
185
+ if (docLevel === 0) return null; // 차단
186
+
187
+ const accessLevel = getAccessibleLevel(requesterNodeLevel, docLevel);
188
+ if (accessLevel === 0) return null;
189
+
190
+ return {
191
+ title: accessLevel >= 1 ? doc.title : '[Hidden]',
192
+ similarity,
193
+ snippet: accessLevel >= 2 ? sanitizeSnippet(doc.content.slice(0, 50)) : undefined,
194
+ fullTextAvailable: docLevel >= 3,
195
+ autoShare: docLevel >= 4,
196
+ level: accessLevel,
197
+ };
198
+ }
199
+
200
+ // 전문 열람 요청
201
+ export function createFullTextRequest(
202
+ fromPeerId: string, fromName: string,
203
+ documentId: string, documentTitle: string,
204
+ ): FullTextRequest {
205
+ const cfg = loadSharingConfig();
206
+ const request: FullTextRequest = {
207
+ requestId: `req-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
208
+ fromPeerId, fromName, documentTitle, documentId,
209
+ requestedAt: new Date().toISOString(),
210
+ status: 'pending',
211
+ };
212
+ cfg.pendingRequests.push(request);
213
+ // 최근 50개만 유지
214
+ if (cfg.pendingRequests.length > 50) cfg.pendingRequests = cfg.pendingRequests.slice(-50);
215
+ saveSharingConfig(cfg);
216
+ return request;
217
+ }
218
+
219
+ export function approveRequest(requestId: string): boolean {
220
+ const cfg = loadSharingConfig();
221
+ const req = cfg.pendingRequests.find(r => r.requestId === requestId);
222
+ if (!req) return false;
223
+ req.status = 'approved';
224
+ saveSharingConfig(cfg);
101
225
  return true;
102
226
  }
103
227
 
104
- // 스니펫에서 민감 정보 제거
228
+ export function denyRequest(requestId: string): boolean {
229
+ const cfg = loadSharingConfig();
230
+ const req = cfg.pendingRequests.find(r => r.requestId === requestId);
231
+ if (!req) return false;
232
+ req.status = 'denied';
233
+ saveSharingConfig(cfg);
234
+ return true;
235
+ }
236
+
237
+ export function getPendingRequests(): FullTextRequest[] {
238
+ return loadSharingConfig().pendingRequests.filter(r => r.status === 'pending');
239
+ }
240
+
241
+ // 스니펫 민감 정보 제거
105
242
  export function sanitizeSnippet(snippet: string): string {
106
243
  let safe = snippet;
107
244
  for (const pattern of SENSITIVE_PATTERNS) {
@@ -110,54 +247,67 @@ export function sanitizeSnippet(snippet: string): string {
110
247
  return safe;
111
248
  }
112
249
 
113
- // CLI 헬퍼: 현재 공유 설정 요약
114
- export function getSharingSummary(config?: SharingConfig): string {
115
- const cfg = config ?? loadSharingConfig();
116
- const lines: string[] = [];
117
- lines.push(`Mode: ${cfg.mode}`);
118
- if (cfg.mode === 'blacklist') {
119
- lines.push(`Blocked tags: ${cfg.blockedTags.join(', ') || 'none'}`);
120
- lines.push(`Blocked folders: ${cfg.blockedFolders.join(', ') || 'none'}`);
121
- } else {
122
- lines.push(`Allowed tags: ${cfg.allowedTags.join(', ') || 'all'}`);
123
- lines.push(`Allowed folders: ${cfg.allowedFolders.join(', ') || 'all'}`);
124
- }
125
- lines.push(`Blocked docs: ${cfg.blockedDocIds.length}`);
126
- lines.push(`Sensitive pattern filter: ${cfg.blockSensitivePatterns ? 'ON' : 'OFF'}`);
127
- return lines.join('\n');
250
+ // 규칙 관리 헬퍼
251
+ export function setTagLevel(tag: string, level: SharingLevel): void {
252
+ const cfg = loadSharingConfig();
253
+ const existing = cfg.rules.findIndex(r => r.type === 'tag' && r.pattern.toLowerCase() === tag.toLowerCase());
254
+ if (existing >= 0) cfg.rules[existing].level = level;
255
+ else cfg.rules.push({ pattern: tag.toLowerCase(), type: 'tag', level });
256
+ saveSharingConfig(cfg);
128
257
  }
129
258
 
130
- // 태그 추가/제거 헬퍼
131
- export function addBlockedTag(tag: string): void {
259
+ export function setFolderLevel(folder: string, level: SharingLevel): void {
132
260
  const cfg = loadSharingConfig();
133
- if (!cfg.blockedTags.includes(tag.toLowerCase())) {
134
- cfg.blockedTags.push(tag.toLowerCase());
135
- saveSharingConfig(cfg);
136
- }
261
+ const existing = cfg.rules.findIndex(r => r.type === 'folder' && r.pattern === folder);
262
+ if (existing >= 0) cfg.rules[existing].level = level;
263
+ else cfg.rules.push({ pattern: folder, type: 'folder', level });
264
+ saveSharingConfig(cfg);
137
265
  }
138
266
 
139
- export function removeBlockedTag(tag: string): void {
267
+ export function setNodeLevel(level: SharingLevel): void {
140
268
  const cfg = loadSharingConfig();
141
- cfg.blockedTags = cfg.blockedTags.filter(t => t !== tag.toLowerCase());
269
+ cfg.myNodeLevel = level;
142
270
  saveSharingConfig(cfg);
143
271
  }
144
272
 
145
- export function addBlockedFolder(folder: string): void {
273
+ export function setDefaultLevel(level: SharingLevel): void {
146
274
  const cfg = loadSharingConfig();
147
- if (!cfg.blockedFolders.includes(folder)) {
148
- cfg.blockedFolders.push(folder);
149
- saveSharingConfig(cfg);
275
+ cfg.defaultLevel = level;
276
+ saveSharingConfig(cfg);
277
+ }
278
+
279
+ // CLI 요약
280
+ export function getSharingSummary(config?: SharingConfig): string {
281
+ const cfg = config ?? loadSharingConfig();
282
+ const lines: string[] = [];
283
+ lines.push(`My Node Level: ${LEVEL_ICONS[cfg.myNodeLevel]} Level ${cfg.myNodeLevel} (${LEVEL_LABELS[cfg.myNodeLevel]})`);
284
+ lines.push(`Default Doc Level: ${LEVEL_ICONS[cfg.defaultLevel]} Level ${cfg.defaultLevel}`);
285
+ lines.push(`Credit Multiplier: ${LEVEL_CREDIT_MULTIPLIER[cfg.myNodeLevel]}x`);
286
+ lines.push('');
287
+ lines.push('Rules:');
288
+ for (const rule of cfg.rules) {
289
+ lines.push(` ${LEVEL_ICONS[rule.level]} [${rule.type}] ${rule.pattern} → Level ${rule.level}`);
290
+ }
291
+ if (cfg.blockedDocIds.length > 0) {
292
+ lines.push(` 🚫 ${cfg.blockedDocIds.length} docs individually blocked`);
293
+ }
294
+ lines.push('');
295
+ const pending = cfg.pendingRequests.filter(r => r.status === 'pending');
296
+ if (pending.length > 0) {
297
+ lines.push(`📬 ${pending.length} pending full-text requests`);
150
298
  }
299
+ lines.push(`Sensitive pattern filter: ${cfg.blockSensitivePatterns ? 'ON' : 'OFF'}`);
300
+ return lines.join('\n');
151
301
  }
152
302
 
303
+ // 레거시 호환
304
+ export function addBlockedTag(tag: string): void { setTagLevel(tag, 0); }
305
+ export function removeBlockedTag(tag: string): void { setTagLevel(tag, 2); }
306
+ export function addBlockedFolder(folder: string): void { setFolderLevel(folder, 0); }
153
307
  export function blockDocument(docId: string): void {
154
308
  const cfg = loadSharingConfig();
155
- if (!cfg.blockedDocIds.includes(docId)) {
156
- cfg.blockedDocIds.push(docId);
157
- saveSharingConfig(cfg);
158
- }
309
+ if (!cfg.blockedDocIds.includes(docId)) { cfg.blockedDocIds.push(docId); saveSharingConfig(cfg); }
159
310
  }
160
-
161
311
  export function unblockDocument(docId: string): void {
162
312
  const cfg = loadSharingConfig();
163
313
  cfg.blockedDocIds = cfg.blockedDocIds.filter(id => id !== docId);
@@ -90,8 +90,8 @@ export type { PackListing } from './pack/marketplace.js';
90
90
  export { FederationNode, FederatedSearch, getOrCreateIdentity } from './federation/index.js';
91
91
  export type { PeerInfo, FederatedSearchResult, FederationMessage, NodeIdentity } from './federation/index.js';
92
92
  export { vouch, revoke, block, getTrustLevel, isBlocked, listTrusted, computeTrustScore } from './federation/trust.js';
93
- export { loadSharingConfig, saveSharingConfig, isDocumentShareable, sanitizeSnippet, getSharingSummary, addBlockedTag, removeBlockedTag, addBlockedFolder, blockDocument, unblockDocument } from './federation/sharing.js';
94
- export type { SharingConfig } from './federation/sharing.js';
93
+ export { loadSharingConfig, saveSharingConfig, isDocumentShareable, sanitizeSnippet, getSharingSummary, addBlockedTag, removeBlockedTag, addBlockedFolder, blockDocument, unblockDocument, getDocumentLevel, getAccessibleLevel, buildLeveledResult, setTagLevel, setFolderLevel, setNodeLevel, setDefaultLevel, createFullTextRequest, approveRequest, denyRequest, getPendingRequests, LEVEL_LABELS, LEVEL_ICONS, LEVEL_CREDIT_MULTIPLIER } from './federation/sharing.js';
94
+ export type { SharingConfig, SharingLevel, SharingRule, FullTextRequest, LeveledSearchResult } from './federation/sharing.js';
95
95
  export { computeReputation, verifyConsensus, recordInteraction, recordConsistency, recordFeedback, recordConsensus, getReputationBoard, filterByReputation } from './federation/reputation.js';
96
96
  export type { ReputationRecord } from './federation/reputation.js';
97
97
  export type { TrustEntry } from './federation/trust.js';
@@ -0,0 +1 @@
1
+ import{c as q,g as K}from"./index-DMEe2diW.js";function L(d,m){for(var w=0;w<m.length;w++){const f=m[w];if(typeof f!="string"&&!Array.isArray(f)){for(const a in f)if(a!=="default"&&!(a in d)){const j=Object.getOwnPropertyDescriptor(f,a);j&&Object.defineProperty(d,a,j.get?j:{enumerable:!0,get:()=>f[a]})}}}return Object.freeze(Object.defineProperty(d,Symbol.toStringTag,{value:"Module"}))}var F={},T;function Q(){return T||(T=1,(function(){function d(t){var e=0;return function(){return e<t.length?{done:!1,value:t[e++]}:{done:!0}}}var m=typeof Object.defineProperties=="function"?Object.defineProperty:function(t,e,o){return t==Array.prototype||t==Object.prototype||(t[e]=o.value),t};function w(t){t=[typeof globalThis=="object"&&globalThis,t,typeof window=="object"&&window,typeof self=="object"&&self,typeof q=="object"&&q];for(var e=0;e<t.length;++e){var o=t[e];if(o&&o.Math==Math)return o}throw Error("Cannot find global object")}var f=w(this);function a(t,e){if(e)t:{var o=f;t=t.split(".");for(var i=0;i<t.length-1;i++){var s=t[i];if(!(s in o))break t;o=o[s]}t=t[t.length-1],i=o[t],e=e(i),e!=i&&e!=null&&m(o,t,{configurable:!0,writable:!0,value:e})}}a("Symbol",function(t){function e(l){if(this instanceof e)throw new TypeError("Symbol is not a constructor");return new o(i+(l||"")+"_"+s++,l)}function o(l,n){this.g=l,m(this,"description",{configurable:!0,writable:!0,value:n})}if(t)return t;o.prototype.toString=function(){return this.g};var i="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",s=0;return e}),a("Symbol.iterator",function(t){if(t)return t;t=Symbol("Symbol.iterator");for(var e="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),o=0;o<e.length;o++){var i=f[e[o]];typeof i=="function"&&typeof i.prototype[t]!="function"&&m(i.prototype,t,{configurable:!0,writable:!0,value:function(){return j(d(this))}})}return t});function j(t){return t={next:t},t[Symbol.iterator]=function(){return this},t}function A(t){var e=typeof Symbol<"u"&&Symbol.iterator&&t[Symbol.iterator];return e?e.call(t):{next:d(t)}}function E(){this.i=!1,this.g=null,this.o=void 0,this.j=1,this.m=0,this.h=null}function S(t){if(t.i)throw new TypeError("Generator is already running");t.i=!0}E.prototype.l=function(t){this.o=t};function _(t,e){t.h={F:e,G:!0},t.j=t.m}E.prototype.return=function(t){this.h={return:t},this.j=this.m};function U(t){this.g=new E,this.h=t}function H(t,e){S(t.g);var o=t.g.g;return o?C(t,"return"in o?o.return:function(i){return{value:i,done:!0}},e,t.g.return):(t.g.return(e),b(t))}function C(t,e,o,i){try{var s=e.call(t.g.g,o);if(!(s instanceof Object))throw new TypeError("Iterator result "+s+" is not an object");if(!s.done)return t.g.i=!1,s;var l=s.value}catch(n){return t.g.g=null,_(t.g,n),b(t)}return t.g.g=null,i.call(t.g,l),b(t)}function b(t){for(;t.g.j;)try{var e=t.h(t.g);if(e)return t.g.i=!1,{value:e.value,done:!1}}catch(o){t.g.o=void 0,_(t.g,o)}if(t.g.i=!1,t.g.h){if(e=t.g.h,t.g.h=null,e.G)throw e.F;return{value:e.return,done:!0}}return{value:void 0,done:!0}}function I(t){this.next=function(e){return S(t.g),t.g.g?e=C(t,t.g.g.next,e,t.g.l):(t.g.l(e),e=b(t)),e},this.throw=function(e){return S(t.g),t.g.g?e=C(t,t.g.g.throw,e,t.g.l):(_(t.g,e),e=b(t)),e},this.return=function(e){return H(t,e)},this[Symbol.iterator]=function(){return this}}function G(t){function e(i){return t.next(i)}function o(i){return t.throw(i)}return new Promise(function(i,s){function l(n){n.done?i(n.value):Promise.resolve(n.value).then(e,o).then(l,s)}l(t.next())})}a("Promise",function(t){function e(n){this.h=0,this.i=void 0,this.g=[],this.o=!1;var r=this.j();try{n(r.resolve,r.reject)}catch(u){r.reject(u)}}function o(){this.g=null}function i(n){return n instanceof e?n:new e(function(r){r(n)})}if(t)return t;o.prototype.h=function(n){if(this.g==null){this.g=[];var r=this;this.i(function(){r.l()})}this.g.push(n)};var s=f.setTimeout;o.prototype.i=function(n){s(n,0)},o.prototype.l=function(){for(;this.g&&this.g.length;){var n=this.g;this.g=[];for(var r=0;r<n.length;++r){var u=n[r];n[r]=null;try{u()}catch(c){this.j(c)}}}this.g=null},o.prototype.j=function(n){this.i(function(){throw n})},e.prototype.j=function(){function n(c){return function(h){u||(u=!0,c.call(r,h))}}var r=this,u=!1;return{resolve:n(this.A),reject:n(this.l)}},e.prototype.A=function(n){if(n===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(n instanceof e)this.C(n);else{t:switch(typeof n){case"object":var r=n!=null;break t;case"function":r=!0;break t;default:r=!1}r?this.v(n):this.m(n)}},e.prototype.v=function(n){var r=void 0;try{r=n.then}catch(u){this.l(u);return}typeof r=="function"?this.D(r,n):this.m(n)},e.prototype.l=function(n){this.u(2,n)},e.prototype.m=function(n){this.u(1,n)},e.prototype.u=function(n,r){if(this.h!=0)throw Error("Cannot settle("+n+", "+r+"): Promise already settled in state"+this.h);this.h=n,this.i=r,this.h===2&&this.B(),this.H()},e.prototype.B=function(){var n=this;s(function(){if(n.I()){var r=f.console;typeof r<"u"&&r.error(n.i)}},1)},e.prototype.I=function(){if(this.o)return!1;var n=f.CustomEvent,r=f.Event,u=f.dispatchEvent;return typeof u>"u"?!0:(typeof n=="function"?n=new n("unhandledrejection",{cancelable:!0}):typeof r=="function"?n=new r("unhandledrejection",{cancelable:!0}):(n=f.document.createEvent("CustomEvent"),n.initCustomEvent("unhandledrejection",!1,!0,n)),n.promise=this,n.reason=this.i,u(n))},e.prototype.H=function(){if(this.g!=null){for(var n=0;n<this.g.length;++n)l.h(this.g[n]);this.g=null}};var l=new o;return e.prototype.C=function(n){var r=this.j();n.s(r.resolve,r.reject)},e.prototype.D=function(n,r){var u=this.j();try{n.call(r,u.resolve,u.reject)}catch(c){u.reject(c)}},e.prototype.then=function(n,r){function u(v,y){return typeof v=="function"?function(k){try{c(v(k))}catch(D){h(D)}}:y}var c,h,M=new e(function(v,y){c=v,h=y});return this.s(u(n,c),u(r,h)),M},e.prototype.catch=function(n){return this.then(void 0,n)},e.prototype.s=function(n,r){function u(){switch(c.h){case 1:n(c.i);break;case 2:r(c.i);break;default:throw Error("Unexpected state: "+c.h)}}var c=this;this.g==null?l.h(u):this.g.push(u),this.o=!0},e.resolve=i,e.reject=function(n){return new e(function(r,u){u(n)})},e.race=function(n){return new e(function(r,u){for(var c=A(n),h=c.next();!h.done;h=c.next())i(h.value).s(r,u)})},e.all=function(n){var r=A(n),u=r.next();return u.done?i([]):new e(function(c,h){function M(k){return function(D){v[k]=D,y--,y==0&&c(v)}}var v=[],y=0;do v.push(void 0),y++,i(u.value).s(M(v.length-1),h),u=r.next();while(!u.done)})},e});var N=typeof Object.assign=="function"?Object.assign:function(t,e){for(var o=1;o<arguments.length;o++){var i=arguments[o];if(i)for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t};a("Object.assign",function(t){return t||N});var z=this||self,R={facingMode:"user",width:640,height:480};function O(t,e){this.video=t,this.i=0,this.h=Object.assign(Object.assign({},R),e)}O.prototype.stop=function(){var t=this,e,o,i,s;return G(new I(new U(function(l){if(t.g){for(e=t.g.getTracks(),o=A(e),i=o.next();!i.done;i=o.next())s=i.value,s.stop();t.g=void 0}l.j=0})))},O.prototype.start=function(){var t=this,e;return G(new I(new U(function(o){return navigator.mediaDevices&&navigator.mediaDevices.getUserMedia||alert("No navigator.mediaDevices.getUserMedia exists."),e=t.h,o.return(navigator.mediaDevices.getUserMedia({video:{facingMode:e.facingMode,width:e.width,height:e.height}}).then(function(i){$(t,i)}).catch(function(i){var s="Failed to acquire camera feed: "+i;throw console.error(s),alert(s),i}))})))};function P(t){window.requestAnimationFrame(function(){J(t)})}function $(t,e){t.g=e,t.video.srcObject=e,t.video.onloadedmetadata=function(){t.video.play(),P(t)}}function J(t){var e=null;t.video.paused||t.video.currentTime===t.i||(t.i=t.video.currentTime,e=t.h.onFrame()),e?e.then(function(){P(t)}):P(t)}var x=["Camera"],g=z;x[0]in g||typeof g.execScript>"u"||g.execScript("var "+x[0]);for(var p;x.length&&(p=x.shift());)x.length||O===void 0?g[p]&&g[p]!==Object.prototype[p]?g=g[p]:g=g[p]={}:g[p]=O}).call(F)),F}var B=Q();const V=K(B),X=L({__proto__:null,default:V},[B]);export{X as c};
@@ -0,0 +1,18 @@
1
+ import{c as fr,g as dn}from"./index-DMEe2diW.js";function yn(j,Q){for(var H=0;H<Q.length;H++){const z=Q[H];if(typeof z!="string"&&!Array.isArray(z)){for(const T in z)if(T!=="default"&&!(T in j)){const w=Object.getOwnPropertyDescriptor(z,T);w&&Object.defineProperty(j,T,w.get?w:{enumerable:!0,get:()=>z[T]})}}}return Object.freeze(Object.defineProperty(j,Symbol.toStringTag,{value:"Module"}))}var Jt={},ar;function mn(){return ar||(ar=1,(function(){var j;function Q(t){var e=0;return function(){return e<t.length?{done:!1,value:t[e++]}:{done:!0}}}var H=typeof Object.defineProperties=="function"?Object.defineProperty:function(t,e,r){return t==Array.prototype||t==Object.prototype||(t[e]=r.value),t};function z(t){t=[typeof globalThis=="object"&&globalThis,t,typeof window=="object"&&window,typeof self=="object"&&self,typeof fr=="object"&&fr];for(var e=0;e<t.length;++e){var r=t[e];if(r&&r.Math==Math)return r}throw Error("Cannot find global object")}var T=z(this);function w(t,e){if(e)t:{var r=T;t=t.split(".");for(var n=0;n<t.length-1;n++){var i=t[n];if(!(i in r))break t;r=r[i]}t=t[t.length-1],n=r[t],e=e(n),e!=n&&e!=null&&H(r,t,{configurable:!0,writable:!0,value:e})}}w("Symbol",function(t){function e(u){if(this instanceof e)throw new TypeError("Symbol is not a constructor");return new r(n+(u||"")+"_"+i++,u)}function r(u,o){this.h=u,H(this,"description",{configurable:!0,writable:!0,value:o})}if(t)return t;r.prototype.toString=function(){return this.h};var n="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",i=0;return e}),w("Symbol.iterator",function(t){if(t)return t;t=Symbol("Symbol.iterator");for(var e="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),r=0;r<e.length;r++){var n=T[e[r]];typeof n=="function"&&typeof n.prototype[t]!="function"&&H(n.prototype,t,{configurable:!0,writable:!0,value:function(){return hr(Q(this))}})}return t});function hr(t){return t={next:t},t[Symbol.iterator]=function(){return this},t}function F(t){var e=typeof Symbol<"u"&&Symbol.iterator&&t[Symbol.iterator];return e?e.call(t):{next:Q(t)}}function qt(t){if(!(t instanceof Array)){t=F(t);for(var e,r=[];!(e=t.next()).done;)r.push(e.value);t=r}return t}var pr=typeof Object.assign=="function"?Object.assign:function(t,e){for(var r=1;r<arguments.length;r++){var n=arguments[r];if(n)for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t};w("Object.assign",function(t){return t||pr});var vr=typeof Object.create=="function"?Object.create:function(t){function e(){}return e.prototype=t,new e},bt;if(typeof Object.setPrototypeOf=="function")bt=Object.setPrototypeOf;else{var Et;t:{var dr={a:!0},te={};try{te.__proto__=dr,Et=te.a;break t}catch{}Et=!1}bt=Et?function(t,e){if(t.__proto__=e,t.__proto__!==e)throw new TypeError(t+" is not extensible");return t}:null}var ee=bt;function J(t,e){if(t.prototype=vr(e.prototype),t.prototype.constructor=t,ee)ee(t,e);else for(var r in e)if(r!="prototype")if(Object.defineProperties){var n=Object.getOwnPropertyDescriptor(e,r);n&&Object.defineProperty(t,r,n)}else t[r]=e[r];t.ya=e.prototype}function _t(){this.m=!1,this.j=null,this.i=void 0,this.h=1,this.v=this.s=0,this.l=null}function Ot(t){if(t.m)throw new TypeError("Generator is already running");t.m=!0}_t.prototype.u=function(t){this.i=t};function Ft(t,e){t.l={ma:e,na:!0},t.h=t.s||t.v}_t.prototype.return=function(t){this.l={return:t},this.h=this.v};function x(t,e,r){return t.h=r,{value:e}}function yr(t){this.h=new _t,this.i=t}function mr(t,e){Ot(t.h);var r=t.h.j;return r?St(t,"return"in r?r.return:function(n){return{value:n,done:!0}},e,t.h.return):(t.h.return(e),q(t))}function St(t,e,r,n){try{var i=e.call(t.h.j,r);if(!(i instanceof Object))throw new TypeError("Iterator result "+i+" is not an object");if(!i.done)return t.h.m=!1,i;var u=i.value}catch(o){return t.h.j=null,Ft(t.h,o),q(t)}return t.h.j=null,n.call(t.h,u),q(t)}function q(t){for(;t.h.h;)try{var e=t.i(t.h);if(e)return t.h.m=!1,{value:e.value,done:!1}}catch(r){t.h.i=void 0,Ft(t.h,r)}if(t.h.m=!1,t.h.l){if(e=t.h.l,t.h.l=null,e.na)throw e.ma;return{value:e.return,done:!0}}return{value:void 0,done:!0}}function gr(t){this.next=function(e){return Ot(t.h),t.h.j?e=St(t,t.h.j.next,e,t.h.u):(t.h.u(e),e=q(t)),e},this.throw=function(e){return Ot(t.h),t.h.j?e=St(t,t.h.j.throw,e,t.h.u):(Ft(t.h,e),e=q(t)),e},this.return=function(e){return mr(t,e)},this[Symbol.iterator]=function(){return this}}function wr(t){function e(n){return t.next(n)}function r(n){return t.throw(n)}return new Promise(function(n,i){function u(o){o.done?n(o.value):Promise.resolve(o.value).then(e,r).then(u,i)}u(t.next())})}function O(t){return wr(new gr(new yr(t)))}w("Promise",function(t){function e(o){this.i=0,this.j=void 0,this.h=[],this.u=!1;var s=this.l();try{o(s.resolve,s.reject)}catch(l){s.reject(l)}}function r(){this.h=null}function n(o){return o instanceof e?o:new e(function(s){s(o)})}if(t)return t;r.prototype.i=function(o){if(this.h==null){this.h=[];var s=this;this.j(function(){s.m()})}this.h.push(o)};var i=T.setTimeout;r.prototype.j=function(o){i(o,0)},r.prototype.m=function(){for(;this.h&&this.h.length;){var o=this.h;this.h=[];for(var s=0;s<o.length;++s){var l=o[s];o[s]=null;try{l()}catch(f){this.l(f)}}}this.h=null},r.prototype.l=function(o){this.j(function(){throw o})},e.prototype.l=function(){function o(f){return function(a){l||(l=!0,f.call(s,a))}}var s=this,l=!1;return{resolve:o(this.I),reject:o(this.m)}},e.prototype.I=function(o){if(o===this)this.m(new TypeError("A Promise cannot resolve to itself"));else if(o instanceof e)this.L(o);else{t:switch(typeof o){case"object":var s=o!=null;break t;case"function":s=!0;break t;default:s=!1}s?this.F(o):this.s(o)}},e.prototype.F=function(o){var s=void 0;try{s=o.then}catch(l){this.m(l);return}typeof s=="function"?this.M(s,o):this.s(o)},e.prototype.m=function(o){this.v(2,o)},e.prototype.s=function(o){this.v(1,o)},e.prototype.v=function(o,s){if(this.i!=0)throw Error("Cannot settle("+o+", "+s+"): Promise already settled in state"+this.i);this.i=o,this.j=s,this.i===2&&this.K(),this.H()},e.prototype.K=function(){var o=this;i(function(){if(o.D()){var s=T.console;typeof s<"u"&&s.error(o.j)}},1)},e.prototype.D=function(){if(this.u)return!1;var o=T.CustomEvent,s=T.Event,l=T.dispatchEvent;return typeof l>"u"?!0:(typeof o=="function"?o=new o("unhandledrejection",{cancelable:!0}):typeof s=="function"?o=new s("unhandledrejection",{cancelable:!0}):(o=T.document.createEvent("CustomEvent"),o.initCustomEvent("unhandledrejection",!1,!0,o)),o.promise=this,o.reason=this.j,l(o))},e.prototype.H=function(){if(this.h!=null){for(var o=0;o<this.h.length;++o)u.i(this.h[o]);this.h=null}};var u=new r;return e.prototype.L=function(o){var s=this.l();o.T(s.resolve,s.reject)},e.prototype.M=function(o,s){var l=this.l();try{o.call(s,l.resolve,l.reject)}catch(f){l.reject(f)}},e.prototype.then=function(o,s){function l(h,c){return typeof h=="function"?function(v){try{f(h(v))}catch(d){a(d)}}:c}var f,a,p=new e(function(h,c){f=h,a=c});return this.T(l(o,f),l(s,a)),p},e.prototype.catch=function(o){return this.then(void 0,o)},e.prototype.T=function(o,s){function l(){switch(f.i){case 1:o(f.j);break;case 2:s(f.j);break;default:throw Error("Unexpected state: "+f.i)}}var f=this;this.h==null?u.i(l):this.h.push(l),this.u=!0},e.resolve=n,e.reject=function(o){return new e(function(s,l){l(o)})},e.race=function(o){return new e(function(s,l){for(var f=F(o),a=f.next();!a.done;a=f.next())n(a.value).T(s,l)})},e.all=function(o){var s=F(o),l=s.next();return l.done?n([]):new e(function(f,a){function p(v){return function(d){h[v]=d,c--,c==0&&f(h)}}var h=[],c=0;do h.push(void 0),c++,n(l.value).T(p(h.length-1),a),l=s.next();while(!l.done)})},e});function Ar(t,e){t instanceof String&&(t+="");var r=0,n=!1,i={next:function(){if(!n&&r<t.length){var u=r++;return{value:e(u,t[u]),done:!1}}return n=!0,{done:!0,value:void 0}}};return i[Symbol.iterator]=function(){return i},i}w("Array.prototype.keys",function(t){return t||function(){return Ar(this,function(e){return e})}}),w("Array.prototype.fill",function(t){return t||function(e,r,n){var i=this.length||0;for(0>r&&(r=Math.max(0,i+r)),(n==null||n>i)&&(n=i),n=Number(n),0>n&&(n=Math.max(0,i+n)),r=Number(r||0);r<n;r++)this[r]=e;return this}});function k(t){return t||Array.prototype.fill}w("Int8Array.prototype.fill",k),w("Uint8Array.prototype.fill",k),w("Uint8ClampedArray.prototype.fill",k),w("Int16Array.prototype.fill",k),w("Uint16Array.prototype.fill",k),w("Int32Array.prototype.fill",k),w("Uint32Array.prototype.fill",k),w("Float32Array.prototype.fill",k),w("Float64Array.prototype.fill",k),w("Object.is",function(t){return t||function(e,r){return e===r?e!==0||1/e===1/r:e!==e&&r!==r}}),w("Array.prototype.includes",function(t){return t||function(e,r){var n=this;n instanceof String&&(n=String(n));var i=n.length;for(r=r||0,0>r&&(r=Math.max(r+i,0));r<i;r++){var u=n[r];if(u===e||Object.is(u,e))return!0}return!1}}),w("String.prototype.includes",function(t){return t||function(e,r){if(this==null)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(e instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return this.indexOf(e,r||0)!==-1}});var Tt=this||self;function tt(t,e){t=t.split(".");var r=Tt;t[0]in r||typeof r.execScript>"u"||r.execScript("var "+t[0]);for(var n;t.length&&(n=t.shift());)t.length||e===void 0?r[n]&&r[n]!==Object.prototype[n]?r=r[n]:r=r[n]={}:r[n]=e}function re(t){var e;t:{if((e=Tt.navigator)&&(e=e.userAgent))break t;e=""}return e.indexOf(t)!=-1}var jr=Array.prototype.map?function(t,e){return Array.prototype.map.call(t,e,void 0)}:function(t,e){for(var r=t.length,n=Array(r),i=typeof t=="string"?t.split(""):t,u=0;u<r;u++)u in i&&(n[u]=e.call(void 0,i[u],u,t));return n},ne={},et=null;function xr(t){var e=t.length,r=3*e/4;r%3?r=Math.floor(r):"=.".indexOf(t[e-1])!=-1&&(r="=.".indexOf(t[e-2])!=-1?r-2:r-1);var n=new Uint8Array(r),i=0;return br(t,function(u){n[i++]=u}),i!==r?n.subarray(0,i):n}function br(t,e){function r(l){for(;n<t.length;){var f=t.charAt(n++),a=et[f];if(a!=null)return a;if(!/^[\s\xa0]*$/.test(f))throw Error("Unknown base64 encoding at char: "+f)}return l}ie();for(var n=0;;){var i=r(-1),u=r(0),o=r(64),s=r(64);if(s===64&&i===-1)break;e(i<<2|u>>4),o!=64&&(e(u<<4&240|o>>2),s!=64&&e(o<<6&192|s))}}function ie(){if(!et){et={};for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"],r=0;5>r;r++){var n=t.concat(e[r].split(""));ne[r]=n;for(var i=0;i<n.length;i++){var u=n[i];et[u]===void 0&&(et[u]=i)}}}}var Rt=typeof Uint8Array<"u",oe=!(re("Trident")||re("MSIE"))&&typeof Tt.btoa=="function";function ue(t){if(!oe){var e;e===void 0&&(e=0),ie(),e=ne[e];for(var r=Array(Math.floor(t.length/3)),n=e[64]||"",i=0,u=0;i<t.length-2;i+=3){var o=t[i],s=t[i+1],l=t[i+2],f=e[o>>2];o=e[(o&3)<<4|s>>4],s=e[(s&15)<<2|l>>6],l=e[l&63],r[u++]=f+o+s+l}switch(f=0,l=n,t.length-i){case 2:f=t[i+1],l=e[(f&15)<<2]||n;case 1:t=t[i],r[u]=e[t>>2]+e[(t&3)<<4|f>>4]+l+n}return r.join("")}for(e="";10240<t.length;)e+=String.fromCharCode.apply(null,t.subarray(0,10240)),t=t.subarray(10240);return e+=String.fromCharCode.apply(null,t),btoa(e)}var se=RegExp("[-_.]","g");function Er(t){switch(t){case"-":return"+";case"_":return"/";case".":return"=";default:return""}}function le(t){if(!oe)return xr(t);se.test(t)&&(t=t.replace(se,Er)),t=atob(t);for(var e=new Uint8Array(t.length),r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}var fe;function Ut(){return fe||(fe=new Uint8Array(0))}var rt={},_r=typeof Uint8Array.prototype.slice=="function",b=0,S=0;function ae(t){var e=0>t;t=Math.abs(t);var r=t>>>0;t=Math.floor((t-r)/4294967296),e&&(r=F(ce(r,t)),e=r.next().value,t=r.next().value,r=e),b=r>>>0,S=t>>>0}var Or=typeof BigInt=="function";function ce(t,e){return e=~e,t?t=~t+1:e+=1,[t,e]}function he(t,e){this.i=t>>>0,this.h=e>>>0}function pe(t){if(!t)return ve||(ve=new he(0,0));if(!/^-?\d+$/.test(t))return null;if(16>t.length)ae(Number(t));else if(Or)t=BigInt(t),b=Number(t&BigInt(4294967295))>>>0,S=Number(t>>BigInt(32)&BigInt(4294967295));else{var e=+(t[0]==="-");S=b=0;for(var r=t.length,n=e,i=(r-e)%6+e;i<=r;n=i,i+=6)n=Number(t.slice(n,i)),S*=1e6,b=1e6*b+n,4294967296<=b&&(S+=b/4294967296|0,b%=4294967296);e&&(e=F(ce(b,S)),t=e.next().value,e=e.next().value,b=t,S=e)}return new he(b,S)}var ve;function de(t,e){return Error("Invalid wire type: "+t+" (at position "+e+")")}function Pt(){return Error("Failed to read varint, encoding is invalid.")}function ye(t,e){return Error("Tried to read past the end of the data "+e+" > "+t)}function W(){throw Error("Invalid UTF8")}function me(t,e){return e=String.fromCharCode.apply(null,e),t==null?e:t+e}var at=void 0,Ct,Fr=typeof TextDecoder<"u",ge,Sr=typeof TextEncoder<"u",we;function Ae(t){if(t!==rt)throw Error("illegal external caller")}function nt(t,e){if(Ae(e),this.V=t,t!=null&&t.length===0)throw Error("ByteString should be constructed with non-empty values")}function Nt(){return we||(we=new nt(null,rt))}function je(t){Ae(rt);var e=t.V;return e=e==null||Rt&&e!=null&&e instanceof Uint8Array?e:typeof e=="string"?le(e):null,e==null?e:t.V=e}function Tr(t){if(typeof t=="string")return{buffer:le(t),C:!1};if(Array.isArray(t))return{buffer:new Uint8Array(t),C:!1};if(t.constructor===Uint8Array)return{buffer:t,C:!1};if(t.constructor===ArrayBuffer)return{buffer:new Uint8Array(t),C:!1};if(t.constructor===nt)return{buffer:je(t)||Ut(),C:!0};if(t instanceof Uint8Array)return{buffer:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),C:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}function xe(t,e){this.i=null,this.m=!1,this.h=this.j=this.l=0,Mt(this,t,e)}function Mt(t,e,r){r=r===void 0?{}:r,t.S=r.S===void 0?!1:r.S,e&&(e=Tr(e),t.i=e.buffer,t.m=e.C,t.l=0,t.j=t.i.length,t.h=t.l)}xe.prototype.reset=function(){this.h=this.l};function V(t,e){if(t.h=e,e>t.j)throw ye(t.j,e)}function it(t){var e=t.i,r=t.h,n=e[r++],i=n&127;if(n&128&&(n=e[r++],i|=(n&127)<<7,n&128&&(n=e[r++],i|=(n&127)<<14,n&128&&(n=e[r++],i|=(n&127)<<21,n&128&&(n=e[r++],i|=n<<28,n&128&&e[r++]&128&&e[r++]&128&&e[r++]&128&&e[r++]&128&&e[r++]&128)))))throw Pt();return V(t,r),i}function be(t,e){if(0>e)throw Error("Tried to read a negative byte length: "+e);var r=t.h,n=r+e;if(n>t.j)throw ye(e,t.j-r);return t.h=n,r}var Ee=[];function Lt(){this.h=[]}Lt.prototype.length=function(){return this.h.length},Lt.prototype.end=function(){var t=this.h;return this.h=[],t};function _e(t,e,r){for(;0<r||127<e;)t.h.push(e&127|128),e=(e>>>7|r<<25)>>>0,r>>>=7;t.h.push(e)}function X(t,e){for(;127<e;)t.h.push(e&127|128),e>>>=7;t.h.push(e)}function Bt(t,e){if(Ee.length){var r=Ee.pop();Mt(r,t,e),t=r}else t=new xe(t,e);this.h=t,this.j=this.h.h,this.i=this.l=-1,this.setOptions(e)}Bt.prototype.setOptions=function(t){t=t===void 0?{}:t,this.ca=t.ca===void 0?!1:t.ca},Bt.prototype.reset=function(){this.h.reset(),this.j=this.h.h,this.i=this.l=-1};function Oe(t){var e=t.h;if(e.h==e.j)return!1;t.j=t.h.h;var r=it(t.h)>>>0;if(e=r>>>3,r&=7,!(0<=r&&5>=r))throw de(r,t.j);if(1>e)throw Error("Invalid field number: "+e+" (at position "+t.j+")");return t.l=e,t.i=r,!0}function ct(t){switch(t.i){case 0:if(t.i!=0)ct(t);else t:{t=t.h;for(var e=t.h,r=e+10,n=t.i;e<r;)if((n[e++]&128)===0){V(t,e);break t}throw Pt()}break;case 1:t=t.h,V(t,t.h+8);break;case 2:t.i!=2?ct(t):(e=it(t.h)>>>0,t=t.h,V(t,t.h+e));break;case 5:t=t.h,V(t,t.h+4);break;case 3:e=t.l;do{if(!Oe(t))throw Error("Unmatched start-group tag: stream EOF");if(t.i==4){if(t.l!=e)throw Error("Unmatched end-group tag");break}ct(t)}while(!0);break;default:throw de(t.i,t.j)}}var ht=[];function Rr(){this.j=[],this.i=0,this.h=new Lt}function K(t,e){e.length!==0&&(t.j.push(e),t.i+=e.length)}function Ur(t,e){if(e=e.R){K(t,t.h.end());for(var r=0;r<e.length;r++)K(t,je(e[r])||Ut())}}var I=typeof Symbol=="function"&&typeof Symbol()=="symbol"?Symbol():void 0;function Y(t,e){return I?t[I]|=e:t.A!==void 0?t.A|=e:(Object.defineProperties(t,{A:{value:e,configurable:!0,writable:!0,enumerable:!1}}),e)}function Fe(t,e){I?t[I]&&(t[I]&=~e):t.A!==void 0&&(t.A&=~e)}function A(t){var e;return I?e=t[I]:e=t.A,e??0}function M(t,e){I?t[I]=e:t.A!==void 0?t.A=e:Object.defineProperties(t,{A:{value:e,configurable:!0,writable:!0,enumerable:!1}})}function Dt(t){return Y(t,1),t}function Pr(t,e){M(e,(t|0)&-51)}function pt(t,e){M(e,(t|18)&-41)}var kt={};function vt(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)&&t.constructor===Object}var ot,Se=[];M(Se,23),ot=Object.freeze(Se);function It(t){if(A(t.o)&2)throw Error("Cannot mutate an immutable Message")}function Gt(t){var e=t.length;(e=e?t[e-1]:void 0)&&vt(e)?e.g=1:(e={},t.push((e.g=1,e)))}function Te(t){var e=t.i+t.G;return t.B||(t.B=t.o[e]={})}function C(t,e){return e===-1?null:e>=t.i?t.B?t.B[e]:void 0:t.o[e+t.G]}function L(t,e,r,n){It(t),ut(t,e,r,n)}function ut(t,e,r,n){t.j&&(t.j=void 0),e>=t.i||n?Te(t)[e]=r:(t.o[e+t.G]=r,(t=t.B)&&e in t&&delete t[e])}function Ht(t,e,r,n){var i=C(t,e);Array.isArray(i)||(i=ot);var u=A(i);if(u&1||Dt(i),n)u&2||Y(i,2),r&1||Object.freeze(i);else{n=!(r&2);var o=u&2;r&1||!o?n&&u&16&&!o&&Fe(i,16):(i=Dt(Array.prototype.slice.call(i)),ut(t,e,i))}return i}function zt(t,e){var r=C(t,e),n=r==null?r:typeof r=="number"||r==="NaN"||r==="Infinity"||r==="-Infinity"?Number(r):void 0;return n!=null&&n!==r&&ut(t,e,n),n}function Re(t,e,r,n,i){t.h||(t.h={});var u=t.h[r],o=Ht(t,r,3,i);if(!u){var s=o;u=[];var l=!!(A(t.o)&16);o=!!(A(s)&2);var f=s;!i&&o&&(s=Array.prototype.slice.call(s));for(var a=o,p=0;p<s.length;p++){var h=s[p],c=e,v=!1;if(v=v===void 0?!1:v,h=Array.isArray(h)?new c(h):v?new c:void 0,h!==void 0){c=h.o;var d=v=A(c);o&&(d|=2),l&&(d|=16),d!=v&&M(c,d),c=d,a=a||!!(2&c),u.push(h)}}return t.h[r]=u,l=A(s),e=l|33,e=a?e&-9:e|8,l!=e&&(a=s,Object.isFrozen(a)&&(a=Array.prototype.slice.call(a)),M(a,e),s=a),f!==s&&ut(t,r,s),(i||n&&o)&&Y(u,2),n&&Object.freeze(u),u}return i||(i=Object.isFrozen(u),n&&!i?Object.freeze(u):!n&&i&&(u=Array.prototype.slice.call(u),t.h[r]=u)),u}function dt(t,e,r){var n=!!(A(t.o)&2);if(e=Re(t,e,r,n,n),t=Ht(t,r,3,n),!(n||A(t)&8)){for(n=0;n<e.length;n++){if(r=e[n],A(r.o)&2){var i=Le(r,!1);i.j=r}else i=r;r!==i&&(e[n]=i,t[n]=i.o)}Y(t,8)}return e}function B(t,e,r){if(r!=null&&typeof r!="number")throw Error("Value of float/double field must be a number|null|undefined, found "+typeof r+": "+r);L(t,e,r)}function Ue(t,e,r,n,i){It(t);var u=Re(t,r,e,!1,!1);return r=n??new r,t=Ht(t,e,2,!1),i!=null?(u.splice(i,0,r),t.splice(i,0,r.o)):(u.push(r),t.push(r.o)),r.C()&&Fe(t,8),r}function yt(t,e){return t??e}function D(t,e,r){return r=r===void 0?0:r,yt(zt(t,e),r)}var mt;function Cr(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"object":if(t)if(Array.isArray(t)){if((A(t)&128)!==0)return t=Array.prototype.slice.call(t),Gt(t),t}else{if(Rt&&t!=null&&t instanceof Uint8Array)return ue(t);if(t instanceof nt){var e=t.V;return e==null?"":typeof e=="string"?e:t.V=ue(e)}}}return t}function Pe(t,e,r,n){if(t!=null){if(Array.isArray(t))t=Wt(t,e,r,n!==void 0);else if(vt(t)){var i={},u;for(u in t)i[u]=Pe(t[u],e,r,n);t=i}else t=e(t,n);return t}}function Wt(t,e,r,n){var i=A(t);n=n?!!(i&16):void 0,t=Array.prototype.slice.call(t);for(var u=0;u<t.length;u++)t[u]=Pe(t[u],e,r,n);return r(i,t),t}function Nr(t){return t.ja===kt?t.toJSON():Cr(t)}function Mr(t,e){t&128&&Gt(e)}function Ce(t,e,r){if(r=r===void 0?pt:r,t!=null){if(Rt&&t instanceof Uint8Array)return t.length?new nt(new Uint8Array(t),rt):Nt();if(Array.isArray(t)){var n=A(t);return n&2?t:e&&!(n&32)&&(n&16||n===0)?(M(t,n|2),t):(t=Wt(t,Ce,n&4?pt:r,!0),e=A(t),e&4&&e&2&&Object.freeze(t),t)}return t.ja===kt?Me(t):t}}function Ne(t,e,r,n,i,u,o){if(t=t.h&&t.h[r]){if(n=A(t),n&2?n=t:(u=jr(t,Me),pt(n,u),Object.freeze(u),n=u),It(e),o=n==null?ot:Dt([]),n!=null){for(u=!!n.length,t=0;t<n.length;t++){var s=n[t];u=u&&!(A(s.o)&2),o[t]=s.o}u=(u?8:0)|1,t=A(o),(t&u)!==u&&(Object.isFrozen(o)&&(o=Array.prototype.slice.call(o)),M(o,t|u)),e.h||(e.h={}),e.h[r]=n}else e.h&&(e.h[r]=void 0);ut(e,r,o,i)}else L(e,r,Ce(n,u,o),i)}function Me(t){return A(t.o)&2||(t=Le(t,!0),Y(t.o,2)),t}function Le(t,e){var r=t.o,n=[];Y(n,16);var i=t.constructor.h;if(i&&n.push(i),i=t.B,i){n.length=r.length,n.fill(void 0,n.length,r.length);var u={};n[n.length-1]=u}(A(r)&128)!==0&&Gt(n),e=e||t.C()?pt:Pr,u=t.constructor,mt=n,n=new u(n),mt=void 0,t.R&&(n.R=t.R.slice()),u=!!(A(r)&16);for(var o=i?r.length-1:r.length,s=0;s<o;s++)Ne(t,n,s-t.G,r[s],!1,u,e);if(i)for(var l in i)Ne(t,n,+l,i[l],!0,u,e);return n}function R(t,e,r){t==null&&(t=mt),mt=void 0;var n=this.constructor.i||0,i=0<n,u=this.constructor.h,o=!1;if(t==null){t=u?[u]:[];var s=48,l=!0;i&&(n=0,s|=128),M(t,s)}else{if(!Array.isArray(t)||u&&u!==t[0])throw Error();var f=s=Y(t,0);if((l=(16&f)!==0)&&((o=(32&f)!==0)||(f|=32)),i){if(128&f)n=0;else if(0<t.length){var a=t[t.length-1];if(vt(a)&&"g"in a){n=0,f|=128,delete a.g;var p=!0,h;for(h in a){p=!1;break}p&&t.pop()}}}else if(128&f)throw Error();s!==f&&M(t,f)}this.G=(u?0:-1)-n,this.h=void 0,this.o=t;t:{if(u=this.o.length,n=u-1,u&&(u=this.o[n],vt(u))){this.B=u,this.i=n-this.G;break t}e!==void 0&&-1<e?(this.i=Math.max(e,n+1-this.G),this.B=void 0):this.i=Number.MAX_VALUE}if(!i&&this.B&&"g"in this.B)throw Error('Unexpected "g" flag in sparse object of message that is not a group type.');if(r){e=l&&!o&&!0,i=this.i;var c;for(l=0;l<r.length;l++)o=r[l],o<i?(o+=this.G,(n=t[o])?Be(n,e):t[o]=ot):(c||(c=Te(this)),(n=c[o])?Be(n,e):c[o]=ot)}}R.prototype.toJSON=function(){return Wt(this.o,Nr,Mr)},R.prototype.C=function(){return!!(A(this.o)&2)};function Be(t,e){if(Array.isArray(t)){var r=A(t),n=1;!e||r&2||(n|=16),(r&n)!==n&&M(t,r|n)}}R.prototype.ja=kt,R.prototype.toString=function(){return this.o.toString()};function De(t,e,r){if(r){var n={},i;for(i in r){var u=r[i],o=u.qa;o||(n.J=u.wa||u.oa.W,u.ia?(n.aa=ze(u.ia),o=(function(s){return function(l,f,a){return s.J(l,f,a,s.aa)}})(n)):u.ka?(n.Z=We(u.da.P,u.ka),o=(function(s){return function(l,f,a){return s.J(l,f,a,s.Z)}})(n)):o=n.J,u.qa=o),o(e,t,u.da),n={J:n.J,aa:n.aa,Z:n.Z}}}Ur(e,t)}var gt=Symbol();function ke(t,e,r){return t[gt]||(t[gt]=function(n,i){return e(n,i,r)})}function Ie(t){var e=t[gt];if(!e){var r=Xt(t);e=function(n,i){return Ve(n,i,r)},t[gt]=e}return e}function Lr(t){var e=t.ia;if(e)return Ie(e);if(e=t.va)return ke(t.da.P,e,t.ka)}function Br(t){var e=Lr(t),r=t.da,n=t.oa.U;return e?function(i,u){return n(i,u,r,e)}:function(i,u){return n(i,u,r)}}function Ge(t,e){var r=t[e];return typeof r=="function"&&r.length===0&&(r=r(),t[e]=r),Array.isArray(r)&&(lt in r||st in r||0<r.length&&typeof r[0]=="function")?r:void 0}function He(t,e,r,n,i,u){e.P=t[0];var o=1;if(t.length>o&&typeof t[o]!="number"){var s=t[o++];r(e,s)}for(;o<t.length;){r=t[o++];for(var l=o+1;l<t.length&&typeof t[l]!="number";)l++;switch(s=t[o++],l-=o,l){case 0:n(e,r,s);break;case 1:(l=Ge(t,o))?(o++,i(e,r,s,l)):n(e,r,s,t[o++]);break;case 2:l=o++,l=Ge(t,l),i(e,r,s,l,t[o++]);break;case 3:u(e,r,s,t[o++],t[o++],t[o++]);break;case 4:u(e,r,s,t[o++],t[o++],t[o++],t[o++]);break;default:throw Error("unexpected number of binary field arguments: "+l)}}return e}var wt=Symbol();function ze(t){var e=t[wt];if(!e){var r=Vt(t);e=function(n,i){return Xe(n,i,r)},t[wt]=e}return e}function We(t,e){var r=t[wt];return r||(r=function(n,i){return De(n,i,e)},t[wt]=r),r}var st=Symbol();function Dr(t,e){t.push(e)}function kr(t,e,r){t.push(e,r.W)}function Ir(t,e,r,n){var i=ze(n),u=Vt(n).P,o=r.W;t.push(e,function(s,l,f){return o(s,l,f,u,i)})}function Gr(t,e,r,n,i,u){var o=We(n,u),s=r.W;t.push(e,function(l,f,a){return s(l,f,a,n,o)})}function Vt(t){var e=t[st];return e||(e=He(t,t[st]=[],Dr,kr,Ir,Gr),lt in t&&st in t&&(t.length=0),e)}var lt=Symbol();function Hr(t,e){t[0]=e}function zr(t,e,r,n){var i=r.U;t[e]=n?function(u,o,s){return i(u,o,s,n)}:i}function Wr(t,e,r,n,i){var u=r.U,o=Ie(n),s=Xt(n).P;t[e]=function(l,f,a){return u(l,f,a,s,o,i)}}function Vr(t,e,r,n,i,u,o){var s=r.U,l=ke(n,i,u);t[e]=function(f,a,p){return s(f,a,p,n,l,o)}}function Xt(t){var e=t[lt];return e||(e=He(t,t[lt]={},Hr,zr,Wr,Vr),lt in t&&st in t&&(t.length=0),e)}function Ve(t,e,r){for(;Oe(e)&&e.i!=4;){var n=e.l,i=r[n];if(!i){var u=r[0];u&&(u=u[n])&&(i=r[n]=Br(u))}if(!i||!i(e,t,n)){i=e,n=t,u=i.j,ct(i);var o=i;if(!o.ca){if(i=o.h.h-u,o.h.h=u,o=o.h,i==0)i=Nt();else{if(u=be(o,i),o.S&&o.m)i=o.i.subarray(u,u+i);else{o=o.i;var s=u;i=u+i,i=s===i?Ut():_r?o.slice(s,i):new Uint8Array(o.subarray(s,i))}i=i.length==0?Nt():new nt(i,rt)}(u=n.R)?u.push(i):n.R=[i]}}}return t}function Xe(t,e,r){for(var n=r.length,i=n%2==1,u=i?1:0;u<n;u+=2)(0,r[u+1])(e,t,r[u]);De(t,e,i?r[0]:void 0)}function ft(t,e){return{U:t,W:e}}var N=ft(function(t,e,r){if(t.i!==5)return!1;t=t.h;var n=t.i,i=t.h,u=n[i],o=n[i+1],s=n[i+2];return n=n[i+3],V(t,t.h+4),o=(u<<0|o<<8|s<<16|n<<24)>>>0,t=2*(o>>31)+1,u=o>>>23&255,o&=8388607,L(e,r,u==255?o?NaN:1/0*t:u==0?t*Math.pow(2,-149)*o:t*Math.pow(2,u-150)*(o+Math.pow(2,23))),!0},function(t,e,r){if(e=zt(e,r),e!=null){X(t.h,8*r+5),t=t.h;var n=+e;n===0?0<1/n?b=S=0:(S=0,b=2147483648):isNaN(n)?(S=0,b=2147483647):(n=(r=0>n?-2147483648:0)?-n:n,34028234663852886e22<n?(S=0,b=(r|2139095040)>>>0):11754943508222875e-54>n?(n=Math.round(n/Math.pow(2,-149)),S=0,b=(r|n)>>>0):(e=Math.floor(Math.log(n)/Math.LN2),n*=Math.pow(2,-e),n=Math.round(8388608*n),16777216<=n&&++e,S=0,b=(r|e+127<<23|n&8388607)>>>0)),r=b,t.h.push(r>>>0&255),t.h.push(r>>>8&255),t.h.push(r>>>16&255),t.h.push(r>>>24&255)}}),Xr=ft(function(t,e,r){if(t.i!==0)return!1;var n=t.h,i=0,u=t=0,o=n.i,s=n.h;do{var l=o[s++];i|=(l&127)<<u,u+=7}while(32>u&&l&128);for(32<u&&(t|=(l&127)>>4),u=3;32>u&&l&128;u+=7)l=o[s++],t|=(l&127)<<u;if(V(n,s),128>l)n=i>>>0,l=t>>>0,(t=l&2147483648)&&(n=~n+1>>>0,l=~l>>>0,n==0&&(l=l+1>>>0)),n=4294967296*l+(n>>>0);else throw Pt();return L(e,r,t?-n:n),!0},function(t,e,r){e=C(e,r),e!=null&&(typeof e=="string"&&pe(e),e!=null&&(X(t.h,8*r),typeof e=="number"?(t=t.h,ae(e),_e(t,b,S)):(r=pe(e),_e(t.h,r.i,r.h))))}),Yr=ft(function(t,e,r){return t.i!==0?!1:(L(e,r,it(t.h)),!0)},function(t,e,r){if(e=C(e,r),e!=null&&e!=null)if(X(t.h,8*r),t=t.h,r=e,0<=r)X(t,r);else{for(e=0;9>e;e++)t.h.push(r&127|128),r>>=7;t.h.push(1)}}),Ye=ft(function(t,e,r){if(t.i!==2)return!1;var n=it(t.h)>>>0;t=t.h;var i=be(t,n);if(t=t.i,Fr){var u=t,o;(o=Ct)||(o=Ct=new TextDecoder("utf-8",{fatal:!0})),t=i+n,u=i===0&&t===u.length?u:u.subarray(i,t);try{var s=o.decode(u)}catch(p){if(at===void 0){try{o.decode(new Uint8Array([128]))}catch{}try{o.decode(new Uint8Array([97])),at=!0}catch{at=!1}}throw!at&&(Ct=void 0),p}}else{s=i,n=s+n,i=[];for(var l=null,f,a;s<n;)f=t[s++],128>f?i.push(f):224>f?s>=n?W():(a=t[s++],194>f||(a&192)!==128?(s--,W()):i.push((f&31)<<6|a&63)):240>f?s>=n-1?W():(a=t[s++],(a&192)!==128||f===224&&160>a||f===237&&160<=a||((u=t[s++])&192)!==128?(s--,W()):i.push((f&15)<<12|(a&63)<<6|u&63)):244>=f?s>=n-2?W():(a=t[s++],(a&192)!==128||(f<<28)+(a-144)>>30!==0||((u=t[s++])&192)!==128||((o=t[s++])&192)!==128?(s--,W()):(f=(f&7)<<18|(a&63)<<12|(u&63)<<6|o&63,f-=65536,i.push((f>>10&1023)+55296,(f&1023)+56320))):W(),8192<=i.length&&(l=me(l,i),i.length=0);s=me(l,i)}return L(e,r,s),!0},function(t,e,r){if(e=C(e,r),e!=null){var n=!1;if(n=n===void 0?!1:n,Sr){if(n&&/(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(e))throw Error("Found an unpaired surrogate");e=(ge||(ge=new TextEncoder)).encode(e)}else{for(var i=0,u=new Uint8Array(3*e.length),o=0;o<e.length;o++){var s=e.charCodeAt(o);if(128>s)u[i++]=s;else{if(2048>s)u[i++]=s>>6|192;else{if(55296<=s&&57343>=s){if(56319>=s&&o<e.length){var l=e.charCodeAt(++o);if(56320<=l&&57343>=l){s=1024*(s-55296)+l-56320+65536,u[i++]=s>>18|240,u[i++]=s>>12&63|128,u[i++]=s>>6&63|128,u[i++]=s&63|128;continue}else o--}if(n)throw Error("Found an unpaired surrogate");s=65533}u[i++]=s>>12|224,u[i++]=s>>6&63|128}u[i++]=s&63|128}}e=i===u.length?u:u.subarray(0,i)}X(t.h,8*r+2),X(t.h,e.length),K(t,t.h.end()),K(t,e)}}),Ke=ft(function(t,e,r,n,i){if(t.i!==2)return!1;e=Ue(e,r,n),r=t.h.j,n=it(t.h)>>>0;var u=t.h.h+n,o=u-r;if(0>=o&&(t.h.j=u,i(e,t,void 0,void 0,void 0),o=u-t.h.h),o)throw Error("Message parsing ended unexpectedly. Expected to read "+(n+" bytes, instead read "+(n-o)+" bytes, either the data ended unexpectedly or the message misreported its own length"));return t.h.h=u,t.h.j=r,!0},function(t,e,r,n,i){if(e=dt(e,n,r),e!=null)for(n=0;n<e.length;n++){var u=t;X(u.h,8*r+2);var o=u.h.end();K(u,o),o.push(u.i),u=o,i(e[n],t),o=t;var s=u.pop();for(s=o.i+o.h.length()-s;127<s;)u.push(s&127|128),s>>>=7,o.i++;u.push(s),o.i++}});function Yt(t){return function(e,r){t:{if(ht.length){var n=ht.pop();n.setOptions(r),Mt(n.h,e,r),e=n}else e=new Bt(e,r);try{var i=Xt(t),u=Ve(new i.P,e,i);break t}finally{i=e.h,i.i=null,i.m=!1,i.l=0,i.j=0,i.h=0,i.S=!1,e.l=-1,e.i=-1,100>ht.length&&ht.push(e)}u=void 0}return u}}function Kt(t){return function(){var e=new Rr;Xe(this,e,Vt(t)),K(e,e.h.end());for(var r=new Uint8Array(e.i),n=e.j,i=n.length,u=0,o=0;o<i;o++){var s=n[o];r.set(s,u),u+=s.length}return e.j=[r],r}}function Z(t){R.call(this,t)}J(Z,R);var Ze=[Z,1,Yr,2,N,3,Ye,4,Ye];Z.prototype.l=Kt(Ze);function Zt(t){R.call(this,t,-1,Kr)}J(Zt,R),Zt.prototype.addClassification=function(t,e){return Ue(this,1,Z,t,e),this};var Kr=[1],$e=Yt([Zt,1,Ke,Ze]);function $(t){R.call(this,t)}J($,R);var Qe=[$,1,N,2,N,3,N,4,N,5,N];$.prototype.l=Kt(Qe);function Je(t){R.call(this,t,-1,Zr)}J(Je,R);var Zr=[1],qe=Yt([Je,1,Ke,Qe]);function At(t){R.call(this,t)}J(At,R);var tr=[At,1,N,2,N,3,N,4,N,5,N,6,Xr],$r=Yt(tr);At.prototype.l=Kt(tr);function er(t,e,r){if(r=t.createShader(r===0?t.VERTEX_SHADER:t.FRAGMENT_SHADER),t.shaderSource(r,e),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw Error(`Could not compile WebGL shader.
2
+
3
+ `+t.getShaderInfoLog(r));return r}function rr(t){return dt(t,Z,1).map(function(e){var r=C(e,1);return{index:r??0,score:D(e,2),label:C(e,3)!=null?yt(C(e,3),""):void 0,displayName:C(e,4)!=null?yt(C(e,4),""):void 0}})}function nr(t){return{x:D(t,1),y:D(t,2),z:D(t,3),visibility:zt(t,4)!=null?D(t,4):void 0}}function ir(t){return t.map(function(e){return dt(qe(e),$,1).map(nr)})}function $t(t,e){this.i=t,this.h=e,this.m=0}function or(t,e,r){return Qr(t,e),typeof t.h.canvas.transferToImageBitmap=="function"?Promise.resolve(t.h.canvas.transferToImageBitmap()):r?Promise.resolve(t.h.canvas):typeof createImageBitmap=="function"?createImageBitmap(t.h.canvas):(t.j===void 0&&(t.j=document.createElement("canvas")),new Promise(function(n){t.j.height=t.h.canvas.height,t.j.width=t.h.canvas.width,t.j.getContext("2d",{}).drawImage(t.h.canvas,0,0,t.h.canvas.width,t.h.canvas.height),n(t.j)}))}function Qr(t,e){var r=t.h;if(t.s===void 0){var n=er(r,`
4
+ attribute vec2 aVertex;
5
+ attribute vec2 aTex;
6
+ varying vec2 vTex;
7
+ void main(void) {
8
+ gl_Position = vec4(aVertex, 0.0, 1.0);
9
+ vTex = aTex;
10
+ }`,0),i=er(r,`
11
+ precision mediump float;
12
+ varying vec2 vTex;
13
+ uniform sampler2D sampler0;
14
+ void main(){
15
+ gl_FragColor = texture2D(sampler0, vTex);
16
+ }`,1),u=r.createProgram();if(r.attachShader(u,n),r.attachShader(u,i),r.linkProgram(u),!r.getProgramParameter(u,r.LINK_STATUS))throw Error(`Could not compile WebGL program.
17
+
18
+ `+r.getProgramInfoLog(u));n=t.s=u,r.useProgram(n),i=r.getUniformLocation(n,"sampler0"),t.l={O:r.getAttribLocation(n,"aVertex"),N:r.getAttribLocation(n,"aTex"),xa:i},t.v=r.createBuffer(),r.bindBuffer(r.ARRAY_BUFFER,t.v),r.enableVertexAttribArray(t.l.O),r.vertexAttribPointer(t.l.O,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),t.u=r.createBuffer(),r.bindBuffer(r.ARRAY_BUFFER,t.u),r.enableVertexAttribArray(t.l.N),r.vertexAttribPointer(t.l.N,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),r.uniform1i(i,0)}n=t.l,r.useProgram(t.s),r.canvas.width=e.width,r.canvas.height=e.height,r.viewport(0,0,e.width,e.height),r.activeTexture(r.TEXTURE0),t.i.bindTexture2d(e.glName),r.enableVertexAttribArray(n.O),r.bindBuffer(r.ARRAY_BUFFER,t.v),r.vertexAttribPointer(n.O,2,r.FLOAT,!1,0,0),r.enableVertexAttribArray(n.N),r.bindBuffer(r.ARRAY_BUFFER,t.u),r.vertexAttribPointer(n.N,2,r.FLOAT,!1,0,0),r.bindFramebuffer(r.DRAW_FRAMEBUFFER?r.DRAW_FRAMEBUFFER:r.FRAMEBUFFER,null),r.clearColor(0,0,0,0),r.clear(r.COLOR_BUFFER_BIT),r.colorMask(!0,!0,!0,!0),r.drawArrays(r.TRIANGLE_FAN,0,4),r.disableVertexAttribArray(n.O),r.disableVertexAttribArray(n.N),r.bindBuffer(r.ARRAY_BUFFER,null),t.i.bindTexture2d(0)}function Jr(t){this.h=t}var qr=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]);function tn(t,e){return e+t}function ur(t,e){window[t]=e}function en(t){var e=document.createElement("script");return e.setAttribute("src",t),e.setAttribute("crossorigin","anonymous"),new Promise(function(r){e.addEventListener("load",function(){r()},!1),e.addEventListener("error",function(){r()},!1),document.body.appendChild(e)})}function rn(){return O(function(t){switch(t.h){case 1:return t.s=2,x(t,WebAssembly.instantiate(qr),4);case 4:t.h=3,t.s=0;break;case 2:return t.s=0,t.l=null,t.return(!1);case 3:return t.return(!0)}})}function Qt(t){if(this.h=t,this.listeners={},this.l={},this.L={},this.s={},this.v={},this.M=this.u=this.ga=!0,this.I=Promise.resolve(),this.fa="",this.D={},this.locateFile=t&&t.locateFile||tn,typeof window=="object")var e=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else if(typeof location<"u")e=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/";else throw Error("solutions can only be loaded on a web page or in a web worker");if(this.ha=e,t.options){e=F(Object.keys(t.options));for(var r=e.next();!r.done;r=e.next()){r=r.value;var n=t.options[r].default;n!==void 0&&(this.l[r]=typeof n=="function"?n():n)}}}j=Qt.prototype,j.close=function(){return this.j&&this.j.delete(),Promise.resolve()};function nn(t){var e,r,n,i,u,o,s,l,f,a,p;return O(function(h){switch(h.h){case 1:return t.ga?(e=t.h.files===void 0?[]:typeof t.h.files=="function"?t.h.files(t.l):t.h.files,x(h,rn(),2)):h.return();case 2:if(r=h.i,typeof window=="object")return ur("createMediapipeSolutionsWasm",{locateFile:t.locateFile}),ur("createMediapipeSolutionsPackedAssets",{locateFile:t.locateFile}),o=e.filter(function(c){return c.data!==void 0}),s=e.filter(function(c){return c.data===void 0}),l=Promise.all(o.map(function(c){var v=jt(t,c.url);if(c.path!==void 0){var d=c.path;v=v.then(function(g){return t.overrideFile(d,g),Promise.resolve(g)})}return v})),f=Promise.all(s.map(function(c){return c.simd===void 0||c.simd&&r||!c.simd&&!r?en(t.locateFile(c.url,t.ha)):Promise.resolve()})).then(function(){var c,v,d;return O(function(g){if(g.h==1)return c=window.createMediapipeSolutionsWasm,v=window.createMediapipeSolutionsPackedAssets,d=t,x(g,c(v),2);d.i=g.i,g.h=0})}),a=(function(){return O(function(c){return t.h.graph&&t.h.graph.url?c=x(c,jt(t,t.h.graph.url),0):(c.h=0,c=void 0),c})})(),x(h,Promise.all([f,l,a]),7);if(typeof importScripts!="function")throw Error("solutions can only be loaded on a web page or in a web worker");return n=e.filter(function(c){return c.simd===void 0||c.simd&&r||!c.simd&&!r}).map(function(c){return t.locateFile(c.url,t.ha)}),importScripts.apply(null,qt(n)),i=t,x(h,createMediapipeSolutionsWasm(Module),6);case 6:i.i=h.i,t.m=new OffscreenCanvas(1,1),t.i.canvas=t.m,u=t.i.GL.createContext(t.m,{antialias:!1,alpha:!1,ua:typeof WebGL2RenderingContext<"u"?2:1}),t.i.GL.makeContextCurrent(u),h.h=4;break;case 7:if(t.m=document.createElement("canvas"),p=t.m.getContext("webgl2",{}),!p&&(p=t.m.getContext("webgl",{}),!p))return alert("Failed to create WebGL canvas context when passing video frame."),h.return();t.K=p,t.i.canvas=t.m,t.i.createContext(t.m,!0,!0,{});case 4:t.j=new t.i.SolutionWasm,t.ga=!1,h.h=0}})}function on(t){var e,r,n,i,u,o,s,l;return O(function(f){if(f.h==1){if(t.h.graph&&t.h.graph.url&&t.fa===t.h.graph.url)return f.return();if(t.u=!0,!t.h.graph||!t.h.graph.url){f.h=2;return}return t.fa=t.h.graph.url,x(f,jt(t,t.h.graph.url),3)}for(f.h!=2&&(e=f.i,t.j.loadGraph(e)),r=F(Object.keys(t.D)),n=r.next();!n.done;n=r.next())i=n.value,t.j.overrideFile(i,t.D[i]);if(t.D={},t.h.listeners)for(u=F(t.h.listeners),o=u.next();!o.done;o=u.next())s=o.value,fn(t,s);l=t.l,t.l={},t.setOptions(l),f.h=0})}j.reset=function(){var t=this;return O(function(e){t.j&&(t.j.reset(),t.s={},t.v={}),e.h=0})},j.setOptions=function(t,e){var r=this;if(e=e||this.h.options){for(var n=[],i=[],u={},o=F(Object.keys(t)),s=o.next();!s.done;u={X:u.X,Y:u.Y},s=o.next())if(s=s.value,!(s in this.l&&this.l[s]===t[s])){this.l[s]=t[s];var l=e[s];l!==void 0&&(l.onChange&&(u.X=l.onChange,u.Y=t[s],n.push((function(f){return function(){var a;return O(function(p){if(p.h==1)return x(p,f.X(f.Y),2);a=p.i,a===!0&&(r.u=!0),p.h=0})}})(u))),l.graphOptionXref&&(s=Object.assign({},{calculatorName:"",calculatorIndex:0},l.graphOptionXref,{valueNumber:l.type===1?t[s]:0,valueBoolean:l.type===0?t[s]:!1,valueString:l.type===2?t[s]:""}),i.push(s)))}(n.length!==0||i.length!==0)&&(this.u=!0,this.H=(this.H===void 0?[]:this.H).concat(i),this.F=(this.F===void 0?[]:this.F).concat(n))}};function un(t){var e,r,n,i,u,o,s;return O(function(l){switch(l.h){case 1:if(!t.u)return l.return();if(!t.F){l.h=2;break}e=F(t.F),r=e.next();case 3:if(r.done){l.h=5;break}return n=r.value,x(l,n(),4);case 4:r=e.next(),l.h=3;break;case 5:t.F=void 0;case 2:if(t.H){for(i=new t.i.GraphOptionChangeRequestList,u=F(t.H),o=u.next();!o.done;o=u.next())s=o.value,i.push_back(s);t.j.changeOptions(i),i.delete(),t.H=void 0}t.u=!1,l.h=0}})}j.initialize=function(){var t=this;return O(function(e){return e.h==1?x(e,nn(t),2):e.h!=3?x(e,on(t),3):x(e,un(t),0)})};function jt(t,e){var r,n;return O(function(i){return e in t.L?i.return(t.L[e]):(r=t.locateFile(e,""),n=fetch(r).then(function(u){return u.arrayBuffer()}),t.L[e]=n,i.return(n))})}j.overrideFile=function(t,e){this.j?this.j.overrideFile(t,e):this.D[t]=e},j.clearOverriddenFiles=function(){this.D={},this.j&&this.j.clearOverriddenFiles()},j.send=function(t,e){var r=this,n,i,u,o,s,l,f,a,p;return O(function(h){switch(h.h){case 1:return r.h.inputs?(n=1e3*(e??performance.now()),x(h,r.I,2)):h.return();case 2:return x(h,r.initialize(),3);case 3:for(i=new r.i.PacketDataList,u=F(Object.keys(t)),o=u.next();!o.done;o=u.next())if(s=o.value,l=r.h.inputs[s]){t:{var c=t[s];switch(l.type){case"video":var v=r.s[l.stream];if(v||(v=new $t(r.i,r.K),r.s[l.stream]=v),v.m===0&&(v.m=v.i.createTexture()),typeof HTMLVideoElement<"u"&&c instanceof HTMLVideoElement)var d=c.videoWidth,g=c.videoHeight;else typeof HTMLImageElement<"u"&&c instanceof HTMLImageElement?(d=c.naturalWidth,g=c.naturalHeight):(d=c.width,g=c.height);g={glName:v.m,width:d,height:g},d=v.h,d.canvas.width=g.width,d.canvas.height=g.height,d.activeTexture(d.TEXTURE0),v.i.bindTexture2d(v.m),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,c),v.i.bindTexture2d(0),v=g;break t;case"detections":for(v=r.s[l.stream],v||(v=new Jr(r.i),r.s[l.stream]=v),v.data||(v.data=new v.h.DetectionListData),v.data.reset(c.length),g=0;g<c.length;++g){d=c[g];var m=v.data,E=m.setBoundingBox,P=g,U=d.la,y=new At;if(B(y,1,U.ra),B(y,2,U.sa),B(y,3,U.height),B(y,4,U.width),B(y,5,U.rotation),L(y,6,U.pa),U=y.l(),E.call(m,P,U),d.ea)for(m=0;m<d.ea.length;++m){y=d.ea[m],E=v.data,P=E.addNormalizedLandmark,U=g,y=Object.assign({},y,{visibility:y.visibility?y.visibility:0});var _=new $;B(_,1,y.x),B(_,2,y.y),B(_,3,y.z),y.visibility&&B(_,4,y.visibility),y=_.l(),P.call(E,U,y)}if(d.ba)for(m=0;m<d.ba.length;++m)E=v.data,P=E.addClassification,U=g,y=d.ba[m],_=new Z,B(_,2,y.score),y.index&&L(_,1,y.index),y.label&&L(_,3,y.label),y.displayName&&L(_,4,y.displayName),y=_.l(),P.call(E,U,y)}v=v.data;break t;default:v={}}}switch(f=v,a=l.stream,l.type){case"video":i.pushTexture2d(Object.assign({},f,{stream:a,timestamp:n}));break;case"detections":p=f,p.stream=a,p.timestamp=n,i.pushDetectionList(p);break;default:throw Error("Unknown input config type: '"+l.type+"'")}}return r.j.send(i),x(h,r.I,4);case 4:i.delete(),h.h=0}})};function sn(t,e,r){var n,i,u,o,s,l,f,a,p,h,c,v,d,g;return O(function(m){switch(m.h){case 1:if(!r)return m.return(e);for(n={},i=0,u=F(Object.keys(r)),o=u.next();!o.done;o=u.next())s=o.value,l=r[s],typeof l!="string"&&l.type==="texture"&&e[l.stream]!==void 0&&++i;1<i&&(t.M=!1),f=F(Object.keys(r)),o=f.next();case 2:if(o.done){m.h=4;break}if(a=o.value,p=r[a],typeof p=="string")return d=n,g=a,x(m,ln(t,a,e[p]),14);if(h=e[p.stream],p.type==="detection_list"){if(h){for(var E=h.getRectList(),P=h.getLandmarksList(),U=h.getClassificationsList(),y=[],_=0;_<E.size();++_){var G=$r(E.get(_)),an=D(G,1),cn=D(G,2),hn=D(G,3),pn=D(G,4),vn=D(G,5,0),xt=void 0;xt=xt===void 0?0:xt,G={la:{ra:an,sa:cn,height:hn,width:pn,rotation:vn,pa:yt(C(G,6),xt)},ea:dt(qe(P.get(_)),$,1).map(nr),ba:rr($e(U.get(_)))},y.push(G)}E=y}else E=[];n[a]=E,m.h=7;break}if(p.type==="proto_list"){if(h){for(E=Array(h.size()),P=0;P<h.size();P++)E[P]=h.get(P);h.delete()}else E=[];n[a]=E,m.h=7;break}if(h===void 0){m.h=3;break}if(p.type==="float_list"){n[a]=h,m.h=7;break}if(p.type==="proto"){n[a]=h,m.h=7;break}if(p.type!=="texture")throw Error("Unknown output config type: '"+p.type+"'");return c=t.v[a],c||(c=new $t(t.i,t.K),t.v[a]=c),x(m,or(c,h,t.M),13);case 13:v=m.i,n[a]=v;case 7:p.transform&&n[a]&&(n[a]=p.transform(n[a])),m.h=3;break;case 14:d[g]=m.i;case 3:o=f.next(),m.h=2;break;case 4:return m.return(n)}})}function ln(t,e,r){var n;return O(function(i){return typeof r=="number"||r instanceof Uint8Array||r instanceof t.i.Uint8BlobList?i.return(r):r instanceof t.i.Texture2dDataOut?(n=t.v[e],n||(n=new $t(t.i,t.K),t.v[e]=n),i.return(or(n,r,t.M))):i.return(void 0)})}function fn(t,e){for(var r=e.name||"$",n=[].concat(qt(e.wants)),i=new t.i.StringList,u=F(e.wants),o=u.next();!o.done;o=u.next())i.push_back(o.value);u=t.i.PacketListener.implement({onResults:function(s){for(var l={},f=0;f<e.wants.length;++f)l[n[f]]=s.get(f);var a=t.listeners[r];a&&(t.I=sn(t,l,e.outs).then(function(p){p=a(p);for(var h=0;h<e.wants.length;++h){var c=l[n[h]];typeof c=="object"&&c.hasOwnProperty&&c.hasOwnProperty("delete")&&c.delete()}p&&(t.I=p)}))}}),t.j.attachMultiListener(i,u),i.delete()}j.onResults=function(t,e){this.listeners[e||"$"]=t},tt("Solution",Qt),tt("OptionType",{BOOL:0,NUMBER:1,ta:2,0:"BOOL",1:"NUMBER",2:"STRING"});function sr(t){return t===void 0&&(t=0),t===1?"hand_landmark_full.tflite":"hand_landmark_lite.tflite"}function lr(t){var e=this;t=t||{},this.h=new Qt({locateFile:t.locateFile,files:function(r){return[{url:"hands_solution_packed_assets_loader.js"},{simd:!1,url:"hands_solution_wasm_bin.js"},{simd:!0,url:"hands_solution_simd_wasm_bin.js"},{data:!0,url:sr(r.modelComplexity)}]},graph:{url:"hands.binarypb"},inputs:{image:{type:"video",stream:"input_frames_gpu"}},listeners:[{wants:["multi_hand_landmarks","multi_hand_world_landmarks","image_transformed","multi_handedness"],outs:{image:"image_transformed",multiHandLandmarks:{type:"proto_list",stream:"multi_hand_landmarks",transform:ir},multiHandWorldLandmarks:{type:"proto_list",stream:"multi_hand_world_landmarks",transform:ir},multiHandedness:{type:"proto_list",stream:"multi_handedness",transform:function(r){return r.map(function(n){return rr($e(n))[0]})}}}}],options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:typeof window!="object"||window.navigator===void 0?!1:"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document},selfieMode:{type:0,graphOptionXref:{calculatorType:"GlScalerCalculator",calculatorIndex:1,fieldName:"flip_horizontal"}},maxNumHands:{type:1,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculator",fieldName:"int_value"}},modelComplexity:{type:1,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorModelComplexity",fieldName:"int_value"},onChange:function(r){var n,i,u;return O(function(o){return o.h==1?(n=sr(r),i="third_party/mediapipe/modules/hand_landmark/"+n,x(o,jt(e.h,n),2)):(u=o.i,e.h.overrideFile(i,u),o.return(!0))})}},minDetectionConfidence:{type:1,graphOptionXref:{calculatorType:"TensorsToDetectionsCalculator",calculatorName:"handlandmarktrackinggpu__palmdetectiongpu__TensorsToDetectionsCalculator",fieldName:"min_score_thresh"}},minTrackingConfidence:{type:1,graphOptionXref:{calculatorType:"ThresholdingCalculator",calculatorName:"handlandmarktrackinggpu__handlandmarkgpu__ThresholdingCalculator",fieldName:"threshold"}}}})}j=lr.prototype,j.close=function(){return this.h.close(),Promise.resolve()},j.onResults=function(t){this.h.onResults(t)},j.initialize=function(){var t=this;return O(function(e){return x(e,t.h.initialize(),0)})},j.reset=function(){this.h.reset()},j.send=function(t){var e=this;return O(function(r){return x(r,e.h.send(t),0)})},j.setOptions=function(t){this.h.setOptions(t)},tt("Hands",lr),tt("HAND_CONNECTIONS",[[0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]]),tt("VERSION","0.4.1675469240")}).call(Jt)),Jt}var cr=mn();const gn=dn(cr),An=yn({__proto__:null,default:gn},[cr]);export{An as h};