@ids-group-ltd/ids-design-system 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/CHANGELOG.md +261 -3
  2. package/agent/INDEX.md +12 -2
  3. package/agent/feedback/ds-attachment.md +12 -0
  4. package/agent/feedback/ds-chat-attachment.md +10 -0
  5. package/agent/feedback/ds-chat-message.md +11 -0
  6. package/agent/feedback/ds-chat-step.md +10 -0
  7. package/agent/feedback/ds-chat-steps.md +10 -0
  8. package/agent/feedback/ds-chat-thread.md +11 -0
  9. package/agent/feedback/ds-timeline-item.md +3 -1
  10. package/agent/feedback/ds-timeline.md +9 -0
  11. package/agent/feedback/ds-toast.md +1 -1
  12. package/agent/feedback/ds-tree.md +3 -1
  13. package/agent/forms/ds-chat-input.md +16 -0
  14. package/agent/forms/ds-inline-edit.md +14 -0
  15. package/agent/foundations/tokens.md +3 -3
  16. package/agent/navigation/ds-splitter.md +14 -0
  17. package/agent/platform/toast-service.md +3 -2
  18. package/agent/tables/ds-table.md +1 -1
  19. package/components.md +107 -9
  20. package/fesm2022/ids-group-ltd-ids-design-system-components-app-layout.mjs +2 -2
  21. package/fesm2022/ids-group-ltd-ids-design-system-components-app-layout.mjs.map +1 -1
  22. package/fesm2022/ids-group-ltd-ids-design-system-components-avatar.mjs +7 -4
  23. package/fesm2022/ids-group-ltd-ids-design-system-components-avatar.mjs.map +1 -1
  24. package/fesm2022/ids-group-ltd-ids-design-system-components-chat.mjs +858 -0
  25. package/fesm2022/ids-group-ltd-ids-design-system-components-chat.mjs.map +1 -0
  26. package/fesm2022/ids-group-ltd-ids-design-system-components-color-picker.mjs +2 -2
  27. package/fesm2022/ids-group-ltd-ids-design-system-components-color-picker.mjs.map +1 -1
  28. package/fesm2022/ids-group-ltd-ids-design-system-components-date-picker.mjs +2 -2
  29. package/fesm2022/ids-group-ltd-ids-design-system-components-date-picker.mjs.map +1 -1
  30. package/fesm2022/ids-group-ltd-ids-design-system-components-drawer.mjs +2 -2
  31. package/fesm2022/ids-group-ltd-ids-design-system-components-drawer.mjs.map +1 -1
  32. package/fesm2022/ids-group-ltd-ids-design-system-components-inline-edit.mjs +107 -0
  33. package/fesm2022/ids-group-ltd-ids-design-system-components-inline-edit.mjs.map +1 -0
  34. package/fesm2022/ids-group-ltd-ids-design-system-components-list.mjs +2 -2
  35. package/fesm2022/ids-group-ltd-ids-design-system-components-list.mjs.map +1 -1
  36. package/fesm2022/ids-group-ltd-ids-design-system-components-menu.mjs +2 -2
  37. package/fesm2022/ids-group-ltd-ids-design-system-components-menu.mjs.map +1 -1
  38. package/fesm2022/ids-group-ltd-ids-design-system-components-modal.mjs +4 -4
  39. package/fesm2022/ids-group-ltd-ids-design-system-components-modal.mjs.map +1 -1
  40. package/fesm2022/ids-group-ltd-ids-design-system-components-popover.mjs +2 -2
  41. package/fesm2022/ids-group-ltd-ids-design-system-components-popover.mjs.map +1 -1
  42. package/fesm2022/ids-group-ltd-ids-design-system-components-splitter.mjs +359 -0
  43. package/fesm2022/ids-group-ltd-ids-design-system-components-splitter.mjs.map +1 -0
  44. package/fesm2022/ids-group-ltd-ids-design-system-components-stepper.mjs +2 -2
  45. package/fesm2022/ids-group-ltd-ids-design-system-components-stepper.mjs.map +1 -1
  46. package/fesm2022/ids-group-ltd-ids-design-system-components-table.mjs +2 -2
  47. package/fesm2022/ids-group-ltd-ids-design-system-components-table.mjs.map +1 -1
  48. package/fesm2022/ids-group-ltd-ids-design-system-components-time-picker.mjs +2 -2
  49. package/fesm2022/ids-group-ltd-ids-design-system-components-time-picker.mjs.map +1 -1
  50. package/fesm2022/ids-group-ltd-ids-design-system-components-timeline.mjs +74 -17
  51. package/fesm2022/ids-group-ltd-ids-design-system-components-timeline.mjs.map +1 -1
  52. package/fesm2022/ids-group-ltd-ids-design-system-components-toast.mjs +163 -20
  53. package/fesm2022/ids-group-ltd-ids-design-system-components-toast.mjs.map +1 -1
  54. package/fesm2022/ids-group-ltd-ids-design-system-components-tooltip.mjs +2 -2
  55. package/fesm2022/ids-group-ltd-ids-design-system-components-tooltip.mjs.map +1 -1
  56. package/fesm2022/ids-group-ltd-ids-design-system-components-tree.mjs +146 -24
  57. package/fesm2022/ids-group-ltd-ids-design-system-components-tree.mjs.map +1 -1
  58. package/fesm2022/ids-group-ltd-ids-design-system-core.mjs +54 -0
  59. package/fesm2022/ids-group-ltd-ids-design-system-core.mjs.map +1 -1
  60. package/fesm2022/ids-group-ltd-ids-design-system.mjs +4 -1
  61. package/fesm2022/ids-group-ltd-ids-design-system.mjs.map +1 -1
  62. package/migrations/1.0.2.json +28 -0
  63. package/migrations/1.0.3.json +15 -0
  64. package/migrations/1.1.0.json +183 -0
  65. package/package.json +25 -1
  66. package/schematics/check-overrides/surface.json +181 -5
  67. package/styles/_dropdown-overlay.scss +6 -4
  68. package/styles/_step-marker.scss +51 -0
  69. package/styles/_tokens.scss +5 -3
  70. package/themes/README.md +2 -1
  71. package/themes/_semantic.scss +10 -0
  72. package/themes/dark/_palette.scss +1 -2
  73. package/themes/dark/_theme.scss +24 -3
  74. package/types/ids-group-ltd-ids-design-system-components-avatar.d.ts +3 -1
  75. package/types/ids-group-ltd-ids-design-system-components-button.d.ts +2 -2
  76. package/types/ids-group-ltd-ids-design-system-components-chart.d.ts +1 -1
  77. package/types/ids-group-ltd-ids-design-system-components-chat.d.ts +340 -0
  78. package/types/ids-group-ltd-ids-design-system-components-inline-edit.d.ts +43 -0
  79. package/types/ids-group-ltd-ids-design-system-components-pie-chart.d.ts +1 -1
  80. package/types/ids-group-ltd-ids-design-system-components-splitter.d.ts +83 -0
  81. package/types/ids-group-ltd-ids-design-system-components-timeline.d.ts +34 -5
  82. package/types/ids-group-ltd-ids-design-system-components-toast.d.ts +53 -4
  83. package/types/ids-group-ltd-ids-design-system-components-tree.d.ts +51 -7
  84. package/types/ids-group-ltd-ids-design-system-core.d.ts +104 -0
  85. package/types/ids-group-ltd-ids-design-system.d.ts +6 -3
