@posiwise/shared-components 0.0.202 → 0.0.204

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,7 +1,7 @@
1
1
  import * as i8 from '@angular/common';
2
2
  import { DOCUMENT, CommonModule, NgIf } from '@angular/common';
3
3
  import * as i0 from '@angular/core';
4
- import { Component, Injectable, HostListener, Directive, EventEmitter, Output, Input, ChangeDetectionStrategy, ViewChild, Pipe, Optional, ViewContainerRef, booleanAttribute, Inject, isDevMode, HostBinding, ContentChild, Host, SkipSelf, DOCUMENT as DOCUMENT$1, NgModule } from '@angular/core';
4
+ import { Component, Injectable, InjectionToken, HostListener, Directive, EventEmitter, Output, Input, ChangeDetectionStrategy, ViewChild, Pipe, Optional, Inject, ViewContainerRef, booleanAttribute, isDevMode, HostBinding, ContentChild, Host, SkipSelf, DOCUMENT as DOCUMENT$1, NgModule } from '@angular/core';
5
5
  import * as i2$2 from '@angular/forms';
6
6
  import { NG_VALUE_ACCESSOR, UntypedFormControl, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
7
7
  import * as i2 from '@angular/router';
@@ -39,8 +39,8 @@ import { AppBaseComponent } from '@posiwise/app-base-component';
39
39
  import * as i1 from '@posiwise/common-services';
40
40
  import { PermissionService } from '@posiwise/common-services';
41
41
  import * as i2$1 from '@posiwise/app-config-service';
42
- import { Subject, BehaviorSubject, of } from 'rxjs';
43
- import { take, takeUntil, map, filter, debounceTime, distinctUntilChanged, switchMap, catchError } from 'rxjs/operators';
42
+ import { takeUntil, Subject, BehaviorSubject, of } from 'rxjs';
43
+ import { take, takeUntil as takeUntil$1, map, filter, debounceTime, distinctUntilChanged, switchMap, catchError } from 'rxjs/operators';
44
44
  import * as i3 from '@ngrx/store';
45
45
  import { HelperService } from '@posiwise/helper-service';
46
46
  import * as i5$1 from '@jsverse/transloco';
@@ -127,6 +127,490 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImpo
127
127
  args: [{ providedIn: 'root' }]
128
128
  }] });
129
129
 
130
+ /**
131
+ * File-attachment rules for the chat composer. Split out of the component so
132
+ * the validation is unit-testable without a TestBed, matching the existing
133
+ * `pw-brain-chat-*.helpers.ts` convention.
134
+ *
135
+ * The limits come from the capability the owning tool advertises, which is a
136
+ * projection of that service's upload registry. Client-side checks are a
137
+ * courtesy so the user gets an instant answer — the server re-checks every one
138
+ * of them and remains the authority.
139
+ */
140
+ function fileExtension(name) {
141
+ const dot = name.lastIndexOf('.');
142
+ return dot === -1 ? '' : name.slice(dot + 1).toLowerCase();
143
+ }
144
+ /** @returns a human-readable reason to reject, or null when the file is fine. */
145
+ function validateChatFile(file, capability) {
146
+ if (file.size === 0) {
147
+ return 'That file is empty.';
148
+ }
149
+ if (file.size > capability.max_bytes) {
150
+ return `That file is ${formatFileSize(file.size)} — the limit is ${formatFileSize(capability.max_bytes)}.`;
151
+ }
152
+ return null;
153
+ }
154
+ /** Every extension any available capability accepts, de-duplicated. */
155
+ function acceptedExtensions(capabilities) {
156
+ return [...new Set(capabilities.flatMap(c => c.allowed_extensions))];
157
+ }
158
+ function formatFileSize(bytes) {
159
+ if (bytes < 1024) {
160
+ return `${bytes} B`;
161
+ }
162
+ const kb = bytes / 1024;
163
+ if (kb < 1024) {
164
+ return `${Math.round(kb)} KB`;
165
+ }
166
+ const mb = kb / 1024;
167
+ // One decimal below 10 MB, whole numbers above — "1.4 MB" is useful,
168
+ // "23.7 MB" is noise at that scale.
169
+ return mb < 10 ? `${mb.toFixed(1)} MB` : `${Math.round(mb)} MB`;
170
+ }
171
+ /** Pulls the single file out of a drop, ignoring directories and extra files. */
172
+ function fileFromDrop(event) {
173
+ const items = event.dataTransfer?.files;
174
+ return items && items.length > 0 ? items[0] : null;
175
+ }
176
+ /** True when the drag carries files (not text, a link, or an in-page element). */
177
+ function dragCarriesFile(event) {
178
+ const types = event.dataTransfer?.types;
179
+ return !!types && Array.from(types).includes('Files');
180
+ }
181
+ /**
182
+ * What the attachment contributes to `workspace_context`.
183
+ *
184
+ * Only the KEY and the filename travel — never the bytes, and never anything
185
+ * read out of the file. The planner decides which tool to call from this plus
186
+ * the user's sentence; the server re-derives everything else from the key.
187
+ *
188
+ * The `note` mirrors the `active_page` convention in
189
+ * `pw-brain-chat-context.helpers.ts`: a short instruction telling the model
190
+ * what the context means and which tool consumes it.
191
+ */
192
+ function attachmentContext(attachment) {
193
+ if (!attachment || attachment.status !== 'ready' || !attachment.key) {
194
+ return null;
195
+ }
196
+ return {
197
+ attachment: {
198
+ filename: attachment.name,
199
+ staged_key: attachment.key,
200
+ size_bytes: attachment.size,
201
+ // Named so the planner doesn't have to infer which tool consumes
202
+ // the file — the capability already told us.
203
+ tool: attachment.tool,
204
+ note: 'The user attached this file to the chat. It is already uploaded. ' +
205
+ `To act on it, call ${attachment.tool} with this staged_key. Ask ` +
206
+ 'the user for any details that tool needs and they have not said — ' +
207
+ 'never invent them.'
208
+ }
209
+ };
210
+ }
211
+
212
+ /**
213
+ * How the attachment presents itself. Pure functions of (capabilities,
214
+ * attachment) so the copy is unit-testable without constructing a controller,
215
+ * and so the controller stays inside the 200-line cap.
216
+ */
217
+ const IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'svg'];
218
+ const SHEET_EXTENSIONS = ['csv', 'xls', 'xlsx'];
219
+ /**
220
+ * Named after the KIND of file accepted, not the tool.
221
+ *
222
+ * A descriptor `title` is an action ("Set Your Profile Picture"), so framing
223
+ * it as "Drop your {title}" produces "Drop your set your profile picture".
224
+ * The extension set is the honest signal for what to call the thing, and it
225
+ * degrades to a generic label whenever the types are mixed.
226
+ */
227
+ function dropzoneLabel(capabilities) {
228
+ const extensions = acceptedExtensions(capabilities);
229
+ if (extensions.length === 0) {
230
+ return 'Drop a file';
231
+ }
232
+ if (extensions.every(e => IMAGE_EXTENSIONS.includes(e))) {
233
+ return 'Drop an image';
234
+ }
235
+ if (extensions.every(e => SHEET_EXTENSIONS.includes(e))) {
236
+ return 'Drop a spreadsheet';
237
+ }
238
+ return 'Drop a file';
239
+ }
240
+ function dropzoneHint(capabilities) {
241
+ const exts = acceptedExtensions(capabilities)
242
+ .map(e => e.toUpperCase())
243
+ .join(', ');
244
+ const cap = Math.max(0, ...capabilities.map(c => c.max_bytes));
245
+ return `${exts} · up to ${formatFileSize(cap)}`;
246
+ }
247
+ function acceptAttribute(capabilities) {
248
+ return acceptedExtensions(capabilities)
249
+ .map(e => `.${e}`)
250
+ .join(',');
251
+ }
252
+ function attachmentMeta(attachment) {
253
+ if (!attachment) {
254
+ return '';
255
+ }
256
+ if (attachment.status === 'error') {
257
+ return attachment.error ?? 'Upload failed.';
258
+ }
259
+ const size = formatFileSize(attachment.size);
260
+ if (attachment.status === 'choosing') {
261
+ return `Not uploaded yet · ${size}`;
262
+ }
263
+ // Name the action the file is for, so a wrong pick is visible before sending.
264
+ const action = attachment.title ? ` · ${attachment.title}` : '';
265
+ return attachment.status === 'uploading'
266
+ ? `Uploading… ${attachment.percent}%${action} · ${size}`
267
+ : `Ready${action} · ${size}`;
268
+ }
269
+ /** Fontawesome glyph matching the file type (AI62: FA only). */
270
+ function attachmentIcon(attachment) {
271
+ if (!attachment) {
272
+ return 'fa-file';
273
+ }
274
+ if (attachment.status === 'error') {
275
+ return 'fa-triangle-exclamation';
276
+ }
277
+ const ext = fileExtension(attachment.name);
278
+ if (ext === 'csv')
279
+ return 'fa-file-csv';
280
+ if (['xls', 'xlsx'].includes(ext))
281
+ return 'fa-file-excel';
282
+ if (['png', 'jpg', 'jpeg', 'gif', 'webp', 'svg'].includes(ext))
283
+ return 'fa-file-image';
284
+ return 'fa-file';
285
+ }
286
+ /** Names what WAS dropped and what would be accepted, not just "invalid". */
287
+ function unsupportedFileMessage(file, capabilities) {
288
+ const ext = fileExtension(file.name);
289
+ const accepted = acceptedExtensions(capabilities).join(', ');
290
+ return ext
291
+ ? `.${ext} files aren't accepted here — try ${accepted}.`
292
+ : `That file type isn't accepted here — try ${accepted}.`;
293
+ }
294
+
295
+ function routeUpload(file, capabilities) {
296
+ const ext = fileExtension(file.name);
297
+ const matching = capabilities.filter(c => c.allowed_extensions.includes(ext));
298
+ if (!matching.length) {
299
+ return { kind: 'rejected', message: unsupportedFileMessage(file, capabilities) };
300
+ }
301
+ // A tool whose size cap the file breaks is not a real option.
302
+ const fitting = matching.filter(c => !validateChatFile(file, c));
303
+ if (!fitting.length) {
304
+ return { kind: 'rejected', message: validateChatFile(file, matching[0]) };
305
+ }
306
+ return fitting.length === 1
307
+ ? { kind: 'single', capability: fitting[0] }
308
+ : { kind: 'choose', options: fitting };
309
+ }
310
+ /** Button text: the tool's advertised title is an action ("Set Your Profile Picture"). */
311
+ function choiceLabel(capability) {
312
+ return capability.title?.trim() || capability.tool;
313
+ }
314
+ /** The file held back while the user picks, and what they may pick from. */
315
+ class BrainChatUploadChoice {
316
+ constructor() {
317
+ this.file = null;
318
+ this.options = [];
319
+ }
320
+ offer(file, options) {
321
+ this.file = file;
322
+ this.options = options;
323
+ }
324
+ /** The held file, if `capability` is one of the offered options. */
325
+ take(capability) {
326
+ const file = this.options.includes(capability) ? this.file : null;
327
+ if (file) {
328
+ this.clear();
329
+ }
330
+ return file;
331
+ }
332
+ clear() {
333
+ this.file = null;
334
+ this.options = [];
335
+ }
336
+ }
337
+
338
+ /**
339
+ * Drag state for the panel-wide drop target.
340
+ *
341
+ * Separate from the attachment controller because it is purely about pointer
342
+ * events — no upload, no capabilities — and because keeping it here leaves the
343
+ * controller inside the 200-line cap.
344
+ */
345
+ class BrainChatDragTracker {
346
+ constructor(enabled, onChange) {
347
+ this.enabled = enabled;
348
+ this.onChange = onChange;
349
+ this.active = false;
350
+ }
351
+ enter(event) {
352
+ if (!this.enabled() || !dragCarriesFile(event)) {
353
+ return;
354
+ }
355
+ event.preventDefault();
356
+ this.active = true;
357
+ this.onChange();
358
+ }
359
+ /** Must preventDefault or the browser navigates away to the file. */
360
+ over(event) {
361
+ if (!this.enabled() || !dragCarriesFile(event)) {
362
+ return;
363
+ }
364
+ event.preventDefault();
365
+ }
366
+ leave(event) {
367
+ // dragleave fires for every child crossed, so only the pointer
368
+ // genuinely exiting the panel should clear the overlay.
369
+ if (event.relatedTarget &&
370
+ event.currentTarget.contains(event.relatedTarget)) {
371
+ return;
372
+ }
373
+ this.active = false;
374
+ this.onChange();
375
+ }
376
+ /** @returns the dropped file, or null when the drop carried none. */
377
+ drop(event) {
378
+ if (!this.enabled()) {
379
+ return null;
380
+ }
381
+ event.preventDefault();
382
+ this.active = false;
383
+ return fileFromDrop(event);
384
+ }
385
+ reset() {
386
+ this.active = false;
387
+ }
388
+ }
389
+
390
+ /**
391
+ * The two network concerns of an attachment — discovering what may be
392
+ * attached, and sending the bytes — kept out of the controller so it stays
393
+ * inside the 200-line cap and remains readable as pure state.
394
+ */
395
+ /**
396
+ * Discovery is best-effort: a failure yields an EMPTY capability list, so the
397
+ * panel shows no upload affordance rather than a broken one, and the chat
398
+ * still works. Only capabilities whose service the host app can actually reach
399
+ * are kept — one we have no client for would advertise an upload with nowhere
400
+ * to go.
401
+ */
402
+ function discoverCapabilities(opts) {
403
+ opts.source.pipe(takeUntil(opts.destroy$)).subscribe({
404
+ next: response => opts.onResolved((response.uploads ?? []).filter(c => !!opts.apis[c.service])),
405
+ error: () => opts.onResolved([])
406
+ });
407
+ }
408
+ /**
409
+ * Sends the bytes straight to the owning service — never through brain-api,
410
+ * which advertises the capability but must not carry files. Size-routed by
411
+ * DirectUploadService: small files through the API, large ones direct to S3.
412
+ */
413
+ function sendUpload(opts) {
414
+ opts.uploads
415
+ .uploadBySize(opts.api, {
416
+ purpose: opts.capability.purpose,
417
+ file: opts.file,
418
+ subscriptionId: opts.subscriptionId
419
+ })
420
+ .subscribe({
421
+ next: event => event.kind === 'progress'
422
+ ? opts.onProgress(event.percent)
423
+ : opts.onStaged(event.key),
424
+ error: () => opts.onError()
425
+ });
426
+ }
427
+ /**
428
+ * Upload ``file`` for ``capability`` and reflect progress on the attachment
429
+ * ``current()`` returns. Guarded on every callback: the chip may have been
430
+ * removed mid-flight.
431
+ */
432
+ function stageInto(p) {
433
+ const update = (patch) => {
434
+ const attachment = p.current();
435
+ if (attachment) {
436
+ Object.assign(attachment, patch);
437
+ p.changed();
438
+ }
439
+ };
440
+ if (!p.uploads || !p.api || p.subscriptionId == null) {
441
+ update({
442
+ status: 'error',
443
+ error: 'We could not work out which subscription to upload this to.'
444
+ });
445
+ return;
446
+ }
447
+ sendUpload({
448
+ uploads: p.uploads,
449
+ api: p.api,
450
+ capability: p.capability,
451
+ file: p.file,
452
+ subscriptionId: p.subscriptionId,
453
+ onProgress: percent => update({ percent }),
454
+ onStaged: key => update({ percent: 100, status: 'ready', key }),
455
+ onError: () => update({
456
+ status: 'error',
457
+ error: 'That upload did not complete. Try attaching it again.'
458
+ })
459
+ });
460
+ }
461
+
462
+ /**
463
+ * Owns the composer's file attachment: drag state, the upload, and the single
464
+ * staged file. Split out of the component the same way BrainChatDictation and
465
+ * BrainChatVoiceChat are, so the panel stays composable and this is testable
466
+ * without a TestBed.
467
+ *
468
+ * What it may accept is DISCOVERED, not configured: brain-api reports the
469
+ * upload-capable tools this caller can reach, each carrying its own purpose,
470
+ * extensions and size cap. So a product gains a drop affordance by shipping a
471
+ * tool that advertises one — with no change here and none in the host app
472
+ * beyond naming its API.
473
+ */
474
+ class BrainChatAttachment {
475
+ constructor(uploads, apis, subscriptionId, onChange) {
476
+ this.uploads = uploads;
477
+ this.apis = apis;
478
+ this.subscriptionId = subscriptionId;
479
+ this.onChange = onChange;
480
+ this.current = null;
481
+ this.drag = new BrainChatDragTracker(() => this.enabled, () => this.onChange());
482
+ this.capabilities = [];
483
+ this.choice = new BrainChatUploadChoice();
484
+ }
485
+ discover(source, destroy$) {
486
+ if (!this.uploads || !this.apis) {
487
+ return;
488
+ }
489
+ discoverCapabilities({
490
+ source,
491
+ destroy$,
492
+ apis: this.apis,
493
+ onResolved: capabilities => {
494
+ this.capabilities = capabilities;
495
+ this.onChange();
496
+ }
497
+ });
498
+ }
499
+ get enabled() {
500
+ return this.capabilities.length > 0;
501
+ }
502
+ get busy() {
503
+ return this.current?.status === 'uploading';
504
+ }
505
+ /** Several tools accept the file; nothing is uploaded until one is picked. */
506
+ get choosing() {
507
+ return this.current?.status === 'choosing';
508
+ }
509
+ get choices() {
510
+ return this.choice.options;
511
+ }
512
+ choiceLabel(capability) {
513
+ return choiceLabel(capability);
514
+ }
515
+ get ready() {
516
+ return this.current?.status === 'ready';
517
+ }
518
+ get context() {
519
+ return attachmentContext(this.current);
520
+ }
521
+ get label() {
522
+ return dropzoneLabel(this.capabilities);
523
+ }
524
+ get hint() {
525
+ return dropzoneHint(this.capabilities);
526
+ }
527
+ get acceptAttr() {
528
+ return acceptAttribute(this.capabilities);
529
+ }
530
+ get dragActive() {
531
+ return this.drag.active;
532
+ }
533
+ dragEnter(event) {
534
+ this.drag.enter(event);
535
+ }
536
+ dragOver(event) {
537
+ this.drag.over(event);
538
+ }
539
+ dragLeave(event) {
540
+ this.drag.leave(event);
541
+ }
542
+ drop(event) {
543
+ const file = this.drag.drop(event);
544
+ if (file) {
545
+ this.accept(file);
546
+ }
547
+ else {
548
+ this.onChange();
549
+ }
550
+ }
551
+ /** Shared by the drop target and the paperclip file input. */
552
+ accept(file) {
553
+ const route = routeUpload(file, this.capabilities);
554
+ this.choice.clear();
555
+ this.current = { name: file.name, size: file.size, percent: 0, status: 'choosing' };
556
+ if (route.kind === 'rejected') {
557
+ Object.assign(this.current, { status: 'error', error: route.message });
558
+ }
559
+ else if (route.kind === 'choose') {
560
+ this.choice.offer(file, route.options);
561
+ }
562
+ else {
563
+ this.upload(file, route.capability);
564
+ }
565
+ this.onChange();
566
+ }
567
+ /** The user picked which tool this file is for — only now is it uploaded. */
568
+ choose(capability) {
569
+ const file = this.choice.take(capability);
570
+ if (file) {
571
+ this.upload(file, capability);
572
+ this.onChange();
573
+ }
574
+ }
575
+ remove() {
576
+ this.choice.clear();
577
+ this.current = null;
578
+ this.drag.reset();
579
+ this.onChange();
580
+ }
581
+ /** Cleared after a send so the file travels with exactly one message. */
582
+ clearAfterSend() {
583
+ if (this.ready) {
584
+ this.current = null;
585
+ }
586
+ }
587
+ meta() {
588
+ return attachmentMeta(this.current);
589
+ }
590
+ icon() {
591
+ return attachmentIcon(this.current);
592
+ }
593
+ upload(file, capability) {
594
+ if (this.current) {
595
+ const chosen = {
596
+ status: 'uploading',
597
+ tool: capability.tool,
598
+ title: choiceLabel(capability)
599
+ };
600
+ Object.assign(this.current, chosen);
601
+ }
602
+ stageInto({
603
+ uploads: this.uploads,
604
+ api: this.apis?.[capability.service],
605
+ subscriptionId: this.subscriptionId(),
606
+ capability,
607
+ file,
608
+ current: () => this.current,
609
+ changed: () => this.onChange()
610
+ });
611
+ }
612
+ }
613
+
130
614
  /**
131
615
  * Builds the assistant bubble that carries a pending-confirmation card
132
616
  * from a `needs_confirmation` orchestrator envelope. Extracted from
@@ -601,6 +1085,23 @@ function stickThreadToBottom(getEl, force) {
601
1085
  }, 0);
602
1086
  }
603
1087
 
1088
+ /**
1089
+ * Which product API to POST bytes to, keyed by the service name the tool
1090
+ * catalog reports (e.g. `'cloudolive-api'`, `'main-api'`).
1091
+ *
1092
+ * This is the ONE thing discovery cannot supply. Everything else about an
1093
+ * upload — the purpose, the accepted extensions, the size cap, which tool
1094
+ * consumes it — is advertised by the tool itself via `posiwise.upload` and
1095
+ * fetched from brain-api, so no frontend restates limits the owning service
1096
+ * already enforces. But the file goes STRAIGHT to the owning service rather
1097
+ * than through brain-api (bytes must never transit the chat pipeline), and
1098
+ * only the host app knows how to reach its own APIs.
1099
+ *
1100
+ * A service the map doesn't cover is simply not offered: the affordance is
1101
+ * hidden rather than advertised-then-broken.
1102
+ */
1103
+ const BRAIN_CHAT_UPLOAD_APIS = new InjectionToken('BRAIN_CHAT_UPLOAD_APIS');
1104
+
604
1105
  // Voice Chat state vocabulary + status copy + visual mapping — extracted from
