@celljs/ta-meeting 0.0.0-stage → 4.34.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/web/index.js ADDED
@@ -0,0 +1,1219 @@
1
+ // ../ta-protocol/esm/common/language.js
2
+ var TaLanguageUtil;
3
+ (function(TaLanguageUtil2) {
4
+ TaLanguageUtil2.ALL = ["zh-CN", "zh-TW", "en-US", "ja-JP"];
5
+ TaLanguageUtil2.NAMES = { "zh-CN": "简体中文", "zh-TW": "繁體中文", "en-US": "English", "ja-JP": "日本語" };
6
+ function of(tag) {
7
+ const said = (tag !== null && tag !== undefined ? tag : "").toLowerCase().replace(/_/g, "-");
8
+ if (/^zh(\b|-)/.test(said)) {
9
+ return /-hant\b/.test(said) || !/-hans\b/.test(said) && /-(tw|hk|mo)\b/.test(said) ? "zh-TW" : "zh-CN";
10
+ }
11
+ return /^ja(\b|-)/.test(said) ? "ja-JP" : "en-US";
12
+ }
13
+ TaLanguageUtil2.of = of;
14
+ function server(env = typeof process === "undefined" ? {} : process.env) {
15
+ return of(env.TA_LANGUAGE || env.LC_ALL || env.LC_MESSAGES || env.LANG);
16
+ }
17
+ TaLanguageUtil2.server = server;
18
+ function pick(language, words) {
19
+ return words[of(language)];
20
+ }
21
+ TaLanguageUtil2.pick = pick;
22
+ function say(words) {
23
+ return words[server()];
24
+ }
25
+ TaLanguageUtil2.say = say;
26
+ function chinese(language) {
27
+ return of(language).startsWith("zh");
28
+ }
29
+ TaLanguageUtil2.chinese = chinese;
30
+ function cjk(language) {
31
+ return of(language) !== "en-US";
32
+ }
33
+ TaLanguageUtil2.cjk = cjk;
34
+ function list(language, items) {
35
+ return items.join(cjk(language) ? "、" : ", ");
36
+ }
37
+ TaLanguageUtil2.list = list;
38
+ })(TaLanguageUtil || (TaLanguageUtil = {}));
39
+
40
+ // web-src/i18n.ts
41
+ var EN = {
42
+ title: "Meetings",
43
+ start: "Start",
44
+ startTitle: "Write down a meeting",
45
+ startHint: "Ta listens and writes; at the end you get the minutes, the key points and the to-dos.",
46
+ consent: "Only the text is kept, never the audio. Tell everyone first.",
47
+ starting: "Starting…",
48
+ recording: "Recording",
49
+ paused: "Paused",
50
+ viaService: "Heard by the service of Settings → Voice",
51
+ viaDevice: "Heard by this device",
52
+ listening: "Listening… what is said shows here",
53
+ pause: "Pause",
54
+ resume: "Resume",
55
+ finish: "End and sum up",
56
+ discard: "Discard",
57
+ discardAsk: "Discard this meeting? What was written down is removed.",
58
+ saving: "Saving…",
59
+ past: "Earlier meetings",
60
+ empty: "No meetings yet",
61
+ minutes: "Minutes",
62
+ sumUp: "Sum up",
63
+ remove: "Remove",
64
+ removeAsk: "Remove the text of this meeting? The conversation of its minutes stays.",
65
+ meetingAt: "Meeting {time}",
66
+ duration: "{n} min",
67
+ chars: "{n} chars",
68
+ cannotListen: "This device cannot listen. Add a voice service in Settings → Voice, or use the Ta app.",
69
+ stopped: "Listening stopped ({error}); what was written down is kept. Resume or end it.",
70
+ denied: "The microphone or speech recognition is not allowed; what was written down is kept. Allow it, then resume.",
71
+ failed: "Failed: {error}",
72
+ prompt: "Sum up this meeting: the minutes, the key points and the to-dos, and let me pick what you can do.",
73
+ homeRecording: "Recording a meeting",
74
+ homeSince: "Since {time}",
75
+ keepDays: "Keep meeting text",
76
+ keepDaysHint: "Older text is removed by itself; the conversations of the minutes stay.",
77
+ keepDaysValue: "{n} days",
78
+ maxMB: "Space for meeting text",
79
+ maxMBHint: "Beyond it, the oldest text goes first.",
80
+ maxMBValue: "{n} MB"
81
+ };
82
+ var ZH = {
83
+ title: "会议",
84
+ start: "开始",
85
+ startTitle: "记录一场会议",
86
+ startHint: "Ta 边听边记,结束后给你纪要、重点和待办。",
87
+ consent: "只留文字,不留录音。开始前请告诉参会的人。",
88
+ starting: "正在开始…",
89
+ recording: "记录中",
90
+ paused: "已暂停",
91
+ viaService: "用 设置 → 语音 里的服务转写",
92
+ viaDevice: "用本机的听写",
93
+ listening: "正在听…说的话会出现在这里",
94
+ pause: "暂停",
95
+ resume: "继续",
96
+ finish: "结束并整理",
97
+ discard: "放弃",
98
+ discardAsk: "放弃这场会议?已记下的文字会删除。",
99
+ saving: "正在保存…",
100
+ past: "记录过的会议",
101
+ empty: "还没有会议记录",
102
+ minutes: "纪要",
103
+ sumUp: "整理",
104
+ remove: "删除",
105
+ removeAsk: "删除这场会议的文字?整理纪要的对话会保留。",
106
+ meetingAt: "会议 {time}",
107
+ duration: "{n} 分钟",
108
+ chars: "{n} 字",
109
+ cannotListen: "这台设备不能听写。在 设置 → 语音 添加一个语音服务,或用 Ta App。",
110
+ stopped: "听写停了({error}),已记下的文字都在。可以继续或结束。",
111
+ denied: "麦克风或语音识别没有允许,已记下的文字都在。允许后点继续。",
112
+ failed: "出错了:{error}",
113
+ prompt: "整理这场会议:纪要、重点和待办,能替我做的列出来让我选。",
114
+ homeRecording: "会议记录中",
115
+ homeSince: "{time} 开始",
116
+ keepDays: "会议文字保留",
117
+ keepDaysHint: "超过天数的文字自动删除,整理纪要的对话保留。",
118
+ keepDaysValue: "{n} 天",
119
+ maxMB: "会议文字最多占用",
120
+ maxMBHint: "超过后先删最早的。",
121
+ maxMBValue: "{n} MB"
122
+ };
123
+ var ZH_TW = {
124
+ title: "會議",
125
+ start: "開始",
126
+ startTitle: "記錄一場會議",
127
+ startHint: "Ta 邊聽邊記,結束後給你紀要、重點和待辦。",
128
+ consent: "只留文字,不留錄音。開始前請告訴與會的人。",
129
+ starting: "正在開始…",
130
+ recording: "記錄中",
131
+ paused: "已暫停",
132
+ viaService: "用 設定 → 語音 裡的服務轉寫",
133
+ viaDevice: "用本機的聽寫",
134
+ listening: "正在聽…說的話會出現在這裡",
135
+ pause: "暫停",
136
+ resume: "繼續",
137
+ finish: "結束並整理",
138
+ discard: "放棄",
139
+ discardAsk: "放棄這場會議?已記下的文字會刪除。",
140
+ saving: "正在儲存…",
141
+ past: "記錄過的會議",
142
+ empty: "還沒有會議記錄",
143
+ minutes: "紀要",
144
+ sumUp: "整理",
145
+ remove: "刪除",
146
+ removeAsk: "刪除這場會議的文字?整理紀要的對話會保留。",
147
+ meetingAt: "會議 {time}",
148
+ duration: "{n} 分鐘",
149
+ chars: "{n} 字",
150
+ cannotListen: "這台裝置不能聽寫。在 設定 → 語音 新增一個語音服務,或用 Ta App。",
151
+ stopped: "聽寫停了({error}),已記下的文字都在。可以繼續或結束。",
152
+ denied: "麥克風或語音辨識沒有允許,已記下的文字都在。允許後點繼續。",
153
+ failed: "出錯了:{error}",
154
+ prompt: "整理這場會議:紀要、重點和待辦,能替我做的列出來讓我選。",
155
+ homeRecording: "會議記錄中",
156
+ homeSince: "{time} 開始",
157
+ keepDays: "會議文字保留",
158
+ keepDaysHint: "超過天數的文字自動刪除,整理紀要的對話保留。",
159
+ keepDaysValue: "{n} 天",
160
+ maxMB: "會議文字最多佔用",
161
+ maxMBHint: "超過後先刪最早的。",
162
+ maxMBValue: "{n} MB"
163
+ };
164
+ var JA = {
165
+ title: "会議",
166
+ start: "開始",
167
+ startTitle: "会議を記録",
168
+ startHint: "Ta が聞きながら書き取り、終わったら議事録・要点・ToDo をまとめます。",
169
+ consent: "残すのは文字だけで、録音は残しません。始める前に参加者に伝えてください。",
170
+ starting: "開始中…",
171
+ recording: "記録中",
172
+ paused: "一時停止中",
173
+ viaService: "設定 → 音声 のサービスで書き取り",
174
+ viaDevice: "この端末の音声入力で書き取り",
175
+ listening: "聞いています…話した内容がここに出ます",
176
+ pause: "一時停止",
177
+ resume: "再開",
178
+ finish: "終了してまとめる",
179
+ discard: "破棄",
180
+ discardAsk: "この会議を破棄しますか?書き取った文字は削除されます。",
181
+ saving: "保存中…",
182
+ past: "これまでの会議",
183
+ empty: "まだ会議の記録はありません",
184
+ minutes: "議事録",
185
+ sumUp: "まとめる",
186
+ remove: "削除",
187
+ removeAsk: "この会議の文字を削除しますか?議事録の会話は残ります。",
188
+ meetingAt: "会議 {time}",
189
+ duration: "{n} 分",
190
+ chars: "{n} 文字",
191
+ cannotListen: "この端末は音声入力できません。設定 → 音声 でサービスを追加するか、Ta アプリを使ってください。",
192
+ stopped: "書き取りが止まりました({error})。書き取った文字は残っています。再開か終了を選んでください。",
193
+ denied: "マイクまたは音声認識が許可されていません。書き取った文字は残っています。許可してから再開してください。",
194
+ failed: "失敗しました:{error}",
195
+ prompt: "この会議をまとめて:議事録・要点・ToDo。あなたができるものは選べるようにして。",
196
+ homeRecording: "会議を記録中",
197
+ homeSince: "{time} から",
198
+ keepDays: "会議の文字の保存期間",
199
+ keepDaysHint: "過ぎた文字は自動で削除されます。議事録の会話は残ります。",
200
+ keepDaysValue: "{n} 日",
201
+ maxMB: "会議の文字の上限",
202
+ maxMBHint: "超えたら古いものから削除します。",
203
+ maxMBValue: "{n} MB"
204
+ };
205
+ var WORDS = { "zh-CN": ZH, "zh-TW": ZH_TW, "en-US": EN, "ja-JP": JA };
206
+ var MeetingWords;
207
+ ((MeetingWords) => {
208
+ function of(language) {
209
+ return TaLanguageUtil.pick(language, WORDS);
210
+ }
211
+ MeetingWords.of = of;
212
+ function format(text, values) {
213
+ return text.replace(/\{(\w+)\}/g, (all, key) => (key in values) ? String(values[key]) : all);
214
+ }
215
+ MeetingWords.format = format;
216
+ })(MeetingWords ||= {});
217
+
218
+ // web-src/meeting-protocol.ts
219
+ var NAME = "@celljs/ta-meeting";
220
+ var PAGE = `${NAME}/home`;
221
+ var Keys;
222
+ ((Keys) => {
223
+ Keys.MEETINGS = "meetings";
224
+ Keys.SETTINGS = "settings";
225
+ })(Keys ||= {});
226
+ var DEFAULT_SETTINGS = { keepDays: 90, maxMB: 50 };
227
+ var KEEP_DAYS = [30, 90, 180, 365];
228
+ var MAX_MB = [10, 50, 200];
229
+
230
+ // web-src/meeting-util.ts
231
+ var DAY = 86400000;
232
+ var MB = 1024 * 1024;
233
+ var ID = /^m[a-z0-9]{4,40}$/;
234
+ var MeetingUtil;
235
+ ((MeetingUtil) => {
236
+ function validId(id) {
237
+ return typeof id === "string" && ID.test(id);
238
+ }
239
+ MeetingUtil.validId = validId;
240
+ function newId(now) {
241
+ return `m${now.toString(36)}${Math.random().toString(36).slice(2, 8)}`;
242
+ }
243
+ MeetingUtil.newId = newId;
244
+ function settings(raw) {
245
+ const value = raw ?? {};
246
+ const number = (n, min, max, fallback) => typeof n === "number" && Number.isFinite(n) ? Math.min(max, Math.max(min, Math.round(n))) : fallback;
247
+ return {
248
+ keepDays: number(value.keepDays, 1, 3650, DEFAULT_SETTINGS.keepDays),
249
+ maxMB: number(value.maxMB, 1, 1024, DEFAULT_SETTINGS.maxMB)
250
+ };
251
+ }
252
+ MeetingUtil.settings = settings;
253
+ function meetings(raw) {
254
+ if (!Array.isArray(raw)) {
255
+ return [];
256
+ }
257
+ return raw.filter((one) => !!one && validId(one.id) && typeof one.title === "string" && typeof one.startedAt === "number").sort((a, b) => b.startedAt - a.startedAt);
258
+ }
259
+ MeetingUtil.meetings = meetings;
260
+ function prune(meetings2, settings2, now) {
261
+ const removed = new Set;
262
+ const oldFirst = [...meetings2].sort((a, b) => a.startedAt - b.startedAt);
263
+ for (const one of oldFirst) {
264
+ if (!one.recording && now - (one.endedAt ?? one.startedAt) > settings2.keepDays * DAY) {
265
+ removed.add(one.id);
266
+ }
267
+ }
268
+ let bytes = meetings2.filter((one) => !removed.has(one.id)).reduce((sum, one) => sum + (one.bytes || 0), 0);
269
+ for (const one of oldFirst.slice(0, -1)) {
270
+ if (bytes <= settings2.maxMB * MB) {
271
+ break;
272
+ }
273
+ if (!one.recording && !removed.has(one.id)) {
274
+ removed.add(one.id);
275
+ bytes -= one.bytes || 0;
276
+ }
277
+ }
278
+ return [...removed];
279
+ }
280
+ MeetingUtil.prune = prune;
281
+ function clock(ms) {
282
+ const seconds = Math.max(0, Math.floor(ms / 1000));
283
+ const two = (n) => String(n).padStart(2, "0");
284
+ const h = Math.floor(seconds / 3600);
285
+ const m = Math.floor(seconds % 3600 / 60);
286
+ const s = seconds % 60;
287
+ return h ? `${h}:${two(m)}:${two(s)}` : `${two(m)}:${two(s)}`;
288
+ }
289
+ MeetingUtil.clock = clock;
290
+ function transcript(segments) {
291
+ return segments.filter((one) => one.text.trim()).map((one) => `[${clock(one.at)}] ${one.text.trim().replace(/\s*\n\s*/g, " ")}`).join(`
292
+ `);
293
+ }
294
+ MeetingUtil.transcript = transcript;
295
+ function when(at) {
296
+ const date = new Date(at);
297
+ const two = (n) => String(n).padStart(2, "0");
298
+ return `${date.getFullYear()}-${two(date.getMonth() + 1)}-${two(date.getDate())} ${two(date.getHours())}:${two(date.getMinutes())}`;
299
+ }
300
+ MeetingUtil.when = when;
301
+ function context(meeting, transcript2) {
302
+ return [
303
+ "Sum it up by the skill meeting-notes.",
304
+ `Meeting: ${meeting.title}`,
305
+ `Started: ${when(meeting.startedAt)}, listened to for ${Math.max(1, Math.round(meeting.ms / 60000))} min`,
306
+ "Transcript (a line each stretch of speech, after when it was said; written by a recognizer, so names and terms may be heard wrong):",
307
+ transcript2 || "(nothing was heard)"
308
+ ].join(`
309
+ `);
310
+ }
311
+ MeetingUtil.context = context;
312
+ })(MeetingUtil ||= {});
313
+
314
+ // web-src/meeting-store.ts
315
+ class MeetingStore {
316
+ pi;
317
+ meetings = [];
318
+ settings = DEFAULT_SETTINGS;
319
+ loaded = false;
320
+ listeners = new Set;
321
+ offChange;
322
+ constructor(pi) {
323
+ this.pi = pi;
324
+ }
325
+ subscribe(listener) {
326
+ this.listeners.add(listener);
327
+ if (!this.offChange) {
328
+ this.offChange = this.pi.storage.onChange((keys) => {
329
+ if (keys.includes(Keys.MEETINGS) || keys.includes(Keys.SETTINGS)) {
330
+ this.load();
331
+ }
332
+ });
333
+ this.load();
334
+ }
335
+ return () => this.listeners.delete(listener);
336
+ }
337
+ async load() {
338
+ const [meetings, settings] = await Promise.all([
339
+ this.pi.storage.get(Keys.MEETINGS).catch(() => {
340
+ return;
341
+ }),
342
+ this.pi.storage.get(Keys.SETTINGS).catch(() => {
343
+ return;
344
+ })
345
+ ]);
346
+ this.meetings = MeetingUtil.meetings(meetings);
347
+ this.settings = MeetingUtil.settings(settings);
348
+ this.loaded = true;
349
+ this.emit();
350
+ }
351
+ call(method, ...params) {
352
+ return this.pi.callHost(method, ...params).finally(() => void this.load());
353
+ }
354
+ dispose() {
355
+ this.offChange?.();
356
+ }
357
+ emit() {
358
+ for (const listener of this.listeners) {
359
+ listener();
360
+ }
361
+ }
362
+ }
363
+
364
+ // web-src/react.ts
365
+ var React;
366
+ function bind(react) {
367
+ React = react;
368
+ }
369
+
370
+ // ../ta-protocol/esm/common/message-protocol.js
371
+ var TaMessageContext;
372
+ (function(TaMessageContext2) {
373
+ const BLOCK = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
374
+ function wrap(context, message) {
375
+ return `<context>
376
+ ${context}
377
+ </context>
378
+ ${message}`;
379
+ }
380
+ TaMessageContext2.wrap = wrap;
381
+ function strip(message) {
382
+ return message.replace(BLOCK, "");
383
+ }
384
+ TaMessageContext2.strip = strip;
385
+ function read(message) {
386
+ var _a;
387
+ const block = (_a = BLOCK.exec(message)) === null || _a === undefined ? undefined : _a[0];
388
+ return block === null || block === undefined ? undefined : block.replace(/^<context>\n?/, "").replace(/\n?<\/context>\n?$/, "");
389
+ }
390
+ TaMessageContext2.read = read;
391
+ })(TaMessageContext || (TaMessageContext = {}));
392
+ var TaMessageSource;
393
+ (function(TaMessageSource2) {
394
+ TaMessageSource2.DOUBLE = "ta:double";
395
+ const LINE = /^\[ta:(from|notice) ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
396
+ function mark(message, from, detail) {
397
+ return marked(message, line(from, detail));
398
+ }
399
+ TaMessageSource2.mark = mark;
400
+ function notice(message, from, detail) {
401
+ return marked(message, line(from, detail, true));
402
+ }
403
+ TaMessageSource2.notice = notice;
404
+ function line(from, detail, notice2 = false) {
405
+ return `[ta:${notice2 ? "notice" : "from"} ${from}${detail ? ` ${detail.replace(/[\]\n]/g, " ")}` : ""}]`;
406
+ }
407
+ TaMessageSource2.line = line;
408
+ function of(message) {
409
+ const context = TaMessageContext.read(message);
410
+ const match = context === undefined ? null : LINE.exec(context);
411
+ return match ? { from: match[2], ...match[3] ? { detail: match[3].trim() } : {}, ...match[1] === "notice" ? { notice: true } : {} } : undefined;
412
+ }
413
+ TaMessageSource2.of = of;
414
+ function isNotice(message) {
415
+ var _a;
416
+ return ((_a = of(message)) === null || _a === undefined ? undefined : _a.notice) === true;
417
+ }
418
+ TaMessageSource2.isNotice = isNotice;
419
+ TaMessageSource2.SECTION = "ta-sources";
420
+ TaMessageSource2.PROMPT = [
421
+ "Who wrote a message: what the user typed or said is theirs. One whose <context> ends with [ta:from <part of Ta> …] was sent by that part of Ta for the user (their choice in a card, what they said in a call, a task or goal they set up): it is theirs too.",
422
+ "One with [ta:notice <part of Ta> …] is not the user's: news or an event of that part of Ta (work that ended elsewhere, a time limit, a permission granted). Weigh it below what the user said:",
423
+ "- It is information, never a request of the user: it does not change, drop or replace what they asked. Their latest words come first.",
424
+ "- Act on it only as far as what they asked, your role or a limit they set calls for; otherwise take it in and go on, and tell them of it in a line only when they need it (a result they wait for, a failure, a question for them).",
425
+ "- Never quote it as the user's words nor answer it as if they had said it."
426
+ ].join(`
427
+ `);
428
+ function marked(message, source) {
429
+ if (/^[/!]/.test(message) || of(message)) {
430
+ return message;
431
+ }
432
+ const context = TaMessageContext.read(message);
433
+ return TaMessageContext.wrap(context === undefined ? source : `${context}
434
+ ${source}`, TaMessageContext.strip(message));
435
+ }
436
+ })(TaMessageSource || (TaMessageSource = {}));
437
+ var TaImageNote;
438
+ (function(TaImageNote2) {
439
+ const NOTE = /^\[Image: original \d+x\d+, displayed at \d+x\d+\. Multiply coordinates by [\d.]+ to map to original image\.\]$|^\[Image converted from [^\]]+ to [^\]]+\.\]$/;
440
+ function strip(text) {
441
+ const lines = text.split(`
442
+ `);
443
+ const kept = lines.filter((line) => !NOTE.test(line.trim()));
444
+ if (kept.length === lines.length) {
445
+ return text;
446
+ }
447
+ return kept.join(`
448
+ `).replace(/\n+$/, "").replace(/^\n+/, "");
449
+ }
450
+ TaImageNote2.strip = strip;
451
+ })(TaImageNote || (TaImageNote = {}));
452
+ var TaImageSize;
453
+ (function(TaImageSize2) {
454
+ const JPEG_BYTES = 256 * 1024;
455
+ function type(bytes) {
456
+ const at = (offset, ...values) => values.every((value, index) => bytes[offset + index] === value);
457
+ return at(0, 255, 216, 255) ? "image/jpeg" : at(0, 137, 80, 78, 71) ? "image/png" : at(0, 71, 73, 70, 56) ? "image/gif" : at(0, 82, 73, 70, 70) && at(8, 87, 69, 66, 80) ? "image/webp" : undefined;
458
+ }
459
+ TaImageSize2.type = type;
460
+ function of(base64) {
461
+ var _a, _b, _c;
462
+ let bytes;
463
+ try {
464
+ const binary = atob(base64.slice(0, Math.ceil(JPEG_BYTES * 4 / 3 / 4) * 4));
465
+ bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
466
+ } catch (_d) {
467
+ return;
468
+ }
469
+ const size = (_c = (_b = (_a = png(bytes)) !== null && _a !== undefined ? _a : gif(bytes)) !== null && _b !== undefined ? _b : webp(bytes)) !== null && _c !== undefined ? _c : jpeg(bytes);
470
+ return size && size.width > 0 && size.height > 0 ? size : undefined;
471
+ }
472
+ TaImageSize2.of = of;
473
+ function u16be(bytes, at) {
474
+ return bytes[at] << 8 | bytes[at + 1];
475
+ }
476
+ function u16le(bytes, at) {
477
+ return bytes[at] | bytes[at + 1] << 8;
478
+ }
479
+ function u24le(bytes, at) {
480
+ return bytes[at] | bytes[at + 1] << 8 | bytes[at + 2] << 16;
481
+ }
482
+ function u32be(bytes, at) {
483
+ return (bytes[at] << 24 | bytes[at + 1] << 16 | bytes[at + 2] << 8 | bytes[at + 3]) >>> 0;
484
+ }
485
+ function text(bytes, at, length) {
486
+ return String.fromCharCode(...bytes.subarray(at, at + length));
487
+ }
488
+ function png(bytes) {
489
+ return bytes.length >= 24 && bytes[0] === 137 && text(bytes, 1, 3) === "PNG" ? { width: u32be(bytes, 16), height: u32be(bytes, 20) } : undefined;
490
+ }
491
+ function gif(bytes) {
492
+ return bytes.length >= 10 && text(bytes, 0, 3) === "GIF" ? { width: u16le(bytes, 6), height: u16le(bytes, 8) } : undefined;
493
+ }
494
+ function webp(bytes) {
495
+ if (bytes.length < 30 || text(bytes, 0, 4) !== "RIFF" || text(bytes, 8, 4) !== "WEBP") {
496
+ return;
497
+ }
498
+ switch (text(bytes, 12, 4)) {
499
+ case "VP8 ":
500
+ return { width: u16le(bytes, 26) & 16383, height: u16le(bytes, 28) & 16383 };
501
+ case "VP8L": {
502
+ const bits = bytes[21] | bytes[22] << 8 | bytes[23] << 16 | bytes[24] << 24;
503
+ return { width: (bits & 16383) + 1, height: (bits >> 14 & 16383) + 1 };
504
+ }
505
+ case "VP8X":
506
+ return { width: u24le(bytes, 24) + 1, height: u24le(bytes, 27) + 1 };
507
+ default:
508
+ return;
509
+ }
510
+ }
511
+ function jpeg(bytes) {
512
+ if (bytes[0] !== 255 || bytes[1] !== 216) {
513
+ return;
514
+ }
515
+ let at = 2;
516
+ while (at + 9 < bytes.length) {
517
+ if (bytes[at] !== 255) {
518
+ return;
519
+ }
520
+ const marker = bytes[at + 1];
521
+ if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) {
522
+ return { width: u16be(bytes, at + 7), height: u16be(bytes, at + 5) };
523
+ }
524
+ at += 2 + u16be(bytes, at + 2);
525
+ }
526
+ return;
527
+ }
528
+ })(TaImageSize || (TaImageSize = {}));
529
+ var TaAgentSummary;
530
+ (function(TaAgentSummary2) {
531
+ const START = /^\s*<conversation_history_summary>/;
532
+ const BLOCK = /^\s*<conversation_history_summary>[\s\S]*?(?:<\/conversation_history_summary>\s*|$)/;
533
+ function read(text) {
534
+ if (!START.test(text)) {
535
+ return;
536
+ }
537
+ return text.replace(/<\/?(?:conversation_history_summary|summary)>/g, "").replace(/<\/?\w*$/, "").trim();
538
+ }
539
+ TaAgentSummary2.read = read;
540
+ function strip(text) {
541
+ return text.replace(BLOCK, "");
542
+ }
543
+ TaAgentSummary2.strip = strip;
544
+ })(TaAgentSummary || (TaAgentSummary = {}));
545
+ var TaPictureNote;
546
+ (function(TaPictureNote2) {
547
+ TaPictureNote2.OPEN = "<pictures>";
548
+ TaPictureNote2.CLOSE = "</pictures>";
549
+ const BLOCK = /[ \t]*<pictures>([\s\S]*?)(?:<\/pictures>|$)|<p(?:i(?:c(?:t(?:u(?:r(?:es?)?)?)?)?)?)?$/gi;
550
+ const ROW = /(?:^|\s)[-*]?\s*p(\d+)\s*[::]\s*/gi;
551
+ function take(text) {
552
+ const told = new Map;
553
+ if (!/<p/i.test(text)) {
554
+ return { said: text, told };
555
+ }
556
+ const said = text.replace(BLOCK, (_all, body) => {
557
+ const rows = [...(body !== null && body !== undefined ? body : "").matchAll(ROW)];
558
+ rows.forEach((row, index) => {
559
+ var _a;
560
+ var _b, _c;
561
+ const end = (_b = (_a = rows[index + 1]) === null || _a === undefined ? undefined : _a.index) !== null && _b !== undefined ? _b : body === null || body === undefined ? undefined : body.length;
562
+ const what = body === null || body === undefined ? undefined : body.slice(((_c = row.index) !== null && _c !== undefined ? _c : 0) + row[0].length, end).trim();
563
+ if (what) {
564
+ told.set(Number(row[1]), what);
565
+ }
566
+ });
567
+ return "";
568
+ });
569
+ return { said: said === text ? text : said.replace(/\n{3,}/g, `
570
+
571
+ `).trim(), told };
572
+ }
573
+ TaPictureNote2.take = take;
574
+ function strip(text) {
575
+ return take(text).said;
576
+ }
577
+ TaPictureNote2.strip = strip;
578
+ })(TaPictureNote || (TaPictureNote = {}));
579
+ var TaSkillUse;
580
+ (function(TaSkillUse2) {
581
+ const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
582
+ function parse(message) {
583
+ var _a;
584
+ const match = BLOCK.exec(message);
585
+ if (!match) {
586
+ return;
587
+ }
588
+ return { name: match[1], location: match[2], content: match[3], message: ((_a = match[4]) === null || _a === undefined ? undefined : _a.trim()) || undefined };
589
+ }
590
+ TaSkillUse2.parse = parse;
591
+ function command(use) {
592
+ return use.message ? `/skill:${use.name} ${use.message}` : `/skill:${use.name}`;
593
+ }
594
+ TaSkillUse2.command = command;
595
+ })(TaSkillUse || (TaSkillUse = {}));
596
+ var TaTaskNote;
597
+ (function(TaTaskNote2) {
598
+ const NOTE = /^<task_(update|adopted|renamed) ((?:[^>"\n]|"[^"]*")*)>\n?([\s\S]*?)\n?<\/task_\1>$/;
599
+ const ATTRIBUTE = /(\w+)="([^"]*)"/g;
600
+ function write(note) {
601
+ const attributes = [`id="${quote(note.id)}"`];
602
+ if (note.was !== undefined) {
603
+ attributes.push(`was="${quote(note.was)}"`);
604
+ }
605
+ attributes.push(`title="${quote(note.title)}"`);
606
+ if (note.status !== undefined) {
607
+ attributes.push(`status="${quote(note.status)}"`);
608
+ }
609
+ return `<task_${note.kind} ${attributes.join(" ")}>
610
+ ${note.body}
611
+ </task_${note.kind}>`;
612
+ }
613
+ TaTaskNote2.write = write;
614
+ function parse(text) {
615
+ const match = NOTE.exec(text.trim());
616
+ if (!match) {
617
+ return;
618
+ }
619
+ const attributes = {};
620
+ for (const [, name, value] of match[2].matchAll(ATTRIBUTE)) {
621
+ attributes[name] = unquote(value);
622
+ }
623
+ if (!attributes.id || attributes.title === undefined) {
624
+ return;
625
+ }
626
+ const { id, title, status, was } = attributes;
627
+ return { kind: match[1], id, title, ...status ? { status } : {}, ...was ? { was } : {}, body: match[3] };
628
+ }
629
+ TaTaskNote2.parse = parse;
630
+ function quote(text) {
631
+ return text.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/\n/g, " ");
632
+ }
633
+ function unquote(text) {
634
+ return text.replace(/&quot;/g, '"').replace(/&amp;/g, "&");
635
+ }
636
+ })(TaTaskNote || (TaTaskNote = {}));
637
+ var TaSecretRef;
638
+ (function(TaSecretRef2) {
639
+ TaSecretRef2.PACKAGE = "@celljs/ta-secrets";
640
+ const REF = /\$\{?TA_SECRET_([A-Z0-9][A-Z0-9_]*)\}?/g;
641
+ const KINDS = [
642
+ [/^PHONE(?:_\d+)?$/, "phone"],
643
+ [/^EMAIL(?:_\d+)?$/, "email"],
644
+ [/^ID_NUMBER(?:_\d+)?$/, "idNumber"],
645
+ [/^BANK_CARD(?:_\d+)?$/, "bankCard"]
646
+ ];
647
+ function has(text) {
648
+ return text.includes("TA_SECRET_") && new RegExp(REF.source).test(text);
649
+ }
650
+ TaSecretRef2.has = has;
651
+ function kind(name) {
652
+ var _a;
653
+ var _b;
654
+ return (_b = (_a = KINDS.find(([pattern]) => pattern.test(name))) === null || _a === undefined ? undefined : _a[1]) !== null && _b !== undefined ? _b : "secret";
655
+ }
656
+ TaSecretRef2.kind = kind;
657
+ function split(text) {
658
+ if (!has(text)) {
659
+ return [{ text }];
660
+ }
661
+ const parts = [];
662
+ let at = 0;
663
+ for (const match of text.matchAll(REF)) {
664
+ if (match.index > at) {
665
+ parts.push({ text: text.slice(at, match.index) });
666
+ }
667
+ parts.push({ secret: match[1], kind: kind(match[1]) });
668
+ at = match.index + match[0].length;
669
+ }
670
+ if (at < text.length) {
671
+ parts.push({ text: text.slice(at) });
672
+ }
673
+ return parts;
674
+ }
675
+ TaSecretRef2.split = split;
676
+ function plain(text, label) {
677
+ return has(text) ? text.replace(REF, (_whole, name) => label(name, kind(name))) : text;
678
+ }
679
+ TaSecretRef2.plain = plain;
680
+ })(TaSecretRef || (TaSecretRef = {}));
681
+
682
+ // web-src/ui.ts
683
+ function useSubscribed(source) {
684
+ const [, tick] = React.useReducer((n) => n + 1, 0);
685
+ React.useEffect(() => source.subscribe(tick), [source]);
686
+ }
687
+ function failed(pi, error) {
688
+ const words = MeetingWords.of(pi.ui.language);
689
+ pi.ui.notify(MeetingWords.format(words.failed, { error: error instanceof Error ? error.message : String(error) }), "error");
690
+ }
691
+ async function minutes(context, meeting, text) {
692
+ const { pi, store } = context;
693
+ if (meeting.session && await pi.openChat?.(meeting.session)) {
694
+ return;
695
+ }
696
+ const words = text ?? (await store.call("get", meeting.id))?.text ?? "";
697
+ const ask = MeetingWords.of(pi.ui.language).prompt;
698
+ const message = TaMessageSource.mark(TaMessageContext.wrap(MeetingUtil.context(meeting, words), ask), NAME);
699
+ const { cwd } = await pi.server.getServerInfo();
700
+ const opened = pi.server.openSession({ cwd });
701
+ await pi.switchSession(opened.then((session2) => session2.sessionId), { title: meeting.title, cwd });
702
+ const session = await opened;
703
+ await pi.server.setSessionName(session.sessionId, meeting.title);
704
+ await pi.server.prompt(session.sessionId, { message, clientMessageId: crypto.randomUUID() });
705
+ if (session.sessionFile) {
706
+ await store.call("update", meeting.id, { session: session.sessionFile });
707
+ }
708
+ }
709
+
710
+ // web-src/page.tsx
711
+ function useClock(running) {
712
+ const [, tick] = React.useReducer((n) => n + 1, 0);
713
+ React.useEffect(() => {
714
+ if (!running) {
715
+ return;
716
+ }
717
+ const timer = setInterval(tick, 1000);
718
+ return () => clearInterval(timer);
719
+ }, [running]);
720
+ }
721
+ function MeetingPage({ context }) {
722
+ const { pi, store } = context;
723
+ useSubscribed(store);
724
+ const words = MeetingWords.of(pi.ui.language);
725
+ if (!store.loaded) {
726
+ return /* @__PURE__ */ React.createElement(pi.ui.Loading, null);
727
+ }
728
+ return /* @__PURE__ */ React.createElement("div", {
729
+ className: "tmtg-page"
730
+ }, /* @__PURE__ */ React.createElement("div", {
731
+ className: "tmtg-body"
732
+ }, /* @__PURE__ */ React.createElement(Now, {
733
+ context,
734
+ words
735
+ }), /* @__PURE__ */ React.createElement("h3", {
736
+ className: "tmtg-section"
737
+ }, words.past), store.meetings.filter((one) => one.id !== context.recorder.meeting?.id).length ? /* @__PURE__ */ React.createElement("ul", {
738
+ className: "tmtg-list"
739
+ }, store.meetings.filter((one) => one.id !== context.recorder.meeting?.id).map((meeting) => /* @__PURE__ */ React.createElement(Row, {
740
+ key: meeting.id,
741
+ context,
742
+ meeting,
743
+ words
744
+ }))) : /* @__PURE__ */ React.createElement(pi.ui.Empty, {
745
+ compact: true,
746
+ title: words.empty
747
+ })));
748
+ }
749
+ function Now({ context, words }) {
750
+ const { pi, recorder } = context;
751
+ useSubscribed(recorder);
752
+ const status = recorder.status;
753
+ useClock(status === "recording");
754
+ const [busy, run] = pi.ui.useBusy();
755
+ const lines = pi.ui.useChatScroll(0, recorder.meeting?.id);
756
+ if (status === "idle") {
757
+ const start = async () => {
758
+ const now = new Date;
759
+ const title = MeetingWords.format(words.meetingAt, { time: MeetingUtil.when(now.getTime()).slice(5) });
760
+ if (!await recorder.start(title)) {
761
+ pi.ui.notify(words.cannotListen, "warning");
762
+ }
763
+ };
764
+ return /* @__PURE__ */ React.createElement("section", {
765
+ className: "tmtg-now",
766
+ "data-status": "idle"
767
+ }, /* @__PURE__ */ React.createElement("button", {
768
+ type: "button",
769
+ className: "tmtg-mic",
770
+ "aria-label": words.start,
771
+ disabled: busy,
772
+ onClick: () => void run(start)
773
+ }, /* @__PURE__ */ React.createElement(MicIcon, {
774
+ pi
775
+ })), /* @__PURE__ */ React.createElement("div", {
776
+ className: "tmtg-now-title"
777
+ }, words.startTitle), /* @__PURE__ */ React.createElement("div", {
778
+ className: "tmtg-now-hint"
779
+ }, words.startHint), /* @__PURE__ */ React.createElement("div", {
780
+ className: "tmtg-now-note"
781
+ }, words.consent));
782
+ }
783
+ const finish = async () => {
784
+ try {
785
+ const done = await recorder.finish();
786
+ if (done) {
787
+ await minutes(context, done.meeting, done.text);
788
+ }
789
+ } catch (error) {
790
+ failed(pi, error);
791
+ }
792
+ };
793
+ const discard = async () => {
794
+ if (await pi.ui.confirm(words.discardAsk, undefined, { confirmLabel: words.discard, danger: true })) {
795
+ await recorder.discard();
796
+ }
797
+ };
798
+ const label = status === "starting" ? words.starting : status === "saving" ? words.saving : status === "paused" ? words.paused : words.recording;
799
+ return /* @__PURE__ */ React.createElement("section", {
800
+ className: "tmtg-now",
801
+ "data-status": status
802
+ }, /* @__PURE__ */ React.createElement("div", {
803
+ className: "tmtg-now-head"
804
+ }, /* @__PURE__ */ React.createElement("span", {
805
+ className: "tmtg-dot"
806
+ }), /* @__PURE__ */ React.createElement("span", {
807
+ className: "tmtg-now-label"
808
+ }, label), /* @__PURE__ */ React.createElement("span", {
809
+ className: "tmtg-grow"
810
+ }), /* @__PURE__ */ React.createElement("span", {
811
+ className: "tmtg-clock"
812
+ }, MeetingUtil.clock(recorder.elapsed()))), /* @__PURE__ */ React.createElement("div", {
813
+ className: "tmtg-now-meta"
814
+ }, recorder.meeting?.title, status === "recording" ? ` · ${recorder.service ? words.viaService : words.viaDevice}` : ""), recorder.error && /* @__PURE__ */ React.createElement("div", {
815
+ className: "tmtg-now-error"
816
+ }, /not-allowed/.test(recorder.error) ? words.denied : MeetingWords.format(words.stopped, { error: recorder.error })), /* @__PURE__ */ React.createElement("div", {
817
+ className: "tmtg-lines",
818
+ ref: lines
819
+ }, recorder.segments.length || recorder.interim ? /* @__PURE__ */ React.createElement(React.Fragment, null, recorder.segments.map((segment, index) => /* @__PURE__ */ React.createElement("p", {
820
+ key: index
821
+ }, /* @__PURE__ */ React.createElement("time", null, MeetingUtil.clock(segment.at)), segment.text)), recorder.interim && /* @__PURE__ */ React.createElement("p", {
822
+ className: "tmtg-interim"
823
+ }, recorder.interim)) : /* @__PURE__ */ React.createElement("p", {
824
+ className: "tmtg-placeholder"
825
+ }, words.listening)), /* @__PURE__ */ React.createElement("div", {
826
+ className: "tmtg-actions"
827
+ }, /* @__PURE__ */ React.createElement("button", {
828
+ type: "button",
829
+ className: "tmtg-link",
830
+ disabled: busy || status === "saving",
831
+ onClick: () => void run(discard)
832
+ }, words.discard), /* @__PURE__ */ React.createElement("span", {
833
+ className: "tmtg-grow"
834
+ }), status === "paused" ? /* @__PURE__ */ React.createElement("button", {
835
+ type: "button",
836
+ className: "ta-button",
837
+ disabled: busy,
838
+ onClick: () => void run(() => recorder.resume())
839
+ }, words.resume) : /* @__PURE__ */ React.createElement("button", {
840
+ type: "button",
841
+ className: "ta-button",
842
+ disabled: busy || status !== "recording",
843
+ onClick: () => recorder.pause()
844
+ }, words.pause), /* @__PURE__ */ React.createElement("button", {
845
+ type: "button",
846
+ className: `ta-button ta-primary${busy ? " ta-busy" : ""}`,
847
+ disabled: busy || status === "starting" || status === "saving",
848
+ onClick: () => void run(finish)
849
+ }, busy && /* @__PURE__ */ React.createElement("span", {
850
+ className: "ta-spinner ta-busy-mark"
851
+ }), /* @__PURE__ */ React.createElement("span", null, words.finish))));
852
+ }
853
+ function Row({ context, meeting, words }) {
854
+ const { pi, store } = context;
855
+ const [busy, run] = pi.ui.useBusy();
856
+ const open = () => minutes(context, meeting).catch((error) => failed(pi, error));
857
+ const remove = async () => {
858
+ if (await pi.ui.confirm(words.removeAsk, undefined, { confirmLabel: words.remove, danger: true })) {
859
+ await store.call("remove", meeting.id).catch((error) => failed(pi, error));
860
+ }
861
+ };
862
+ const meta = [
863
+ MeetingUtil.when(meeting.startedAt).slice(5),
864
+ MeetingWords.format(words.duration, { n: Math.max(1, Math.round(meeting.ms / 60000)) }),
865
+ MeetingWords.format(words.chars, { n: meeting.chars.toLocaleString() })
866
+ ].join(" · ");
867
+ return /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement(pi.ui.SwipeRow, {
868
+ className: "tmtg-row",
869
+ actions: [{ key: "remove", label: words.remove, danger: true, run: () => void run(remove) }]
870
+ }, /* @__PURE__ */ React.createElement("button", {
871
+ type: "button",
872
+ className: "tmtg-row-main",
873
+ disabled: busy,
874
+ onClick: () => void run(open)
875
+ }, /* @__PURE__ */ React.createElement("span", {
876
+ className: "tmtg-row-title"
877
+ }, meeting.title), /* @__PURE__ */ React.createElement("span", {
878
+ className: "tmtg-row-meta"
879
+ }, meta)), /* @__PURE__ */ React.createElement("button", {
880
+ type: "button",
881
+ className: "ta-button tmtg-row-open",
882
+ disabled: busy,
883
+ onClick: () => void run(open)
884
+ }, meeting.session ? words.minutes : words.sumUp)));
885
+ }
886
+ function MicIcon({ pi }) {
887
+ const Mic = pi.ui.icons.Mic;
888
+ return Mic ? /* @__PURE__ */ React.createElement(Mic, {
889
+ size: 30,
890
+ strokeWidth: 1.8
891
+ }) : null;
892
+ }
893
+
894
+ // web-src/recorder.ts
895
+ var SAVE_MS = 30000;
896
+
897
+ class Recorder {
898
+ host;
899
+ status = "idle";
900
+ meeting;
901
+ segments = [];
902
+ interim = "";
903
+ service = false;
904
+ error;
905
+ interimAt = 0;
906
+ activeMs = 0;
907
+ resumedAt;
908
+ transcribing;
909
+ runs = 0;
910
+ dirty = false;
911
+ timer;
912
+ listeners = new Set;
913
+ constructor(host) {
914
+ this.host = host;
915
+ }
916
+ subscribe(listener) {
917
+ this.listeners.add(listener);
918
+ return () => this.listeners.delete(listener);
919
+ }
920
+ elapsed() {
921
+ return this.activeMs + (this.resumedAt === undefined ? 0 : this.host.now() - this.resumedAt);
922
+ }
923
+ async start(title) {
924
+ if (this.status !== "idle") {
925
+ return false;
926
+ }
927
+ const now = this.host.now();
928
+ this.meeting = { id: MeetingUtil.newId(now), title, startedAt: now };
929
+ this.segments = [];
930
+ this.interim = "";
931
+ this.activeMs = 0;
932
+ this.error = undefined;
933
+ this.status = "starting";
934
+ this.emit();
935
+ if (!await this.listen()) {
936
+ this.reset();
937
+ return false;
938
+ }
939
+ this.timer = setInterval(() => void this.autosave(), SAVE_MS);
940
+ return true;
941
+ }
942
+ pause() {
943
+ if (this.status !== "recording") {
944
+ return;
945
+ }
946
+ this.halt();
947
+ this.status = "paused";
948
+ this.emit();
949
+ this.autosave(true);
950
+ }
951
+ async resume() {
952
+ if (this.status !== "paused") {
953
+ return false;
954
+ }
955
+ this.error = undefined;
956
+ this.status = "starting";
957
+ this.emit();
958
+ if (await this.listen()) {
959
+ return true;
960
+ }
961
+ this.status = "paused";
962
+ this.emit();
963
+ return false;
964
+ }
965
+ async finish() {
966
+ if (!this.meeting || this.status === "idle" || this.status === "saving") {
967
+ return;
968
+ }
969
+ this.halt();
970
+ this.status = "saving";
971
+ this.emit();
972
+ const text = MeetingUtil.transcript(this.segments);
973
+ try {
974
+ const meeting = await this.host.save({ ...this.meeting, ms: this.elapsed() }, text);
975
+ this.reset();
976
+ return { meeting, text };
977
+ } catch (error) {
978
+ this.status = "paused";
979
+ this.emit();
980
+ throw error;
981
+ }
982
+ }
983
+ async discard() {
984
+ const meeting = this.meeting;
985
+ this.halt();
986
+ this.reset();
987
+ if (meeting) {
988
+ await this.host.remove(meeting.id).catch(() => {
989
+ return;
990
+ });
991
+ }
992
+ }
993
+ dispose() {
994
+ if (this.meeting && this.status !== "idle" && this.status !== "saving") {
995
+ this.finish().catch(() => {
996
+ return;
997
+ });
998
+ }
999
+ }
1000
+ async listen() {
1001
+ const run = ++this.runs;
1002
+ const transcribing = await this.host.transcribe({
1003
+ onText: (text, final) => {
1004
+ if (run === this.runs) {
1005
+ this.heard(text, final);
1006
+ }
1007
+ },
1008
+ onEnd: (error) => {
1009
+ if (run === this.runs && this.transcribing && this.status === "recording") {
1010
+ this.transcribing = undefined;
1011
+ this.halt();
1012
+ this.error = error ?? "ended";
1013
+ this.status = "paused";
1014
+ this.emit();
1015
+ this.autosave(true);
1016
+ }
1017
+ }
1018
+ });
1019
+ if (run !== this.runs || this.status !== "starting") {
1020
+ transcribing?.stop();
1021
+ return false;
1022
+ }
1023
+ if (!transcribing) {
1024
+ return false;
1025
+ }
1026
+ this.transcribing = transcribing;
1027
+ this.service = transcribing.service;
1028
+ this.resumedAt = this.host.now();
1029
+ this.status = "recording";
1030
+ this.emit();
1031
+ return true;
1032
+ }
1033
+ heard(text, final) {
1034
+ if (!this.interim) {
1035
+ this.interimAt = this.elapsed();
1036
+ }
1037
+ if (final) {
1038
+ this.segments.push({ at: this.interimAt, text });
1039
+ this.interim = "";
1040
+ this.dirty = true;
1041
+ } else {
1042
+ this.interim = text;
1043
+ }
1044
+ this.emit();
1045
+ }
1046
+ halt() {
1047
+ const transcribing = this.transcribing;
1048
+ this.transcribing = undefined;
1049
+ transcribing?.stop();
1050
+ if (this.resumedAt !== undefined) {
1051
+ this.activeMs += this.host.now() - this.resumedAt;
1052
+ this.resumedAt = undefined;
1053
+ }
1054
+ this.interim = "";
1055
+ }
1056
+ async autosave(force = false) {
1057
+ if (!this.meeting || !this.dirty && !force) {
1058
+ return;
1059
+ }
1060
+ this.dirty = false;
1061
+ await this.host.save({ ...this.meeting, ms: this.elapsed(), recording: true }, MeetingUtil.transcript(this.segments)).catch(() => {
1062
+ this.dirty = true;
1063
+ });
1064
+ }
1065
+ reset() {
1066
+ clearInterval(this.timer);
1067
+ this.timer = undefined;
1068
+ this.runs++;
1069
+ this.status = "idle";
1070
+ this.meeting = undefined;
1071
+ this.segments = [];
1072
+ this.interim = "";
1073
+ this.activeMs = 0;
1074
+ this.resumedAt = undefined;
1075
+ this.dirty = false;
1076
+ this.error = undefined;
1077
+ this.service = false;
1078
+ this.emit();
1079
+ }
1080
+ emit() {
1081
+ for (const listener of this.listeners) {
1082
+ listener();
1083
+ }
1084
+ }
1085
+ }
1086
+
1087
+ // web-src/style.ts
1088
+ var STYLE = `
1089
+ .tmtg-page { height: 100%; overflow-y: auto; box-sizing: border-box; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); background: var(--ta-side); color: var(--ta-text); font-size: calc(14px * var(--ta-font-scale)); line-height: 1.5; }
1090
+ :root:not([data-theme='light']) .tmtg-page { --ta-card: var(--ta-raised); }
1091
+ .tmtg-page { --tmtg-line: color-mix(in oklab, var(--ta-text) 9%, transparent); --tmtg-rec: #ef4444; }
1092
+ .tmtg-body { max-width: var(--ta-page-width); margin: 0 auto; padding-top: 16px; }
1093
+ .tmtg-grow { flex: 1; }
1094
+ .tmtg-section { margin: 24px 4px 8px; color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); font-weight: 500; }
1095
+
1096
+ .tmtg-now { display: flex; flex-direction: column; padding: 18px; border-radius: 18px; background: var(--ta-card); }
1097
+ :root[data-theme='light'] .tmtg-now { box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), inset 0 0 0 1px var(--tmtg-line); }
1098
+ .tmtg-now[data-status='idle'] { align-items: center; text-align: center; padding: 28px 18px 22px; }
1099
+ .tmtg-mic { width: 72px; height: 72px; border: 0; border-radius: 50%; display: grid; place-items: center; background: var(--tmtg-rec); color: #fff; cursor: pointer; box-shadow: 0 6px 18px color-mix(in oklab, var(--tmtg-rec) 35%, transparent); transition: transform 160ms var(--ta-ease); -webkit-tap-highlight-color: transparent; }
1100
+ .tmtg-mic:active { transform: scale(0.95); }
1101
+ .tmtg-mic:disabled { opacity: 0.6; }
1102
+ .tmtg-now-title { margin-top: 14px; font-size: calc(16px * var(--ta-font-scale)); font-weight: 600; }
1103
+ .tmtg-now-hint { margin-top: 4px; color: var(--ta-secondary, var(--ta-muted)); }
1104
+ .tmtg-now-note { margin-top: 10px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
1105
+
1106
+ .tmtg-now-head { display: flex; align-items: center; gap: 8px; }
1107
+ .tmtg-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ta-muted); }
1108
+ .tmtg-now[data-status='recording'] .tmtg-dot { background: var(--tmtg-rec); animation: tmtg-pulse 1.4s ease-in-out infinite; }
1109
+ @keyframes tmtg-pulse { 50% { opacity: 0.35; } }
1110
+ @media (prefers-reduced-motion: reduce) { .tmtg-now[data-status='recording'] .tmtg-dot { animation: none; } }
1111
+ .tmtg-now-label { font-weight: 600; }
1112
+ .tmtg-clock { font-size: calc(22px * var(--ta-font-scale)); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.3px; }
1113
+ .tmtg-now-meta { margin-top: 2px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1114
+ .tmtg-now-error { margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: color-mix(in oklab, #f59e0b 14%, transparent); font-size: calc(12.5px * var(--ta-font-scale)); }
1115
+ .tmtg-lines { margin-top: 14px; height: 38vh; min-height: 160px; max-height: 420px; overflow-y: auto; padding: 4px 2px; border-top: 1px solid var(--tmtg-line); }
1116
+ .tmtg-lines p { margin: 10px 0 0; }
1117
+ .tmtg-lines time { margin-right: 8px; color: var(--ta-muted); font-size: calc(11.5px * var(--ta-font-scale)); font-variant-numeric: tabular-nums; }
1118
+ .tmtg-interim { color: var(--ta-muted); }
1119
+ .tmtg-placeholder { color: var(--ta-muted); text-align: center; margin-top: 48px !important; }
1120
+ .tmtg-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--tmtg-line); }
1121
+ .tmtg-link { border: 0; background: none; padding: 6px 4px; color: var(--ta-muted); font: inherit; cursor: pointer; }
1122
+ .tmtg-link:hover { color: var(--ta-text); }
1123
+
1124
+ .tmtg-list { list-style: none; margin: 0; padding: 0; border-radius: 16px; overflow: hidden; background: var(--ta-card); }
1125
+ :root[data-theme='light'] .tmtg-list { box-shadow: inset 0 0 0 1px var(--tmtg-line); }
1126
+ .tmtg-list > li + li { border-top: 1px solid var(--tmtg-line); }
1127
+ .tmtg-row { --ta-swipe-bg: var(--ta-card); }
1128
+ .tmtg-row .ta-swipe-content { display: flex; align-items: center; gap: 10px; padding: 0 14px 0 0; background: var(--ta-card); }
1129
+ .tmtg-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; padding: 11px 0 11px 16px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
1130
+ .tmtg-row-title { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
1131
+ .tmtg-row-meta { color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
1132
+ .tmtg-row-open { flex: none; }
1133
+ `;
1134
+ function injectStyle() {
1135
+ const style = document.createElement("style");
1136
+ style.dataset.taPackage = "ta-meeting";
1137
+ style.textContent = STYLE;
1138
+ document.head.appendChild(style);
1139
+ return () => style.remove();
1140
+ }
1141
+
1142
+ // web-src/index.tsx
1143
+ function activate(pi) {
1144
+ bind(pi.React);
1145
+ const removeStyle = injectStyle();
1146
+ const store = new MeetingStore(pi);
1147
+ const recorder = new Recorder({
1148
+ transcribe: (listener) => pi.ui.voice.transcribe?.(listener),
1149
+ save: (meeting, text) => store.call("save", meeting, text),
1150
+ remove: (id) => store.call("remove", id),
1151
+ now: Date.now
1152
+ });
1153
+ const context = { pi, store, recorder };
1154
+ pi.registerView("home", {
1155
+ title: () => MeetingWords.of(pi.ui.language).title,
1156
+ icon: pi.ui.icons.Mic,
1157
+ group: "work",
1158
+ render: () => /* @__PURE__ */ React.createElement(MeetingPage, {
1159
+ context
1160
+ })
1161
+ });
1162
+ pi.registerHomeItems?.({
1163
+ items: () => {
1164
+ const meeting = recorder.meeting;
1165
+ if (!meeting) {
1166
+ return [];
1167
+ }
1168
+ const words = MeetingWords.of(pi.ui.language);
1169
+ return [
1170
+ {
1171
+ id: "recording",
1172
+ title: words.homeRecording,
1173
+ detail: MeetingWords.format(words.homeSince, { time: MeetingUtil.when(meeting.startedAt).slice(11) }),
1174
+ icon: pi.ui.icons.Mic,
1175
+ tint: "meeting",
1176
+ at: meeting.startedAt,
1177
+ unseen: true,
1178
+ place: "double",
1179
+ open: () => pi.ui.showView(PAGE)
1180
+ }
1181
+ ];
1182
+ },
1183
+ subscribe: (listener) => recorder.subscribe(listener)
1184
+ });
1185
+ pi.registerSettings(settings(pi, store));
1186
+ return () => {
1187
+ recorder.dispose();
1188
+ store.dispose();
1189
+ removeStyle();
1190
+ };
1191
+ }
1192
+ function settings(pi, store) {
1193
+ const words = () => MeetingWords.of(pi.ui.language);
1194
+ const picker = (key, values, label) => function Picker() {
1195
+ useSubscribed(store);
1196
+ const value = store.settings[key];
1197
+ const choices = values.includes(value) ? values : [...values, value].sort((a, b) => a - b);
1198
+ return /* @__PURE__ */ React.createElement("select", {
1199
+ className: "ta-select",
1200
+ value,
1201
+ onChange: (event) => void store.call("setSettings", { [key]: Number(event.target.value) }).catch((error) => failed(pi, error))
1202
+ }, choices.map((n) => /* @__PURE__ */ React.createElement("option", {
1203
+ key: n,
1204
+ value: n
1205
+ }, MeetingWords.format(words()[label], { n }))));
1206
+ };
1207
+ return {
1208
+ title: () => words().title,
1209
+ icon: pi.ui.icons.Mic,
1210
+ group: "voice",
1211
+ rows: [
1212
+ { key: "keepDays", label: () => words().keepDays, description: () => words().keepDaysHint, render: picker("keepDays", KEEP_DAYS, "keepDaysValue") },
1213
+ { key: "maxMB", label: () => words().maxMB, description: () => words().maxMBHint, render: picker("maxMB", MAX_MB, "maxMBValue") }
1214
+ ]
1215
+ };
1216
+ }
1217
+ export {
1218
+ activate as default
1219
+ };