@@ -0,0 +1,858 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, input, model, inject, computed, ViewEncapsulation, Component, contentChildren, forwardRef, booleanAttribute, output, contentChild, ElementRef, signal, afterNextRender, effect, untracked, Injector, DestroyRef, viewChild } from '@angular/core';
3
+ import { DS_INTL, DS_INTL_DEFAULTS, injectDsLocale } from '@ids-group-ltd/ids-design-system/core';
4
+ import { ButtonComponent } from '@ids-group-ltd/ids-design-system/components/button';
5
+ import { IconComponent } from '@ids-group-ltd/ids-design-system/icons';
6
+ import { SpinnerComponent } from '@ids-group-ltd/ids-design-system/components/spinner';
7
+ import { TextareaComponent } from '@ids-group-ltd/ids-design-system/components/textarea';
8
+ import { FieldClickFocusDirective } from '@ids-group-ltd/ids-design-system/components';
9
+
10
+ const CHAT_THREAD = new InjectionToken('CHAT_THREAD');
11
+ const CHAT_STEPS = new InjectionToken('CHAT_STEPS');
12
+
13
+ const STATUS_ICONS = {
14
+ done: 'check',
15
+ waiting: 'pause',
16
+ error: 'x',
17
+ };
18
+ const STATUS_WORDING = {
19
+ done: 'stepDone',
20
+ running: 'stepRunning',
21
+ pending: 'stepPending',
22
+ waiting: 'stepWaiting',
23
+ error: 'stepFailed',
24
+ };
25
+ let nextId$1 = 0;
26
+ /**
27
+ * One step of an agent's work inside `ds-chat-steps`: a marker for its `status`, the heading, and
28
+ * optional content under it (such as Approve buttons on a `waiting` step). Slots: `[trailing]` at the
29
+ * end of the heading row (Stop, Retry), `[details]` behind a chevron (the step's log).
30
+ */
31
+ class ChatStepComponent {
32
+ /** What the step does, such as "Run the build". */
33
+ heading = input('', ...(ngDevMode ? [{ debugName: "heading" }] : /* istanbul ignore next */ []));
34
+ /** Time or duration label under the content. */
35
+ time = input('', ...(ngDevMode ? [{ debugName: "time" }] : /* istanbul ignore next */ []));
36
+ /** Where the step is: draws the marker and is spoken before the heading. */
37
+ status = input(null, ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
38
+ /** Whether the `[details]` area is open, two-way bound. */
39
+ expanded = model(false, ...(ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []));
40
+ intl = inject(DS_INTL);
41
+ steps = inject(CHAT_STEPS, { optional: true });
42
+ detailsId = `ds-chat-step-${++nextId$1}-details`;
43
+ isFirst = computed(() => this.steps?.firstStep() === this, ...(ngDevMode ? [{ debugName: "isFirst" }] : /* istanbul ignore next */ []));
44
+ isLast = computed(() => this.steps?.lastStep() === this, ...(ngDevMode ? [{ debugName: "isLast" }] : /* istanbul ignore next */ []));
45
+ nodeIcon = computed(() => {
46
+ const status = this.status();
47
+ return status ? (STATUS_ICONS[status] ?? null) : null;
48
+ }, ...(ngDevMode ? [{ debugName: "nodeIcon" }] : /* istanbul ignore next */ []));
49
+ wording = computed(() => ({
50
+ ...DS_INTL_DEFAULTS.chat,
51
+ ...this.intl().chat,
52
+ }), ...(ngDevMode ? [{ debugName: "wording" }] : /* istanbul ignore next */ []));
53
+ statusLabel = computed(() => {
54
+ const status = this.status();
55
+ return status ? this.wording()[STATUS_WORDING[status]] : '';
56
+ }, ...(ngDevMode ? [{ debugName: "statusLabel" }] : /* istanbul ignore next */ []));
57
+ detailsLabel = computed(() => this.wording().stepDetails(this.heading()), ...(ngDevMode ? [{ debugName: "detailsLabel" }] : /* istanbul ignore next */ []));
58
+ toggle() {
59
+ this.expanded.set(!this.expanded());
60
+ }
61
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ChatStepComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
62
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.22", type: ChatStepComponent, isStandalone: true, selector: "ds-chat-step", inputs: { heading: { classPropertyName: "heading", publicName: "heading", isSignal: true, isRequired: false, transformFunction: null }, time: { classPropertyName: "time", publicName: "time", isSignal: true, isRequired: false, transformFunction: null }, status: { classPropertyName: "status", publicName: "status", isSignal: true, isRequired: false, transformFunction: null }, expanded: { classPropertyName: "expanded", publicName: "expanded", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { expanded: "expandedChange" }, host: { attributes: { "role": "listitem" }, properties: { "attr.data-status": "status()", "class.is-first": "isFirst()", "class.is-last": "isLast()", "class.is-expanded": "expanded()", "class.outside-steps": "!steps" } }, ngImport: i0, template: "<div\n class=\"node-col\"\n aria-hidden=\"true\">\n <span class=\"spine lead\"></span>\n\n <span class=\"node\">\n @if (status() === 'running') {\n <ds-spinner size=\"sm\" />\n } @else if (nodeIcon(); as name) {\n <ds-icon\n [name]=\"name\"\n [size]=\"10\"\n [stroke]=\"2.4\" />\n }\n </span>\n\n <span class=\"spine\"></span>\n</div>\n\n<div class=\"text\">\n <div class=\"head\">\n @if (statusLabel()) {\n <span class=\"visually-hidden\">\n {{ statusLabel() }}:\n </span>\n }\n\n @if (heading()) {\n <span class=\"heading\">\n {{ heading() }}\n </span>\n }\n\n <span class=\"trailing\">\n <ng-content select=\"[trailing]\"></ng-content>\n\n <button\n type=\"button\"\n class=\"toggle\"\n [attr.aria-label]=\"detailsLabel()\"\n [attr.aria-expanded]=\"expanded()\"\n [attr.aria-controls]=\"detailsId\"\n (click)=\"toggle()\">\n <ds-icon\n class=\"chev\"\n name=\"chevronDown\"\n [size]=\"16\" />\n </button>\n </span>\n </div>\n\n <ng-content></ng-content>\n\n @if (time()) {\n <span class=\"time\">\n {{ time() }}\n </span>\n }\n</div>\n\n<span\n class=\"spine tail\"\n aria-hidden=\"true\">\n</span>\n\n<div class=\"rest\">\n <div\n class=\"details\"\n [id]=\"detailsId\"\n [attr.inert]=\"expanded() ? null : ''\">\n <div class=\"details-content\">\n <div class=\"details-body\">\n <ng-content select=\"[details]\"></ng-content>\n </div>\n </div>\n </div>\n</div>\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{--_step-node-size: var(--chat-step-node-size);--_step-spine-width: var(--timeline-spine-w);--_step-gap: var(--chat-step-gap);--_step-node-bg-color: var(--surface-secondary);--_step-node-color: var(--text-tertiary);--_step-node-border-color: var(--text-tertiary);--_step-spine-color: var(--border-divider);--_step-toggle-icon-color: var(--icon-default);--_step-toggle-icon-color-hover: var(--icon-strong);--_step-open-bg-color: var(--surface-secondary);display:grid;grid-template-columns:var(--_step-node-size) 1fr;column-gap:var(--space-2)}.node-col{grid-area:1/1;display:flex;flex-direction:column;align-items:center}.node{display:inline-flex;align-items:center;justify-content:center;flex:none;width:var(--_step-node-size);height:var(--_step-node-size);border-radius:var(--radius-pill);background-color:var(--_step-node-bg-color);color:var(--_step-node-color);border:var(--border-width-default) solid var(--_step-node-border-color)}.spine{visibility:hidden;flex:1;width:var(--_step-spine-width);margin-top:var(--space-1);background-color:var(--_step-spine-color)}.lead{margin-top:0;margin-bottom:var(--space-1)}.tail{grid-area:2/1;justify-self:center;margin-top:0}.text{grid-area:1/2;display:flex;flex-direction:column;align-self:center;gap:var(--space-0-5);min-width:0}.rest{grid-area:2/2;padding-bottom:var(--_step-gap);min-width:0}:host(.is-last) .spine:not(.lead),:host(.outside-steps:last-child) .spine:not(.lead){visibility:hidden}:host(.is-last) .rest,:host(.outside-steps:last-child) .rest{padding-bottom:0}:host(.is-first) .lead,:host(.outside-steps:first-child) .lead{visibility:hidden}.head{position:relative;display:flex;align-items:flex-start;gap:var(--space-2);min-width:0}.visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.trailing{display:inline-flex;align-items:center;gap:var(--space-2);margin-left:auto;flex:none;height:calc(var(--font-size-xs) * var(--line-height-base))}.head:has(.trailing>:not(.toggle)){align-items:center;margin-bottom:var(--space-1-5);padding-top:var(--space-2)}.head:has(.trailing>:not(.toggle)) .trailing{height:auto}.toggle{display:inline-flex;align-items:center;justify-content:center;padding:var(--space-0-5);border:0;background:none;cursor:pointer}.toggle:active:not(:disabled,[disabled],.is-disabled,.disabled,[aria-disabled=true]){filter:brightness(var(--ds-press-brightness, .9));transform:scale(var(--ds-press-scale, .97))}.toggle{position:relative}.toggle:before{content:\"\";position:absolute;top:50%;left:50%;width:max(100%,var(--hit-xs));height:max(100%,var(--hit-xs));translate:-50% -50%;border-radius:inherit}.toggle:focus-visible{outline-style:none}.toggle:focus-visible:before{outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:calc(var(--focus-ring-offset) - 2 * var(--focus-ring-width));animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard)}.toggle{color:var(--_step-toggle-icon-color)}.toggle:hover{color:var(--_step-toggle-icon-color-hover)}.toggle .chev{transition:transform var(--duration-base) var(--ease-standard)}.toggle[aria-expanded=true] .chev{transform:rotate(180deg)}:host:not(:has(.details-body>*)) .toggle{display:none}:host(.is-expanded){isolation:isolate}:host(.is-expanded):before{content:\"\";grid-area:1/1/3/3;z-index:-1;margin:0 calc(-1 * var(--space-2)) var(--_step-gap);border-radius:var(--ds-radius-control);background-color:var(--_step-open-bg-color)}:host(.is-expanded.is-last):before,:host(.is-expanded.outside-steps:last-child):before{margin-bottom:0}.details{display:grid;grid-template-rows:0fr;min-width:0;visibility:hidden;transition:grid-template-rows var(--duration-slow) var(--ease-decelerate),visibility var(--duration-slow) allow-discrete}.details:not(:has(.details-body>*)){display:none}:host(.is-expanded) .details{grid-template-rows:1fr;visibility:visible}.details-content{min-height:0;overflow:hidden}.details-body{padding-top:var(--space-1)}.heading{color:var(--text-primary);font:var(--font-weight-regular) var(--font-size-xs)/var(--line-height-base) var(--font-sans)}.time{color:var(--text-tertiary);font:var(--font-weight-regular) var(--font-size-xs)/var(--line-height-base) var(--font-sans)}:host([data-status=done]){--_step-node-bg-color: var(--success);--_step-node-color: var(--text-on-success);--_step-node-border-color: var(--success)}:host([data-status=running]){--_step-node-bg-color: var(--surface-default);--_step-node-color: var(--accent);--_step-node-border-color: var(--accent)}:host([data-status=pending]){--_step-node-bg-color: var(--surface-default);--_step-node-color: var(--text-tertiary);--_step-node-border-color: var(--text-tertiary)}:host([data-status=error]){--_step-node-bg-color: var(--error);--_step-node-color: var(--text-on-error);--_step-node-border-color: var(--error)}:host([data-status=pending]) .node{border-style:dashed}:host([data-status=pending]) .heading{color:var(--text-tertiary);font-weight:var(--font-weight-regular)}:host([data-status=waiting]){--_step-node-bg-color: var(--text-secondary);--_step-node-color: var(--surface-default);--_step-node-border-color: var(--text-secondary)}:host([data-status=waiting]){--_step-heading-line: calc(var(--font-size-xs) * var(--line-height-base))}:host([data-status=waiting]) .text{align-self:start;padding-top:max(0px,var(--_step-node-size) / 2 + var(--space-1) - var(--_step-heading-line) / 2)}:host([data-status=waiting]) .lead{flex:none;height:max(0px,var(--_step-heading-line) / 2 - var(--_step-node-size) / 2 - var(--space-1))}\n"], dependencies: [{ kind: "component", type: IconComponent, selector: "ds-icon", inputs: ["name", "size", "stroke", "ariaLabel"] }, { kind: "component", type: SpinnerComponent, selector: "ds-spinner", inputs: ["size"] }] });
63
+ }
64
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ChatStepComponent, decorators: [{
65
+ type: Component,
66
+ args: [{ selector: 'ds-chat-step', standalone: true, imports: [IconComponent, SpinnerComponent], encapsulation: ViewEncapsulation.Emulated, host: {
67
+ role: 'listitem',
68
+ '[attr.data-status]': 'status()',
69
+ '[class.is-first]': 'isFirst()',
70
+ '[class.is-last]': 'isLast()',
71
+ '[class.is-expanded]': 'expanded()',
72
+ '[class.outside-steps]': '!steps',
73
+ }, template: "<div\n class=\"node-col\"\n aria-hidden=\"true\">\n <span class=\"spine lead\"></span>\n\n <span class=\"node\">\n @if (status() === 'running') {\n <ds-spinner size=\"sm\" />\n } @else if (nodeIcon(); as name) {\n <ds-icon\n [name]=\"name\"\n [size]=\"10\"\n [stroke]=\"2.4\" />\n }\n </span>\n\n <span class=\"spine\"></span>\n</div>\n\n<div class=\"text\">\n <div class=\"head\">\n @if (statusLabel()) {\n <span class=\"visually-hidden\">\n {{ statusLabel() }}:\n </span>\n }\n\n @if (heading()) {\n <span class=\"heading\">\n {{ heading() }}\n </span>\n }\n\n <span class=\"trailing\">\n <ng-content select=\"[trailing]\"></ng-content>\n\n <button\n type=\"button\"\n class=\"toggle\"\n [attr.aria-label]=\"detailsLabel()\"\n [attr.aria-expanded]=\"expanded()\"\n [attr.aria-controls]=\"detailsId\"\n (click)=\"toggle()\">\n <ds-icon\n class=\"chev\"\n name=\"chevronDown\"\n [size]=\"16\" />\n </button>\n </span>\n </div>\n\n <ng-content></ng-content>\n\n @if (time()) {\n <span class=\"time\">\n {{ time() }}\n </span>\n }\n</div>\n\n<span\n class=\"spine tail\"\n aria-hidden=\"true\">\n</span>\n\n<div class=\"rest\">\n <div\n class=\"details\"\n [id]=\"detailsId\"\n [attr.inert]=\"expanded() ? null : ''\">\n <div class=\"details-content\">\n <div class=\"details-body\">\n <ng-content select=\"[details]\"></ng-content>\n </div>\n </div>\n </div>\n</div>\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{--_step-node-size: var(--chat-step-node-size);--_step-spine-width: var(--timeline-spine-w);--_step-gap: var(--chat-step-gap);--_step-node-bg-color: var(--surface-secondary);--_step-node-color: var(--text-tertiary);--_step-node-border-color: var(--text-tertiary);--_step-spine-color: var(--border-divider);--_step-toggle-icon-color: var(--icon-default);--_step-toggle-icon-color-hover: var(--icon-strong);--_step-open-bg-color: var(--surface-secondary);display:grid;grid-template-columns:var(--_step-node-size) 1fr;column-gap:var(--space-2)}.node-col{grid-area:1/1;display:flex;flex-direction:column;align-items:center}.node{display:inline-flex;align-items:center;justify-content:center;flex:none;width:var(--_step-node-size);height:var(--_step-node-size);border-radius:var(--radius-pill);background-color:var(--_step-node-bg-color);color:var(--_step-node-color);border:var(--border-width-default) solid var(--_step-node-border-color)}.spine{visibility:hidden;flex:1;width:var(--_step-spine-width);margin-top:var(--space-1);background-color:var(--_step-spine-color)}.lead{margin-top:0;margin-bottom:var(--space-1)}.tail{grid-area:2/1;justify-self:center;margin-top:0}.text{grid-area:1/2;display:flex;flex-direction:column;align-self:center;gap:var(--space-0-5);min-width:0}.rest{grid-area:2/2;padding-bottom:var(--_step-gap);min-width:0}:host(.is-last) .spine:not(.lead),:host(.outside-steps:last-child) .spine:not(.lead){visibility:hidden}:host(.is-last) .rest,:host(.outside-steps:last-child) .rest{padding-bottom:0}:host(.is-first) .lead,:host(.outside-steps:first-child) .lead{visibility:hidden}.head{position:relative;display:flex;align-items:flex-start;gap:var(--space-2);min-width:0}.visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.trailing{display:inline-flex;align-items:center;gap:var(--space-2);margin-left:auto;flex:none;height:calc(var(--font-size-xs) * var(--line-height-base))}.head:has(.trailing>:not(.toggle)){align-items:center;margin-bottom:var(--space-1-5);padding-top:var(--space-2)}.head:has(.trailing>:not(.toggle)) .trailing{height:auto}.toggle{display:inline-flex;align-items:center;justify-content:center;padding:var(--space-0-5);border:0;background:none;cursor:pointer}.toggle:active:not(:disabled,[disabled],.is-disabled,.disabled,[aria-disabled=true]){filter:brightness(var(--ds-press-brightness, .9));transform:scale(var(--ds-press-scale, .97))}.toggle{position:relative}.toggle:before{content:\"\";position:absolute;top:50%;left:50%;width:max(100%,var(--hit-xs));height:max(100%,var(--hit-xs));translate:-50% -50%;border-radius:inherit}.toggle:focus-visible{outline-style:none}.toggle:focus-visible:before{outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:calc(var(--focus-ring-offset) - 2 * var(--focus-ring-width));animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard)}.toggle{color:var(--_step-toggle-icon-color)}.toggle:hover{color:var(--_step-toggle-icon-color-hover)}.toggle .chev{transition:transform var(--duration-base) var(--ease-standard)}.toggle[aria-expanded=true] .chev{transform:rotate(180deg)}:host:not(:has(.details-body>*)) .toggle{display:none}:host(.is-expanded){isolation:isolate}:host(.is-expanded):before{content:\"\";grid-area:1/1/3/3;z-index:-1;margin:0 calc(-1 * var(--space-2)) var(--_step-gap);border-radius:var(--ds-radius-control);background-color:var(--_step-open-bg-color)}:host(.is-expanded.is-last):before,:host(.is-expanded.outside-steps:last-child):before{margin-bottom:0}.details{display:grid;grid-template-rows:0fr;min-width:0;visibility:hidden;transition:grid-template-rows var(--duration-slow) var(--ease-decelerate),visibility var(--duration-slow) allow-discrete}.details:not(:has(.details-body>*)){display:none}:host(.is-expanded) .details{grid-template-rows:1fr;visibility:visible}.details-content{min-height:0;overflow:hidden}.details-body{padding-top:var(--space-1)}.heading{color:var(--text-primary);font:var(--font-weight-regular) var(--font-size-xs)/var(--line-height-base) var(--font-sans)}.time{color:var(--text-tertiary);font:var(--font-weight-regular) var(--font-size-xs)/var(--line-height-base) var(--font-sans)}:host([data-status=done]){--_step-node-bg-color: var(--success);--_step-node-color: var(--text-on-success);--_step-node-border-color: var(--success)}:host([data-status=running]){--_step-node-bg-color: var(--surface-default);--_step-node-color: var(--accent);--_step-node-border-color: var(--accent)}:host([data-status=pending]){--_step-node-bg-color: var(--surface-default);--_step-node-color: var(--text-tertiary);--_step-node-border-color: var(--text-tertiary)}:host([data-status=error]){--_step-node-bg-color: var(--error);--_step-node-color: var(--text-on-error);--_step-node-border-color: var(--error)}:host([data-status=pending]) .node{border-style:dashed}:host([data-status=pending]) .heading{color:var(--text-tertiary);font-weight:var(--font-weight-regular)}:host([data-status=waiting]){--_step-node-bg-color: var(--text-secondary);--_step-node-color: var(--surface-default);--_step-node-border-color: var(--text-secondary)}:host([data-status=waiting]){--_step-heading-line: calc(var(--font-size-xs) * var(--line-height-base))}:host([data-status=waiting]) .text{align-self:start;padding-top:max(0px,var(--_step-node-size) / 2 + var(--space-1) - var(--_step-heading-line) / 2)}:host([data-status=waiting]) .lead{flex:none;height:max(0px,var(--_step-heading-line) / 2 - var(--_step-node-size) / 2 - var(--space-1))}\n"] }]
74
+ }], propDecorators: { heading: [{ type: i0.Input, args: [{ isSignal: true, alias: "heading", required: false }] }], time: [{ type: i0.Input, args: [{ isSignal: true, alias: "time", required: false }] }], status: [{ type: i0.Input, args: [{ isSignal: true, alias: "status", required: false }] }], expanded: [{ type: i0.Input, args: [{ isSignal: true, alias: "expanded", required: false }] }, { type: i0.Output, args: ["expandedChange"] }] } });
75
+
76
+ /**
77
+ * The steps of an agent's work, in the `[steps]` slot of a `ds-chat-message`: `ds-chat-step`s in
78
+ * order. The message folds them into a chip on its bubble and grows new steps in.
79
+ */
80
+ class ChatStepsComponent {
81
+ /** How steps that arrive together (a plan given at once) come in: `'together'` grows them in as
82
+ * one block, `'stagger'` one after another. Steps that arrive one at a time grow in either way. */
83
+ enter = input('together', ...(ngDevMode ? [{ debugName: "enter" }] : /* istanbul ignore next */ []));
84
+ // Descendants, so a step inside a wrapper element or an @for block still counts.
85
+ items = contentChildren(ChatStepComponent, { ...(ngDevMode ? { debugName: "items" } : /* istanbul ignore next */ {}), descendants: true });
86
+ /** The step that draws no gap above it. */
87
+ firstStep = computed(() => this.items().at(0), ...(ngDevMode ? [{ debugName: "firstStep" }] : /* istanbul ignore next */ []));
88
+ /** The step that draws no gap below it. */
89
+ lastStep = computed(() => this.items().at(-1), ...(ngDevMode ? [{ debugName: "lastStep" }] : /* istanbul ignore next */ []));
90
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ChatStepsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
91
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.2.22", type: ChatStepsComponent, isStandalone: true, selector: "ds-chat-steps", inputs: { enter: { classPropertyName: "enter", publicName: "enter", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "list", "data-density": "compact" } }, providers: [
92
+ {
93
+ provide: CHAT_STEPS,
94
+ useExisting: forwardRef(() => ChatStepsComponent),
95
+ },
96
+ ], queries: [{ propertyName: "items", predicate: ChatStepComponent, descendants: true, isSignal: true }], ngImport: i0, template: '<ng-content></ng-content>', isInline: true, styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{display:flex;flex-direction:column}\n"] });
97
+ }
98
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ChatStepsComponent, decorators: [{
99
+ type: Component,
100
+ args: [{ selector: 'ds-chat-steps', standalone: true, template: '<ng-content></ng-content>', encapsulation: ViewEncapsulation.Emulated, host: {
101
+ role: 'list',
102
+ // The compact density tokens apply to whatever the steps hold.
103
+ 'data-density': 'compact',
104
+ }, providers: [
105
+ {
106
+ provide: CHAT_STEPS,
107
+ useExisting: forwardRef(() => ChatStepsComponent),
108
+ },
109
+ ], styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{display:flex;flex-direction:column}\n"] }]
110
+ }], propDecorators: { enter: [{ type: i0.Input, args: [{ isSignal: true, alias: "enter", required: false }] }], items: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => ChatStepComponent), { ...{
111
+ descendants: true,
112
+ }, isSignal: true }] }] } });
113
+
114
+ /**
115
+ * One message of a conversation: a bubble on the right for the user, on the left for the
116
+ * assistant. Slots: default (the text or rendered markdown), `[steps]` (a `ds-chat-steps` of the
117
+ * agent's steps, above the bubble), `[attachments]` (under the text), `[actions]` (under the bubble).
118
+ * With `stepsFolded` the steps fold into a chip at the top of the bubble that opens them again.
119
+ */
120
+ class ChatMessageComponent {
121
+ /** Who wrote it: `'user'` draws a filled bubble on the right, `'assistant'` a subtle one on the left. */
122
+ role = input('assistant', ...(ngDevMode ? [{ debugName: "role" }] : /* istanbul ignore next */ []));
123
+ /** Name shown above the bubble. Without it the role is spoken (`DS_INTL.chat.user` / `assistant`). */
124
+ author = input('', ...(ngDevMode ? [{ debugName: "author" }] : /* istanbul ignore next */ []));
125
+ /** Time label, already formatted, shown under the bubble. In a `ds-chat-thread` only the last message
126
+ * of a run shows it. */
127
+ time = input('', ...(ngDevMode ? [{ debugName: "time" }] : /* istanbul ignore next */ []));
128
+ /** When it was sent. Inside a `ds-chat-thread` it splits a run by time and dates the divider. */
129
+ sentAt = input(null, ...(ngDevMode ? [{ debugName: "sentAt" }] : /* istanbul ignore next */ []));
130
+ /** The text is still arriving: a caret blinks after it and `[actions]` stay hidden until it is done. */
131
+ streaming = input(false, { ...(ngDevMode ? { debugName: "streaming" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
132
+ /** Delivery of a message the reader sent: `'sending'` dims it and `'failed'` says it was not sent and
133
+ * offers Retry, both in place of `time`. `'sent'` shows nothing and is only spoken. */
134
+ status = input(null, ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
135
+ /** The `[steps]` fold into a chip at the top of the bubble, which opens them again; two-way bound.
136
+ * Inside a `ds-chat-thread` the steps of the reply before a new user message fold on their own
137
+ * (`foldStepsOnSend`). Folds only steps given as `ds-chat-step`s. */
138
+ stepsFolded = model(false, ...(ngDevMode ? [{ debugName: "stepsFolded" }] : /* istanbul ignore next */ []));
139
+ /** Retry was pressed on a `'failed'` message. Send it again and move `status` back to `'sending'`. */
140
+ retry = output();
141
+ stepList = contentChild(ChatStepsComponent, { ...(ngDevMode ? { debugName: "stepList" } : /* istanbul ignore next */ {}), descendants: true });
142
+ steps = contentChildren(ChatStepComponent, { ...(ngDevMode ? { debugName: "steps" } : /* istanbul ignore next */ {}), descendants: true });
143
+ stepElements = contentChildren(ChatStepComponent, { ...(ngDevMode ? { debugName: "stepElements" } : /* istanbul ignore next */ {}), descendants: true,
144
+ read: (ElementRef) });
145
+ /** How many `ds-chat-step`s the `[steps]` hold. @internal */
146
+ stepCount = computed(() => this.steps().length, ...(ngDevMode ? [{ debugName: "stepCount" }] : /* istanbul ignore next */ []));
147
+ /** How many of them have `status="error"`. @internal */
148
+ failedStepCount = computed(() => this.steps().filter((step) => step.status() === 'error').length, ...(ngDevMode ? [{ debugName: "failedStepCount" }] : /* istanbul ignore next */ []));
149
+ openedFailures = new Set();
150
+ openedFailuresVersion = signal(0, ...(ngDevMode ? [{ debugName: "openedFailuresVersion" }] : /* istanbul ignore next */ []));
151
+ /** Failed steps the reader has not opened yet; while any remain the thread does not fold them.
152
+ * @internal */
153
+ unopenedFailedStepCount = computed(() => {
154
+ this.openedFailuresVersion();
155
+ return this.steps().filter((step) => step.status() === 'error' && !this.openedFailures.has(step)).length;
156
+ }, ...(ngDevMode ? [{ debugName: "unopenedFailedStepCount" }] : /* istanbul ignore next */ []));
157
+ stagger = computed(() => this.stepList()?.enter() === 'stagger', ...(ngDevMode ? [{ debugName: "stagger" }] : /* istanbul ignore next */ []));
158
+ folded = computed(() => this.stepsFolded() && this.stepCount() > 0, ...(ngDevMode ? [{ debugName: "folded" }] : /* istanbul ignore next */ []));
159
+ intl = inject(DS_INTL);
160
+ thread = inject(CHAT_THREAD, { optional: true });
161
+ isFirst = computed(() => this.thread?.firstMessage() === this, ...(ngDevMode ? [{ debugName: "isFirst" }] : /* istanbul ignore next */ []));
162
+ isGrouped = computed(() => this.thread?.groupedMessages().has(this) ?? false, ...(ngDevMode ? [{ debugName: "isGrouped" }] : /* istanbul ignore next */ []));
163
+ isContinued = computed(() => this.thread?.continuedMessages().has(this) ?? false, ...(ngDevMode ? [{ debugName: "isContinued" }] : /* istanbul ignore next */ []));
164
+ timeBreak = computed(() => this.thread?.timeBreaks().get(this) ?? '', ...(ngDevMode ? [{ debugName: "timeBreak" }] : /* istanbul ignore next */ []));
165
+ /** `sentAt` in milliseconds, or `null` when unset or unreadable. */
166
+ sentAtMs = computed(() => {
167
+ const value = this.sentAt();
168
+ const ms = value === null ? Number.NaN : new Date(value).getTime();
169
+ return Number.isNaN(ms) ? null : ms;
170
+ }, ...(ngDevMode ? [{ debugName: "sentAtMs" }] : /* istanbul ignore next */ []));
171
+ wording = computed(() => ({
172
+ ...DS_INTL_DEFAULTS.chat,
173
+ ...this.intl().chat,
174
+ }), ...(ngDevMode ? [{ debugName: "wording" }] : /* istanbul ignore next */ []));
175
+ speaker = computed(() => this.author() || this.wording()[this.role()], ...(ngDevMode ? [{ debugName: "speaker" }] : /* istanbul ignore next */ []));
176
+ host = inject(ElementRef);
177
+ constructor() {
178
+ // The fold is applied here rather than through a template binding, so it can animate from the
179
+ // current boxes. The first state is applied without motion.
180
+ let rendered = false;
181
+ afterNextRender(() => {
182
+ rendered = true;
183
+ this.applyFold(this.folded(), false);
184
+ if (this.thread?.appendedAfterRender(this)) {
185
+ const steps = this.stepElements().map((step) => step.nativeElement);
186
+ // A plan given at once: the steps grow in one after another, or the message as one block.
187
+ if (this.stagger() && steps.length) {
188
+ this.growIn(steps, 70);
189
+ }
190
+ else {
191
+ this.growIn([this.host.nativeElement]);
192
+ }
193
+ }
194
+ });
195
+ effect(() => {
196
+ const folded = this.folded();
197
+ untracked(() => {
198
+ if (rendered) {
199
+ this.applyFold(folded, true);
200
+ }
201
+ });
202
+ });
203
+ // Opening a failed step's details counts as the reader having seen it.
204
+ effect(() => {
205
+ for (const step of this.steps()) {
206
+ if (step.status() === 'error' &&
207
+ step.expanded() &&
208
+ !this.openedFailures.has(step)) {
209
+ this.openedFailures.add(step);
210
+ untracked(() => this.openedFailuresVersion.update((version) => version + 1));
211
+ }
212
+ }
213
+ });
214
+ // A step that fails while folded opens the steps again, so a failure is never hidden.
215
+ effect(() => {
216
+ if (this.stepsFolded() && this.unopenedFailedStepCount() > 0) {
217
+ untracked(() => this.stepsFolded.set(false));
218
+ }
219
+ });
220
+ // Steps that arrive into a message already on screen grow in, one after another.
221
+ let knownSteps = new Set();
222
+ effect(() => {
223
+ const items = this.steps();
224
+ untracked(() => {
225
+ const added = items.filter((item) => !knownSteps.has(item));
226
+ knownSteps = new Set(items);
227
+ // Started here, before the frame paints, so a step never shows at full height first.
228
+ if (rendered && added.length) {
229
+ const elements = this.stepElements();
230
+ this.growIn(added.map((item) => elements[items.indexOf(item)].nativeElement), this.stagger() ? 70 : 0);
231
+ }
232
+ });
233
+ });
234
+ }
235
+ toggleSteps() {
236
+ this.stepsFolded.set(!this.stepsFolded());
237
+ }
238
+ motion() {
239
+ const host = this.host.nativeElement;
240
+ return (typeof matchMedia === 'function' &&
241
+ !matchMedia('(prefers-reduced-motion: reduce)').matches &&
242
+ typeof host.animate === 'function');
243
+ }
244
+ // Height, not a transform, so the thread's layout follows every frame and a pinned thread keeps
245
+ // its bottom still.
246
+ growIn(elements, stagger = 0) {
247
+ if (!this.motion()) {
248
+ return;
249
+ }
250
+ // To `auto` (interpolate-size), so nothing is measured and it can start before the first paint.
251
+ elements.forEach((element, index) => {
252
+ element.animate([
253
+ {
254
+ height: '0px',
255
+ opacity: 0,
256
+ transform: 'translateY(-4px)',
257
+ overflow: 'hidden',
258
+ },
259
+ {
260
+ height: 'auto',
261
+ opacity: 1,
262
+ transform: 'none',
263
+ overflow: 'hidden',
264
+ },
265
+ ], {
266
+ duration: 200,
267
+ delay: index * stagger,
268
+ easing: 'cubic-bezier(0.2, 0, 0, 1)',
269
+ fill: 'backwards',
270
+ });
271
+ });
272
+ }
273
+ // Folding, the steps shrink toward the chip as the chip grows at the top of the bubble; opening,
274
+ // the steps grow back above it. Both run on height, so the bubble and its text move with the
275
+ // layout rather than jumping. The chip stays once shown, to fold the steps again.
276
+ applyFold(folded, animate) {
277
+ const host = this.host.nativeElement;
278
+ if (host.classList.contains('steps-folded') === folded) {
279
+ return;
280
+ }
281
+ const steps = host.querySelector(':scope > .steps');
282
+ const chip = host.querySelector(':scope > .bubble > .steps-chip');
283
+ const chipNew = folded && !host.classList.contains('steps-chip-shown');
284
+ host.classList.add('steps-chip-shown');
285
+ if (!animate || !this.motion() || !steps) {
286
+ host.classList.toggle('steps-folded', folded);
287
+ return;
288
+ }
289
+ const timing = {
290
+ duration: 380,
291
+ easing: 'cubic-bezier(0.34, 1.25, 0.64, 1)',
292
+ };
293
+ if (chip && chipNew) {
294
+ const chipHeight = chip.getBoundingClientRect().height;
295
+ chip.animate([
296
+ {
297
+ height: '0px',
298
+ opacity: 0,
299
+ transform: 'scale(0.9)',
300
+ overflow: 'hidden',
301
+ },
302
+ {
303
+ height: `${chipHeight}px`,
304
+ opacity: 1,
305
+ transform: 'none',
306
+ overflow: 'hidden',
307
+ },
308
+ ], { ...timing, easing: 'cubic-bezier(0.2, 0, 0, 1)' });
309
+ }
310
+ if (folded) {
311
+ const height = steps.getBoundingClientRect().height;
312
+ steps.style.transformOrigin = 'bottom left';
313
+ steps.animate([
314
+ {
315
+ height: `${height}px`,
316
+ opacity: 1,
317
+ transform: 'none',
318
+ overflow: 'hidden',
319
+ },
320
+ {
321
+ height: '0px',
322
+ opacity: 0,
323
+ transform: 'scale(0.6)',
324
+ overflow: 'hidden',
325
+ },
326
+ ], { duration: 380, easing: 'cubic-bezier(0.2, 0, 0, 1)' }).onfinish = () => host.classList.toggle('steps-folded', this.folded());
327
+ }
328
+ else {
329
+ host.classList.remove('steps-folded');
330
+ const height = steps.getBoundingClientRect().height;
331
+ steps.style.transformOrigin = 'bottom left';
332
+ steps.animate([
333
+ {
334
+ height: '0px',
335
+ opacity: 0,
336
+ transform: 'scale(0.6)',
337
+ overflow: 'hidden',
338
+ },
339
+ {
340
+ height: `${height}px`,
341
+ opacity: 1,
342
+ transform: 'none',
343
+ overflow: 'hidden',
344
+ },
345
+ ], timing);
346
+ }
347
+ }
348
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ChatMessageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
349
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.22", type: ChatMessageComponent, isStandalone: true, selector: "ds-chat-message", inputs: { role: { classPropertyName: "role", publicName: "role", isSignal: true, isRequired: false, transformFunction: null }, author: { classPropertyName: "author", publicName: "author", isSignal: true, isRequired: false, transformFunction: null }, time: { classPropertyName: "time", publicName: "time", isSignal: true, isRequired: false, transformFunction: null }, sentAt: { classPropertyName: "sentAt", publicName: "sentAt", isSignal: true, isRequired: false, transformFunction: null }, streaming: { classPropertyName: "streaming", publicName: "streaming", isSignal: true, isRequired: false, transformFunction: null }, status: { classPropertyName: "status", publicName: "status", isSignal: true, isRequired: false, transformFunction: null }, stepsFolded: { classPropertyName: "stepsFolded", publicName: "stepsFolded", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { stepsFolded: "stepsFoldedChange", retry: "retry" }, host: { properties: { "attr.role": "null", "attr.data-role": "role()", "class.in-thread": "!!thread", "class.is-first": "isFirst()", "class.is-grouped": "isGrouped()", "class.is-continued": "isContinued()", "class.has-divider": "!!timeBreak()", "attr.data-status": "status()", "attr.aria-busy": "streaming() || null" } }, queries: [{ propertyName: "stepList", first: true, predicate: ChatStepsComponent, descendants: true, isSignal: true }, { propertyName: "steps", predicate: ChatStepComponent, descendants: true, isSignal: true }, { propertyName: "stepElements", predicate: ChatStepComponent, descendants: true, read: ElementRef, isSignal: true }], ngImport: i0, template: "@if (timeBreak(); as label) {\n <div class=\"divider\">\n <span class=\"divider-label\">\n {{ label }}\n </span>\n </div>\n}\n\n<div class=\"meta\">\n <span\n class=\"speaker\"\n [class.visually-hidden]=\"!author() || isGrouped()\">\n {{ speaker() }}\n </span>\n</div>\n\n<div class=\"steps\">\n <ng-content select=\"[steps]\"></ng-content>\n</div>\n\n<div class=\"bubble\">\n @if (stepCount()) {\n <button\n type=\"button\"\n class=\"steps-chip\"\n [attr.aria-expanded]=\"!folded()\"\n [attr.aria-label]=\"\n folded() ? wording().stepsFolded(stepCount(), failedStepCount()) : null\n \"\n (click)=\"toggleSteps()\">\n @if (failedStepCount()) {\n <ds-icon\n class=\"steps-chip-failed\"\n name=\"error\"\n [size]=\"12\" />\n } @else {\n <ds-icon\n class=\"steps-chip-done\"\n name=\"check\"\n [size]=\"12\" />\n }\n\n <span>\n {{ wording().steps(stepCount()) }}\n </span>\n\n @if (failedStepCount()) {\n <span class=\"steps-chip-failed\">\n \u00B7 {{ wording().stepsFailed(failedStepCount()) }}\n </span>\n }\n\n <ds-icon\n [name]=\"folded() ? 'chevronUp' : 'chevronDown'\"\n [size]=\"12\" />\n </button>\n }\n\n <div class=\"body\">\n <ng-content></ng-content>\n </div>\n\n <div class=\"attachments\">\n <ng-content select=\"[attachments]\"></ng-content>\n </div>\n</div>\n\n@switch (status()) {\n @case ('sending') {\n <div\n class=\"status\"\n role=\"status\">\n {{ wording().sending }}\n </div>\n }\n @case ('failed') {\n <div\n class=\"status is-failed\"\n role=\"status\">\n <ds-icon\n name=\"error\"\n [size]=\"14\" />\n {{ wording().notSent }}\n <ds-button\n variant=\"text\"\n size=\"sm\"\n (pressed)=\"retry.emit()\">\n {{ wording().retry }}\n </ds-button>\n </div>\n }\n @default {\n @if (status() === 'sent') {\n <span\n class=\"visually-hidden\"\n role=\"status\">\n {{ wording().sent }}\n </span>\n }\n\n @if (time() && !isContinued() && !streaming()) {\n <div class=\"status time\">\n {{ time() }}\n </div>\n }\n }\n}\n\n@if (!streaming()) {\n <div class=\"actions\">\n <ng-content select=\"[actions]\"></ng-content>\n </div>\n}\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{--_chat-bubble-max-width: var(--ds-chat-message-max-width, 85%);--_chat-bubble-radius: var(--ds-chat-message-radius, var(--ds-radius-panel));--_chat-bubble-padding: var(--ds-chat-message-padding, var(--space-2) var(--space-3));--_chat-bubble-bg-color: var(--ds-chat-message-assistant-bg-color, var(--surface-secondary));--_chat-bubble-color: var(--ds-chat-message-assistant-color, var(--text-primary));position:relative;display:flex;flex-direction:column;align-items:flex-start;min-width:0}:host([data-role=user]){--_chat-bubble-bg-color: var(--ds-chat-message-user-bg-color, var(--primary));--_chat-bubble-color: var(--ds-chat-message-user-color, var(--text-on-primary));align-items:flex-end}:host(.in-thread){margin-top:var(--_chat-thread-gap)}:host(.is-grouped){margin-top:var(--_chat-thread-group-gap)}:host(.is-first){margin-top:0}.divider{display:flex;align-items:center;gap:var(--space-3);align-self:stretch;margin-bottom:var(--space-3);font-size:var(--font-size-xs);line-height:var(--line-height-base);color:var(--text-tertiary)}.divider:before,.divider:after{content:\"\";flex:1;border-top:var(--border-width-default) solid var(--border-divider)}.divider-label{flex:none}.visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.meta{display:flex;align-items:baseline;gap:var(--space-2);max-width:100%;font-size:var(--font-size-xs);line-height:var(--line-height-base);color:var(--text-tertiary)}.meta:has(.speaker:not(.visually-hidden)){margin-bottom:var(--space-1)}.speaker{font-weight:var(--font-weight-semibold);color:var(--text-secondary)}.bubble{display:flex;flex-direction:column;gap:var(--space-2);max-width:var(--_chat-bubble-max-width);min-width:0;padding:var(--_chat-bubble-padding);border-radius:var(--_chat-bubble-radius);background-color:var(--_chat-bubble-bg-color);color:var(--_chat-bubble-color);font-size:var(--font-size-s);line-height:var(--line-height-base);overflow-wrap:anywhere;-webkit-user-select:text;user-select:text}:host([data-role=assistant]:not(.is-continued)) .bubble{border-end-start-radius:var(--ds-radius-inner)}:host([data-role=user]:not(.is-continued)) .bubble{border-end-end-radius:var(--ds-radius-inner)}:host([data-role=user]) .bubble ::selection{background-color:var(--_chat-bubble-color);color:var(--_chat-bubble-bg-color)}:host([data-role=user]) .body{white-space:pre-line}.steps,.body,.attachments{min-width:0}.steps{inline-size:100%;max-inline-size:var(--_chat-bubble-max-width);margin-bottom:var(--space-2);padding-inline:var(--space-1);overflow-wrap:anywhere}.bubble:has(>.body:empty):not(:has(>.attachments>*)){display:none}.attachments{display:flex;flex-wrap:wrap;gap:var(--space-1)}:host([aria-busy=true]) .body:after{content:\"\";display:inline-block;inline-size:.5em;block-size:1em;margin-inline-start:var(--space-0-5);vertical-align:text-bottom;background-color:currentcolor;animation:chat-caret var(--duration-loop-fast) steps(1) infinite}@keyframes chat-caret{50%{opacity:0}}:host([data-status=sending]) .bubble{opacity:var(--opacity-disabled)}.status{display:inline-flex;align-items:center;gap:var(--space-1);margin-top:var(--space-1);font-size:var(--font-size-xs);line-height:var(--line-height-base);color:var(--text-tertiary)}.status.is-failed{color:var(--error-text)}.actions{display:flex;align-items:center;gap:var(--space-1);margin-top:var(--space-1);opacity:0;transition:opacity var(--duration-fast) var(--ease-standard)}:host(:hover) .actions,.actions:focus-within{opacity:1}@media(hover:none){.actions{opacity:1}}.steps:not(:has(*)),.attachments:not(:has(*)),.actions:not(:has(*)),.body:empty{display:none}.steps-chip{display:none;align-items:center;align-self:flex-start;gap:var(--space-1);padding:var(--space-0-5) var(--space-2);border:var(--border-width-default) solid var(--border-default);border-radius:var(--ds-radius-pill);background-color:var(--surface-default);color:var(--text-secondary);font:inherit;font-size:var(--font-size-xs);line-height:var(--line-height-base);cursor:pointer}.steps-chip:hover{border-color:var(--border-strong);color:var(--text-primary)}.steps-chip-done{color:var(--success-text)}.steps-chip-failed{color:var(--error-text);font-weight:var(--font-weight-semibold)}:host(.steps-folded)>.steps{display:none}:host(.steps-chip-shown) .steps-chip{display:inline-flex}\n"], dependencies: [{ kind: "component", type: ButtonComponent, selector: "ds-button", inputs: ["color", "variant", "align", "size", "routerLink", "href", "fragment", "queryParams", "queryParamsHandling", "target", "rel", "routerLinkActiveOptions", "ariaCurrent", "type", "disabled", "loading", "loadingMode", "fullWidth", "ariaLabel", "icon", "trailingIcon", "ariaHasPopup", "ariaExpanded", "ariaControls", "disabledReason", "ariaDescribedBy"], outputs: ["pressed"] }, { kind: "component", type: IconComponent, selector: "ds-icon", inputs: ["name", "size", "stroke", "ariaLabel"] }] });
350
+ }
351
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ChatMessageComponent, decorators: [{
352
+ type: Component,
353
+ args: [{ selector: 'ds-chat-message', standalone: true, imports: [ButtonComponent, IconComponent], encapsulation: ViewEncapsulation.Emulated, host: {
354
+ // The `role` input would otherwise stay on the host as an invalid ARIA role.
355
+ '[attr.role]': 'null',
356
+ '[attr.data-role]': 'role()',
357
+ '[class.in-thread]': '!!thread',
358
+ '[class.is-first]': 'isFirst()',
359
+ '[class.is-grouped]': 'isGrouped()',
360
+ '[class.is-continued]': 'isContinued()',
361
+ '[class.has-divider]': '!!timeBreak()',
362
+ '[attr.data-status]': 'status()',
363
+ '[attr.aria-busy]': 'streaming() || null',
364
+ }, template: "@if (timeBreak(); as label) {\n <div class=\"divider\">\n <span class=\"divider-label\">\n {{ label }}\n </span>\n </div>\n}\n\n<div class=\"meta\">\n <span\n class=\"speaker\"\n [class.visually-hidden]=\"!author() || isGrouped()\">\n {{ speaker() }}\n </span>\n</div>\n\n<div class=\"steps\">\n <ng-content select=\"[steps]\"></ng-content>\n</div>\n\n<div class=\"bubble\">\n @if (stepCount()) {\n <button\n type=\"button\"\n class=\"steps-chip\"\n [attr.aria-expanded]=\"!folded()\"\n [attr.aria-label]=\"\n folded() ? wording().stepsFolded(stepCount(), failedStepCount()) : null\n \"\n (click)=\"toggleSteps()\">\n @if (failedStepCount()) {\n <ds-icon\n class=\"steps-chip-failed\"\n name=\"error\"\n [size]=\"12\" />\n } @else {\n <ds-icon\n class=\"steps-chip-done\"\n name=\"check\"\n [size]=\"12\" />\n }\n\n <span>\n {{ wording().steps(stepCount()) }}\n </span>\n\n @if (failedStepCount()) {\n <span class=\"steps-chip-failed\">\n \u00B7 {{ wording().stepsFailed(failedStepCount()) }}\n </span>\n }\n\n <ds-icon\n [name]=\"folded() ? 'chevronUp' : 'chevronDown'\"\n [size]=\"12\" />\n </button>\n }\n\n <div class=\"body\">\n <ng-content></ng-content>\n </div>\n\n <div class=\"attachments\">\n <ng-content select=\"[attachments]\"></ng-content>\n </div>\n</div>\n\n@switch (status()) {\n @case ('sending') {\n <div\n class=\"status\"\n role=\"status\">\n {{ wording().sending }}\n </div>\n }\n @case ('failed') {\n <div\n class=\"status is-failed\"\n role=\"status\">\n <ds-icon\n name=\"error\"\n [size]=\"14\" />\n {{ wording().notSent }}\n <ds-button\n variant=\"text\"\n size=\"sm\"\n (pressed)=\"retry.emit()\">\n {{ wording().retry }}\n </ds-button>\n </div>\n }\n @default {\n @if (status() === 'sent') {\n <span\n class=\"visually-hidden\"\n role=\"status\">\n {{ wording().sent }}\n </span>\n }\n\n @if (time() && !isContinued() && !streaming()) {\n <div class=\"status time\">\n {{ time() }}\n </div>\n }\n }\n}\n\n@if (!streaming()) {\n <div class=\"actions\">\n <ng-content select=\"[actions]\"></ng-content>\n </div>\n}\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{--_chat-bubble-max-width: var(--ds-chat-message-max-width, 85%);--_chat-bubble-radius: var(--ds-chat-message-radius, var(--ds-radius-panel));--_chat-bubble-padding: var(--ds-chat-message-padding, var(--space-2) var(--space-3));--_chat-bubble-bg-color: var(--ds-chat-message-assistant-bg-color, var(--surface-secondary));--_chat-bubble-color: var(--ds-chat-message-assistant-color, var(--text-primary));position:relative;display:flex;flex-direction:column;align-items:flex-start;min-width:0}:host([data-role=user]){--_chat-bubble-bg-color: var(--ds-chat-message-user-bg-color, var(--primary));--_chat-bubble-color: var(--ds-chat-message-user-color, var(--text-on-primary));align-items:flex-end}:host(.in-thread){margin-top:var(--_chat-thread-gap)}:host(.is-grouped){margin-top:var(--_chat-thread-group-gap)}:host(.is-first){margin-top:0}.divider{display:flex;align-items:center;gap:var(--space-3);align-self:stretch;margin-bottom:var(--space-3);font-size:var(--font-size-xs);line-height:var(--line-height-base);color:var(--text-tertiary)}.divider:before,.divider:after{content:\"\";flex:1;border-top:var(--border-width-default) solid var(--border-divider)}.divider-label{flex:none}.visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.meta{display:flex;align-items:baseline;gap:var(--space-2);max-width:100%;font-size:var(--font-size-xs);line-height:var(--line-height-base);color:var(--text-tertiary)}.meta:has(.speaker:not(.visually-hidden)){margin-bottom:var(--space-1)}.speaker{font-weight:var(--font-weight-semibold);color:var(--text-secondary)}.bubble{display:flex;flex-direction:column;gap:var(--space-2);max-width:var(--_chat-bubble-max-width);min-width:0;padding:var(--_chat-bubble-padding);border-radius:var(--_chat-bubble-radius);background-color:var(--_chat-bubble-bg-color);color:var(--_chat-bubble-color);font-size:var(--font-size-s);line-height:var(--line-height-base);overflow-wrap:anywhere;-webkit-user-select:text;user-select:text}:host([data-role=assistant]:not(.is-continued)) .bubble{border-end-start-radius:var(--ds-radius-inner)}:host([data-role=user]:not(.is-continued)) .bubble{border-end-end-radius:var(--ds-radius-inner)}:host([data-role=user]) .bubble ::selection{background-color:var(--_chat-bubble-color);color:var(--_chat-bubble-bg-color)}:host([data-role=user]) .body{white-space:pre-line}.steps,.body,.attachments{min-width:0}.steps{inline-size:100%;max-inline-size:var(--_chat-bubble-max-width);margin-bottom:var(--space-2);padding-inline:var(--space-1);overflow-wrap:anywhere}.bubble:has(>.body:empty):not(:has(>.attachments>*)){display:none}.attachments{display:flex;flex-wrap:wrap;gap:var(--space-1)}:host([aria-busy=true]) .body:after{content:\"\";display:inline-block;inline-size:.5em;block-size:1em;margin-inline-start:var(--space-0-5);vertical-align:text-bottom;background-color:currentcolor;animation:chat-caret var(--duration-loop-fast) steps(1) infinite}@keyframes chat-caret{50%{opacity:0}}:host([data-status=sending]) .bubble{opacity:var(--opacity-disabled)}.status{display:inline-flex;align-items:center;gap:var(--space-1);margin-top:var(--space-1);font-size:var(--font-size-xs);line-height:var(--line-height-base);color:var(--text-tertiary)}.status.is-failed{color:var(--error-text)}.actions{display:flex;align-items:center;gap:var(--space-1);margin-top:var(--space-1);opacity:0;transition:opacity var(--duration-fast) var(--ease-standard)}:host(:hover) .actions,.actions:focus-within{opacity:1}@media(hover:none){.actions{opacity:1}}.steps:not(:has(*)),.attachments:not(:has(*)),.actions:not(:has(*)),.body:empty{display:none}.steps-chip{display:none;align-items:center;align-self:flex-start;gap:var(--space-1);padding:var(--space-0-5) var(--space-2);border:var(--border-width-default) solid var(--border-default);border-radius:var(--ds-radius-pill);background-color:var(--surface-default);color:var(--text-secondary);font:inherit;font-size:var(--font-size-xs);line-height:var(--line-height-base);cursor:pointer}.steps-chip:hover{border-color:var(--border-strong);color:var(--text-primary)}.steps-chip-done{color:var(--success-text)}.steps-chip-failed{color:var(--error-text);font-weight:var(--font-weight-semibold)}:host(.steps-folded)>.steps{display:none}:host(.steps-chip-shown) .steps-chip{display:inline-flex}\n"] }]
365
+ }], ctorParameters: () => [], propDecorators: { role: [{ type: i0.Input, args: [{ isSignal: true, alias: "role", required: false }] }], author: [{ type: i0.Input, args: [{ isSignal: true, alias: "author", required: false }] }], time: [{ type: i0.Input, args: [{ isSignal: true, alias: "time", required: false }] }], sentAt: [{ type: i0.Input, args: [{ isSignal: true, alias: "sentAt", required: false }] }], streaming: [{ type: i0.Input, args: [{ isSignal: true, alias: "streaming", required: false }] }], status: [{ type: i0.Input, args: [{ isSignal: true, alias: "status", required: false }] }], stepsFolded: [{ type: i0.Input, args: [{ isSignal: true, alias: "stepsFolded", required: false }] }, { type: i0.Output, args: ["stepsFoldedChange"] }], retry: [{ type: i0.Output, args: ["retry"] }], stepList: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ChatStepsComponent), { ...{
366
+ descendants: true,
367
+ }, isSignal: true }] }], steps: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => ChatStepComponent), { ...{
368
+ descendants: true,
369
+ }, isSignal: true }] }], stepElements: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => ChatStepComponent), { ...{
370
+ descendants: true,
371
+ read: (ElementRef),
372
+ }, isSignal: true }] }] } });
373
+
374
+ // Closer to the end than this still counts as at the end, so a sub-pixel scroll position or a
375
+ // small nudge does not unpin the thread.
376
+ const PIN_TOLERANCE_PX = 32;
377
+ // Closer to the start than this asks for older messages.
378
+ const OLDER_THRESHOLD_PX = 64;
379
+ /**
380
+ * Scrollable list of `ds-chat-message`s that stays at the newest message unless the reader has
381
+ * scrolled up, then offers a jump button instead. Groups consecutive messages of one role, shows a
382
+ * working row while `working`, and announces each finished reply once.
383
+ */
384
+ class ChatThreadComponent {
385
+ /** Shows the working row at the end of the thread: a spinner and `workingLabel`. */
386
+ working = input(false, { ...(ngDevMode ? { debugName: "working" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
387
+ /** The current step while `working`, such as "Rebuilding"; empty falls back to `DS_INTL.chat.working`. */
388
+ workingLabel = input('', ...(ngDevMode ? [{ debugName: "workingLabel" }] : /* istanbul ignore next */ []));
389
+ /** Accessible name of the scroll area; unset falls back to `DS_INTL.chat.thread`. */
390
+ ariaLabel = input(null, ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
391
+ /** A new user message folds the steps of the replies before it (`ds-chat-message` `stepsFolded`).
392
+ * A reply keeps its steps open while it has a failed step the reader has not opened. */
393
+ foldStepsOnSend = input(true, { ...(ngDevMode ? { debugName: "foldStepsOnSend" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
394
+ /** Minutes between two messages' `sentAt` that start a new section with a time divider. */
395
+ timeBreakMinutes = input(15, ...(ngDevMode ? [{ debugName: "timeBreakMinutes" }] : /* istanbul ignore next */ []));
396
+ /** More messages exist before the first one; scrolling near the start then emits `loadOlder`. */
397
+ hasOlder = input(false, { ...(ngDevMode ? { debugName: "hasOlder" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
398
+ /** Older messages are on their way: a spinner shows over the top of the list. */
399
+ loadingOlder = input(false, { ...(ngDevMode ? { debugName: "loadingOlder" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
400
+ /** The reader scrolled near the start while `hasOlder` and not `loadingOlder`. Prepend the older
401
+ * messages; the thread keeps the message the reader was looking at in place. */
402
+ loadOlder = output();
403
+ // Descendants, so a message inside a wrapper element or an @for block still counts.
404
+ messages = contentChildren(ChatMessageComponent, { ...(ngDevMode ? { debugName: "messages" } : /* istanbul ignore next */ {}), descendants: true });
405
+ /** The first message, which takes no space above it. */
406
+ firstMessage = computed(() => this.messages().at(0), ...(ngDevMode ? [{ debugName: "firstMessage" }] : /* istanbul ignore next */ []));
407
+ /** Messages that open a time section, with their divider text: the first message with a
408
+ * `sentAt`, and each one sent `timeBreakMinutes` or more after the message before it. */
409
+ timeBreaks = computed(() => {
410
+ const breaks = new Map();
411
+ const gap = this.timeBreakMinutes() * 60_000;
412
+ let previous = null;
413
+ for (const message of this.messages()) {
414
+ const sent = message.sentAtMs();
415
+ if (sent !== null && (previous === null || sent - previous >= gap)) {
416
+ breaks.set(message, this.dividerText(sent));
417
+ }
418
+ previous = sent ?? previous;
419
+ }
420
+ return breaks;
421
+ }, ...(ngDevMode ? [{ debugName: "timeBreaks" }] : /* istanbul ignore next */ []));
422
+ /** Messages that follow one of the same role with no time break between them. */
423
+ groupedMessages = computed(() => {
424
+ const list = this.messages();
425
+ const breaks = this.timeBreaks();
426
+ return new Set(list.filter((message, i) => i > 0 &&
427
+ message.role() === list[i - 1].role() &&
428
+ !breaks.has(message)));
429
+ }, ...(ngDevMode ? [{ debugName: "groupedMessages" }] : /* istanbul ignore next */ []));
430
+ /** Messages followed by one of the same run. */
431
+ continuedMessages = computed(() => {
432
+ const list = this.messages();
433
+ const grouped = this.groupedMessages();
434
+ return new Set(list.filter((_, i) => grouped.has(list[i + 1])));
435
+ }, ...(ngDevMode ? [{ debugName: "continuedMessages" }] : /* istanbul ignore next */ []));
436
+ intl = inject(DS_INTL);
437
+ locale = injectDsLocale();
438
+ host = inject(ElementRef);
439
+ injector = inject(Injector);
440
+ destroyRef = inject(DestroyRef);
441
+ scroller = viewChild.required('scroller');
442
+ content = viewChild.required('content');
443
+ wording = computed(() => ({
444
+ ...DS_INTL_DEFAULTS.chat,
445
+ ...this.intl().chat,
446
+ }), ...(ngDevMode ? [{ debugName: "wording" }] : /* istanbul ignore next */ []));
447
+ label = computed(() => this.ariaLabel() || this.wording().thread, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
448
+ workingText = computed(() => this.workingLabel() || this.wording().working, ...(ngDevMode ? [{ debugName: "workingText" }] : /* istanbul ignore next */ []));
449
+ appended = new WeakSet();
450
+ /** @internal */
451
+ appendedAfterRender(message) {
452
+ return this.appended.has(message);
453
+ }
454
+ /** True once the thread has rendered. @internal */
455
+ live = signal(false, ...(ngDevMode ? [{ debugName: "live" }] : /* istanbul ignore next */ []));
456
+ pinned = signal(true, ...(ngDevMode ? [{ debugName: "pinned" }] : /* istanbul ignore next */ []));
457
+ unseen = signal(0, ...(ngDevMode ? [{ debugName: "unseen" }] : /* istanbul ignore next */ []));
458
+ announcement = signal('', ...(ngDevMode ? [{ debugName: "announcement" }] : /* istanbul ignore next */ []));
459
+ jumpLabel = computed(() => {
460
+ const count = this.unseen();
461
+ return count ? this.wording().newMessages(count) : this.wording().latest;
462
+ }, ...(ngDevMode ? [{ debugName: "jumpLabel" }] : /* istanbul ignore next */ []));
463
+ constructor() {
464
+ afterNextRender(() => {
465
+ this.live.set(true);
466
+ this.toEnd();
467
+ // Growth of the content (a new message, a streamed line, an opened snapshot) and a smaller
468
+ // viewport both move the end away; a pinned thread follows it.
469
+ const observer = new ResizeObserver(() => {
470
+ if (this.pinned()) {
471
+ this.toEnd();
472
+ }
473
+ else {
474
+ this.holdAnchor();
475
+ }
476
+ this.recordAnchor();
477
+ });
478
+ observer.observe(this.content().nativeElement);
479
+ observer.observe(this.scroller().nativeElement);
480
+ this.destroyRef.onDestroy(() => observer.disconnect());
481
+ });
482
+ // The messages present at the first render, or the first batch to arrive into an empty
483
+ // thread, are history: they are scrolled to, never announced.
484
+ let seen = -1;
485
+ let lastMessage;
486
+ let known = new Set();
487
+ effect(() => {
488
+ const list = this.messages();
489
+ untracked(() => {
490
+ const previous = seen;
491
+ const previousLast = lastMessage;
492
+ const added = previous > 0 ? list.filter((message) => !known.has(message)) : [];
493
+ const lastKnown = previous > 0
494
+ ? list.indexOf(previousLast)
495
+ : -1;
496
+ for (const message of added) {
497
+ if (list.indexOf(message) > lastKnown) {
498
+ this.appended.add(message);
499
+ }
500
+ }
501
+ known = new Set(list);
502
+ seen = list.length;
503
+ lastMessage = list.at(-1);
504
+ if (added.length && this.foldStepsOnSend()) {
505
+ this.afterRender(() => this.foldBefore(list, added));
506
+ }
507
+ this.olderRequested = false;
508
+ // Messages prepended by `loadOlder` leave the last one in place and are not new.
509
+ if (previous > 0 &&
510
+ list.length > previous &&
511
+ list.at(-1) !== previousLast) {
512
+ // After the render: a message created in this pass has not read its `role` input yet.
513
+ this.afterRender(() => this.onArrival());
514
+ }
515
+ });
516
+ });
517
+ // A reply that was still streaming is read once its text is complete.
518
+ let streaming = new Set();
519
+ effect(() => {
520
+ const now = new Set(this.messages().filter((message) => message.streaming()));
521
+ untracked(() => {
522
+ const finished = [...streaming].some((message) => !now.has(message));
523
+ streaming = now;
524
+ if (finished && !this.working()) {
525
+ this.afterRender(() => this.announceLastReply());
526
+ }
527
+ });
528
+ });
529
+ effect(() => {
530
+ if (!this.loadingOlder()) {
531
+ this.olderRequested = false;
532
+ }
533
+ });
534
+ let wasWorking = false;
535
+ effect(() => {
536
+ const working = this.working();
537
+ const text = this.workingText();
538
+ untracked(() => {
539
+ if (working) {
540
+ this.announce(text);
541
+ }
542
+ else if (wasWorking) {
543
+ this.afterRender(() => this.announceLastReply());
544
+ }
545
+ wasWorking = working;
546
+ });
547
+ });
548
+ }
549
+ /** Scrolls to the newest message and pins the thread there. */
550
+ scrollToEnd() {
551
+ this.pinned.set(true);
552
+ this.unseen.set(0);
553
+ this.toEnd();
554
+ }
555
+ onScroll() {
556
+ const scroller = this.scroller().nativeElement;
557
+ const atEnd = scroller.scrollHeight - scroller.scrollTop - scroller.clientHeight <=
558
+ PIN_TOLERANCE_PX;
559
+ // Only the reader scrolling up unpins. The event for the thread's own scroll to the end can land
560
+ // a frame after the content grew again, which reads as "away from the end" without anyone
561
+ // scrolling up.
562
+ const scrolledUp = scroller.scrollTop < this.lastScrollTop - 1;
563
+ this.lastScrollTop = scroller.scrollTop;
564
+ if (atEnd || scrolledUp) {
565
+ this.pinned.set(atEnd);
566
+ }
567
+ if (atEnd) {
568
+ this.unseen.set(0);
569
+ }
570
+ this.recordAnchor();
571
+ if (scroller.scrollTop <= OLDER_THRESHOLD_PX &&
572
+ this.hasOlder() &&
573
+ !this.loadingOlder() &&
574
+ !this.olderRequested) {
575
+ this.olderRequested = true;
576
+ this.loadOlder.emit();
577
+ }
578
+ }
579
+ olderRequested = false;
580
+ lastScrollTop = 0;
581
+ anchor = null;
582
+ // The first message still in view, and how far below the top of the viewport it sits.
583
+ recordAnchor() {
584
+ const scroller = this.scroller().nativeElement;
585
+ const viewTop = scroller.getBoundingClientRect().top;
586
+ const element = [
587
+ ...this.content().nativeElement.querySelectorAll('ds-chat-message'),
588
+ ].find((message) => message.getBoundingClientRect().bottom > viewTop);
589
+ this.anchor = element
590
+ ? { element, top: element.getBoundingClientRect().top - viewTop }
591
+ : null;
592
+ }
593
+ // Content added or grown above the reader (older messages, an opened snapshot) pushes the message
594
+ // they were reading down; scroll by the same amount so it stays where it was.
595
+ holdAnchor() {
596
+ const anchor = this.anchor;
597
+ if (!anchor?.element.isConnected) {
598
+ return;
599
+ }
600
+ const scroller = this.scroller().nativeElement;
601
+ const top = anchor.element.getBoundingClientRect().top -
602
+ scroller.getBoundingClientRect().top;
603
+ scroller.scrollTop += top - anchor.top;
604
+ }
605
+ onArrival() {
606
+ if (this.messages().at(-1)?.role() === 'user') {
607
+ // The reader just sent it: show it, wherever they had scrolled to.
608
+ this.scrollToEnd();
609
+ return;
610
+ }
611
+ if (!this.pinned()) {
612
+ this.unseen.update((count) => count + 1);
613
+ }
614
+ if (!this.working() && !this.messages().at(-1)?.streaming()) {
615
+ this.announceLastReply();
616
+ }
617
+ }
618
+ dividerText(sent) {
619
+ const date = new Date(sent);
620
+ const today = new Date();
621
+ const yesterday = new Date(today);
622
+ yesterday.setDate(today.getDate() - 1);
623
+ const sameDay = (other) => date.toDateString() === other.toDateString();
624
+ let day;
625
+ if (sameDay(today)) {
626
+ day = this.wording().today;
627
+ }
628
+ else if (sameDay(yesterday)) {
629
+ day = this.wording().yesterday;
630
+ }
631
+ else {
632
+ day = date.toLocaleDateString(this.locale, {
633
+ day: 'numeric',
634
+ month: 'short',
635
+ year: date.getFullYear() === today.getFullYear() ? undefined : 'numeric',
636
+ });
637
+ }
638
+ const time = date.toLocaleTimeString(this.locale, {
639
+ hour: '2-digit',
640
+ minute: '2-digit',
641
+ });
642
+ return `${day} ${time}`;
643
+ }
644
+ // A user message that arrived folds the steps of every reply before it, except a reply whose failed
645
+ // step the reader has not opened yet.
646
+ foldBefore(list, added) {
647
+ const sent = added.find((message) => message.role() === 'user');
648
+ if (!sent) {
649
+ return;
650
+ }
651
+ for (const reply of list.slice(0, list.indexOf(sent))) {
652
+ if (reply.role() === 'assistant' &&
653
+ reply.stepCount() > 0 &&
654
+ reply.unopenedFailedStepCount() === 0) {
655
+ reply.stepsFolded.set(true);
656
+ }
657
+ }
658
+ }
659
+ toEnd() {
660
+ const scroller = this.scroller().nativeElement;
661
+ scroller.scrollTop = scroller.scrollHeight;
662
+ }
663
+ afterRender(read) {
664
+ afterNextRender({ read }, { injector: this.injector });
665
+ }
666
+ announceLastReply() {
667
+ if (this.messages().at(-1)?.role() !== 'assistant') {
668
+ return;
669
+ }
670
+ const replies = this.host.nativeElement.querySelectorAll('ds-chat-message[data-role="assistant"]');
671
+ const reply = replies[replies.length - 1];
672
+ if (!reply) {
673
+ return;
674
+ }
675
+ const speaker = reply.querySelector('.speaker')?.textContent?.trim() ?? '';
676
+ const text = reply.querySelector('.bubble')?.textContent?.trim() ?? '';
677
+ if (text) {
678
+ this.announce(speaker ? `${speaker}: ${text}` : text);
679
+ }
680
+ }
681
+ // Cleared first, so the same words twice in a row are still spoken.
682
+ announce(text) {
683
+ this.announcement.set('');
684
+ this.afterRender(() => this.announcement.set(text));
685
+ }
686
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ChatThreadComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
687
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.22", type: ChatThreadComponent, isStandalone: true, selector: "ds-chat-thread", inputs: { working: { classPropertyName: "working", publicName: "working", isSignal: true, isRequired: false, transformFunction: null }, workingLabel: { classPropertyName: "workingLabel", publicName: "workingLabel", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, foldStepsOnSend: { classPropertyName: "foldStepsOnSend", publicName: "foldStepsOnSend", isSignal: true, isRequired: false, transformFunction: null }, timeBreakMinutes: { classPropertyName: "timeBreakMinutes", publicName: "timeBreakMinutes", isSignal: true, isRequired: false, transformFunction: null }, hasOlder: { classPropertyName: "hasOlder", publicName: "hasOlder", isSignal: true, isRequired: false, transformFunction: null }, loadingOlder: { classPropertyName: "loadingOlder", publicName: "loadingOlder", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { loadOlder: "loadOlder" }, providers: [
688
+ {
689
+ provide: CHAT_THREAD,
690
+ useExisting: forwardRef(() => ChatThreadComponent),
691
+ },
692
+ ], queries: [{ propertyName: "messages", predicate: ChatMessageComponent, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "scroller", first: true, predicate: ["scroller"], descendants: true, isSignal: true }, { propertyName: "content", first: true, predicate: ["content"], descendants: true, isSignal: true }], ngImport: i0, template: "<div\n #scroller\n class=\"scroller\"\n role=\"region\"\n tabindex=\"0\"\n [attr.aria-label]=\"label()\"\n (scroll)=\"onScroll()\">\n <div\n #content\n class=\"content\">\n <ng-content></ng-content>\n\n @if (working()) {\n <div class=\"working\">\n <span aria-hidden=\"true\">\n <ds-spinner size=\"sm\" />\n </span>\n\n <span class=\"working-label\">\n {{ workingText() }}\n </span>\n </div>\n }\n </div>\n</div>\n\n@if (loadingOlder()) {\n <div class=\"older\">\n <ds-spinner size=\"sm\" />\n </div>\n}\n\n@if (!pinned()) {\n <ds-button\n class=\"jump\"\n variant=\"outline\"\n color=\"neutral\"\n size=\"sm\"\n trailingIcon=\"arrowDown\"\n (pressed)=\"scrollToEnd()\">\n {{ jumpLabel() }}\n </ds-button>\n}\n\n<div\n class=\"visually-hidden\"\n aria-live=\"polite\"\n aria-atomic=\"true\">\n {{ announcement() }}\n</div>\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{--_chat-thread-gap: var(--ds-chat-thread-gap, var(--space-4));--_chat-thread-group-gap: var(--ds-chat-thread-group-gap, var(--space-1));--_chat-thread-padding: var(--ds-chat-thread-padding, var(--space-4));position:relative;display:flex;flex-direction:column;inline-size:100%;min-height:0}.scroller{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;overflow-anchor:none;padding:var(--_chat-thread-padding)}.content{display:flex;flex-direction:column}.older{position:absolute;top:var(--space-3);left:50%;translate:-50% 0;display:flex;padding:var(--space-1-5);border-radius:var(--ds-radius-pill);background-color:var(--surface-default);box-shadow:var(--shadow-popover)}.working{display:flex;align-items:center;gap:var(--space-2);margin-top:var(--_chat-thread-gap);font-size:var(--font-size-s);line-height:var(--line-height-base);color:var(--text-secondary)}.working-label{min-width:0;overflow-wrap:anywhere}.jump{position:absolute;bottom:var(--space-3);left:50%;translate:-50% 0;--ds-button-radius: var(--ds-radius-pill);--ds-button-bg-color: var(--surface-default);--ds-button-shadow: var(--shadow-popover)}.visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}\n"], dependencies: [{ kind: "component", type: ButtonComponent, selector: "ds-button", inputs: ["color", "variant", "align", "size", "routerLink", "href", "fragment", "queryParams", "queryParamsHandling", "target", "rel", "routerLinkActiveOptions", "ariaCurrent", "type", "disabled", "loading", "loadingMode", "fullWidth", "ariaLabel", "icon", "trailingIcon", "ariaHasPopup", "ariaExpanded", "ariaControls", "disabledReason", "ariaDescribedBy"], outputs: ["pressed"] }, { kind: "component", type: SpinnerComponent, selector: "ds-spinner", inputs: ["size"] }] });
693
+ }
694
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ChatThreadComponent, decorators: [{
695
+ type: Component,
696
+ args: [{ selector: 'ds-chat-thread', standalone: true, imports: [ButtonComponent, SpinnerComponent], encapsulation: ViewEncapsulation.Emulated, providers: [
697
+ {
698
+ provide: CHAT_THREAD,
699
+ useExisting: forwardRef(() => ChatThreadComponent),
700
+ },
701
+ ], template: "<div\n #scroller\n class=\"scroller\"\n role=\"region\"\n tabindex=\"0\"\n [attr.aria-label]=\"label()\"\n (scroll)=\"onScroll()\">\n <div\n #content\n class=\"content\">\n <ng-content></ng-content>\n\n @if (working()) {\n <div class=\"working\">\n <span aria-hidden=\"true\">\n <ds-spinner size=\"sm\" />\n </span>\n\n <span class=\"working-label\">\n {{ workingText() }}\n </span>\n </div>\n }\n </div>\n</div>\n\n@if (loadingOlder()) {\n <div class=\"older\">\n <ds-spinner size=\"sm\" />\n </div>\n}\n\n@if (!pinned()) {\n <ds-button\n class=\"jump\"\n variant=\"outline\"\n color=\"neutral\"\n size=\"sm\"\n trailingIcon=\"arrowDown\"\n (pressed)=\"scrollToEnd()\">\n {{ jumpLabel() }}\n </ds-button>\n}\n\n<div\n class=\"visually-hidden\"\n aria-live=\"polite\"\n aria-atomic=\"true\">\n {{ announcement() }}\n</div>\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{--_chat-thread-gap: var(--ds-chat-thread-gap, var(--space-4));--_chat-thread-group-gap: var(--ds-chat-thread-group-gap, var(--space-1));--_chat-thread-padding: var(--ds-chat-thread-padding, var(--space-4));position:relative;display:flex;flex-direction:column;inline-size:100%;min-height:0}.scroller{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;overflow-anchor:none;padding:var(--_chat-thread-padding)}.content{display:flex;flex-direction:column}.older{position:absolute;top:var(--space-3);left:50%;translate:-50% 0;display:flex;padding:var(--space-1-5);border-radius:var(--ds-radius-pill);background-color:var(--surface-default);box-shadow:var(--shadow-popover)}.working{display:flex;align-items:center;gap:var(--space-2);margin-top:var(--_chat-thread-gap);font-size:var(--font-size-s);line-height:var(--line-height-base);color:var(--text-secondary)}.working-label{min-width:0;overflow-wrap:anywhere}.jump{position:absolute;bottom:var(--space-3);left:50%;translate:-50% 0;--ds-button-radius: var(--ds-radius-pill);--ds-button-bg-color: var(--surface-default);--ds-button-shadow: var(--shadow-popover)}.visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}\n"] }]
702
+ }], ctorParameters: () => [], propDecorators: { working: [{ type: i0.Input, args: [{ isSignal: true, alias: "working", required: false }] }], workingLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "workingLabel", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], foldStepsOnSend: [{ type: i0.Input, args: [{ isSignal: true, alias: "foldStepsOnSend", required: false }] }], timeBreakMinutes: [{ type: i0.Input, args: [{ isSignal: true, alias: "timeBreakMinutes", required: false }] }], hasOlder: [{ type: i0.Input, args: [{ isSignal: true, alias: "hasOlder", required: false }] }], loadingOlder: [{ type: i0.Input, args: [{ isSignal: true, alias: "loadingOlder", required: false }] }], loadOlder: [{ type: i0.Output, args: ["loadOlder"] }], messages: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => ChatMessageComponent), { ...{
703
+ descendants: true,
704
+ }, isSignal: true }] }], scroller: [{ type: i0.ViewChild, args: ['scroller', { isSignal: true }] }], content: [{ type: i0.ViewChild, args: ['content', { isSignal: true }] }] } });
705
+
706
+ let nextId = 0;
707
+ /**
708
+ * A chip in a message's `[attachments]` slot that opens to show what was attached as it was when
709
+ * sent. The default slot is the snapshot, shown in a framed preview. A plain file with nothing to show is a `ds-tag`.
710
+ */
711
+ class ChatAttachmentComponent {
712
+ /** Chip text: the file name, or the picked element's name. */
713
+ label = input.required(...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
714
+ /** Where it came from, shown muted after the label: the page or screen it was picked on. */
715
+ source = input('', ...(ngDevMode ? [{ debugName: "source" }] : /* istanbul ignore next */ []));
716
+ /** Icon before the label. */
717
+ icon = input('paperclip', ...(ngDevMode ? [{ debugName: "icon" }] : /* istanbul ignore next */ []));
718
+ /** Whether the snapshot is open, two-way bound. */
719
+ expanded = model(false, ...(ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []));
720
+ snapshotId = `ds-chat-attachment-${++nextId}`;
721
+ toggle() {
722
+ this.expanded.set(!this.expanded());
723
+ }
724
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ChatAttachmentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
725
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.22", type: ChatAttachmentComponent, isStandalone: true, selector: "ds-chat-attachment", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, expanded: { classPropertyName: "expanded", publicName: "expanded", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { expanded: "expandedChange" }, host: { properties: { "class.is-expanded": "expanded()" } }, ngImport: i0, template: "<button\n type=\"button\"\n class=\"head\"\n [attr.aria-expanded]=\"expanded()\"\n [attr.aria-controls]=\"snapshotId\"\n (click)=\"toggle()\">\n @if (icon(); as name) {\n <ds-icon\n class=\"icon\"\n [name]=\"name\"\n [size]=\"14\" />\n }\n\n <span class=\"label\">\n {{ label() }}\n </span>\n\n @if (source()) {\n <span class=\"source\">\n {{ source() }}\n </span>\n }\n\n <ds-icon\n class=\"chev\"\n name=\"chevronDown\"\n [size]=\"14\" />\n</button>\n\n<div\n class=\"preview\"\n [id]=\"snapshotId\"\n [hidden]=\"!expanded()\">\n <ng-content></ng-content>\n</div>\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{--_chat-attachment-bg-color: var(--ds-chat-attachment-bg-color, var(--surface-default));--_chat-attachment-preview-bg-color: var(--ds-chat-attachment-preview-bg-color, var(--surface-secondary));--_chat-attachment-preview-max-height: var(--ds-chat-attachment-preview-max-height, 16rem);display:inline-flex;flex-direction:column;max-width:100%;min-width:0}.head{display:inline-flex;align-items:center;gap:var(--space-1-5);max-width:100%;min-width:0;padding:var(--space-1) var(--space-2-5) var(--space-1) var(--space-2);border:0;border-radius:var(--ds-radius-pill);background-color:color-mix(in srgb,currentcolor 14%,transparent);color:inherit;font:inherit;font-size:var(--font-size-xs);line-height:var(--line-height-base);text-align:start;cursor:pointer}.head:active:not(:disabled,[disabled],.is-disabled,.disabled,[aria-disabled=true]){filter:brightness(var(--ds-press-brightness, .9));transform:scale(var(--ds-press-scale, .97))}.head:hover{background-color:color-mix(in srgb,currentcolor 22%,transparent)}.icon,.chev{flex:none}.label{min-width:0;font-weight:var(--font-weight-semibold);overflow-wrap:anywhere}.source{min-width:0;opacity:.75;overflow-wrap:anywhere}.chev{margin-inline-start:auto;transition:transform var(--duration-base) var(--ease-standard)}.head[aria-expanded=true] .chev{transform:rotate(180deg)}:host(.is-expanded){flex-basis:100%;border:var(--border-width-default) solid var(--border-default);border-radius:var(--ds-radius-control);background-color:var(--_chat-attachment-bg-color);color:var(--text-primary)}:host(.is-expanded) .head{width:100%;padding:var(--space-2) var(--space-3);border-radius:var(--ds-radius-control) var(--ds-radius-control) 0 0;background-color:transparent}:host(.is-expanded) .head:hover{background-color:var(--surface-secondary)}:host(.is-expanded) .icon,:host(.is-expanded) .source,:host(.is-expanded) .chev{color:var(--text-secondary);opacity:1}.preview{display:flex;align-items:center;justify-content:center;max-height:var(--_chat-attachment-preview-max-height);min-width:0;margin:0 var(--space-2) var(--space-2);padding:var(--space-4);overflow:auto;border-radius:var(--ds-radius-inner);background-color:var(--_chat-attachment-preview-bg-color)}.preview[hidden]{display:none}\n"], dependencies: [{ kind: "component", type: IconComponent, selector: "ds-icon", inputs: ["name", "size", "stroke", "ariaLabel"] }] });
726
+ }
727
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ChatAttachmentComponent, decorators: [{
728
+ type: Component,
729
+ args: [{ selector: 'ds-chat-attachment', standalone: true, imports: [IconComponent], encapsulation: ViewEncapsulation.Emulated, host: {
730
+ '[class.is-expanded]': 'expanded()',
731
+ }, template: "<button\n type=\"button\"\n class=\"head\"\n [attr.aria-expanded]=\"expanded()\"\n [attr.aria-controls]=\"snapshotId\"\n (click)=\"toggle()\">\n @if (icon(); as name) {\n <ds-icon\n class=\"icon\"\n [name]=\"name\"\n [size]=\"14\" />\n }\n\n <span class=\"label\">\n {{ label() }}\n </span>\n\n @if (source()) {\n <span class=\"source\">\n {{ source() }}\n </span>\n }\n\n <ds-icon\n class=\"chev\"\n name=\"chevronDown\"\n [size]=\"14\" />\n</button>\n\n<div\n class=\"preview\"\n [id]=\"snapshotId\"\n [hidden]=\"!expanded()\">\n <ng-content></ng-content>\n</div>\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{--_chat-attachment-bg-color: var(--ds-chat-attachment-bg-color, var(--surface-default));--_chat-attachment-preview-bg-color: var(--ds-chat-attachment-preview-bg-color, var(--surface-secondary));--_chat-attachment-preview-max-height: var(--ds-chat-attachment-preview-max-height, 16rem);display:inline-flex;flex-direction:column;max-width:100%;min-width:0}.head{display:inline-flex;align-items:center;gap:var(--space-1-5);max-width:100%;min-width:0;padding:var(--space-1) var(--space-2-5) var(--space-1) var(--space-2);border:0;border-radius:var(--ds-radius-pill);background-color:color-mix(in srgb,currentcolor 14%,transparent);color:inherit;font:inherit;font-size:var(--font-size-xs);line-height:var(--line-height-base);text-align:start;cursor:pointer}.head:active:not(:disabled,[disabled],.is-disabled,.disabled,[aria-disabled=true]){filter:brightness(var(--ds-press-brightness, .9));transform:scale(var(--ds-press-scale, .97))}.head:hover{background-color:color-mix(in srgb,currentcolor 22%,transparent)}.icon,.chev{flex:none}.label{min-width:0;font-weight:var(--font-weight-semibold);overflow-wrap:anywhere}.source{min-width:0;opacity:.75;overflow-wrap:anywhere}.chev{margin-inline-start:auto;transition:transform var(--duration-base) var(--ease-standard)}.head[aria-expanded=true] .chev{transform:rotate(180deg)}:host(.is-expanded){flex-basis:100%;border:var(--border-width-default) solid var(--border-default);border-radius:var(--ds-radius-control);background-color:var(--_chat-attachment-bg-color);color:var(--text-primary)}:host(.is-expanded) .head{width:100%;padding:var(--space-2) var(--space-3);border-radius:var(--ds-radius-control) var(--ds-radius-control) 0 0;background-color:transparent}:host(.is-expanded) .head:hover{background-color:var(--surface-secondary)}:host(.is-expanded) .icon,:host(.is-expanded) .source,:host(.is-expanded) .chev{color:var(--text-secondary);opacity:1}.preview{display:flex;align-items:center;justify-content:center;max-height:var(--_chat-attachment-preview-max-height);min-width:0;margin:0 var(--space-2) var(--space-2);padding:var(--space-4);overflow:auto;border-radius:var(--ds-radius-inner);background-color:var(--_chat-attachment-preview-bg-color)}.preview[hidden]{display:none}\n"] }]
732
+ }], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], source: [{ type: i0.Input, args: [{ isSignal: true, alias: "source", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], expanded: [{ type: i0.Input, args: [{ isSignal: true, alias: "expanded", required: false }] }, { type: i0.Output, args: ["expandedChange"] }] } });
733
+
734
+ /**
735
+ * Message box for a chat or an instruction: an auto-growing text area with chips above it, actions
736
+ * on the left of a bottom bar and a send button on the right. Enter submits, Shift+Enter breaks the
737
+ * line. Slots: `[attachments]` above the frame, `[chips]`, `[actions]`, `[send]` (replaces the default send
738
+ * button).
739
+ */
740
+ class ChatInputComponent {
741
+ intl = inject(DS_INTL);
742
+ textarea = viewChild.required(TextareaComponent);
743
+ /** Message text, two-way bound. Not cleared on submit: clear it once the message is accepted. */
744
+ value = model('', ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
745
+ /** Placeholder shown when empty. */
746
+ placeholder = input('', ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
747
+ /** Accessible name of the text area; unset falls back to `DS_INTL.chatInput.label`. */
748
+ ariaLabel = input(null, ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
749
+ /** Height in lines the text area starts at. */
750
+ minRows = input(1, ...(ngDevMode ? [{ debugName: "minRows" }] : /* istanbul ignore next */ []));
751
+ /** Height in lines the text area grows to before it scrolls. */
752
+ maxRows = input(8, ...(ngDevMode ? [{ debugName: "maxRows" }] : /* istanbul ignore next */ []));
753
+ /** Disables the text area and the send button. Projected controls are the consumer's to disable. */
754
+ disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
755
+ /** Work in flight: the send button keeps its place, shows a spinner and refuses to submit, and
756
+ * Enter does not submit. The text area stays editable. */
757
+ busy = input(false, { ...(ngDevMode ? { debugName: "busy" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
758
+ /** The current step while `busy`, such as "Rebuilding"; where it shows follows `layout`. */
759
+ busyLabel = input('', ...(ngDevMode ? [{ debugName: "busyLabel" }] : /* istanbul ignore next */ []));
760
+ /** Where the buttons and the step text sit. `'status-bar'`: buttons inside, the step text in the
761
+ * bar beside a fixed-size send button. `'status-above'`: the step text on a line above the box.
762
+ * `'split'`: attach outside on the left, send outside on the right, the step text above.
763
+ * `'send-outside'`: attach and the step inside, a round send button outside on the right.
764
+ * `'toolbar'`: the box holds the text, attach, the step and send sit in a row under it. */
765
+ layout = input('status-bar', ...(ngDevMode ? [{ debugName: "layout" }] : /* istanbul ignore next */ []));
766
+ /** The trimmed text, on Enter or the send button. Never fires for blank text, while `busy` or
767
+ * while `disabled`. */
768
+ submitted = output();
769
+ /** Image files pasted into the text area. The paste inserts no text when it carries images. */
770
+ filesPasted = output();
771
+ /** True when Enter or the send button would submit; bind it in a `[send]` slot. */
772
+ canSubmit = computed(() => !this.disabled() && !this.busy() && this.value().trim() !== '', ...(ngDevMode ? [{ debugName: "canSubmit" }] : /* istanbul ignore next */ []));
773
+ labels = computed(() => ({
774
+ ...DS_INTL_DEFAULTS.chatInput,
775
+ ...this.intl().chatInput,
776
+ }), ...(ngDevMode ? [{ debugName: "labels" }] : /* istanbul ignore next */ []));
777
+ textareaLabel = computed(() => this.ariaLabel() || this.labels().label, ...(ngDevMode ? [{ debugName: "textareaLabel" }] : /* istanbul ignore next */ []));
778
+ sendLabel = computed(() => this.labels().send, ...(ngDevMode ? [{ debugName: "sendLabel" }] : /* istanbul ignore next */ []));
779
+ statusAbove = computed(() => this.layout() === 'status-above' || this.layout() === 'split', ...(ngDevMode ? [{ debugName: "statusAbove" }] : /* istanbul ignore next */ []));
780
+ statusText = computed(() => this.busy() ? this.busyLabel() : '', ...(ngDevMode ? [{ debugName: "statusText" }] : /* istanbul ignore next */ []));
781
+ /** Emits `submitted` when `canSubmit`; for a send button rendered in the `[send]` slot. */
782
+ submit() {
783
+ if (this.canSubmit()) {
784
+ this.submitted.emit(this.value().trim());
785
+ }
786
+ }
787
+ /** Moves keyboard focus to the text area. */
788
+ focus(options) {
789
+ this.textarea().focus(options);
790
+ }
791
+ onKeydown(event) {
792
+ // keyCode 229 is the IME key Safari sends after compositionend, with isComposing already false.
793
+ if (event.key !== 'Enter' ||
794
+ event.shiftKey ||
795
+ event.isComposing ||
796
+ event.keyCode === 229) {
797
+ return;
798
+ }
799
+ event.preventDefault();
800
+ this.submit();
801
+ }
802
+ onPaste(event) {
803
+ const images = Array.from(event.clipboardData?.files ?? []).filter((file) => file.type.startsWith('image/'));
804
+ if (images.length) {
805
+ event.preventDefault();
806
+ this.filesPasted.emit(images);
807
+ }
808
+ }
809
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ChatInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
810
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.22", type: ChatInputComponent, isStandalone: true, selector: "ds-chat-input", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, minRows: { classPropertyName: "minRows", publicName: "minRows", isSignal: true, isRequired: false, transformFunction: null }, maxRows: { classPropertyName: "maxRows", publicName: "maxRows", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, busy: { classPropertyName: "busy", publicName: "busy", isSignal: true, isRequired: false, transformFunction: null }, busyLabel: { classPropertyName: "busyLabel", publicName: "busyLabel", isSignal: true, isRequired: false, transformFunction: null }, layout: { classPropertyName: "layout", publicName: "layout", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", submitted: "submitted", filesPasted: "filesPasted" }, viewQueries: [{ propertyName: "textarea", first: true, predicate: TextareaComponent, descendants: true, isSignal: true }], ngImport: i0, template: "<div [class]=\"'chat-input layout-' + layout()\">\n <div class=\"attachments\">\n <ng-content select=\"[attachments]\" />\n </div>\n\n @if (statusAbove()) {\n <div\n class=\"status status-above\"\n aria-live=\"polite\">\n {{ statusText() }}\n </div>\n }\n\n <div\n class=\"frame\"\n dsFieldClickFocus\n [class.disabled]=\"disabled()\">\n <div class=\"box\"></div>\n\n <div class=\"chips\">\n <ng-content select=\"[chips]\" />\n </div>\n\n <ds-textarea\n autosize\n resize=\"none\"\n [rows]=\"minRows()\"\n [minRows]=\"minRows()\"\n [maxRows]=\"maxRows()\"\n [placeholder]=\"placeholder()\"\n [ariaLabel]=\"textareaLabel()\"\n [disabled]=\"disabled()\"\n [(value)]=\"value\"\n (keydown)=\"onKeydown($event)\"\n (paste)=\"onPaste($event)\" />\n\n <div class=\"actions\">\n <ng-content select=\"[actions]\" />\n </div>\n\n @if (!statusAbove()) {\n <span\n class=\"status status-bar\"\n aria-live=\"polite\">\n {{ statusText() }}\n </span>\n }\n\n <div class=\"send\">\n <ng-content select=\"[send]\">\n <ds-button\n icon=\"arrowUp\"\n size=\"sm\"\n class=\"send-button\"\n loadingMode=\"icon\"\n [ariaLabel]=\"sendLabel()\"\n [disabled]=\"!busy() && !canSubmit()\"\n [loading]=\"busy()\"\n (pressed)=\"submit()\" />\n </ng-content>\n </div>\n </div>\n</div>\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{--_field-border-color: var(--ds-field-border-color, var(--border-default));--_field-border-color-hover: var(--ds-field-border-color-hover, var(--border-strong));--_field-border-color-focus: var(--ds-field-border-color-focus, var(--accent));--_field-text-color: var(--ds-field-text-color, var(--text-primary));--_field-placeholder-color: var(--ds-field-placeholder-color, var(--text-tertiary));--_field-font-size: var(--ds-field-font-size, var(--font-size-s));--_chat-input-bg-color: var(--ds-chat-input-bg-color, var(--surface-default));--_chat-input-radius: var(--ds-chat-input-radius, var(--ds-radius-control));--_chat-input-padding: var(--ds-chat-input-padding, var(--space-2));display:block}.chat-input{display:flex;flex-direction:column;gap:var(--space-1)}.frame{--_p: var(--_chat-input-padding);display:grid;grid-template-columns:auto minmax(0,1fr) auto;grid-template-rows:auto auto auto;grid-template-areas:\"chips chips chips\" \"text text text\" \"actions status send\";column-gap:var(--space-2);cursor:text}@media not (forced-colors:active){.frame ds-textarea:where(:focus-visible){outline:none}}.box{grid-row:1/4;grid-column:1/4;background-color:var(--_chat-input-bg-color);border:var(--border-width-default) solid var(--_field-border-color);border-radius:var(--_chat-input-radius);transition:border-color var(--duration-fast) var(--ease-standard),box-shadow var(--duration-fast) var(--ease-standard)}.frame:has(ds-textarea:hover,.chips:hover) .box{border-color:var(--_field-border-color-hover)}.frame:has(ds-textarea:focus-within) .box{border-color:var(--_field-border-color-focus);box-shadow:var(--ds-field-focus-shadow)}.frame.disabled{cursor:default}.frame.disabled .box{background-color:var(--surface-disabled);border-color:var(--border-disabled)}ds-textarea{--ds-input-bg-color: transparent;--ds-input-bg-color-disabled: transparent;--ds-input-border: transparent;--ds-input-border-hover: transparent;--ds-input-border-focus: transparent;--ds-input-focus-shadow: none;--ds-input-padding-x: var(--space-2);--ds-input-padding-y: var(--space-1);--border-disabled: transparent;grid-area:text;margin:var(--_p) var(--_p) var(--space-1)}.chips{display:flex;flex-wrap:wrap;grid-area:chips;gap:var(--space-2);margin:var(--_p) calc(var(--_p) + var(--space-1)) 0}.chips:empty{display:none}.actions{display:flex;grid-area:actions;align-items:center;gap:var(--space-1);margin:0 0 var(--_p) var(--_p)}.status{overflow:clip visible;text-overflow:ellipsis;white-space:nowrap;color:var(--text-secondary);font-size:var(--font-size-s);line-height:var(--line-height-base)}.status-bar{grid-area:status;align-self:center;min-width:0;text-align:end;margin-block-end:var(--_p)}.status-above{min-height:1lh;padding-inline:var(--space-4)}.send{display:flex;grid-area:send;align-items:center;gap:var(--space-2);margin:0 var(--_p) var(--_p) 0}.send-button{--ds-button-padding-x: 0;width:var(--field-h-sm)}.layout-split .frame{grid-template-rows:auto auto;grid-template-areas:\". chips .\" \"actions text send\"}.layout-split .frame .box{grid-row:1/3;grid-column:2/3}.layout-split .frame ds-textarea{margin-block-end:var(--_p)}.layout-split .frame .actions,.layout-split .frame .send{align-self:end;margin:0 0 calc(var(--_p) - var(--space-1) / 2)}.layout-send-outside .frame{grid-template-areas:\"chips chips .\" \"text text .\" \"actions status send\"}.layout-send-outside .frame .box{grid-column:1/3}.layout-send-outside .frame .status-bar{margin-inline-end:var(--_p)}.layout-send-outside .frame .send{align-self:end;margin:0}.layout-send-outside .frame .send-button{--ds-button-height: var(--field-h-md);--ds-button-radius: 50%;width:var(--field-h-md)}.layout-toolbar .frame .box{grid-row:1/3}.layout-toolbar .frame ds-textarea{margin-block-end:var(--_p)}.layout-toolbar .frame .actions,.layout-toolbar .frame .status-bar,.layout-toolbar .frame .send{margin:var(--space-1) 0 0}.attachments{display:flex;flex-direction:column;gap:var(--space-2);margin-block-end:var(--space-1)}.attachments:empty{display:none}\n"], dependencies: [{ kind: "component", type: TextareaComponent, selector: "ds-textarea", inputs: ["value", "size", "label", "placeholder", "disabled", "readOnly", "readonly", "success", "required", "optional", "rows", "name", "autosize", "minRows", "maxRows", "resize", "ariaLabel", "maxLength", "maxLengthMode", "countTrimmed", "minLength", "pattern"], outputs: ["valueChange"] }, { kind: "component", type: ButtonComponent, selector: "ds-button", inputs: ["color", "variant", "align", "size", "routerLink", "href", "fragment", "queryParams", "queryParamsHandling", "target", "rel", "routerLinkActiveOptions", "ariaCurrent", "type", "disabled", "loading", "loadingMode", "fullWidth", "ariaLabel", "icon", "trailingIcon", "ariaHasPopup", "ariaExpanded", "ariaControls", "disabledReason", "ariaDescribedBy"], outputs: ["pressed"] }, { kind: "directive", type: FieldClickFocusDirective, selector: "[dsFieldClickFocus]" }] });
811
+ }
812
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ChatInputComponent, decorators: [{
813
+ type: Component,
814
+ args: [{ selector: 'ds-chat-input', standalone: true, imports: [TextareaComponent, ButtonComponent, FieldClickFocusDirective], encapsulation: ViewEncapsulation.Emulated, template: "<div [class]=\"'chat-input layout-' + layout()\">\n <div class=\"attachments\">\n <ng-content select=\"[attachments]\" />\n </div>\n\n @if (statusAbove()) {\n <div\n class=\"status status-above\"\n aria-live=\"polite\">\n {{ statusText() }}\n </div>\n }\n\n <div\n class=\"frame\"\n dsFieldClickFocus\n [class.disabled]=\"disabled()\">\n <div class=\"box\"></div>\n\n <div class=\"chips\">\n <ng-content select=\"[chips]\" />\n </div>\n\n <ds-textarea\n autosize\n resize=\"none\"\n [rows]=\"minRows()\"\n [minRows]=\"minRows()\"\n [maxRows]=\"maxRows()\"\n [placeholder]=\"placeholder()\"\n [ariaLabel]=\"textareaLabel()\"\n [disabled]=\"disabled()\"\n [(value)]=\"value\"\n (keydown)=\"onKeydown($event)\"\n (paste)=\"onPaste($event)\" />\n\n <div class=\"actions\">\n <ng-content select=\"[actions]\" />\n </div>\n\n @if (!statusAbove()) {\n <span\n class=\"status status-bar\"\n aria-live=\"polite\">\n {{ statusText() }}\n </span>\n }\n\n <div class=\"send\">\n <ng-content select=\"[send]\">\n <ds-button\n icon=\"arrowUp\"\n size=\"sm\"\n class=\"send-button\"\n loadingMode=\"icon\"\n [ariaLabel]=\"sendLabel()\"\n [disabled]=\"!busy() && !canSubmit()\"\n [loading]=\"busy()\"\n (pressed)=\"submit()\" />\n </ng-content>\n </div>\n </div>\n</div>\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{--_field-border-color: var(--ds-field-border-color, var(--border-default));--_field-border-color-hover: var(--ds-field-border-color-hover, var(--border-strong));--_field-border-color-focus: var(--ds-field-border-color-focus, var(--accent));--_field-text-color: var(--ds-field-text-color, var(--text-primary));--_field-placeholder-color: var(--ds-field-placeholder-color, var(--text-tertiary));--_field-font-size: var(--ds-field-font-size, var(--font-size-s));--_chat-input-bg-color: var(--ds-chat-input-bg-color, var(--surface-default));--_chat-input-radius: var(--ds-chat-input-radius, var(--ds-radius-control));--_chat-input-padding: var(--ds-chat-input-padding, var(--space-2));display:block}.chat-input{display:flex;flex-direction:column;gap:var(--space-1)}.frame{--_p: var(--_chat-input-padding);display:grid;grid-template-columns:auto minmax(0,1fr) auto;grid-template-rows:auto auto auto;grid-template-areas:\"chips chips chips\" \"text text text\" \"actions status send\";column-gap:var(--space-2);cursor:text}@media not (forced-colors:active){.frame ds-textarea:where(:focus-visible){outline:none}}.box{grid-row:1/4;grid-column:1/4;background-color:var(--_chat-input-bg-color);border:var(--border-width-default) solid var(--_field-border-color);border-radius:var(--_chat-input-radius);transition:border-color var(--duration-fast) var(--ease-standard),box-shadow var(--duration-fast) var(--ease-standard)}.frame:has(ds-textarea:hover,.chips:hover) .box{border-color:var(--_field-border-color-hover)}.frame:has(ds-textarea:focus-within) .box{border-color:var(--_field-border-color-focus);box-shadow:var(--ds-field-focus-shadow)}.frame.disabled{cursor:default}.frame.disabled .box{background-color:var(--surface-disabled);border-color:var(--border-disabled)}ds-textarea{--ds-input-bg-color: transparent;--ds-input-bg-color-disabled: transparent;--ds-input-border: transparent;--ds-input-border-hover: transparent;--ds-input-border-focus: transparent;--ds-input-focus-shadow: none;--ds-input-padding-x: var(--space-2);--ds-input-padding-y: var(--space-1);--border-disabled: transparent;grid-area:text;margin:var(--_p) var(--_p) var(--space-1)}.chips{display:flex;flex-wrap:wrap;grid-area:chips;gap:var(--space-2);margin:var(--_p) calc(var(--_p) + var(--space-1)) 0}.chips:empty{display:none}.actions{display:flex;grid-area:actions;align-items:center;gap:var(--space-1);margin:0 0 var(--_p) var(--_p)}.status{overflow:clip visible;text-overflow:ellipsis;white-space:nowrap;color:var(--text-secondary);font-size:var(--font-size-s);line-height:var(--line-height-base)}.status-bar{grid-area:status;align-self:center;min-width:0;text-align:end;margin-block-end:var(--_p)}.status-above{min-height:1lh;padding-inline:var(--space-4)}.send{display:flex;grid-area:send;align-items:center;gap:var(--space-2);margin:0 var(--_p) var(--_p) 0}.send-button{--ds-button-padding-x: 0;width:var(--field-h-sm)}.layout-split .frame{grid-template-rows:auto auto;grid-template-areas:\". chips .\" \"actions text send\"}.layout-split .frame .box{grid-row:1/3;grid-column:2/3}.layout-split .frame ds-textarea{margin-block-end:var(--_p)}.layout-split .frame .actions,.layout-split .frame .send{align-self:end;margin:0 0 calc(var(--_p) - var(--space-1) / 2)}.layout-send-outside .frame{grid-template-areas:\"chips chips .\" \"text text .\" \"actions status send\"}.layout-send-outside .frame .box{grid-column:1/3}.layout-send-outside .frame .status-bar{margin-inline-end:var(--_p)}.layout-send-outside .frame .send{align-self:end;margin:0}.layout-send-outside .frame .send-button{--ds-button-height: var(--field-h-md);--ds-button-radius: 50%;width:var(--field-h-md)}.layout-toolbar .frame .box{grid-row:1/3}.layout-toolbar .frame ds-textarea{margin-block-end:var(--_p)}.layout-toolbar .frame .actions,.layout-toolbar .frame .status-bar,.layout-toolbar .frame .send{margin:var(--space-1) 0 0}.attachments{display:flex;flex-direction:column;gap:var(--space-2);margin-block-end:var(--space-1)}.attachments:empty{display:none}\n"] }]
815
+ }], propDecorators: { textarea: [{ type: i0.ViewChild, args: [i0.forwardRef(() => TextareaComponent), { isSignal: true }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], minRows: [{ type: i0.Input, args: [{ isSignal: true, alias: "minRows", required: false }] }], maxRows: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxRows", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], busy: [{ type: i0.Input, args: [{ isSignal: true, alias: "busy", required: false }] }], busyLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "busyLabel", required: false }] }], layout: [{ type: i0.Input, args: [{ isSignal: true, alias: "layout", required: false }] }], submitted: [{ type: i0.Output, args: ["submitted"] }], filesPasted: [{ type: i0.Output, args: ["filesPasted"] }] } });
816
+
817
+ /**
818
+ * A file attached to a message: a type tile or an image preview, the file name and a second line
819
+ * such as its size. Place it in the `[chips]` slot of `ds-chat-input`.
820
+ */
821
+ class AttachmentComponent {
822
+ intl = inject(DS_INTL);
823
+ /** File name, shown on the first line and used in the remove button's accessible name. */
824
+ name = input.required(...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ []));
825
+ /** Second line, such as `'PDF · 240 KB'`. */
826
+ meta = input('', ...(ngDevMode ? [{ debugName: "meta" }] : /* istanbul ignore next */ []));
827
+ /** Draws the type tile and is announced before `meta`. */
828
+ kind = input('file', ...(ngDevMode ? [{ debugName: "kind" }] : /* istanbul ignore next */ []));
829
+ /** Image shown in place of the tile when `kind` is `'image'`. */
830
+ previewUrl = input(null, ...(ngDevMode ? [{ debugName: "previewUrl" }] : /* istanbul ignore next */ []));
831
+ /** Shows a remove button that emits `removed`. */
832
+ removable = input(false, { ...(ngDevMode ? { debugName: "removable" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
833
+ /** Fires when the remove button is pressed. */
834
+ removed = output();
835
+ labels = computed(() => ({
836
+ ...DS_INTL_DEFAULTS.attachment,
837
+ ...this.intl().attachment,
838
+ }), ...(ngDevMode ? [{ debugName: "labels" }] : /* istanbul ignore next */ []));
839
+ kindLabel = computed(() => this.labels()[this.kind()], ...(ngDevMode ? [{ debugName: "kindLabel" }] : /* istanbul ignore next */ []));
840
+ removeLabel = computed(() => this.labels().remove(this.name()), ...(ngDevMode ? [{ debugName: "removeLabel" }] : /* istanbul ignore next */ []));
841
+ showPreview = computed(() => this.kind() === 'image' && !!this.previewUrl(), ...(ngDevMode ? [{ debugName: "showPreview" }] : /* istanbul ignore next */ []));
842
+ tileText = computed(() => ({ pdf: 'PDF', doc: 'DOC', image: 'IMG', file: 'FILE' })[this.kind()], ...(ngDevMode ? [{ debugName: "tileText" }] : /* istanbul ignore next */ []));
843
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: AttachmentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
844
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.22", type: AttachmentComponent, isStandalone: true, selector: "ds-attachment", inputs: { name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: true, transformFunction: null }, meta: { classPropertyName: "meta", publicName: "meta", isSignal: true, isRequired: false, transformFunction: null }, kind: { classPropertyName: "kind", publicName: "kind", isSignal: true, isRequired: false, transformFunction: null }, previewUrl: { classPropertyName: "previewUrl", publicName: "previewUrl", isSignal: true, isRequired: false, transformFunction: null }, removable: { classPropertyName: "removable", publicName: "removable", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { removed: "removed" }, host: { properties: { "class": "'kind-' + kind()" } }, ngImport: i0, template: "@if (showPreview()) {\n <img\n class=\"preview\"\n [src]=\"previewUrl()\"\n [alt]=\"name()\" />\n} @else {\n <span\n class=\"tile\"\n aria-hidden=\"true\">\n {{ tileText() }}\n </span>\n}\n\n<span class=\"text\">\n <span class=\"name\">\n {{ name() }}\n </span>\n\n <span class=\"meta\">\n <span class=\"visually-hidden\">\n {{ kindLabel() }}\n </span>\n {{ meta() }}\n </span>\n</span>\n\n@if (removable()) {\n <button\n type=\"button\"\n class=\"remove\"\n [attr.aria-label]=\"removeLabel()\"\n (click)=\"removed.emit()\">\n <ds-icon\n name=\"x\"\n [size]=\"12\" />\n </button>\n}\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{--_attachment-tile-width: 29px;--_attachment-preview-width: 34px;--_attachment-tile-font-size: 9px;--_attachment-tile-bg-color: var(--text-secondary);--_attachment-tile-text-color: var(--surface-default);display:inline-flex;align-items:center;gap:var(--space-1-5);max-inline-size:100%;padding:var(--space-1) var(--space-1-5);border:var(--border-width-default) solid var(--border-default);border-radius:var(--radius-sm);background-color:var(--surface-secondary);color:var(--text-primary);font-size:var(--font-size-2xs);line-height:var(--line-height-flat)}:host(.kind-pdf){--_attachment-tile-bg-color: var(--error);--_attachment-tile-text-color: var(--error-on)}:host(.kind-doc){--_attachment-tile-bg-color: var(--primary);--_attachment-tile-text-color: var(--primary-on)}.tile,.preview{flex:none;block-size:var(--space-6);border-radius:var(--space-0-5)}.tile{display:grid;place-items:center;inline-size:var(--_attachment-tile-width);background-color:var(--_attachment-tile-bg-color);color:var(--_attachment-tile-text-color);font-size:var(--_attachment-tile-font-size);font-weight:var(--font-weight-extrabold)}.preview{inline-size:var(--_attachment-preview-width);object-fit:cover;border:var(--border-width-default) solid var(--border-default)}.text{display:flex;flex-direction:column;gap:var(--space-0-5);min-inline-size:0}.name{overflow:clip visible;text-overflow:ellipsis;white-space:nowrap;font-weight:var(--font-weight-bold)}.meta{overflow:clip visible;text-overflow:ellipsis;white-space:nowrap;color:var(--text-secondary);font-size:var(--font-size-3xs)}.visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.remove{display:inline-flex;flex:none;align-items:center;justify-content:center;padding:var(--space-0-5);border:0;border-radius:var(--ds-radius-inner);background:transparent;color:var(--text-secondary);cursor:pointer;transition:background-color var(--duration-fast) var(--ease-standard)}.remove:hover{background:color-mix(in oklab,currentcolor calc(var(--opacity-state-hover) * 100%),transparent)}.remove:active:not(:disabled,[disabled],.is-disabled,.disabled,[aria-disabled=true]){filter:brightness(var(--ds-press-brightness, .9));transform:scale(var(--ds-press-scale, .97))}.remove:focus-visible{outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:1px;animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard)}.remove{position:relative}.remove:before{content:\"\";position:absolute;top:50%;left:50%;width:max(100%,var(--hit-xs));height:max(100%,var(--hit-xs));translate:-50% -50%;border-radius:inherit}.remove:focus-visible{outline-style:none}.remove:focus-visible:before{outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:calc(var(--focus-ring-offset) - 2 * var(--focus-ring-width));animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard)}\n"], dependencies: [{ kind: "component", type: IconComponent, selector: "ds-icon", inputs: ["name", "size", "stroke", "ariaLabel"] }] });
845
+ }
846
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: AttachmentComponent, decorators: [{
847
+ type: Component,
848
+ args: [{ selector: 'ds-attachment', standalone: true, imports: [IconComponent], encapsulation: ViewEncapsulation.Emulated, host: {
849
+ '[class]': "'kind-' + kind()",
850
+ }, template: "@if (showPreview()) {\n <img\n class=\"preview\"\n [src]=\"previewUrl()\"\n [alt]=\"name()\" />\n} @else {\n <span\n class=\"tile\"\n aria-hidden=\"true\">\n {{ tileText() }}\n </span>\n}\n\n<span class=\"text\">\n <span class=\"name\">\n {{ name() }}\n </span>\n\n <span class=\"meta\">\n <span class=\"visually-hidden\">\n {{ kindLabel() }}\n </span>\n {{ meta() }}\n </span>\n</span>\n\n@if (removable()) {\n <button\n type=\"button\"\n class=\"remove\"\n [attr.aria-label]=\"removeLabel()\"\n (click)=\"removed.emit()\">\n <ds-icon\n name=\"x\"\n [size]=\"12\" />\n </button>\n}\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{--_attachment-tile-width: 29px;--_attachment-preview-width: 34px;--_attachment-tile-font-size: 9px;--_attachment-tile-bg-color: var(--text-secondary);--_attachment-tile-text-color: var(--surface-default);display:inline-flex;align-items:center;gap:var(--space-1-5);max-inline-size:100%;padding:var(--space-1) var(--space-1-5);border:var(--border-width-default) solid var(--border-default);border-radius:var(--radius-sm);background-color:var(--surface-secondary);color:var(--text-primary);font-size:var(--font-size-2xs);line-height:var(--line-height-flat)}:host(.kind-pdf){--_attachment-tile-bg-color: var(--error);--_attachment-tile-text-color: var(--error-on)}:host(.kind-doc){--_attachment-tile-bg-color: var(--primary);--_attachment-tile-text-color: var(--primary-on)}.tile,.preview{flex:none;block-size:var(--space-6);border-radius:var(--space-0-5)}.tile{display:grid;place-items:center;inline-size:var(--_attachment-tile-width);background-color:var(--_attachment-tile-bg-color);color:var(--_attachment-tile-text-color);font-size:var(--_attachment-tile-font-size);font-weight:var(--font-weight-extrabold)}.preview{inline-size:var(--_attachment-preview-width);object-fit:cover;border:var(--border-width-default) solid var(--border-default)}.text{display:flex;flex-direction:column;gap:var(--space-0-5);min-inline-size:0}.name{overflow:clip visible;text-overflow:ellipsis;white-space:nowrap;font-weight:var(--font-weight-bold)}.meta{overflow:clip visible;text-overflow:ellipsis;white-space:nowrap;color:var(--text-secondary);font-size:var(--font-size-3xs)}.visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.remove{display:inline-flex;flex:none;align-items:center;justify-content:center;padding:var(--space-0-5);border:0;border-radius:var(--ds-radius-inner);background:transparent;color:var(--text-secondary);cursor:pointer;transition:background-color var(--duration-fast) var(--ease-standard)}.remove:hover{background:color-mix(in oklab,currentcolor calc(var(--opacity-state-hover) * 100%),transparent)}.remove:active:not(:disabled,[disabled],.is-disabled,.disabled,[aria-disabled=true]){filter:brightness(var(--ds-press-brightness, .9));transform:scale(var(--ds-press-scale, .97))}.remove:focus-visible{outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:1px;animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard)}.remove{position:relative}.remove:before{content:\"\";position:absolute;top:50%;left:50%;width:max(100%,var(--hit-xs));height:max(100%,var(--hit-xs));translate:-50% -50%;border-radius:inherit}.remove:focus-visible{outline-style:none}.remove:focus-visible:before{outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:calc(var(--focus-ring-offset) - 2 * var(--focus-ring-width));animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard)}\n"] }]
851
+ }], propDecorators: { name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: true }] }], meta: [{ type: i0.Input, args: [{ isSignal: true, alias: "meta", required: false }] }], kind: [{ type: i0.Input, args: [{ isSignal: true, alias: "kind", required: false }] }], previewUrl: [{ type: i0.Input, args: [{ isSignal: true, alias: "previewUrl", required: false }] }], removable: [{ type: i0.Input, args: [{ isSignal: true, alias: "removable", required: false }] }], removed: [{ type: i0.Output, args: ["removed"] }] } });
852
+
853
+ /**
854
+ * Generated bundle index. Do not edit.
855
+ */
856
+
857
+ export { AttachmentComponent, ChatAttachmentComponent, ChatInputComponent, ChatMessageComponent, ChatStepComponent, ChatStepsComponent, ChatThreadComponent };
858
+ //# sourceMappingURL=ids-group-ltd-ids-design-system-components-chat.mjs.map