605
1106
  // the BrainChatVoiceChat controller so it stays under the C1 line cap. The
606
1107
  // controller re-exports the types, so external import sites are unchanged.
@@ -1415,6 +1916,9 @@ const SUBSCRIPTION_SCOPED_SEGMENTS = new Set([
1415
1916
  'hyperdashboard',
1416
1917
  'paas',
1417
1918
  'crm',
1919
+ // CloudOlive's product pages (cloudolive-frontend dashboard-routing.module.ts `:slug/cloudolive`);
1920
+ // no unscoped `/cloudolive` route exists, so prefixing cannot break a valid path.
1921
+ 'cloudolive',
1418
1922
  'enterprise',
1419
1923
  'faq',
1420
1924
  'documentation'
@@ -1743,7 +2247,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImpo
1743
2247
  // Brain chat panel — posts to brain-api's MCP orchestrator; thread +
1744
2248
  // conversation_id persist per-user in localStorage (#4167).
1745
2249
  class PwBrainChatComponent {
1746
- constructor(orchestrator, localStorage, router, cdr, store, dynamicPageCtx, appConfigService, brainSocket, brainVoice, voiceChatService) {
2250
+ constructor(orchestrator, localStorage, router, cdr, store, dynamicPageCtx, appConfigService, brainSocket, brainVoice, voiceChatService, directUpload, uploadApis) {
1747
2251
  this.orchestrator = orchestrator;
1748
2252
  this.localStorage = localStorage;
1749
2253
  this.router = router;
@@ -1754,6 +2258,8 @@ class PwBrainChatComponent {
1754
2258
  this.brainSocket = brainSocket;
1755
2259
  this.brainVoice = brainVoice;
1756
2260
  this.voiceChatService = voiceChatService;
2261
+ this.directUpload = directUpload;
2262
+ this.uploadApis = uploadApis;
1757
2263
  this.messages = [];
1758
2264
  this.draft = '';
1759
2265
  this.loading = false;
@@ -1771,14 +2277,19 @@ class PwBrainChatComponent {
1771
2277
  this.draft = text;
1772
2278
  }, () => this.cdr.markForCheck());
1773
2279
  this.voiceChat = new BrainChatVoiceChat(this.voiceChatService, () => this.cdr.markForCheck(), (userText, replyText) => this.recordVoiceTurn(userText, replyText));
2280
+ this.attachment = new BrainChatAttachment(this.directUpload ?? null, this.uploadApis ?? null, () => PermissionService.selectedSubscription?.id ?? null, () => this.cdr.markForCheck());
1774
2281
  }
1775
2282
  ngOnInit() {
2283
+ // What may be attached is discovered from the federated tool catalog,
2284
+ // not configured here — see BRAIN_CHAT_UPLOAD_APIS. Best-effort: a
2285
+ // failure simply leaves the panel with no upload affordance.
2286
+ this.attachment.discover(this.orchestrator.capabilities(), this.destroy$);
1776
2287
  // Personalise the welcome greeting with the signed-in user's first name
1777
2288
  // (AuthService persists it to native localStorage 'name' at login);
1778
2289
  // absent/blank → the greeting stays the plain "Hi, I'm your … Brain".
1779
2290
  this.userFirstName = localStorage.getItem('name')?.trim() || undefined;
1780
2291
  // White-label brand for placeholder + error text (domain company.name).
1781
- this.appConfigService?.appConfig$.pipe(take(1), takeUntil(this.destroy$)).subscribe(c => {
2292
+ this.appConfigService?.appConfig$.pipe(take(1), takeUntil$1(this.destroy$)).subscribe(c => {
1782
2293
  this.brandName = resolveBrandName(c);
1783
2294
  this.cdr.markForCheck();
1784
2295
  });
@@ -1788,7 +2299,7 @@ class PwBrainChatComponent {
1788
2299
  // Wait for the authenticated user before hydrating — a bare take(1)
1789
2300
  // races currentUser=null and orphans the thread (#4167).
1790
2301
  this.store
1791
- .pipe(map(app => app?.user?.currentUser ?? null), filter((user) => !!user && user.id != null), take(1), takeUntil(this.destroy$))
2302
+ .pipe(map(app => app?.user?.currentUser ?? null), filter((user) => !!user && user.id != null), take(1), takeUntil$1(this.destroy$))
1792
2303
  .subscribe(user => {
1793
2304
  this.storage = new BrainChatPersistence(this.localStorage, String(user.id));
1794
2305
  const hydrated = this.storage.readMessages();
@@ -1813,7 +2324,7 @@ class PwBrainChatComponent {
1813
2324
  subscribeToServerPush() {
1814
2325
  this.brainSocket
1815
2326
  ?.messages$()
1816
- .pipe(takeUntil(this.destroy$))
2327
+ .pipe(takeUntil$1(this.destroy$))
1817
2328
  .subscribe(message => {
1818
2329
  this.pushAssistant(message.text, true);
1819
2330
  this.cdr.markForCheck();
@@ -1825,25 +2336,51 @@ class PwBrainChatComponent {
1825
2336
  this.destroy$.next();
1826
2337
  this.destroy$.complete();
1827
2338
  }
2339
+ /**
2340
+ * Paperclip path. The input is reset after every pick so choosing the same
2341
+ * file twice in a row still fires `change` (the browser suppresses it
2342
+ * otherwise, and "nothing happened" is a maddening bug to hit).
2343
+ */
2344
+ pickFile(input) {
2345
+ const file = input.files?.[0];
2346
+ input.value = '';
2347
+ if (file) {
2348
+ this.attachment.accept(file);
2349
+ }
2350
+ }
1828
2351
  send() {
1829
- const text = this.draft.trim();
1830
- if (!text || this.loading) {
2352
+ // A dropped file is a message on its own — the user should not have to
2353
+ // type something to send it. An upload still in flight blocks the send
2354
+ // rather than racing it, so the staged key is always present. A file
2355
+ // still waiting for "which tool?" blocks it too — sending would drop it.
2356
+ const typed = this.draft.trim();
2357
+ const staged = this.attachment.current;
2358
+ const held = this.attachment.busy || this.attachment.choosing;
2359
+ if ((!typed && !this.attachment.ready) || this.loading || held) {
1831
2360
  return;
1832
2361
  }
2362
+ const text = typed || `${staged?.title ?? 'Use this file'}: ${staged?.name ?? ''}`;
1833
2363
  this.draft = '';
1834
2364
  this.messages.push({ role: 'user', text, at: Date.now() });
1835
2365
  this.storage?.persistMessages(this.messages);
1836
2366
  this.loading = true;
1837
2367
  this.cdr.markForCheck();
1838
2368
  this.stick(true);
1839
- const workspace_context = buildWorkspaceContext(this.router, this.dynamicPageCtx.current, PermissionService.selectedSubscription?.id ?? null);
2369
+ const workspace_context = {
2370
+ ...buildWorkspaceContext(this.router, this.dynamicPageCtx.current, PermissionService.selectedSubscription?.id ?? null),
2371
+ // Only the staging key and filename — never the bytes, and nothing
2372
+ // read out of the file. Null when nothing is attached.
2373
+ ...(this.attachment.context ?? {})
2374
+ };
2375
+ // One file travels with one message; the chip clears as the message goes.
2376
+ this.attachment.clearAfterSend();
1840
2377
  this.streamSub = this.orchestrator
1841
2378
  .executeStream({
1842
2379
  message: text,
1843
2380
  workspace_context,
1844
2381
  conversation_id: this.conversationId ?? undefined
1845
2382
  })
1846
- .pipe(takeUntil(this.destroy$))
2383
+ .pipe(takeUntil$1(this.destroy$))
1847
2384
  .subscribe({
1848
2385
  next: (event) => {
1849
2386
  if (event.type === 'stage') {
@@ -1888,7 +2425,7 @@ class PwBrainChatComponent {
1888
2425
  confirmation_token: token,
1889
2426
  conversation_id: this.conversationId ?? undefined
1890
2427
  })
1891
- .pipe(takeUntil(this.destroy$))
2428
+ .pipe(takeUntil$1(this.destroy$))
1892
2429
  .subscribe({
1893
2430
  next: response => this.handleExecuteResponse(response),
1894
2431
  error: err => this.handleError(err)
@@ -2011,12 +2548,12 @@ class PwBrainChatComponent {
2011
2548
  stick(force) {
2012
2549
  stickThreadToBottom(() => this.threadRef?.nativeElement, force);
2013
2550
  }
2014
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: PwBrainChatComponent, deps: [{ token: i1.MCPOrchestratorService }, { token: i1.LocalStorage }, { token: i2.Router }, { token: i0.ChangeDetectorRef }, { token: i3.Store }, { token: DynamicPageContextService }, { token: i2$1.AppConfigService, optional: true }, { token: i1.BrainSocketService, optional: true }, { token: i1.BrainVoiceService, optional: true }, { token: i1.VoiceChatService, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
2015
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.19", type: PwBrainChatComponent, isStandalone: false, selector: "pw-brain-chat", viewQueries: [{ propertyName: "threadRef", first: true, predicate: ["thread"], descendants: true }], ngImport: i0, template: "<div class=\"pw-brain-chat\">\n <!-- The sidebar host header owns title + close + live status + New chat\n (SidebarContent.status / headerActions) \u2014 so the panel body starts at\n the thread, no duplicate status strip. newChat() is invoked from the\n host header action. -->\n <div #thread pwBrainChatThread class=\"pw-brain-chat__thread\" role=\"log\" aria-live=\"polite\">\n @if (messages.length <= 1 && !loading && !streamingProse) {\n <pw-brain-chat-welcome\n [userFirstName]=\"userFirstName\"\n [prompts]=\"suggestedPrompts\"\n (pick)=\"usePrompt($event)\"\n ></pw-brain-chat-welcome>\n } @else {\n @for (m of messages; track trackByIndex($index, m)) {\n @if (m.role === 'user') {\n <div class=\"pw-brain-chat__turn pw-brain-chat__turn--user\">\n <div class=\"pw-brain-chat__user-bubble\"><pre class=\"pw-brain-chat__user-text\">{{ m.text }}</pre></div>\n @if (m.at) {\n <span class=\"pw-brain-chat__time\">{{ m.at | date: 'shortTime' }}</span>\n }\n </div>\n } @else {\n <div class=\"pw-brain-chat__turn pw-brain-chat__turn--bot\">\n <div class=\"pw-brain-chat__spine\" aria-hidden=\"true\">\n <span class=\"pw-brain-chat__node\"><i class=\"fas fa-brain\"></i></span>\n <span class=\"pw-brain-chat__line\"></span>\n </div>\n <div class=\"pw-brain-chat__artifacts\">\n <span class=\"pw-brain-chat__who\">\n {{ brandName }} Brain\n @if (m.at) {\n <span class=\"pw-brain-chat__time\">\u00B7 {{ m.at | date: 'shortTime' }}</span>\n }\n </span>\n <div class=\"pw-brain-chat__bubble\">\n @if (m.markdownEnabled) {\n <div class=\"pw-brain-chat__text\" [innerHTML]=\"m.text | safeMarkdown\"></div>\n } @else {\n <pre class=\"pw-brain-chat__text\">{{ m.text }}</pre>\n }\n </div>\n @if (m.sourcePage) {\n <div class=\"pw-brain-chat__source\" role=\"note\">\n <i class=\"fas fa-file-lines pw-brain-chat__source-icon\" aria-hidden=\"true\"></i>\n <span class=\"pw-brain-chat__source-text\">Documented on: {{ m.sourcePage }}</span>\n </div>\n }\n @if (m.pending) {\n <pw-brain-chat-confirm\n [pending]=\"m.pending\"\n [loading]=\"loading\"\n (approveEvent)=\"approve(m)\"\n (cancelEvent)=\"cancel(m)\"\n ></pw-brain-chat-confirm>\n }\n </div>\n </div>\n }\n }\n }\n\n @if (loading && streamingProse) {\n <!-- prose streams token-by-token into a partial bot turn; caret = writing (#51) -->\n <div class=\"pw-brain-chat__turn pw-brain-chat__turn--bot\">\n <div class=\"pw-brain-chat__spine\" aria-hidden=\"true\">\n <span class=\"pw-brain-chat__node\"><i class=\"fas fa-brain\"></i></span>\n <span class=\"pw-brain-chat__line\"></span>\n </div>\n <div class=\"pw-brain-chat__artifacts\">\n <span class=\"pw-brain-chat__who\">{{ brandName }} Brain</span>\n <div class=\"pw-brain-chat__bubble\">\n <pre class=\"pw-brain-chat__text\"\n >{{ streamingProse }}<span class=\"pw-brain-chat__caret\" aria-hidden=\"true\"></span></pre>\n </div>\n </div>\n </div>\n }\n </div>\n\n @if (loading && !streamingProse) {\n <div class=\"pw-brain-chat__loading\">\n <i class=\"fas fa-circle-notch fa-spin pw-brain-chat__loading-spinner\" aria-hidden=\"true\"></i>\n <span aria-live=\"polite\">{{ streamingStage || 'Working\u2026' }}</span>\n <button type=\"button\" class=\"pw-brain-chat__iconbtn pw-brain-chat__stop\" (click)=\"cancelRequest()\"\n [ngbTooltip]=\"'Stop request'\" container=\"body\" aria-label=\"Stop request\">\n <i class=\"fas fa-stop\" aria-hidden=\"true\"></i>\n </button>\n </div>\n }\n\n <!-- Voice session / dictation \u2192 animated Sonar overlay (#51) -->\n @if (voiceChat.isActive || voiceChat.error || dictation.phase === 'listening' || dictation.phase === 'processing' || dictation.error) {\n <pw-brain-chat-voice-overlay\n [voice]=\"voiceChat\"\n [dictation]=\"dictation\"\n (end)=\"voiceChat.isActive || voiceChat.error ? voiceChat.stop() : dictation.dismiss()\"\n ></pw-brain-chat-voice-overlay>\n }\n\n <div class=\"pw-brain-chat__compose\">\n @if (messages.length > 1) {\n <div class=\"pw-brain-chat__quick\">\n @for (q of quickActions; track q.text) {\n <button type=\"button\" class=\"pw-brain-chat__chip\" (click)=\"usePrompt(q.text)\">\n <i class=\"fas\" [ngClass]=\"q.icon\" aria-hidden=\"true\"></i>{{ q.label }}\n </button>\n }\n </div>\n }\n <label class=\"visually-hidden\" for=\"pw-brain-chat-input\">Message {{ brandName }} Brain</label>\n <div class=\"pw-brain-chat__field\">\n <textarea\n id=\"pw-brain-chat-input\"\n class=\"pw-brain-chat__input\"\n rows=\"1\"\n [(ngModel)]=\"draft\"\n placeholder=\"Ask a question or tell me what to do\u2026\"\n (keydown.enter)=\"$event.preventDefault(); send()\"\n\n aria-label=\"Ask a question or tell me what to do\u2026\" ></textarea>\n <div class=\"pw-brain-chat__tools\">\n <button\n type=\"button\"\n class=\"pw-brain-chat__iconbtn pw-brain-chat__mic\"\n [class.pw-brain-chat__mic--recording]=\"dictation.isRecording\"\n [disabled]=\"loading || dictation.phase === 'processing'\"\n (click)=\"dictation.toggle(loading)\"\n [ngbTooltip]=\"dictation.phase === 'listening' ? 'Stop dictation' : (dictation.phase === 'processing' ? 'Processing\u2026' : 'Dictate')\"\n container=\"body\"\n [attr.aria-label]=\"dictation.phase === 'listening' ? 'Stop dictation' : 'Dictate with your voice'\"\n [attr.aria-pressed]=\"dictation.isRecording\"\n ><i class=\"fas fa-microphone\" aria-hidden=\"true\"></i></button>\n @if (voiceChat.available) {\n <button\n type=\"button\"\n class=\"pw-brain-chat__iconbtn\"\n [disabled]=\"loading || dictation.isRecording\"\n (click)=\"voiceChat.toggle(loading)\"\n [ngbTooltip]=\"voiceChat.isActive ? 'End voice chat' : 'Voice chat'\"\n container=\"body\"\n [attr.aria-label]=\"voiceChat.isActive ? 'End voice chat' : 'Start voice chat'\"\n [attr.aria-pressed]=\"voiceChat.isActive\"\n >\n @switch (voiceChat.visual) {\n @case ('loader') { <i class=\"fas fa-circle-notch fa-spin\" aria-hidden=\"true\"></i> }\n @case ('wave') { <i class=\"fas fa-volume-high\" aria-hidden=\"true\"></i> }\n <!-- fa-waveform-lines (FA Pro, shipped in assets/fontawesome) \u2014 the\n canonical \"voice mode\" glyph; fa-comment-dots read as a second\n text-chat button. -->\n @default { <i class=\"fas fa-waveform-lines\" aria-hidden=\"true\"></i> }\n }\n </button>\n }\n <button\n type=\"button\"\n class=\"pw-brain-chat__send\"\n [class.pw-brain-chat__send--stop]=\"loading\"\n [disabled]=\"!loading && !draft.trim()\"\n (click)=\"loading ? cancelRequest() : send()\"\n [ngbTooltip]=\"loading ? 'Stop request' : 'Send message'\"\n container=\"body\"\n [attr.aria-label]=\"loading ? 'Stop request' : 'Send message'\"\n >\n <i class=\"fas\" [ngClass]=\"loading ? 'fa-stop' : 'fa-paper-plane'\" aria-hidden=\"true\"></i>\n </button>\n </div>\n </div>\n <div class=\"pw-brain-chat__disclaimer\" role=\"note\">\n <i class=\"fas fa-triangle-exclamation\" aria-hidden=\"true\"></i>\n AI may be inaccurate \u2014 verify before acting.\n </div>\n </div>\n</div>\n", styles: [".pw-brain-chat{--bc-panel: var(--dashboard_bg, #fff);--bc-shade: #20385e;--bc-surface: color-mix(in srgb, var(--bc-panel) 96.6%, var(--bc-shade));--bc-surface-2: color-mix(in srgb, var(--bc-panel) 92.3%, var(--bc-shade));--bc-line: color-mix(in srgb, var(--bc-panel) 86.8%, var(--bc-shade));--bc-line-strong: color-mix(in srgb, var(--bc-panel) 78.3%, var(--bc-shade));--bc-bubble: color-mix(in srgb, var(--bc-panel) 94.1%, var(--bc-shade));--bc-ink: var(--text, #1a1d21);--bc-title: var(--titles, var(--text, #1a1d21));--bc-ink-2: color-mix(in srgb, var(--bc-ink) 72%, var(--bc-panel));--bc-ink-3: color-mix(in srgb, var(--bc-ink) 55%, var(--bc-panel));--bc-accent: var(--first, #1769e1);--bc-accent-wash: color-mix(in srgb, var(--first, #1769e1) 10%, transparent);--bc-accent-line: color-mix(in srgb, var(--first, #1769e1) 32%, var(--bc-line));--bc-success: #1f9d57;--bc-warning: #b7791f;--bc-error: #c0392b;--bc-r-sm: 4px;--bc-r-md: 8px;--bc-r-lg: 12px;--bc-ease: cubic-bezier(.2, .6, .25, 1);display:flex;flex-direction:column;height:100%;min-height:0;font-size:15px;color:var(--bc-ink);position:relative}:host-context([data-theme=dark]) .pw-brain-chat{--bc-panel: #15181d;--bc-surface: #1c2026;--bc-surface-2: #21262e;--bc-line: #2a2f38;--bc-line-strong: #384150;--bc-bubble: #1c2026;--bc-ink: #edeff2;--bc-title: #edeff2;--bc-ink-2: #aab3c0;--bc-ink-3: #7c8696}.pw-brain-chat__thread{flex:1 1 auto;min-height:0;overflow-y:auto;padding:16px 2px 8px;display:flex;flex-direction:column;gap:18px}.pw-brain-chat__thread>:first-child{margin-top:auto}.pw-brain-chat__turn--bot{display:grid;grid-template-columns:26px 1fr;column-gap:10px}.pw-brain-chat__spine{display:flex;flex-direction:column;align-items:center}.pw-brain-chat__node{width:26px;height:26px;border-radius:8px;flex:none;display:grid;place-items:center;background:var(--bc-surface);border:1px solid var(--bc-line);color:var(--bc-ink-2)}.pw-brain-chat__node i{font-size:12px}.pw-brain-chat__line{flex:1 1 auto;width:2px;margin-top:6px;background:var(--bc-line);border-radius:9999px}.pw-brain-chat__artifacts{min-width:0;display:flex;flex-direction:column;gap:9px;padding-top:1px}.pw-brain-chat__who{font-size:11px;text-transform:uppercase;letter-spacing:.11em;color:var(--bc-ink-3);font-weight:600}.pw-brain-chat__bubble{background:var(--bc-bubble);border:1px solid var(--bc-line);border-radius:var(--bc-r-md);padding:10px 13px}.pw-brain-chat__source{display:inline-flex;align-items:center;gap:6px;max-width:100%;margin-top:6px;padding:3px 9px;border:1px solid var(--bc-line);border-radius:var(--bc-r-sm);color:var(--bc-ink-3);font-size:11px;line-height:1.4}.pw-brain-chat__source-icon{flex-shrink:0;font-size:11px}.pw-brain-chat__source-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.pw-brain-chat__turn--user{display:flex;flex-direction:column;align-items:flex-end;gap:3px}.pw-brain-chat__time{font-size:10.5px;font-weight:400;letter-spacing:.02em;color:var(--bc-ink-3);white-space:nowrap}.pw-brain-chat__user-bubble{max-width:82%;background:var(--bc-accent);color:#fff;border-radius:var(--bc-r-md);border-top-right-radius:var(--bc-r-sm);padding:10px 13px;font-size:15px;line-height:1.5}\n", ".pw-brain-chat__welcome{flex:1 1 auto;overflow-y:auto;padding:22px 0 10px;display:flex;flex-direction:column;gap:16px}.pw-brain-chat__hero{width:44px;height:44px;border-radius:12px;display:grid;place-items:center;font-size:22px;color:#fff;background:var(--bc-accent);box-shadow:inset 0 1px #ffffff40}.pw-brain-chat__greet-h{font-size:20px;font-weight:600;letter-spacing:-.02em;margin:12px 0 4px;color:var(--bc-title)}.pw-brain-chat__greet-sub{font-size:14px;color:var(--bc-ink-2);margin:0}.pw-brain-chat__suggest-lab{font-size:11px;text-transform:uppercase;letter-spacing:.11em;color:var(--bc-ink-3);font-weight:600;margin:6px 0 -4px 2px}.pw-brain-chat__prompts{display:flex;flex-direction:column;gap:9px}.pw-brain-chat__prompt{display:flex;align-items:center;gap:11px;width:100%;text-align:left;padding:12px;border-radius:var(--bc-r-md);cursor:pointer;background:var(--bc-panel);border:1px solid var(--bc-line);color:var(--bc-ink);font:inherit;font-size:14px;font-weight:500;transition:border-color .15s var(--bc-ease),background .15s var(--bc-ease)}.pw-brain-chat__prompt:hover{border-color:var(--bc-line-strong);background:var(--bc-surface)}.pw-brain-chat__prompt:focus-visible{outline:2px solid var(--bc-accent);outline-offset:2px}.pw-brain-chat__pic{width:28px;height:28px;border-radius:7px;flex:none;display:grid;place-items:center;background:var(--bc-surface-2);border:1px solid var(--bc-line);color:var(--bc-ink-2)}.pw-brain-chat__pic i{font-size:14px}.pw-brain-chat__prompt-text{flex:1;min-width:0}.pw-brain-chat__arw{margin-left:auto;color:var(--bc-ink-3);font-size:13px}.pw-brain-chat__prompt:hover .pw-brain-chat__arw{color:var(--bc-accent)}.pw-brain-chat__quick{display:flex;gap:7px;margin-bottom:9px;overflow-x:auto;scrollbar-width:none}.pw-brain-chat__quick::-webkit-scrollbar{display:none}.pw-brain-chat__chip{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;flex:none;font:inherit;font-size:12px;font-weight:500;cursor:pointer;padding:6px 11px;border-radius:9999px;background:var(--bc-surface);border:1px solid var(--bc-line);color:var(--bc-ink-2);transition:border-color .15s var(--bc-ease),color .15s var(--bc-ease)}.pw-brain-chat__chip:hover{color:var(--bc-ink);border-color:var(--bc-line-strong)}.pw-brain-chat__chip:focus-visible{outline:2px solid var(--bc-accent);outline-offset:2px}.pw-brain-chat__chip i{font-size:11px;color:var(--bc-ink-3)}.pw-brain-chat__memory{display:inline-flex;align-items:center;gap:8px;align-self:flex-start;padding:7px 11px;border-radius:9999px;background:var(--bc-surface);border:1px solid var(--bc-line);font-size:12px;color:var(--bc-ink-2)}.pw-brain-chat__memory i{color:var(--bc-success);font-size:12px}.pw-brain-chat__memory .lbl{text-transform:uppercase;letter-spacing:.08em;font-size:10px;font-weight:600;color:var(--bc-ink-3)}\n", ".pw-brain-chat__text{margin:0;white-space:pre-wrap;overflow-wrap:break-word;font-family:inherit;font-size:15px;line-height:1.55;color:var(--bc-ink)}.pw-brain-chat__text p{margin:0}.pw-brain-chat__text p+p,.pw-brain-chat__text ul,.pw-brain-chat__text ol{margin-top:7px}.pw-brain-chat__text ul,.pw-brain-chat__text ol{padding-left:18px}.pw-brain-chat__text a{color:var(--bc-ink);text-decoration:underline;text-underline-offset:2px;text-decoration-color:var(--bc-line-strong)}.pw-brain-chat__text a:hover,.pw-brain-chat__text a:focus-visible{color:var(--bc-accent);text-decoration-color:var(--bc-accent)}.pw-brain-chat__text table{width:100%;margin-top:8px;border-collapse:collapse;font-size:13px;border:1px solid var(--bc-line);border-radius:var(--bc-r-md);overflow:hidden}.pw-brain-chat__text th,.pw-brain-chat__text td{text-align:left;padding:8px 12px;border-bottom:1px solid var(--bc-line)}.pw-brain-chat__text th{background:var(--bc-surface);font-weight:600;font-size:11px;letter-spacing:.07em;text-transform:uppercase;color:var(--bc-ink-2)}.pw-brain-chat__text tr:last-child td{border-bottom:0}.pw-brain-chat__user-text{margin:0;white-space:pre-wrap;overflow-wrap:break-word;font-family:inherit;font-size:15px;line-height:1.5}.pw-brain-chat__caret{display:inline-block;width:2px;height:1.05em;vertical-align:-2px;margin-left:2px;background:var(--bc-accent);border-radius:1px;animation:pw-brain-chat-caret 1s steps(2,start) infinite}@keyframes pw-brain-chat-caret{50%{opacity:0}}@media(prefers-reduced-motion:reduce){.pw-brain-chat__caret{animation:none}}\n", ".pw-brain-chat__loading{display:flex;flex-wrap:wrap;align-items:center;gap:10px;padding:4px 2px 0;font-size:12px;color:var(--bc-ink-3, #7c8696)}.pw-brain-chat__loading-spinner{color:var(--bc-accent, #1769e1)}.pw-brain-chat__iconbtn{width:32px;height:32px;flex:none;display:inline-flex;align-items:center;justify-content:center;padding:0;border:1px solid transparent;border-radius:var(--bc-r-md, 8px);background:transparent;color:var(--bc-ink-3, #7c8696);cursor:pointer;transition:background .15s ease,color .15s ease}.pw-brain-chat__iconbtn:hover:not(:disabled){background:var(--bc-surface, #f7f8fa);color:var(--bc-ink, #1a1d21)}.pw-brain-chat__iconbtn:focus-visible{outline:2px solid var(--bc-accent, #1769e1);outline-offset:2px}.pw-brain-chat__iconbtn:disabled{opacity:.5;cursor:default}.pw-brain-chat__mic--recording{color:var(--bc-error, #c0392b)}.pw-brain-chat__stop:hover:not(:disabled){color:var(--bc-error, #c0392b)}.pw-brain-chat__compose{flex-shrink:0;border-top:1px solid var(--bc-line, #e2e5ea);padding:10px 2px 4px}.pw-brain-chat__field{display:flex;align-items:flex-end;gap:8px;border:1px solid var(--bc-line, #e2e5ea);border-radius:var(--bc-r-md, 8px);background:var(--bc-panel, #fff);padding:6px 6px 6px 12px;transition:border-color .15s ease,box-shadow .15s ease}.pw-brain-chat__field:focus-within{border-color:var(--bc-accent, #1769e1);box-shadow:0 0 0 3px var(--bc-accent-wash, rgba(23, 105, 225, .1))}.pw-brain-chat__input{flex:1;border:0;resize:none;background:transparent;font-family:inherit;font-size:14px;line-height:1.5;color:var(--bc-ink, #1a1d21);padding:6px 0;max-height:96px}.pw-brain-chat__input:focus{outline:none;box-shadow:none}.pw-brain-chat__input::placeholder{color:var(--bc-ink-3, #7c8696)}.pw-brain-chat__tools{display:flex;align-items:center;gap:2px;flex:none}.pw-brain-chat__send{width:34px;height:34px;flex:none;display:inline-flex;align-items:center;justify-content:center;border:0;border-radius:var(--bc-r-md, 8px);background:var(--bc-accent, #1769e1);color:#fff;cursor:pointer;transition:filter .15s ease}.pw-brain-chat__send:hover:not(:disabled){filter:brightness(1.07)}.pw-brain-chat__send:disabled{background:var(--bc-line-strong, #cfd4dc);cursor:default}.pw-brain-chat__send:focus-visible{outline:2px solid var(--bc-accent, #1769e1);outline-offset:2px}.pw-brain-chat__send--stop{background:var(--bc-error, #c0392b)!important}.pw-brain-chat__disclaimer{display:flex;align-items:center;gap:6px;margin:8px 2px 2px;font-size:11px;color:var(--bc-ink-3, #7c8696)}\n", ".pw-brain-chat__mic{display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--bs-border-color, #ced4da);background:transparent;color:var(--bs-secondary-color, #6c757d);transition:color .15s ease,border-color .15s ease}.pw-brain-chat__mic:hover:not(:disabled){color:var(--first, #0d6efd);border-color:var(--first, #0d6efd)}.pw-brain-chat__mic--recording{color:#dc3545;border-color:#dc3545;animation:pw-brain-chat-mic-pulse 1.2s ease-in-out infinite}@keyframes pw-brain-chat-mic-pulse{0%,to{opacity:1}50%{opacity:.55}}@media(prefers-reduced-motion:reduce){.pw-brain-chat__mic--recording{animation:none}}\n"], dependencies: [{ kind: "directive", type: i2$2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i5.NgbTooltip, selector: "[ngbTooltip]", inputs: ["animation", "autoClose", "placement", "popperOptions", "triggers", "positionTarget", "container", "disableTooltip", "tooltipClass", "tooltipContext", "openDelay", "closeDelay", "ngbTooltip"], outputs: ["shown", "hidden"], exportAs: ["ngbTooltip"] }, { kind: "directive", type: i8.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: PwBrainChatThreadDirective, selector: "[pwBrainChatThread]" }, { kind: "component", type: PwBrainChatConfirmComponent, selector: "pw-brain-chat-confirm", inputs: ["pending", "loading"], outputs: ["approveEvent", "cancelEvent"] }, { kind: "component", type: PwBrainChatWelcomeComponent, selector: "pw-brain-chat-welcome", inputs: ["userFirstName", "prompts"], outputs: ["pick"] }, { kind: "component", type: PwBrainChatVoiceOverlayComponent, selector: "pw-brain-chat-voice-overlay", inputs: ["voice", "dictation"], outputs: ["end"] }, { kind: "pipe", type: i8.DatePipe, name: "date" }, { kind: "pipe", type: SafeMarkdownPipe, name: "safeMarkdown" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
2551
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: PwBrainChatComponent, deps: [{ token: i1.MCPOrchestratorService }, { token: i1.LocalStorage }, { token: i2.Router }, { token: i0.ChangeDetectorRef }, { token: i3.Store }, { token: DynamicPageContextService }, { token: i2$1.AppConfigService, optional: true }, { token: i1.BrainSocketService, optional: true }, { token: i1.BrainVoiceService, optional: true }, { token: i1.VoiceChatService, optional: true }, { token: i1.DirectUploadService, optional: true }, { token: BRAIN_CHAT_UPLOAD_APIS, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
2552
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.19", type: PwBrainChatComponent, isStandalone: false, selector: "pw-brain-chat", viewQueries: [{ propertyName: "threadRef", first: true, predicate: ["thread"], descendants: true }], ngImport: i0, template: "<div\n class=\"pw-brain-chat\"\n (dragenter)=\"attachment.dragEnter($event)\"\n (dragover)=\"attachment.dragOver($event)\"\n (dragleave)=\"attachment.dragLeave($event)\"\n (drop)=\"attachment.drop($event)\"\n>\n @if (attachment.dragActive) {\n <div class=\"pw-brain-chat__dropzone\" aria-hidden=\"true\">\n <div class=\"pw-brain-chat__dropzone-frame\">\n <i class=\"fas fa-file-arrow-up pw-brain-chat__dropzone-icon\" aria-hidden=\"true\"></i>\n <span class=\"pw-brain-chat__dropzone-title\">{{ attachment.label }}</span>\n <span class=\"pw-brain-chat__dropzone-hint\">{{ attachment.hint }}</span>\n </div>\n </div>\n }\n <!-- The sidebar host header owns title + close + live status + New chat\n (SidebarContent.status / headerActions) \u2014 so the panel body starts at\n the thread, no duplicate status strip. newChat() is invoked from the\n host header action. -->\n <div #thread pwBrainChatThread class=\"pw-brain-chat__thread\" role=\"log\" aria-live=\"polite\">\n @if (messages.length <= 1 && !loading && !streamingProse) {\n <pw-brain-chat-welcome\n [userFirstName]=\"userFirstName\"\n [prompts]=\"suggestedPrompts\"\n (pick)=\"usePrompt($event)\"\n ></pw-brain-chat-welcome>\n } @else {\n @for (m of messages; track trackByIndex($index, m)) {\n @if (m.role === 'user') {\n <div class=\"pw-brain-chat__turn pw-brain-chat__turn--user\">\n <div class=\"pw-brain-chat__user-bubble\"><pre class=\"pw-brain-chat__user-text\">{{ m.text }}</pre></div>\n @if (m.at) {\n <span class=\"pw-brain-chat__time\">{{ m.at | date: 'shortTime' }}</span>\n }\n </div>\n } @else {\n <div class=\"pw-brain-chat__turn pw-brain-chat__turn--bot\">\n <div class=\"pw-brain-chat__spine\" aria-hidden=\"true\">\n <span class=\"pw-brain-chat__node\"><i class=\"fas fa-brain\"></i></span>\n <span class=\"pw-brain-chat__line\"></span>\n </div>\n <div class=\"pw-brain-chat__artifacts\">\n <span class=\"pw-brain-chat__who\">\n {{ brandName }} Brain\n @if (m.at) {\n <span class=\"pw-brain-chat__time\">\u00B7 {{ m.at | date: 'shortTime' }}</span>\n }\n </span>\n <div class=\"pw-brain-chat__bubble\">\n @if (m.markdownEnabled) {\n <div class=\"pw-brain-chat__text\" [innerHTML]=\"m.text | safeMarkdown\"></div>\n } @else {\n <pre class=\"pw-brain-chat__text\">{{ m.text }}</pre>\n }\n </div>\n @if (m.sourcePage) {\n <div class=\"pw-brain-chat__source\" role=\"note\">\n <i class=\"fas fa-file-lines pw-brain-chat__source-icon\" aria-hidden=\"true\"></i>\n <span class=\"pw-brain-chat__source-text\">Documented on: {{ m.sourcePage }}</span>\n </div>\n }\n @if (m.pending) {\n <pw-brain-chat-confirm\n [pending]=\"m.pending\"\n [loading]=\"loading\"\n (approveEvent)=\"approve(m)\"\n (cancelEvent)=\"cancel(m)\"\n ></pw-brain-chat-confirm>\n }\n </div>\n </div>\n }\n }\n }\n\n @if (loading && streamingProse) {\n <!-- prose streams token-by-token into a partial bot turn; caret = writing (#51) -->\n <div class=\"pw-brain-chat__turn pw-brain-chat__turn--bot\">\n <div class=\"pw-brain-chat__spine\" aria-hidden=\"true\">\n <span class=\"pw-brain-chat__node\"><i class=\"fas fa-brain\"></i></span>\n <span class=\"pw-brain-chat__line\"></span>\n </div>\n <div class=\"pw-brain-chat__artifacts\">\n <span class=\"pw-brain-chat__who\">{{ brandName }} Brain</span>\n <div class=\"pw-brain-chat__bubble\">\n <pre class=\"pw-brain-chat__text\"\n >{{ streamingProse }}<span class=\"pw-brain-chat__caret\" aria-hidden=\"true\"></span></pre>\n </div>\n </div>\n </div>\n }\n </div>\n\n @if (loading && !streamingProse) {\n <div class=\"pw-brain-chat__loading\">\n <i class=\"fas fa-circle-notch fa-spin pw-brain-chat__loading-spinner\" aria-hidden=\"true\"></i>\n <span aria-live=\"polite\">{{ streamingStage || 'Working\u2026' }}</span>\n <button type=\"button\" class=\"pw-brain-chat__iconbtn pw-brain-chat__stop\" (click)=\"cancelRequest()\"\n [ngbTooltip]=\"'Stop request'\" container=\"body\" aria-label=\"Stop request\">\n <i class=\"fas fa-stop\" aria-hidden=\"true\"></i>\n </button>\n </div>\n }\n\n <!-- Voice session / dictation \u2192 animated Sonar overlay (#51) -->\n @if (voiceChat.isActive || voiceChat.error || dictation.phase === 'listening' || dictation.phase === 'processing' || dictation.error) {\n <pw-brain-chat-voice-overlay\n [voice]=\"voiceChat\"\n [dictation]=\"dictation\"\n (end)=\"voiceChat.isActive || voiceChat.error ? voiceChat.stop() : dictation.dismiss()\"\n ></pw-brain-chat-voice-overlay>\n }\n\n <div class=\"pw-brain-chat__compose\">\n @if (messages.length > 1) {\n <div class=\"pw-brain-chat__quick\">\n @for (q of quickActions; track q.text) {\n <button type=\"button\" class=\"pw-brain-chat__chip\" (click)=\"usePrompt(q.text)\">\n <i class=\"fas\" [ngClass]=\"q.icon\" aria-hidden=\"true\"></i>{{ q.label }}\n </button>\n }\n </div>\n }\n @if (attachment.current; as file) {\n <div\n class=\"pw-brain-chat__attachment\"\n [class.pw-brain-chat__attachment--error]=\"file.status === 'error'\"\n [style.--pw-upload-progress]=\"file.percent + '%'\"\n >\n <span class=\"pw-brain-chat__attachment-icon\">\n <i class=\"fas\" [ngClass]=\"attachment.icon()\" aria-hidden=\"true\"></i>\n </span>\n <span class=\"pw-brain-chat__attachment-body\">\n <span class=\"pw-brain-chat__attachment-name\" [title]=\"file.name\">{{ file.name }}</span>\n <span class=\"pw-brain-chat__attachment-meta\" role=\"status\" aria-live=\"polite\">{{ attachment.meta() }}</span>\n </span>\n <button\n type=\"button\"\n class=\"pw-brain-chat__iconbtn\"\n (click)=\"attachment.remove()\"\n ngbTooltip=\"Remove file\"\n container=\"body\"\n aria-label=\"Remove attached file\"\n ><i class=\"fas fa-xmark\" aria-hidden=\"true\"></i></button>\n @if (file.status === 'uploading') {\n <span class=\"pw-brain-chat__attachment-progress\"></span>\n }\n </div>\n @if (attachment.choosing) {\n <div class=\"pw-brain-chat__choice\" role=\"group\" aria-label=\"What should I do with this file?\">\n <span class=\"pw-brain-chat__choice-prompt\">What should I do with this file?</span>\n <div class=\"pw-brain-chat__choice-options\">\n @for (option of attachment.choices; track option.tool) {\n <button\n type=\"button\"\n class=\"pw-brain-chat__chip\"\n (click)=\"attachment.choose(option)\"\n >{{ attachment.choiceLabel(option) }}</button>\n }\n </div>\n </div>\n }\n }\n <label class=\"visually-hidden\" for=\"pw-brain-chat-input\">Message {{ brandName }} Brain</label>\n <div class=\"pw-brain-chat__field\">\n <textarea\n id=\"pw-brain-chat-input\"\n class=\"pw-brain-chat__input\"\n rows=\"1\"\n [(ngModel)]=\"draft\"\n placeholder=\"Ask a question or tell me what to do\u2026\"\n (keydown.enter)=\"$event.preventDefault(); send()\"\n\n aria-label=\"Ask a question or tell me what to do\u2026\" ></textarea>\n <div class=\"pw-brain-chat__tools\">\n @if (attachment.enabled) {\n <input\n #fileInput\n type=\"file\"\n class=\"visually-hidden\"\n [accept]=\"attachment.acceptAttr\"\n (change)=\"pickFile(fileInput)\"\n />\n <button\n type=\"button\"\n class=\"pw-brain-chat__iconbtn\"\n [disabled]=\"loading || attachment.busy\"\n (click)=\"fileInput.click()\"\n ngbTooltip=\"Attach a file\"\n container=\"body\"\n aria-label=\"Attach a file\"\n ><i class=\"fas fa-paperclip\" aria-hidden=\"true\"></i></button>\n }\n <button\n type=\"button\"\n class=\"pw-brain-chat__iconbtn pw-brain-chat__mic\"\n [class.pw-brain-chat__mic--recording]=\"dictation.isRecording\"\n [disabled]=\"loading || dictation.phase === 'processing'\"\n (click)=\"dictation.toggle(loading)\"\n [ngbTooltip]=\"dictation.phase === 'listening' ? 'Stop dictation' : (dictation.phase === 'processing' ? 'Processing\u2026' : 'Dictate')\"\n container=\"body\"\n [attr.aria-label]=\"dictation.phase === 'listening' ? 'Stop dictation' : 'Dictate with your voice'\"\n [attr.aria-pressed]=\"dictation.isRecording\"\n ><i class=\"fas fa-microphone\" aria-hidden=\"true\"></i></button>\n @if (voiceChat.available) {\n <button\n type=\"button\"\n class=\"pw-brain-chat__iconbtn\"\n [disabled]=\"loading || dictation.isRecording\"\n (click)=\"voiceChat.toggle(loading)\"\n [ngbTooltip]=\"voiceChat.isActive ? 'End voice chat' : 'Voice chat'\"\n container=\"body\"\n [attr.aria-label]=\"voiceChat.isActive ? 'End voice chat' : 'Start voice chat'\"\n [attr.aria-pressed]=\"voiceChat.isActive\"\n >\n @switch (voiceChat.visual) {\n @case ('loader') { <i class=\"fas fa-circle-notch fa-spin\" aria-hidden=\"true\"></i> }\n @case ('wave') { <i class=\"fas fa-volume-high\" aria-hidden=\"true\"></i> }\n <!-- fa-waveform-lines (FA Pro, shipped in assets/fontawesome) \u2014 the\n canonical \"voice mode\" glyph; fa-comment-dots read as a second\n text-chat button. -->\n @default { <i class=\"fas fa-waveform-lines\" aria-hidden=\"true\"></i> }\n }\n </button>\n }\n <button\n type=\"button\"\n class=\"pw-brain-chat__send\"\n [class.pw-brain-chat__send--stop]=\"loading\"\n [disabled]=\"!loading && ((!draft.trim() && !attachment.ready) || attachment.busy || attachment.choosing)\"\n (click)=\"loading ? cancelRequest() : send()\"\n [ngbTooltip]=\"loading ? 'Stop request' : 'Send message'\"\n container=\"body\"\n [attr.aria-label]=\"loading ? 'Stop request' : 'Send message'\"\n >\n <i class=\"fas\" [ngClass]=\"loading ? 'fa-stop' : 'fa-paper-plane'\" aria-hidden=\"true\"></i>\n </button>\n </div>\n </div>\n <div class=\"pw-brain-chat__disclaimer\" role=\"note\">\n <i class=\"fas fa-triangle-exclamation\" aria-hidden=\"true\"></i>\n AI may be inaccurate \u2014 verify before acting.\n </div>\n </div>\n</div>\n", styles: [".pw-brain-chat{--bc-panel: var(--dashboard_bg, #fff);--bc-shade: #20385e;--bc-surface: color-mix(in srgb, var(--bc-panel) 96.6%, var(--bc-shade));--bc-surface-2: color-mix(in srgb, var(--bc-panel) 92.3%, var(--bc-shade));--bc-line: color-mix(in srgb, var(--bc-panel) 86.8%, var(--bc-shade));--bc-line-strong: color-mix(in srgb, var(--bc-panel) 78.3%, var(--bc-shade));--bc-bubble: color-mix(in srgb, var(--bc-panel) 94.1%, var(--bc-shade));--bc-ink: var(--text, #1a1d21);--bc-title: var(--titles, var(--text, #1a1d21));--bc-ink-2: color-mix(in srgb, var(--bc-ink) 72%, var(--bc-panel));--bc-ink-3: color-mix(in srgb, var(--bc-ink) 55%, var(--bc-panel));--bc-accent: var(--first, #1769e1);--bc-accent-wash: color-mix(in srgb, var(--first, #1769e1) 10%, transparent);--bc-accent-line: color-mix(in srgb, var(--first, #1769e1) 32%, var(--bc-line));--bc-success: #1f9d57;--bc-warning: #b7791f;--bc-error: #c0392b;--bc-r-sm: 4px;--bc-r-md: 8px;--bc-r-lg: 12px;--bc-ease: cubic-bezier(.2, .6, .25, 1);display:flex;flex-direction:column;height:100%;min-height:0;font-size:15px;color:var(--bc-ink);position:relative}:host-context([data-theme=dark]) .pw-brain-chat{--bc-panel: #15181d;--bc-surface: #1c2026;--bc-surface-2: #21262e;--bc-line: #2a2f38;--bc-line-strong: #384150;--bc-bubble: #1c2026;--bc-ink: #edeff2;--bc-title: #edeff2;--bc-ink-2: #aab3c0;--bc-ink-3: #7c8696}.pw-brain-chat__thread{flex:1 1 auto;min-height:0;overflow-y:auto;padding:16px 2px 8px;display:flex;flex-direction:column;gap:18px}.pw-brain-chat__thread>:first-child{margin-top:auto}.pw-brain-chat__turn--bot{display:grid;grid-template-columns:26px 1fr;column-gap:10px}.pw-brain-chat__spine{display:flex;flex-direction:column;align-items:center}.pw-brain-chat__node{width:26px;height:26px;border-radius:8px;flex:none;display:grid;place-items:center;background:var(--bc-surface);border:1px solid var(--bc-line);color:var(--bc-ink-2)}.pw-brain-chat__node i{font-size:12px}.pw-brain-chat__line{flex:1 1 auto;width:2px;margin-top:6px;background:var(--bc-line);border-radius:9999px}.pw-brain-chat__artifacts{min-width:0;display:flex;flex-direction:column;gap:9px;padding-top:1px}.pw-brain-chat__who{font-size:11px;text-transform:uppercase;letter-spacing:.11em;color:var(--bc-ink-3);font-weight:600}.pw-brain-chat__bubble{background:var(--bc-bubble);border:1px solid var(--bc-line);border-radius:var(--bc-r-md);padding:10px 13px}.pw-brain-chat__source{display:inline-flex;align-items:center;gap:6px;max-width:100%;margin-top:6px;padding:3px 9px;border:1px solid var(--bc-line);border-radius:var(--bc-r-sm);color:var(--bc-ink-3);font-size:11px;line-height:1.4}.pw-brain-chat__source-icon{flex-shrink:0;font-size:11px}.pw-brain-chat__source-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.pw-brain-chat__turn--user{display:flex;flex-direction:column;align-items:flex-end;gap:3px}.pw-brain-chat__time{font-size:10.5px;font-weight:400;letter-spacing:.02em;color:var(--bc-ink-3);white-space:nowrap}.pw-brain-chat__user-bubble{max-width:82%;background:var(--bc-accent);color:#fff;border-radius:var(--bc-r-md);border-top-right-radius:var(--bc-r-sm);padding:10px 13px;font-size:15px;line-height:1.5}\n", ".pw-brain-chat__welcome{flex:1 1 auto;overflow-y:auto;padding:22px 0 10px;display:flex;flex-direction:column;gap:16px}.pw-brain-chat__hero{width:44px;height:44px;border-radius:12px;display:grid;place-items:center;font-size:22px;color:#fff;background:var(--bc-accent);box-shadow:inset 0 1px #ffffff40}.pw-brain-chat__greet-h{font-size:20px;font-weight:600;letter-spacing:-.02em;margin:12px 0 4px;color:var(--bc-title)}.pw-brain-chat__greet-sub{font-size:14px;color:var(--bc-ink-2);margin:0}.pw-brain-chat__suggest-lab{font-size:11px;text-transform:uppercase;letter-spacing:.11em;color:var(--bc-ink-3);font-weight:600;margin:6px 0 -4px 2px}.pw-brain-chat__prompts{display:flex;flex-direction:column;gap:9px}.pw-brain-chat__prompt{display:flex;align-items:center;gap:11px;width:100%;text-align:left;padding:12px;border-radius:var(--bc-r-md);cursor:pointer;background:var(--bc-panel);border:1px solid var(--bc-line);color:var(--bc-ink);font:inherit;font-size:14px;font-weight:500;transition:border-color .15s var(--bc-ease),background .15s var(--bc-ease)}.pw-brain-chat__prompt:hover{border-color:var(--bc-line-strong);background:var(--bc-surface)}.pw-brain-chat__prompt:focus-visible{outline:2px solid var(--bc-accent);outline-offset:2px}.pw-brain-chat__pic{width:28px;height:28px;border-radius:7px;flex:none;display:grid;place-items:center;background:var(--bc-surface-2);border:1px solid var(--bc-line);color:var(--bc-ink-2)}.pw-brain-chat__pic i{font-size:14px}.pw-brain-chat__prompt-text{flex:1;min-width:0}.pw-brain-chat__arw{margin-left:auto;color:var(--bc-ink-3);font-size:13px}.pw-brain-chat__prompt:hover .pw-brain-chat__arw{color:var(--bc-accent)}.pw-brain-chat__quick{display:flex;gap:7px;margin-bottom:9px;overflow-x:auto;scrollbar-width:none}.pw-brain-chat__quick::-webkit-scrollbar{display:none}.pw-brain-chat__chip{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;flex:none;font:inherit;font-size:12px;font-weight:500;cursor:pointer;padding:6px 11px;border-radius:9999px;background:var(--bc-surface);border:1px solid var(--bc-line);color:var(--bc-ink-2);transition:border-color .15s var(--bc-ease),color .15s var(--bc-ease)}.pw-brain-chat__chip:hover{color:var(--bc-ink);border-color:var(--bc-line-strong)}.pw-brain-chat__chip:focus-visible{outline:2px solid var(--bc-accent);outline-offset:2px}.pw-brain-chat__chip i{font-size:11px;color:var(--bc-ink-3)}.pw-brain-chat__memory{display:inline-flex;align-items:center;gap:8px;align-self:flex-start;padding:7px 11px;border-radius:9999px;background:var(--bc-surface);border:1px solid var(--bc-line);font-size:12px;color:var(--bc-ink-2)}.pw-brain-chat__memory i{color:var(--bc-success);font-size:12px}.pw-brain-chat__memory .lbl{text-transform:uppercase;letter-spacing:.08em;font-size:10px;font-weight:600;color:var(--bc-ink-3)}\n", ".pw-brain-chat__text{margin:0;white-space:pre-wrap;overflow-wrap:break-word;font-family:inherit;font-size:15px;line-height:1.55;color:var(--bc-ink)}.pw-brain-chat__text p{margin:0}.pw-brain-chat__text p+p,.pw-brain-chat__text ul,.pw-brain-chat__text ol{margin-top:7px}.pw-brain-chat__text ul,.pw-brain-chat__text ol{padding-left:18px}.pw-brain-chat__text a{color:var(--bc-ink);text-decoration:underline;text-underline-offset:2px;text-decoration-color:var(--bc-line-strong)}.pw-brain-chat__text a:hover,.pw-brain-chat__text a:focus-visible{color:var(--bc-accent);text-decoration-color:var(--bc-accent)}.pw-brain-chat__text table{width:100%;margin-top:8px;border-collapse:collapse;font-size:13px;border:1px solid var(--bc-line);border-radius:var(--bc-r-md);overflow:hidden}.pw-brain-chat__text th,.pw-brain-chat__text td{text-align:left;padding:8px 12px;border-bottom:1px solid var(--bc-line)}.pw-brain-chat__text th{background:var(--bc-surface);font-weight:600;font-size:11px;letter-spacing:.07em;text-transform:uppercase;color:var(--bc-ink-2)}.pw-brain-chat__text tr:last-child td{border-bottom:0}.pw-brain-chat__user-text{margin:0;white-space:pre-wrap;overflow-wrap:break-word;font-family:inherit;font-size:15px;line-height:1.5}.pw-brain-chat__caret{display:inline-block;width:2px;height:1.05em;vertical-align:-2px;margin-left:2px;background:var(--bc-accent);border-radius:1px;animation:pw-brain-chat-caret 1s steps(2,start) infinite}@keyframes pw-brain-chat-caret{50%{opacity:0}}@media(prefers-reduced-motion:reduce){.pw-brain-chat__caret{animation:none}}\n", ".pw-brain-chat__loading{display:flex;flex-wrap:wrap;align-items:center;gap:10px;padding:4px 2px 0;font-size:12px;color:var(--bc-ink-3, #7c8696)}.pw-brain-chat__loading-spinner{color:var(--bc-accent, #1769e1)}.pw-brain-chat__iconbtn{width:32px;height:32px;flex:none;display:inline-flex;align-items:center;justify-content:center;padding:0;border:1px solid transparent;border-radius:var(--bc-r-md, 8px);background:transparent;color:var(--bc-ink-3, #7c8696);cursor:pointer;transition:background .15s ease,color .15s ease}.pw-brain-chat__iconbtn:hover:not(:disabled){background:var(--bc-surface, #f7f8fa);color:var(--bc-ink, #1a1d21)}.pw-brain-chat__iconbtn:focus-visible{outline:2px solid var(--bc-accent, #1769e1);outline-offset:2px}.pw-brain-chat__iconbtn:disabled{opacity:.5;cursor:default}.pw-brain-chat__mic--recording{color:var(--bc-error, #c0392b)}.pw-brain-chat__stop:hover:not(:disabled){color:var(--bc-error, #c0392b)}.pw-brain-chat__compose{flex-shrink:0;border-top:1px solid var(--bc-line, #e2e5ea);padding:10px 2px 4px}.pw-brain-chat__field{display:flex;align-items:flex-end;gap:8px;border:1px solid var(--bc-line, #e2e5ea);border-radius:var(--bc-r-md, 8px);background:var(--bc-panel, #fff);padding:6px 6px 6px 12px;transition:border-color .15s ease,box-shadow .15s ease}.pw-brain-chat__field:focus-within{border-color:var(--bc-accent, #1769e1);box-shadow:0 0 0 3px var(--bc-accent-wash, rgba(23, 105, 225, .1))}.pw-brain-chat__input{flex:1;border:0;resize:none;background:transparent;font-family:inherit;font-size:14px;line-height:1.5;color:var(--bc-ink, #1a1d21);padding:6px 0;max-height:96px}.pw-brain-chat__input:focus{outline:none;box-shadow:none}.pw-brain-chat__input::placeholder{color:var(--bc-ink-3, #7c8696)}.pw-brain-chat__tools{display:flex;align-items:center;gap:2px;flex:none}.pw-brain-chat__send{width:34px;height:34px;flex:none;display:inline-flex;align-items:center;justify-content:center;border:0;border-radius:var(--bc-r-md, 8px);background:var(--bc-accent, #1769e1);color:#fff;cursor:pointer;transition:filter .15s ease}.pw-brain-chat__send:hover:not(:disabled){filter:brightness(1.07)}.pw-brain-chat__send:disabled{background:var(--bc-line-strong, #cfd4dc);cursor:default}.pw-brain-chat__send:focus-visible{outline:2px solid var(--bc-accent, #1769e1);outline-offset:2px}.pw-brain-chat__send--stop{background:var(--bc-error, #c0392b)!important}.pw-brain-chat__disclaimer{display:flex;align-items:center;gap:6px;margin:8px 2px 2px;font-size:11px;color:var(--bc-ink-3, #7c8696)}\n", ".pw-brain-chat__dropzone{position:absolute;inset:0;z-index:5;display:flex;align-items:center;justify-content:center;padding:16px;background:color-mix(in srgb,var(--bc-panel, #fff) 82%,transparent);-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);animation:pw-brain-chat-dropzone-in .16s ease-out}.pw-brain-chat__dropzone-frame{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;width:100%;height:100%;padding:24px 16px;text-align:center;border:2px dashed var(--bc-accent, #1769e1);border-radius:var(--bc-r-lg, 12px);background:var(--bc-accent-wash, rgba(23, 105, 225, .1))}.pw-brain-chat__dropzone-icon{width:48px;height:48px;display:inline-flex;align-items:center;justify-content:center;margin-bottom:2px;font-size:19px;line-height:1;border-radius:50%;color:var(--bc-accent, #1769e1);background:var(--bc-panel, #fff);border:1px solid color-mix(in srgb,var(--bc-accent, #1769e1) 28%,transparent);box-shadow:0 1px 3px #0000000f}.pw-brain-chat__dropzone-title{font-size:15px;font-weight:600;letter-spacing:-.1px;color:var(--bc-ink, #1a1d21)}.pw-brain-chat__dropzone-hint{font-size:12px;color:var(--bc-ink-3, #7c8696)}@keyframes pw-brain-chat-dropzone-in{0%{opacity:0;transform:scale(.99)}to{opacity:1;transform:none}}.pw-brain-chat__attachment{position:relative;display:flex;align-items:center;gap:10px;margin:0 2px 8px;padding:8px 10px;overflow:hidden;border:1px solid var(--bc-line, #e2e5ea);border-radius:var(--bc-r-md, 8px);background:var(--bc-surface, #f7f8fa)}.pw-brain-chat__attachment--error{border-color:var(--bc-error, #c0392b);background:color-mix(in srgb,var(--bc-error, #c0392b) 6%,transparent)}.pw-brain-chat__attachment-icon{width:28px;height:28px;flex:none;display:inline-flex;align-items:center;justify-content:center;font-size:13px;border-radius:var(--bc-r-sm, 6px);background:var(--bc-panel, #fff);border:1px solid var(--bc-line, #e2e5ea);color:var(--bc-accent, #1769e1)}.pw-brain-chat__attachment--error .pw-brain-chat__attachment-icon{color:var(--bc-error, #c0392b)}.pw-brain-chat__attachment-body{flex:1;min-width:0}.pw-brain-chat__attachment-name{display:block;font-size:13px;font-weight:600;color:var(--bc-ink, #1a1d21);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.pw-brain-chat__attachment-meta{display:block;margin-top:1px;font-size:11px;color:var(--bc-ink-3, #7c8696)}.pw-brain-chat__attachment--error .pw-brain-chat__attachment-meta{color:var(--bc-error, #c0392b)}.pw-brain-chat__attachment-progress{position:absolute;left:0;bottom:0;height:2px;width:var(--pw-upload-progress, 0%);background:var(--bc-accent, #1769e1);transition:width .18s ease-out}@media(prefers-reduced-motion:reduce){.pw-brain-chat__dropzone{animation:none}.pw-brain-chat__attachment-progress{transition:none}}.pw-brain-chat__choice{display:flex;flex-direction:column;gap:6px;margin:-2px 2px 9px}.pw-brain-chat__choice-prompt{font-size:12px;color:var(--bc-ink-2, #5b6472)}.pw-brain-chat__choice-options{display:flex;flex-wrap:wrap;gap:7px}\n", ".pw-brain-chat__mic{display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--bs-border-color, #ced4da);background:transparent;color:var(--bs-secondary-color, #6c757d);transition:color .15s ease,border-color .15s ease}.pw-brain-chat__mic:hover:not(:disabled){color:var(--first, #0d6efd);border-color:var(--first, #0d6efd)}.pw-brain-chat__mic--recording{color:#dc3545;border-color:#dc3545;animation:pw-brain-chat-mic-pulse 1.2s ease-in-out infinite}@keyframes pw-brain-chat-mic-pulse{0%,to{opacity:1}50%{opacity:.55}}@media(prefers-reduced-motion:reduce){.pw-brain-chat__mic--recording{animation:none}}\n"], dependencies: [{ kind: "directive", type: i2$2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i5.NgbTooltip, selector: "[ngbTooltip]", inputs: ["animation", "autoClose", "placement", "popperOptions", "triggers", "positionTarget", "container", "disableTooltip", "tooltipClass", "tooltipContext", "openDelay", "closeDelay", "ngbTooltip"], outputs: ["shown", "hidden"], exportAs: ["ngbTooltip"] }, { kind: "directive", type: i8.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: PwBrainChatThreadDirective, selector: "[pwBrainChatThread]" }, { kind: "component", type: PwBrainChatConfirmComponent, selector: "pw-brain-chat-confirm", inputs: ["pending", "loading"], outputs: ["approveEvent", "cancelEvent"] }, { kind: "component", type: PwBrainChatWelcomeComponent, selector: "pw-brain-chat-welcome", inputs: ["userFirstName", "prompts"], outputs: ["pick"] }, { kind: "component", type: PwBrainChatVoiceOverlayComponent, selector: "pw-brain-chat-voice-overlay", inputs: ["voice", "dictation"], outputs: ["end"] }, { kind: "pipe", type: i8.DatePipe, name: "date" }, { kind: "pipe", type: SafeMarkdownPipe, name: "safeMarkdown" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
2016
2553
  }
2017
2554
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: PwBrainChatComponent, decorators: [{
2018
2555
  type: Component,
2019
- args: [{ selector: 'pw-brain-chat', changeDetection: ChangeDetectionStrategy.OnPush, standalone: false, template: "<div class=\"pw-brain-chat\">\n <!-- The sidebar host header owns title + close + live status + New chat\n (SidebarContent.status / headerActions) \u2014 so the panel body starts at\n the thread, no duplicate status strip. newChat() is invoked from the\n host header action. -->\n <div #thread pwBrainChatThread class=\"pw-brain-chat__thread\" role=\"log\" aria-live=\"polite\">\n @if (messages.length <= 1 && !loading && !streamingProse) {\n <pw-brain-chat-welcome\n [userFirstName]=\"userFirstName\"\n [prompts]=\"suggestedPrompts\"\n (pick)=\"usePrompt($event)\"\n ></pw-brain-chat-welcome>\n } @else {\n @for (m of messages; track trackByIndex($index, m)) {\n @if (m.role === 'user') {\n <div class=\"pw-brain-chat__turn pw-brain-chat__turn--user\">\n <div class=\"pw-brain-chat__user-bubble\"><pre class=\"pw-brain-chat__user-text\">{{ m.text }}</pre></div>\n @if (m.at) {\n <span class=\"pw-brain-chat__time\">{{ m.at | date: 'shortTime' }}</span>\n }\n </div>\n } @else {\n <div class=\"pw-brain-chat__turn pw-brain-chat__turn--bot\">\n <div class=\"pw-brain-chat__spine\" aria-hidden=\"true\">\n <span class=\"pw-brain-chat__node\"><i class=\"fas fa-brain\"></i></span>\n <span class=\"pw-brain-chat__line\"></span>\n </div>\n <div class=\"pw-brain-chat__artifacts\">\n <span class=\"pw-brain-chat__who\">\n {{ brandName }} Brain\n @if (m.at) {\n <span class=\"pw-brain-chat__time\">\u00B7 {{ m.at | date: 'shortTime' }}</span>\n }\n </span>\n <div class=\"pw-brain-chat__bubble\">\n @if (m.markdownEnabled) {\n <div class=\"pw-brain-chat__text\" [innerHTML]=\"m.text | safeMarkdown\"></div>\n } @else {\n <pre class=\"pw-brain-chat__text\">{{ m.text }}</pre>\n }\n </div>\n @if (m.sourcePage) {\n <div class=\"pw-brain-chat__source\" role=\"note\">\n <i class=\"fas fa-file-lines pw-brain-chat__source-icon\" aria-hidden=\"true\"></i>\n <span class=\"pw-brain-chat__source-text\">Documented on: {{ m.sourcePage }}</span>\n </div>\n }\n @if (m.pending) {\n <pw-brain-chat-confirm\n [pending]=\"m.pending\"\n [loading]=\"loading\"\n (approveEvent)=\"approve(m)\"\n (cancelEvent)=\"cancel(m)\"\n ></pw-brain-chat-confirm>\n }\n </div>\n </div>\n }\n }\n }\n\n @if (loading && streamingProse) {\n <!-- prose streams token-by-token into a partial bot turn; caret = writing (#51) -->\n <div class=\"pw-brain-chat__turn pw-brain-chat__turn--bot\">\n <div class=\"pw-brain-chat__spine\" aria-hidden=\"true\">\n <span class=\"pw-brain-chat__node\"><i class=\"fas fa-brain\"></i></span>\n <span class=\"pw-brain-chat__line\"></span>\n </div>\n <div class=\"pw-brain-chat__artifacts\">\n <span class=\"pw-brain-chat__who\">{{ brandName }} Brain</span>\n <div class=\"pw-brain-chat__bubble\">\n <pre class=\"pw-brain-chat__text\"\n >{{ streamingProse }}<span class=\"pw-brain-chat__caret\" aria-hidden=\"true\"></span></pre>\n </div>\n </div>\n </div>\n }\n </div>\n\n @if (loading && !streamingProse) {\n <div class=\"pw-brain-chat__loading\">\n <i class=\"fas fa-circle-notch fa-spin pw-brain-chat__loading-spinner\" aria-hidden=\"true\"></i>\n <span aria-live=\"polite\">{{ streamingStage || 'Working\u2026' }}</span>\n <button type=\"button\" class=\"pw-brain-chat__iconbtn pw-brain-chat__stop\" (click)=\"cancelRequest()\"\n [ngbTooltip]=\"'Stop request'\" container=\"body\" aria-label=\"Stop request\">\n <i class=\"fas fa-stop\" aria-hidden=\"true\"></i>\n </button>\n </div>\n }\n\n <!-- Voice session / dictation \u2192 animated Sonar overlay (#51) -->\n @if (voiceChat.isActive || voiceChat.error || dictation.phase === 'listening' || dictation.phase === 'processing' || dictation.error) {\n <pw-brain-chat-voice-overlay\n [voice]=\"voiceChat\"\n [dictation]=\"dictation\"\n (end)=\"voiceChat.isActive || voiceChat.error ? voiceChat.stop() : dictation.dismiss()\"\n ></pw-brain-chat-voice-overlay>\n }\n\n <div class=\"pw-brain-chat__compose\">\n @if (messages.length > 1) {\n <div class=\"pw-brain-chat__quick\">\n @for (q of quickActions; track q.text) {\n <button type=\"button\" class=\"pw-brain-chat__chip\" (click)=\"usePrompt(q.text)\">\n <i class=\"fas\" [ngClass]=\"q.icon\" aria-hidden=\"true\"></i>{{ q.label }}\n </button>\n }\n </div>\n }\n <label class=\"visually-hidden\" for=\"pw-brain-chat-input\">Message {{ brandName }} Brain</label>\n <div class=\"pw-brain-chat__field\">\n <textarea\n id=\"pw-brain-chat-input\"\n class=\"pw-brain-chat__input\"\n rows=\"1\"\n [(ngModel)]=\"draft\"\n placeholder=\"Ask a question or tell me what to do\u2026\"\n (keydown.enter)=\"$event.preventDefault(); send()\"\n\n aria-label=\"Ask a question or tell me what to do\u2026\" ></textarea>\n <div class=\"pw-brain-chat__tools\">\n <button\n type=\"button\"\n class=\"pw-brain-chat__iconbtn pw-brain-chat__mic\"\n [class.pw-brain-chat__mic--recording]=\"dictation.isRecording\"\n [disabled]=\"loading || dictation.phase === 'processing'\"\n (click)=\"dictation.toggle(loading)\"\n [ngbTooltip]=\"dictation.phase === 'listening' ? 'Stop dictation' : (dictation.phase === 'processing' ? 'Processing\u2026' : 'Dictate')\"\n container=\"body\"\n [attr.aria-label]=\"dictation.phase === 'listening' ? 'Stop dictation' : 'Dictate with your voice'\"\n [attr.aria-pressed]=\"dictation.isRecording\"\n ><i class=\"fas fa-microphone\" aria-hidden=\"true\"></i></button>\n @if (voiceChat.available) {\n <button\n type=\"button\"\n class=\"pw-brain-chat__iconbtn\"\n [disabled]=\"loading || dictation.isRecording\"\n (click)=\"voiceChat.toggle(loading)\"\n [ngbTooltip]=\"voiceChat.isActive ? 'End voice chat' : 'Voice chat'\"\n container=\"body\"\n [attr.aria-label]=\"voiceChat.isActive ? 'End voice chat' : 'Start voice chat'\"\n [attr.aria-pressed]=\"voiceChat.isActive\"\n >\n @switch (voiceChat.visual) {\n @case ('loader') { <i class=\"fas fa-circle-notch fa-spin\" aria-hidden=\"true\"></i> }\n @case ('wave') { <i class=\"fas fa-volume-high\" aria-hidden=\"true\"></i> }\n <!-- fa-waveform-lines (FA Pro, shipped in assets/fontawesome) \u2014 the\n canonical \"voice mode\" glyph; fa-comment-dots read as a second\n text-chat button. -->\n @default { <i class=\"fas fa-waveform-lines\" aria-hidden=\"true\"></i> }\n }\n </button>\n }\n <button\n type=\"button\"\n class=\"pw-brain-chat__send\"\n [class.pw-brain-chat__send--stop]=\"loading\"\n [disabled]=\"!loading && !draft.trim()\"\n (click)=\"loading ? cancelRequest() : send()\"\n [ngbTooltip]=\"loading ? 'Stop request' : 'Send message'\"\n container=\"body\"\n [attr.aria-label]=\"loading ? 'Stop request' : 'Send message'\"\n >\n <i class=\"fas\" [ngClass]=\"loading ? 'fa-stop' : 'fa-paper-plane'\" aria-hidden=\"true\"></i>\n </button>\n </div>\n </div>\n <div class=\"pw-brain-chat__disclaimer\" role=\"note\">\n <i class=\"fas fa-triangle-exclamation\" aria-hidden=\"true\"></i>\n AI may be inaccurate \u2014 verify before acting.\n </div>\n </div>\n</div>\n", styles: [".pw-brain-chat{--bc-panel: var(--dashboard_bg, #fff);--bc-shade: #20385e;--bc-surface: color-mix(in srgb, var(--bc-panel) 96.6%, var(--bc-shade));--bc-surface-2: color-mix(in srgb, var(--bc-panel) 92.3%, var(--bc-shade));--bc-line: color-mix(in srgb, var(--bc-panel) 86.8%, var(--bc-shade));--bc-line-strong: color-mix(in srgb, var(--bc-panel) 78.3%, var(--bc-shade));--bc-bubble: color-mix(in srgb, var(--bc-panel) 94.1%, var(--bc-shade));--bc-ink: var(--text, #1a1d21);--bc-title: var(--titles, var(--text, #1a1d21));--bc-ink-2: color-mix(in srgb, var(--bc-ink) 72%, var(--bc-panel));--bc-ink-3: color-mix(in srgb, var(--bc-ink) 55%, var(--bc-panel));--bc-accent: var(--first, #1769e1);--bc-accent-wash: color-mix(in srgb, var(--first, #1769e1) 10%, transparent);--bc-accent-line: color-mix(in srgb, var(--first, #1769e1) 32%, var(--bc-line));--bc-success: #1f9d57;--bc-warning: #b7791f;--bc-error: #c0392b;--bc-r-sm: 4px;--bc-r-md: 8px;--bc-r-lg: 12px;--bc-ease: cubic-bezier(.2, .6, .25, 1);display:flex;flex-direction:column;height:100%;min-height:0;font-size:15px;color:var(--bc-ink);position:relative}:host-context([data-theme=dark]) .pw-brain-chat{--bc-panel: #15181d;--bc-surface: #1c2026;--bc-surface-2: #21262e;--bc-line: #2a2f38;--bc-line-strong: #384150;--bc-bubble: #1c2026;--bc-ink: #edeff2;--bc-title: #edeff2;--bc-ink-2: #aab3c0;--bc-ink-3: #7c8696}.pw-brain-chat__thread{flex:1 1 auto;min-height:0;overflow-y:auto;padding:16px 2px 8px;display:flex;flex-direction:column;gap:18px}.pw-brain-chat__thread>:first-child{margin-top:auto}.pw-brain-chat__turn--bot{display:grid;grid-template-columns:26px 1fr;column-gap:10px}.pw-brain-chat__spine{display:flex;flex-direction:column;align-items:center}.pw-brain-chat__node{width:26px;height:26px;border-radius:8px;flex:none;display:grid;place-items:center;background:var(--bc-surface);border:1px solid var(--bc-line);color:var(--bc-ink-2)}.pw-brain-chat__node i{font-size:12px}.pw-brain-chat__line{flex:1 1 auto;width:2px;margin-top:6px;background:var(--bc-line);border-radius:9999px}.pw-brain-chat__artifacts{min-width:0;display:flex;flex-direction:column;gap:9px;padding-top:1px}.pw-brain-chat__who{font-size:11px;text-transform:uppercase;letter-spacing:.11em;color:var(--bc-ink-3);font-weight:600}.pw-brain-chat__bubble{background:var(--bc-bubble);border:1px solid var(--bc-line);border-radius:var(--bc-r-md);padding:10px 13px}.pw-brain-chat__source{display:inline-flex;align-items:center;gap:6px;max-width:100%;margin-top:6px;padding:3px 9px;border:1px solid var(--bc-line);border-radius:var(--bc-r-sm);color:var(--bc-ink-3);font-size:11px;line-height:1.4}.pw-brain-chat__source-icon{flex-shrink:0;font-size:11px}.pw-brain-chat__source-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.pw-brain-chat__turn--user{display:flex;flex-direction:column;align-items:flex-end;gap:3px}.pw-brain-chat__time{font-size:10.5px;font-weight:400;letter-spacing:.02em;color:var(--bc-ink-3);white-space:nowrap}.pw-brain-chat__user-bubble{max-width:82%;background:var(--bc-accent);color:#fff;border-radius:var(--bc-r-md);border-top-right-radius:var(--bc-r-sm);padding:10px 13px;font-size:15px;line-height:1.5}\n", ".pw-brain-chat__welcome{flex:1 1 auto;overflow-y:auto;padding:22px 0 10px;display:flex;flex-direction:column;gap:16px}.pw-brain-chat__hero{width:44px;height:44px;border-radius:12px;display:grid;place-items:center;font-size:22px;color:#fff;background:var(--bc-accent);box-shadow:inset 0 1px #ffffff40}.pw-brain-chat__greet-h{font-size:20px;font-weight:600;letter-spacing:-.02em;margin:12px 0 4px;color:var(--bc-title)}.pw-brain-chat__greet-sub{font-size:14px;color:var(--bc-ink-2);margin:0}.pw-brain-chat__suggest-lab{font-size:11px;text-transform:uppercase;letter-spacing:.11em;color:var(--bc-ink-3);font-weight:600;margin:6px 0 -4px 2px}.pw-brain-chat__prompts{display:flex;flex-direction:column;gap:9px}.pw-brain-chat__prompt{display:flex;align-items:center;gap:11px;width:100%;text-align:left;padding:12px;border-radius:var(--bc-r-md);cursor:pointer;background:var(--bc-panel);border:1px solid var(--bc-line);color:var(--bc-ink);font:inherit;font-size:14px;font-weight:500;transition:border-color .15s var(--bc-ease),background .15s var(--bc-ease)}.pw-brain-chat__prompt:hover{border-color:var(--bc-line-strong);background:var(--bc-surface)}.pw-brain-chat__prompt:focus-visible{outline:2px solid var(--bc-accent);outline-offset:2px}.pw-brain-chat__pic{width:28px;height:28px;border-radius:7px;flex:none;display:grid;place-items:center;background:var(--bc-surface-2);border:1px solid var(--bc-line);color:var(--bc-ink-2)}.pw-brain-chat__pic i{font-size:14px}.pw-brain-chat__prompt-text{flex:1;min-width:0}.pw-brain-chat__arw{margin-left:auto;color:var(--bc-ink-3);font-size:13px}.pw-brain-chat__prompt:hover .pw-brain-chat__arw{color:var(--bc-accent)}.pw-brain-chat__quick{display:flex;gap:7px;margin-bottom:9px;overflow-x:auto;scrollbar-width:none}.pw-brain-chat__quick::-webkit-scrollbar{display:none}.pw-brain-chat__chip{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;flex:none;font:inherit;font-size:12px;font-weight:500;cursor:pointer;padding:6px 11px;border-radius:9999px;background:var(--bc-surface);border:1px solid var(--bc-line);color:var(--bc-ink-2);transition:border-color .15s var(--bc-ease),color .15s var(--bc-ease)}.pw-brain-chat__chip:hover{color:var(--bc-ink);border-color:var(--bc-line-strong)}.pw-brain-chat__chip:focus-visible{outline:2px solid var(--bc-accent);outline-offset:2px}.pw-brain-chat__chip i{font-size:11px;color:var(--bc-ink-3)}.pw-brain-chat__memory{display:inline-flex;align-items:center;gap:8px;align-self:flex-start;padding:7px 11px;border-radius:9999px;background:var(--bc-surface);border:1px solid var(--bc-line);font-size:12px;color:var(--bc-ink-2)}.pw-brain-chat__memory i{color:var(--bc-success);font-size:12px}.pw-brain-chat__memory .lbl{text-transform:uppercase;letter-spacing:.08em;font-size:10px;font-weight:600;color:var(--bc-ink-3)}\n", ".pw-brain-chat__text{margin:0;white-space:pre-wrap;overflow-wrap:break-word;font-family:inherit;font-size:15px;line-height:1.55;color:var(--bc-ink)}.pw-brain-chat__text p{margin:0}.pw-brain-chat__text p+p,.pw-brain-chat__text ul,.pw-brain-chat__text ol{margin-top:7px}.pw-brain-chat__text ul,.pw-brain-chat__text ol{padding-left:18px}.pw-brain-chat__text a{color:var(--bc-ink);text-decoration:underline;text-underline-offset:2px;text-decoration-color:var(--bc-line-strong)}.pw-brain-chat__text a:hover,.pw-brain-chat__text a:focus-visible{color:var(--bc-accent);text-decoration-color:var(--bc-accent)}.pw-brain-chat__text table{width:100%;margin-top:8px;border-collapse:collapse;font-size:13px;border:1px solid var(--bc-line);border-radius:var(--bc-r-md);overflow:hidden}.pw-brain-chat__text th,.pw-brain-chat__text td{text-align:left;padding:8px 12px;border-bottom:1px solid var(--bc-line)}.pw-brain-chat__text th{background:var(--bc-surface);font-weight:600;font-size:11px;letter-spacing:.07em;text-transform:uppercase;color:var(--bc-ink-2)}.pw-brain-chat__text tr:last-child td{border-bottom:0}.pw-brain-chat__user-text{margin:0;white-space:pre-wrap;overflow-wrap:break-word;font-family:inherit;font-size:15px;line-height:1.5}.pw-brain-chat__caret{display:inline-block;width:2px;height:1.05em;vertical-align:-2px;margin-left:2px;background:var(--bc-accent);border-radius:1px;animation:pw-brain-chat-caret 1s steps(2,start) infinite}@keyframes pw-brain-chat-caret{50%{opacity:0}}@media(prefers-reduced-motion:reduce){.pw-brain-chat__caret{animation:none}}\n", ".pw-brain-chat__loading{display:flex;flex-wrap:wrap;align-items:center;gap:10px;padding:4px 2px 0;font-size:12px;color:var(--bc-ink-3, #7c8696)}.pw-brain-chat__loading-spinner{color:var(--bc-accent, #1769e1)}.pw-brain-chat__iconbtn{width:32px;height:32px;flex:none;display:inline-flex;align-items:center;justify-content:center;padding:0;border:1px solid transparent;border-radius:var(--bc-r-md, 8px);background:transparent;color:var(--bc-ink-3, #7c8696);cursor:pointer;transition:background .15s ease,color .15s ease}.pw-brain-chat__iconbtn:hover:not(:disabled){background:var(--bc-surface, #f7f8fa);color:var(--bc-ink, #1a1d21)}.pw-brain-chat__iconbtn:focus-visible{outline:2px solid var(--bc-accent, #1769e1);outline-offset:2px}.pw-brain-chat__iconbtn:disabled{opacity:.5;cursor:default}.pw-brain-chat__mic--recording{color:var(--bc-error, #c0392b)}.pw-brain-chat__stop:hover:not(:disabled){color:var(--bc-error, #c0392b)}.pw-brain-chat__compose{flex-shrink:0;border-top:1px solid var(--bc-line, #e2e5ea);padding:10px 2px 4px}.pw-brain-chat__field{display:flex;align-items:flex-end;gap:8px;border:1px solid var(--bc-line, #e2e5ea);border-radius:var(--bc-r-md, 8px);background:var(--bc-panel, #fff);padding:6px 6px 6px 12px;transition:border-color .15s ease,box-shadow .15s ease}.pw-brain-chat__field:focus-within{border-color:var(--bc-accent, #1769e1);box-shadow:0 0 0 3px var(--bc-accent-wash, rgba(23, 105, 225, .1))}.pw-brain-chat__input{flex:1;border:0;resize:none;background:transparent;font-family:inherit;font-size:14px;line-height:1.5;color:var(--bc-ink, #1a1d21);padding:6px 0;max-height:96px}.pw-brain-chat__input:focus{outline:none;box-shadow:none}.pw-brain-chat__input::placeholder{color:var(--bc-ink-3, #7c8696)}.pw-brain-chat__tools{display:flex;align-items:center;gap:2px;flex:none}.pw-brain-chat__send{width:34px;height:34px;flex:none;display:inline-flex;align-items:center;justify-content:center;border:0;border-radius:var(--bc-r-md, 8px);background:var(--bc-accent, #1769e1);color:#fff;cursor:pointer;transition:filter .15s ease}.pw-brain-chat__send:hover:not(:disabled){filter:brightness(1.07)}.pw-brain-chat__send:disabled{background:var(--bc-line-strong, #cfd4dc);cursor:default}.pw-brain-chat__send:focus-visible{outline:2px solid var(--bc-accent, #1769e1);outline-offset:2px}.pw-brain-chat__send--stop{background:var(--bc-error, #c0392b)!important}.pw-brain-chat__disclaimer{display:flex;align-items:center;gap:6px;margin:8px 2px 2px;font-size:11px;color:var(--bc-ink-3, #7c8696)}\n", ".pw-brain-chat__mic{display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--bs-border-color, #ced4da);background:transparent;color:var(--bs-secondary-color, #6c757d);transition:color .15s ease,border-color .15s ease}.pw-brain-chat__mic:hover:not(:disabled){color:var(--first, #0d6efd);border-color:var(--first, #0d6efd)}.pw-brain-chat__mic--recording{color:#dc3545;border-color:#dc3545;animation:pw-brain-chat-mic-pulse 1.2s ease-in-out infinite}@keyframes pw-brain-chat-mic-pulse{0%,to{opacity:1}50%{opacity:.55}}@media(prefers-reduced-motion:reduce){.pw-brain-chat__mic--recording{animation:none}}\n"] }]
2556
+ args: [{ selector: 'pw-brain-chat', changeDetection: ChangeDetectionStrategy.OnPush, standalone: false, template: "<div\n class=\"pw-brain-chat\"\n (dragenter)=\"attachment.dragEnter($event)\"\n (dragover)=\"attachment.dragOver($event)\"\n (dragleave)=\"attachment.dragLeave($event)\"\n (drop)=\"attachment.drop($event)\"\n>\n @if (attachment.dragActive) {\n <div class=\"pw-brain-chat__dropzone\" aria-hidden=\"true\">\n <div class=\"pw-brain-chat__dropzone-frame\">\n <i class=\"fas fa-file-arrow-up pw-brain-chat__dropzone-icon\" aria-hidden=\"true\"></i>\n <span class=\"pw-brain-chat__dropzone-title\">{{ attachment.label }}</span>\n <span class=\"pw-brain-chat__dropzone-hint\">{{ attachment.hint }}</span>\n </div>\n </div>\n }\n <!-- The sidebar host header owns title + close + live status + New chat\n (SidebarContent.status / headerActions) \u2014 so the panel body starts at\n the thread, no duplicate status strip. newChat() is invoked from the\n host header action. -->\n <div #thread pwBrainChatThread class=\"pw-brain-chat__thread\" role=\"log\" aria-live=\"polite\">\n @if (messages.length <= 1 && !loading && !streamingProse) {\n <pw-brain-chat-welcome\n [userFirstName]=\"userFirstName\"\n [prompts]=\"suggestedPrompts\"\n (pick)=\"usePrompt($event)\"\n ></pw-brain-chat-welcome>\n } @else {\n @for (m of messages; track trackByIndex($index, m)) {\n @if (m.role === 'user') {\n <div class=\"pw-brain-chat__turn pw-brain-chat__turn--user\">\n <div class=\"pw-brain-chat__user-bubble\"><pre class=\"pw-brain-chat__user-text\">{{ m.text }}</pre></div>\n @if (m.at) {\n <span class=\"pw-brain-chat__time\">{{ m.at | date: 'shortTime' }}</span>\n }\n </div>\n } @else {\n <div class=\"pw-brain-chat__turn pw-brain-chat__turn--bot\">\n <div class=\"pw-brain-chat__spine\" aria-hidden=\"true\">\n <span class=\"pw-brain-chat__node\"><i class=\"fas fa-brain\"></i></span>\n <span class=\"pw-brain-chat__line\"></span>\n </div>\n <div class=\"pw-brain-chat__artifacts\">\n <span class=\"pw-brain-chat__who\">\n {{ brandName }} Brain\n @if (m.at) {\n <span class=\"pw-brain-chat__time\">\u00B7 {{ m.at | date: 'shortTime' }}</span>\n }\n </span>\n <div class=\"pw-brain-chat__bubble\">\n @if (m.markdownEnabled) {\n <div class=\"pw-brain-chat__text\" [innerHTML]=\"m.text | safeMarkdown\"></div>\n } @else {\n <pre class=\"pw-brain-chat__text\">{{ m.text }}</pre>\n }\n </div>\n @if (m.sourcePage) {\n <div class=\"pw-brain-chat__source\" role=\"note\">\n <i class=\"fas fa-file-lines pw-brain-chat__source-icon\" aria-hidden=\"true\"></i>\n <span class=\"pw-brain-chat__source-text\">Documented on: {{ m.sourcePage }}</span>\n </div>\n }\n @if (m.pending) {\n <pw-brain-chat-confirm\n [pending]=\"m.pending\"\n [loading]=\"loading\"\n (approveEvent)=\"approve(m)\"\n (cancelEvent)=\"cancel(m)\"\n ></pw-brain-chat-confirm>\n }\n </div>\n </div>\n }\n }\n }\n\n @if (loading && streamingProse) {\n <!-- prose streams token-by-token into a partial bot turn; caret = writing (#51) -->\n <div class=\"pw-brain-chat__turn pw-brain-chat__turn--bot\">\n <div class=\"pw-brain-chat__spine\" aria-hidden=\"true\">\n <span class=\"pw-brain-chat__node\"><i class=\"fas fa-brain\"></i></span>\n <span class=\"pw-brain-chat__line\"></span>\n </div>\n <div class=\"pw-brain-chat__artifacts\">\n <span class=\"pw-brain-chat__who\">{{ brandName }} Brain</span>\n <div class=\"pw-brain-chat__bubble\">\n <pre class=\"pw-brain-chat__text\"\n >{{ streamingProse }}<span class=\"pw-brain-chat__caret\" aria-hidden=\"true\"></span></pre>\n </div>\n </div>\n </div>\n }\n </div>\n\n @if (loading && !streamingProse) {\n <div class=\"pw-brain-chat__loading\">\n <i class=\"fas fa-circle-notch fa-spin pw-brain-chat__loading-spinner\" aria-hidden=\"true\"></i>\n <span aria-live=\"polite\">{{ streamingStage || 'Working\u2026' }}</span>\n <button type=\"button\" class=\"pw-brain-chat__iconbtn pw-brain-chat__stop\" (click)=\"cancelRequest()\"\n [ngbTooltip]=\"'Stop request'\" container=\"body\" aria-label=\"Stop request\">\n <i class=\"fas fa-stop\" aria-hidden=\"true\"></i>\n </button>\n </div>\n }\n\n <!-- Voice session / dictation \u2192 animated Sonar overlay (#51) -->\n @if (voiceChat.isActive || voiceChat.error || dictation.phase === 'listening' || dictation.phase === 'processing' || dictation.error) {\n <pw-brain-chat-voice-overlay\n [voice]=\"voiceChat\"\n [dictation]=\"dictation\"\n (end)=\"voiceChat.isActive || voiceChat.error ? voiceChat.stop() : dictation.dismiss()\"\n ></pw-brain-chat-voice-overlay>\n }\n\n <div class=\"pw-brain-chat__compose\">\n @if (messages.length > 1) {\n <div class=\"pw-brain-chat__quick\">\n @for (q of quickActions; track q.text) {\n <button type=\"button\" class=\"pw-brain-chat__chip\" (click)=\"usePrompt(q.text)\">\n <i class=\"fas\" [ngClass]=\"q.icon\" aria-hidden=\"true\"></i>{{ q.label }}\n </button>\n }\n </div>\n }\n @if (attachment.current; as file) {\n <div\n class=\"pw-brain-chat__attachment\"\n [class.pw-brain-chat__attachment--error]=\"file.status === 'error'\"\n [style.--pw-upload-progress]=\"file.percent + '%'\"\n >\n <span class=\"pw-brain-chat__attachment-icon\">\n <i class=\"fas\" [ngClass]=\"attachment.icon()\" aria-hidden=\"true\"></i>\n </span>\n <span class=\"pw-brain-chat__attachment-body\">\n <span class=\"pw-brain-chat__attachment-name\" [title]=\"file.name\">{{ file.name }}</span>\n <span class=\"pw-brain-chat__attachment-meta\" role=\"status\" aria-live=\"polite\">{{ attachment.meta() }}</span>\n </span>\n <button\n type=\"button\"\n class=\"pw-brain-chat__iconbtn\"\n (click)=\"attachment.remove()\"\n ngbTooltip=\"Remove file\"\n container=\"body\"\n aria-label=\"Remove attached file\"\n ><i class=\"fas fa-xmark\" aria-hidden=\"true\"></i></button>\n @if (file.status === 'uploading') {\n <span class=\"pw-brain-chat__attachment-progress\"></span>\n }\n </div>\n @if (attachment.choosing) {\n <div class=\"pw-brain-chat__choice\" role=\"group\" aria-label=\"What should I do with this file?\">\n <span class=\"pw-brain-chat__choice-prompt\">What should I do with this file?</span>\n <div class=\"pw-brain-chat__choice-options\">\n @for (option of attachment.choices; track option.tool) {\n <button\n type=\"button\"\n class=\"pw-brain-chat__chip\"\n (click)=\"attachment.choose(option)\"\n >{{ attachment.choiceLabel(option) }}</button>\n }\n </div>\n </div>\n }\n }\n <label class=\"visually-hidden\" for=\"pw-brain-chat-input\">Message {{ brandName }} Brain</label>\n <div class=\"pw-brain-chat__field\">\n <textarea\n id=\"pw-brain-chat-input\"\n class=\"pw-brain-chat__input\"\n rows=\"1\"\n [(ngModel)]=\"draft\"\n placeholder=\"Ask a question or tell me what to do\u2026\"\n (keydown.enter)=\"$event.preventDefault(); send()\"\n\n aria-label=\"Ask a question or tell me what to do\u2026\" ></textarea>\n <div class=\"pw-brain-chat__tools\">\n @if (attachment.enabled) {\n <input\n #fileInput\n type=\"file\"\n class=\"visually-hidden\"\n [accept]=\"attachment.acceptAttr\"\n (change)=\"pickFile(fileInput)\"\n />\n <button\n type=\"button\"\n class=\"pw-brain-chat__iconbtn\"\n [disabled]=\"loading || attachment.busy\"\n (click)=\"fileInput.click()\"\n ngbTooltip=\"Attach a file\"\n container=\"body\"\n aria-label=\"Attach a file\"\n ><i class=\"fas fa-paperclip\" aria-hidden=\"true\"></i></button>\n }\n <button\n type=\"button\"\n class=\"pw-brain-chat__iconbtn pw-brain-chat__mic\"\n [class.pw-brain-chat__mic--recording]=\"dictation.isRecording\"\n [disabled]=\"loading || dictation.phase === 'processing'\"\n (click)=\"dictation.toggle(loading)\"\n [ngbTooltip]=\"dictation.phase === 'listening' ? 'Stop dictation' : (dictation.phase === 'processing' ? 'Processing\u2026' : 'Dictate')\"\n container=\"body\"\n [attr.aria-label]=\"dictation.phase === 'listening' ? 'Stop dictation' : 'Dictate with your voice'\"\n [attr.aria-pressed]=\"dictation.isRecording\"\n ><i class=\"fas fa-microphone\" aria-hidden=\"true\"></i></button>\n @if (voiceChat.available) {\n <button\n type=\"button\"\n class=\"pw-brain-chat__iconbtn\"\n [disabled]=\"loading || dictation.isRecording\"\n (click)=\"voiceChat.toggle(loading)\"\n [ngbTooltip]=\"voiceChat.isActive ? 'End voice chat' : 'Voice chat'\"\n container=\"body\"\n [attr.aria-label]=\"voiceChat.isActive ? 'End voice chat' : 'Start voice chat'\"\n [attr.aria-pressed]=\"voiceChat.isActive\"\n >\n @switch (voiceChat.visual) {\n @case ('loader') { <i class=\"fas fa-circle-notch fa-spin\" aria-hidden=\"true\"></i> }\n @case ('wave') { <i class=\"fas fa-volume-high\" aria-hidden=\"true\"></i> }\n <!-- fa-waveform-lines (FA Pro, shipped in assets/fontawesome) \u2014 the\n canonical \"voice mode\" glyph; fa-comment-dots read as a second\n text-chat button. -->\n @default { <i class=\"fas fa-waveform-lines\" aria-hidden=\"true\"></i> }\n }\n </button>\n }\n <button\n type=\"button\"\n class=\"pw-brain-chat__send\"\n [class.pw-brain-chat__send--stop]=\"loading\"\n [disabled]=\"!loading && ((!draft.trim() && !attachment.ready) || attachment.busy || attachment.choosing)\"\n (click)=\"loading ? cancelRequest() : send()\"\n [ngbTooltip]=\"loading ? 'Stop request' : 'Send message'\"\n container=\"body\"\n [attr.aria-label]=\"loading ? 'Stop request' : 'Send message'\"\n >\n <i class=\"fas\" [ngClass]=\"loading ? 'fa-stop' : 'fa-paper-plane'\" aria-hidden=\"true\"></i>\n </button>\n </div>\n </div>\n <div class=\"pw-brain-chat__disclaimer\" role=\"note\">\n <i class=\"fas fa-triangle-exclamation\" aria-hidden=\"true\"></i>\n AI may be inaccurate \u2014 verify before acting.\n </div>\n </div>\n</div>\n", styles: [".pw-brain-chat{--bc-panel: var(--dashboard_bg, #fff);--bc-shade: #20385e;--bc-surface: color-mix(in srgb, var(--bc-panel) 96.6%, var(--bc-shade));--bc-surface-2: color-mix(in srgb, var(--bc-panel) 92.3%, var(--bc-shade));--bc-line: color-mix(in srgb, var(--bc-panel) 86.8%, var(--bc-shade));--bc-line-strong: color-mix(in srgb, var(--bc-panel) 78.3%, var(--bc-shade));--bc-bubble: color-mix(in srgb, var(--bc-panel) 94.1%, var(--bc-shade));--bc-ink: var(--text, #1a1d21);--bc-title: var(--titles, var(--text, #1a1d21));--bc-ink-2: color-mix(in srgb, var(--bc-ink) 72%, var(--bc-panel));--bc-ink-3: color-mix(in srgb, var(--bc-ink) 55%, var(--bc-panel));--bc-accent: var(--first, #1769e1);--bc-accent-wash: color-mix(in srgb, var(--first, #1769e1) 10%, transparent);--bc-accent-line: color-mix(in srgb, var(--first, #1769e1) 32%, var(--bc-line));--bc-success: #1f9d57;--bc-warning: #b7791f;--bc-error: #c0392b;--bc-r-sm: 4px;--bc-r-md: 8px;--bc-r-lg: 12px;--bc-ease: cubic-bezier(.2, .6, .25, 1);display:flex;flex-direction:column;height:100%;min-height:0;font-size:15px;color:var(--bc-ink);position:relative}:host-context([data-theme=dark]) .pw-brain-chat{--bc-panel: #15181d;--bc-surface: #1c2026;--bc-surface-2: #21262e;--bc-line: #2a2f38;--bc-line-strong: #384150;--bc-bubble: #1c2026;--bc-ink: #edeff2;--bc-title: #edeff2;--bc-ink-2: #aab3c0;--bc-ink-3: #7c8696}.pw-brain-chat__thread{flex:1 1 auto;min-height:0;overflow-y:auto;padding:16px 2px 8px;display:flex;flex-direction:column;gap:18px}.pw-brain-chat__thread>:first-child{margin-top:auto}.pw-brain-chat__turn--bot{display:grid;grid-template-columns:26px 1fr;column-gap:10px}.pw-brain-chat__spine{display:flex;flex-direction:column;align-items:center}.pw-brain-chat__node{width:26px;height:26px;border-radius:8px;flex:none;display:grid;place-items:center;background:var(--bc-surface);border:1px solid var(--bc-line);color:var(--bc-ink-2)}.pw-brain-chat__node i{font-size:12px}.pw-brain-chat__line{flex:1 1 auto;width:2px;margin-top:6px;background:var(--bc-line);border-radius:9999px}.pw-brain-chat__artifacts{min-width:0;display:flex;flex-direction:column;gap:9px;padding-top:1px}.pw-brain-chat__who{font-size:11px;text-transform:uppercase;letter-spacing:.11em;color:var(--bc-ink-3);font-weight:600}.pw-brain-chat__bubble{background:var(--bc-bubble);border:1px solid var(--bc-line);border-radius:var(--bc-r-md);padding:10px 13px}.pw-brain-chat__source{display:inline-flex;align-items:center;gap:6px;max-width:100%;margin-top:6px;padding:3px 9px;border:1px solid var(--bc-line);border-radius:var(--bc-r-sm);color:var(--bc-ink-3);font-size:11px;line-height:1.4}.pw-brain-chat__source-icon{flex-shrink:0;font-size:11px}.pw-brain-chat__source-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.pw-brain-chat__turn--user{display:flex;flex-direction:column;align-items:flex-end;gap:3px}.pw-brain-chat__time{font-size:10.5px;font-weight:400;letter-spacing:.02em;color:var(--bc-ink-3);white-space:nowrap}.pw-brain-chat__user-bubble{max-width:82%;background:var(--bc-accent);color:#fff;border-radius:var(--bc-r-md);border-top-right-radius:var(--bc-r-sm);padding:10px 13px;font-size:15px;line-height:1.5}\n", ".pw-brain-chat__welcome{flex:1 1 auto;overflow-y:auto;padding:22px 0 10px;display:flex;flex-direction:column;gap:16px}.pw-brain-chat__hero{width:44px;height:44px;border-radius:12px;display:grid;place-items:center;font-size:22px;color:#fff;background:var(--bc-accent);box-shadow:inset 0 1px #ffffff40}.pw-brain-chat__greet-h{font-size:20px;font-weight:600;letter-spacing:-.02em;margin:12px 0 4px;color:var(--bc-title)}.pw-brain-chat__greet-sub{font-size:14px;color:var(--bc-ink-2);margin:0}.pw-brain-chat__suggest-lab{font-size:11px;text-transform:uppercase;letter-spacing:.11em;color:var(--bc-ink-3);font-weight:600;margin:6px 0 -4px 2px}.pw-brain-chat__prompts{display:flex;flex-direction:column;gap:9px}.pw-brain-chat__prompt{display:flex;align-items:center;gap:11px;width:100%;text-align:left;padding:12px;border-radius:var(--bc-r-md);cursor:pointer;background:var(--bc-panel);border:1px solid var(--bc-line);color:var(--bc-ink);font:inherit;font-size:14px;font-weight:500;transition:border-color .15s var(--bc-ease),background .15s var(--bc-ease)}.pw-brain-chat__prompt:hover{border-color:var(--bc-line-strong);background:var(--bc-surface)}.pw-brain-chat__prompt:focus-visible{outline:2px solid var(--bc-accent);outline-offset:2px}.pw-brain-chat__pic{width:28px;height:28px;border-radius:7px;flex:none;display:grid;place-items:center;background:var(--bc-surface-2);border:1px solid var(--bc-line);color:var(--bc-ink-2)}.pw-brain-chat__pic i{font-size:14px}.pw-brain-chat__prompt-text{flex:1;min-width:0}.pw-brain-chat__arw{margin-left:auto;color:var(--bc-ink-3);font-size:13px}.pw-brain-chat__prompt:hover .pw-brain-chat__arw{color:var(--bc-accent)}.pw-brain-chat__quick{display:flex;gap:7px;margin-bottom:9px;overflow-x:auto;scrollbar-width:none}.pw-brain-chat__quick::-webkit-scrollbar{display:none}.pw-brain-chat__chip{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;flex:none;font:inherit;font-size:12px;font-weight:500;cursor:pointer;padding:6px 11px;border-radius:9999px;background:var(--bc-surface);border:1px solid var(--bc-line);color:var(--bc-ink-2);transition:border-color .15s var(--bc-ease),color .15s var(--bc-ease)}.pw-brain-chat__chip:hover{color:var(--bc-ink);border-color:var(--bc-line-strong)}.pw-brain-chat__chip:focus-visible{outline:2px solid var(--bc-accent);outline-offset:2px}.pw-brain-chat__chip i{font-size:11px;color:var(--bc-ink-3)}.pw-brain-chat__memory{display:inline-flex;align-items:center;gap:8px;align-self:flex-start;padding:7px 11px;border-radius:9999px;background:var(--bc-surface);border:1px solid var(--bc-line);font-size:12px;color:var(--bc-ink-2)}.pw-brain-chat__memory i{color:var(--bc-success);font-size:12px}.pw-brain-chat__memory .lbl{text-transform:uppercase;letter-spacing:.08em;font-size:10px;font-weight:600;color:var(--bc-ink-3)}\n", ".pw-brain-chat__text{margin:0;white-space:pre-wrap;overflow-wrap:break-word;font-family:inherit;font-size:15px;line-height:1.55;color:var(--bc-ink)}.pw-brain-chat__text p{margin:0}.pw-brain-chat__text p+p,.pw-brain-chat__text ul,.pw-brain-chat__text ol{margin-top:7px}.pw-brain-chat__text ul,.pw-brain-chat__text ol{padding-left:18px}.pw-brain-chat__text a{color:var(--bc-ink);text-decoration:underline;text-underline-offset:2px;text-decoration-color:var(--bc-line-strong)}.pw-brain-chat__text a:hover,.pw-brain-chat__text a:focus-visible{color:var(--bc-accent);text-decoration-color:var(--bc-accent)}.pw-brain-chat__text table{width:100%;margin-top:8px;border-collapse:collapse;font-size:13px;border:1px solid var(--bc-line);border-radius:var(--bc-r-md);overflow:hidden}.pw-brain-chat__text th,.pw-brain-chat__text td{text-align:left;padding:8px 12px;border-bottom:1px solid var(--bc-line)}.pw-brain-chat__text th{background:var(--bc-surface);font-weight:600;font-size:11px;letter-spacing:.07em;text-transform:uppercase;color:var(--bc-ink-2)}.pw-brain-chat__text tr:last-child td{border-bottom:0}.pw-brain-chat__user-text{margin:0;white-space:pre-wrap;overflow-wrap:break-word;font-family:inherit;font-size:15px;line-height:1.5}.pw-brain-chat__caret{display:inline-block;width:2px;height:1.05em;vertical-align:-2px;margin-left:2px;background:var(--bc-accent);border-radius:1px;animation:pw-brain-chat-caret 1s steps(2,start) infinite}@keyframes pw-brain-chat-caret{50%{opacity:0}}@media(prefers-reduced-motion:reduce){.pw-brain-chat__caret{animation:none}}\n", ".pw-brain-chat__loading{display:flex;flex-wrap:wrap;align-items:center;gap:10px;padding:4px 2px 0;font-size:12px;color:var(--bc-ink-3, #7c8696)}.pw-brain-chat__loading-spinner{color:var(--bc-accent, #1769e1)}.pw-brain-chat__iconbtn{width:32px;height:32px;flex:none;display:inline-flex;align-items:center;justify-content:center;padding:0;border:1px solid transparent;border-radius:var(--bc-r-md, 8px);background:transparent;color:var(--bc-ink-3, #7c8696);cursor:pointer;transition:background .15s ease,color .15s ease}.pw-brain-chat__iconbtn:hover:not(:disabled){background:var(--bc-surface, #f7f8fa);color:var(--bc-ink, #1a1d21)}.pw-brain-chat__iconbtn:focus-visible{outline:2px solid var(--bc-accent, #1769e1);outline-offset:2px}.pw-brain-chat__iconbtn:disabled{opacity:.5;cursor:default}.pw-brain-chat__mic--recording{color:var(--bc-error, #c0392b)}.pw-brain-chat__stop:hover:not(:disabled){color:var(--bc-error, #c0392b)}.pw-brain-chat__compose{flex-shrink:0;border-top:1px solid var(--bc-line, #e2e5ea);padding:10px 2px 4px}.pw-brain-chat__field{display:flex;align-items:flex-end;gap:8px;border:1px solid var(--bc-line, #e2e5ea);border-radius:var(--bc-r-md, 8px);background:var(--bc-panel, #fff);padding:6px 6px 6px 12px;transition:border-color .15s ease,box-shadow .15s ease}.pw-brain-chat__field:focus-within{border-color:var(--bc-accent, #1769e1);box-shadow:0 0 0 3px var(--bc-accent-wash, rgba(23, 105, 225, .1))}.pw-brain-chat__input{flex:1;border:0;resize:none;background:transparent;font-family:inherit;font-size:14px;line-height:1.5;color:var(--bc-ink, #1a1d21);padding:6px 0;max-height:96px}.pw-brain-chat__input:focus{outline:none;box-shadow:none}.pw-brain-chat__input::placeholder{color:var(--bc-ink-3, #7c8696)}.pw-brain-chat__tools{display:flex;align-items:center;gap:2px;flex:none}.pw-brain-chat__send{width:34px;height:34px;flex:none;display:inline-flex;align-items:center;justify-content:center;border:0;border-radius:var(--bc-r-md, 8px);background:var(--bc-accent, #1769e1);color:#fff;cursor:pointer;transition:filter .15s ease}.pw-brain-chat__send:hover:not(:disabled){filter:brightness(1.07)}.pw-brain-chat__send:disabled{background:var(--bc-line-strong, #cfd4dc);cursor:default}.pw-brain-chat__send:focus-visible{outline:2px solid var(--bc-accent, #1769e1);outline-offset:2px}.pw-brain-chat__send--stop{background:var(--bc-error, #c0392b)!important}.pw-brain-chat__disclaimer{display:flex;align-items:center;gap:6px;margin:8px 2px 2px;font-size:11px;color:var(--bc-ink-3, #7c8696)}\n", ".pw-brain-chat__dropzone{position:absolute;inset:0;z-index:5;display:flex;align-items:center;justify-content:center;padding:16px;background:color-mix(in srgb,var(--bc-panel, #fff) 82%,transparent);-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);animation:pw-brain-chat-dropzone-in .16s ease-out}.pw-brain-chat__dropzone-frame{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;width:100%;height:100%;padding:24px 16px;text-align:center;border:2px dashed var(--bc-accent, #1769e1);border-radius:var(--bc-r-lg, 12px);background:var(--bc-accent-wash, rgba(23, 105, 225, .1))}.pw-brain-chat__dropzone-icon{width:48px;height:48px;display:inline-flex;align-items:center;justify-content:center;margin-bottom:2px;font-size:19px;line-height:1;border-radius:50%;color:var(--bc-accent, #1769e1);background:var(--bc-panel, #fff);border:1px solid color-mix(in srgb,var(--bc-accent, #1769e1) 28%,transparent);box-shadow:0 1px 3px #0000000f}.pw-brain-chat__dropzone-title{font-size:15px;font-weight:600;letter-spacing:-.1px;color:var(--bc-ink, #1a1d21)}.pw-brain-chat__dropzone-hint{font-size:12px;color:var(--bc-ink-3, #7c8696)}@keyframes pw-brain-chat-dropzone-in{0%{opacity:0;transform:scale(.99)}to{opacity:1;transform:none}}.pw-brain-chat__attachment{position:relative;display:flex;align-items:center;gap:10px;margin:0 2px 8px;padding:8px 10px;overflow:hidden;border:1px solid var(--bc-line, #e2e5ea);border-radius:var(--bc-r-md, 8px);background:var(--bc-surface, #f7f8fa)}.pw-brain-chat__attachment--error{border-color:var(--bc-error, #c0392b);background:color-mix(in srgb,var(--bc-error, #c0392b) 6%,transparent)}.pw-brain-chat__attachment-icon{width:28px;height:28px;flex:none;display:inline-flex;align-items:center;justify-content:center;font-size:13px;border-radius:var(--bc-r-sm, 6px);background:var(--bc-panel, #fff);border:1px solid var(--bc-line, #e2e5ea);color:var(--bc-accent, #1769e1)}.pw-brain-chat__attachment--error .pw-brain-chat__attachment-icon{color:var(--bc-error, #c0392b)}.pw-brain-chat__attachment-body{flex:1;min-width:0}.pw-brain-chat__attachment-name{display:block;font-size:13px;font-weight:600;color:var(--bc-ink, #1a1d21);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.pw-brain-chat__attachment-meta{display:block;margin-top:1px;font-size:11px;color:var(--bc-ink-3, #7c8696)}.pw-brain-chat__attachment--error .pw-brain-chat__attachment-meta{color:var(--bc-error, #c0392b)}.pw-brain-chat__attachment-progress{position:absolute;left:0;bottom:0;height:2px;width:var(--pw-upload-progress, 0%);background:var(--bc-accent, #1769e1);transition:width .18s ease-out}@media(prefers-reduced-motion:reduce){.pw-brain-chat__dropzone{animation:none}.pw-brain-chat__attachment-progress{transition:none}}.pw-brain-chat__choice{display:flex;flex-direction:column;gap:6px;margin:-2px 2px 9px}.pw-brain-chat__choice-prompt{font-size:12px;color:var(--bc-ink-2, #5b6472)}.pw-brain-chat__choice-options{display:flex;flex-wrap:wrap;gap:7px}\n", ".pw-brain-chat__mic{display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--bs-border-color, #ced4da);background:transparent;color:var(--bs-secondary-color, #6c757d);transition:color .15s ease,border-color .15s ease}.pw-brain-chat__mic:hover:not(:disabled){color:var(--first, #0d6efd);border-color:var(--first, #0d6efd)}.pw-brain-chat__mic--recording{color:#dc3545;border-color:#dc3545;animation:pw-brain-chat-mic-pulse 1.2s ease-in-out infinite}@keyframes pw-brain-chat-mic-pulse{0%,to{opacity:1}50%{opacity:.55}}@media(prefers-reduced-motion:reduce){.pw-brain-chat__mic--recording{animation:none}}\n"] }]
2020
2557
  }], ctorParameters: () => [{ type: i1.MCPOrchestratorService }, { type: i1.LocalStorage }, { type: i2.Router }, { type: i0.ChangeDetectorRef }, { type: i3.Store }, { type: DynamicPageContextService }, { type: i2$1.AppConfigService, decorators: [{
2021
2558
  type: Optional
2022
2559
  }] }, { type: i1.BrainSocketService, decorators: [{
@@ -2025,6 +2562,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImpo
2025
2562
  type: Optional
2026
2563
  }] }, { type: i1.VoiceChatService, decorators: [{
2027
2564
  type: Optional
2565
+ }] }, { type: i1.DirectUploadService, decorators: [{
2566
+ type: Optional
2567
+ }] }, { type: undefined, decorators: [{
2568
+ type: Optional
2569
+ }, {
2570
+ type: Inject,
2571
+ args: [BRAIN_CHAT_UPLOAD_APIS]
2028
2572
  }] }], propDecorators: { threadRef: [{
2029
2573
  type: ViewChild,
2030
2574
  args: ['thread']
@@ -2393,7 +2937,7 @@ class CollapsibleSidebarComponent {
2393
2937
  .subscribe(config => this.registerBrainPanel(resolveBrandName(config)));
2394
2938
  // Subscribe to expanded state
2395
2939
  this.sidebarService.sidebarExpanded$
2396
- .pipe(takeUntil(this.destroy$))
2940
+ .pipe(takeUntil$1(this.destroy$))
2397
2941
  .subscribe(isExpanded => {
2398
2942
  this.isExpanded = isExpanded;
2399
2943
  this.cdr.markForCheck();
@@ -2406,7 +2950,7 @@ class CollapsibleSidebarComponent {
2406
2950
  // container not found". #4167 (open-on-navigate-back) keeps the slot
2407
2951
  // populated, so subscribe AFTER the view init so the first emission lands
2408
2952
  // with `contentContainer` wired up.
2409
- this.sidebarService.sidebarContent$.pipe(takeUntil(this.destroy$)).subscribe(content => {
2953
+ this.sidebarService.sidebarContent$.pipe(takeUntil$1(this.destroy$)).subscribe(content => {
2410
2954
  this.currentContent = content;
2411
2955
  if (content) {
2412
2956
  this.loadComponent(content);
@@ -3140,12 +3684,12 @@ class CommandPaletteComponent {
3140
3684
  }
3141
3685
  ngOnInit() {
3142
3686
  brandName$(this.appConfigService)
3143
- .pipe(takeUntil(this.destroy$))
3687
+ .pipe(takeUntil$1(this.destroy$))
3144
3688
  .subscribe(name => {
3145
3689
  this.brandName = name;
3146
3690
  this.cdr.markForCheck();
3147
3691
  });
3148
- this.palette.isOpen$.pipe(takeUntil(this.destroy$)).subscribe(isOpen => {
3692
+ this.palette.isOpen$.pipe(takeUntil$1(this.destroy$)).subscribe(isOpen => {
3149
3693
  this.isOpen = isOpen;
3150
3694
  if (isOpen) {
3151
3695
  this.reset();
@@ -3154,7 +3698,7 @@ class CommandPaletteComponent {
3154
3698
  syncPaletteDialog(this.paletteDialog?.nativeElement, isOpen);
3155
3699
  });
3156
3700
  peopleSearch(this.queryChanges, this.dashboard)
3157
- .pipe(takeUntil(this.destroy$))
3701
+ .pipe(takeUntil$1(this.destroy$))
3158
3702
  .subscribe(people => {
3159
3703
  this.people = people;
3160
3704
  this.rebuild();
@@ -6132,5 +6676,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImpo
6132
6676
  * Generated bundle index. Do not edit.
6133
6677
  */
6134
6678
 
6135
- export { AuthenticatorComponent, COMPONENT_REGISTRY, ClearBitIconComponent, CollapsibleSidebarComponent, CollapsibleSidebarKeyboardShortcutDirective, CollapsibleSidebarService, CollapsibleSidebarSuperAdminGuard, CollapsibleSidebarTriggerDirective, ComingSoonComponent, CommandPaletteComponent, CommandPaletteService, CompletionBarComponent, ConfirmDialogComponent, ConfirmDialogService, DateRangePickerComponent, DynamicPageContextService, EntityGroupComponent, GroupDefinitionComponent, GroupsComponent, HeaderComponent, InputContainerComponent, LandingPageFooterBComponent, NoDataComponent, NumberPickerComponent, PasswordValidationComponent, PermissionTreeComponent, PrivacyAndTosComponent, PrivacyPolicyComponent, PwBrainChatComponent, PwCookieBannerComponent, PwDynamicPageComponent, PwTabsComponent, RecordsSummaryComponent, ResourceSharedComponentsModule, SharedComponentsModule, SplashComponent, TermsConditionsComponent, UI_BUILDER_FLAG, UiLayoutService, registeredType, registeredTypeNames };
6679
+ export { AuthenticatorComponent, BRAIN_CHAT_UPLOAD_APIS, COMPONENT_REGISTRY, ClearBitIconComponent, CollapsibleSidebarComponent, CollapsibleSidebarKeyboardShortcutDirective, CollapsibleSidebarService, CollapsibleSidebarSuperAdminGuard, CollapsibleSidebarTriggerDirective, ComingSoonComponent, CommandPaletteComponent, CommandPaletteService, CompletionBarComponent, ConfirmDialogComponent, ConfirmDialogService, DateRangePickerComponent, DynamicPageContextService, EntityGroupComponent, GroupDefinitionComponent, GroupsComponent, HeaderComponent, InputContainerComponent, LandingPageFooterBComponent, NoDataComponent, NumberPickerComponent, PasswordValidationComponent, PermissionTreeComponent, PrivacyAndTosComponent, PrivacyPolicyComponent, PwBrainChatComponent, PwCookieBannerComponent, PwDynamicPageComponent, PwTabsComponent, RecordsSummaryComponent, ResourceSharedComponentsModule, SharedComponentsModule, SplashComponent, TermsConditionsComponent, UI_BUILDER_FLAG, UiLayoutService, registeredType, registeredTypeNames };
6136
6680
  //# sourceMappingURL=posiwise-shared-components.mjs.map