{"version":3,"file":"ng-primitives-ai.mjs","sources":["../../../../packages/ng-primitives/ai/src/thread/thread-state.ts","../../../../packages/ng-primitives/ai/src/prompt-composer/prompt-composer-state.ts","../../../../packages/ng-primitives/ai/src/prompt-composer-input/prompt-composer-input-state.ts","../../../../packages/ng-primitives/ai/src/prompt-composer-input/prompt-composer-input.ts","../../../../packages/ng-primitives/ai/src/prompt-composer-submit/prompt-composer-submit-state.ts","../../../../packages/ng-primitives/ai/src/prompt-composer-submit/prompt-composer-submit.ts","../../../../packages/ng-primitives/ai/src/prompt-composer/prompt-composer.ts","../../../../packages/ng-primitives/ai/src/thread-message/thread-message-state.ts","../../../../packages/ng-primitives/ai/src/thread-message/thread-message.ts","../../../../packages/ng-primitives/ai/src/thread/thread.ts","../../../../packages/ng-primitives/ai/src/config/ai-config.ts","../../../../packages/ng-primitives/ai/src/prompt-composer-dictation/prompt-composer-dictation-state.ts","../../../../packages/ng-primitives/ai/src/prompt-composer-dictation/prompt-composer-dictation.ts","../../../../packages/ng-primitives/ai/src/thread-viewport/thread-viewport-scroll.ts","../../../../packages/ng-primitives/ai/src/thread-viewport/thread-viewport-state.ts","../../../../packages/ng-primitives/ai/src/thread-viewport/thread-viewport.ts","../../../../packages/ng-primitives/ai/src/thread-suggestion/thread-suggestion-state.ts","../../../../packages/ng-primitives/ai/src/thread-suggestion/thread-suggestion.ts","../../../../packages/ng-primitives/ai/src/ng-primitives-ai.ts"],"sourcesContent":["import { signal } from '@angular/core';\nimport { createPrimitive } from 'ng-primitives/state';\nimport type { NgpPromptComposerInputState } from '../prompt-composer-input/prompt-composer-input-state';\nimport type { NgpThreadMessageState } from '../thread-message/thread-message-state';\nimport type { NgpThreadViewportState } from '../thread-viewport/thread-viewport-state';\n\nexport interface NgpThreadState {\n  /**\n   * Scroll the thread viewport to the bottom.\n   * @param behavior The scroll behavior to use.\n   */\n  scrollToBottom(behavior: ScrollBehavior): void;\n  /**\n   * @internal\n   * Scroll the thread viewport to the bottom, but only if it is already at the bottom.\n   * @param behavior The scroll behavior to use.\n   */\n  scrollToBottomIfNeeded(behavior: ScrollBehavior): void;\n  /**\n   * Set the prompt text in the associated prompt composer.\n   * @param value The prompt text.\n   */\n  setPrompt(value: string): void;\n  /**\n   * @internal\n   * Register the viewport that scrolls this thread.\n   */\n  setViewport(viewport: NgpThreadViewportState): void;\n  /**\n   * @internal\n   * Deregister the viewport that scrolls this thread.\n   */\n  removeViewport(viewport: NgpThreadViewportState): void;\n  /**\n   * @internal\n   * Register the prompt input that receives the prompt text.\n   */\n  setPromptInput(input: NgpPromptComposerInputState): void;\n  /**\n   * @internal\n   * Deregister the prompt input that receives the prompt text.\n   */\n  removePromptInput(input: NgpPromptComposerInputState): void;\n  /**\n   * @internal\n   * Register a message with the thread.\n   */\n  registerMessage(message: NgpThreadMessageState): void;\n  /**\n   * @internal\n   * Deregister a message from the thread.\n   */\n  unregisterMessage(message: NgpThreadMessageState): void;\n  /**\n   * @internal\n   * Determine if the given message is the last message in the thread.\n   */\n  isLastMessage(message: NgpThreadMessageState): boolean;\n}\n\nexport const [NgpThreadStateToken, ngpThread, injectThreadState, provideThreadState] =\n  createPrimitive('NgpThread', (): NgpThreadState => {\n    // The parts that carry out the thread's imperative work register themselves here, so the\n    // thread can drive them directly rather than broadcasting requests they may not receive.\n    const viewport = signal<NgpThreadViewportState | null>(null);\n    const promptInput = signal<NgpPromptComposerInputState | null>(null);\n    const messages = signal<NgpThreadMessageState[]>([]);\n\n    function scrollToBottom(behavior: ScrollBehavior): void {\n      viewport()?.scrollToBottom(behavior);\n    }\n\n    function scrollToBottomIfNeeded(behavior: ScrollBehavior): void {\n      viewport()?.scrollToBottomIfNeeded(behavior);\n    }\n\n    function setPrompt(value: string): void {\n      promptInput()?.setPrompt(value);\n    }\n\n    function setViewport(value: NgpThreadViewportState): void {\n      viewport.set(value);\n    }\n\n    function removeViewport(value: NgpThreadViewportState): void {\n      // only clear if this viewport is still the active one, so a newer viewport that has\n      // taken over isn't clobbered when an old one is torn down\n      if (viewport() === value) {\n        viewport.set(null);\n      }\n    }\n\n    function setPromptInput(value: NgpPromptComposerInputState): void {\n      promptInput.set(value);\n    }\n\n    function removePromptInput(value: NgpPromptComposerInputState): void {\n      if (promptInput() === value) {\n        promptInput.set(null);\n      }\n    }\n\n    function registerMessage(message: NgpThreadMessageState): void {\n      messages.update(current => [...current, message]);\n    }\n\n    function unregisterMessage(message: NgpThreadMessageState): void {\n      messages.update(current => current.filter(m => m !== message));\n    }\n\n    function isLastMessage(message: NgpThreadMessageState): boolean {\n      const current = messages();\n      return current.length > 0 && current[current.length - 1] === message;\n    }\n\n    return {\n      scrollToBottom,\n      scrollToBottomIfNeeded,\n      setPrompt,\n      setViewport,\n      removeViewport,\n      setPromptInput,\n      removePromptInput,\n      registerMessage,\n      unregisterMessage,\n      isLastMessage,\n    } satisfies NgpThreadState;\n  });\n","import { computed, signal, Signal } from '@angular/core';\nimport { injectElementRef } from 'ng-primitives/internal';\nimport { createPrimitive, dataBinding } from 'ng-primitives/state';\nimport { injectThreadState } from '../thread/thread-state';\n\nexport interface NgpPromptComposerState {\n  /**\n   * The current prompt text.\n   */\n  readonly prompt: Signal<string>;\n  /**\n   * Whether the prompt input has content.\n   */\n  readonly hasPrompt: Signal<boolean>;\n  /**\n   * Whether the prompt is currently being dictated.\n   */\n  readonly isDictating: Signal<boolean>;\n  /**\n   * Whether dictation is supported by the browser.\n   */\n  readonly dictationSupported: boolean;\n  /**\n   * @internal\n   * Set the current prompt text.\n   */\n  setPrompt(value: string): void;\n  /**\n   * @internal\n   * Set whether the prompt is currently being dictated.\n   */\n  setDictating(value: boolean): void;\n  /**\n   * @internal\n   * Submit the current prompt if there is content, and clear the input.\n   */\n  submitPrompt(): void;\n}\n\nexport interface NgpPromptComposerProps {\n  /**\n   * Emits whenever the user submits the prompt.\n   */\n  readonly onSubmit?: (prompt: string) => void;\n}\n\nexport const [\n  NgpPromptComposerStateToken,\n  ngpPromptComposer,\n  injectPromptComposerState,\n  providePromptComposerState,\n] = createPrimitive(\n  'NgpPromptComposer',\n  ({ onSubmit }: NgpPromptComposerProps): NgpPromptComposerState => {\n    const element = injectElementRef<HTMLElement>();\n    const thread = injectThreadState({ optional: true });\n\n    /** Store the current prompt text. */\n    const prompt = signal<string>('');\n\n    /** Track whether the prompt is currently being dictated. */\n    const isDictating = signal<boolean>(false);\n\n    /** Determine whether the prompt input has content. */\n    const hasPrompt = computed(() => prompt().trim().length > 0);\n\n    /** Whether dictation is supported by the browser. This is resolved once and never changes. */\n    const dictationSupported = !!(\n      (globalThis as any).SpeechRecognition || (globalThis as any).webkitSpeechRecognition\n    );\n\n    // Host bindings\n    dataBinding(element, 'data-prompt', hasPrompt);\n    dataBinding(element, 'data-dictating', isDictating);\n    dataBinding(element, 'data-dictation-supported', dictationSupported);\n\n    function setPrompt(value: string): void {\n      prompt.set(value);\n    }\n\n    function setDictating(value: boolean): void {\n      isDictating.set(value);\n    }\n\n    function submitPrompt(): void {\n      if (!hasPrompt()) {\n        return;\n      }\n\n      onSubmit?.(prompt());\n      prompt.set('');\n      thread()?.scrollToBottom('smooth');\n    }\n\n    return {\n      prompt: prompt.asReadonly(),\n      hasPrompt,\n      isDictating: isDictating.asReadonly(),\n      dictationSupported,\n      setPrompt,\n      setDictating,\n      submitPrompt,\n    } satisfies NgpPromptComposerState;\n  },\n);\n","import { explicitEffect, injectElementRef } from 'ng-primitives/internal';\nimport { createPrimitive, listener, onDestroy } from 'ng-primitives/state';\nimport { injectPromptComposerState } from '../prompt-composer/prompt-composer-state';\nimport { injectThreadState } from '../thread/thread-state';\n\nexport interface NgpPromptComposerInputState {\n  /**\n   * @internal\n   * Set the prompt text, moving the cursor to the end and focusing the input.\n   */\n  setPrompt(value: string): void;\n}\n\nexport const [\n  NgpPromptComposerInputStateToken,\n  ngpPromptComposerInput,\n  injectPromptComposerInputState,\n  providePromptComposerInputState,\n] = createPrimitive('NgpPromptComposerInput', (): NgpPromptComposerInputState => {\n  const element = injectElementRef<HTMLInputElement | HTMLTextAreaElement>();\n  const thread = injectThreadState({ optional: true });\n  const composer = injectPromptComposerState();\n\n  // set the initial state\n  composer().setPrompt(element.nativeElement.value);\n\n  // listen for changes to the text content\n  listener(element, 'input', () => composer().setPrompt(element.nativeElement.value));\n\n  /**\n   * If the user presses Enter, the form will be submitted, unless they are holding Shift.\n   * This primitive automatically handles that behavior.\n   */\n  listener(element, 'keydown', (event: KeyboardEvent) => {\n    if (event.key !== 'Enter' || event.shiftKey || event.ctrlKey || event.altKey || event.metaKey) {\n      return;\n    }\n\n    event.preventDefault();\n\n    // if there is no text content, do nothing\n    if (element.nativeElement.value.trim().length === 0) {\n      return;\n    }\n\n    composer().submitPrompt();\n  });\n\n  // any time the prompt changes, update the input value if needed\n  explicitEffect([composer().prompt], ([prompt]) => (element.nativeElement.value = prompt));\n\n  function setPrompt(value: string): void {\n    composer().setPrompt(value);\n    // write the value now rather than waiting for the effect above, so the cursor is\n    // placed against the text we just set\n    element.nativeElement.value = value;\n    // set the cursor to the end\n    element.nativeElement.setSelectionRange(value.length, value.length);\n    element.nativeElement.focus();\n  }\n\n  const state = { setPrompt } satisfies NgpPromptComposerInputState;\n\n  // the thread routes suggestions to the input that is currently registered\n  thread()?.setPromptInput(state);\n  onDestroy(() => thread()?.removePromptInput(state));\n\n  return state;\n});\n","import { Directive } from '@angular/core';\nimport {\n  ngpPromptComposerInput,\n  providePromptComposerInputState,\n} from './prompt-composer-input-state';\n\n@Directive({\n  selector: 'input[ngpPromptComposerInput], textarea[ngpPromptComposerInput]',\n  exportAs: 'ngpPromptComposerInput',\n  providers: [providePromptComposerInputState()],\n})\nexport class NgpPromptComposerInput {\n  /** The state of the prompt composer input. */\n  protected readonly state = ngpPromptComposerInput();\n}\n","import { computed, signal, Signal } from '@angular/core';\nimport { ngpButton } from 'ng-primitives/button';\nimport { injectElementRef } from 'ng-primitives/internal';\nimport { attrBinding, createPrimitive, dataBinding, listener } from 'ng-primitives/state';\nimport { injectPromptComposerState } from '../prompt-composer/prompt-composer-state';\n\nexport interface NgpPromptComposerSubmitState {\n  /**\n   * Whether dictation is currently active.\n   */\n  readonly isDictating: Signal<boolean>;\n}\n\nexport interface NgpPromptComposerSubmitProps {\n  /**\n   * Whether the submit button should be disabled.\n   */\n  readonly disabled?: Signal<boolean>;\n}\n\nexport const [\n  NgpPromptComposerSubmitStateToken,\n  ngpPromptComposerSubmit,\n  injectPromptComposerSubmitState,\n  providePromptComposerSubmitState,\n] = createPrimitive(\n  'NgpPromptComposerSubmit',\n  ({ disabled = signal(false) }: NgpPromptComposerSubmitProps): NgpPromptComposerSubmitState => {\n    const element = injectElementRef<HTMLElement>();\n    const composer = injectPromptComposerState();\n\n    const isDictating = computed(() => composer().isDictating());\n\n    // the button is disabled explicitly or whenever there is nothing to submit\n    ngpButton({ disabled: computed(() => disabled() || composer().hasPrompt() === false) });\n\n    // Host bindings\n    attrBinding(element, 'type', 'button');\n    dataBinding(element, 'data-prompt', () => composer().hasPrompt());\n    dataBinding(element, 'data-dictating', isDictating);\n    dataBinding(element, 'data-dictation-supported', () => composer().dictationSupported);\n\n    // Listener\n    listener(element, 'click', () => composer().submitPrompt());\n\n    return { isDictating } satisfies NgpPromptComposerSubmitState;\n  },\n);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input } from '@angular/core';\nimport {\n  ngpPromptComposerSubmit,\n  providePromptComposerSubmitState,\n} from './prompt-composer-submit-state';\n\n@Directive({\n  selector: 'button[ngpPromptComposerSubmit]',\n  exportAs: 'ngpPromptComposerSubmit',\n  providers: [providePromptComposerSubmitState()],\n})\nexport class NgpPromptComposerSubmit {\n  /** Whether the submit button should be disabled */\n  readonly disabled = input<boolean, BooleanInput>(false, {\n    transform: booleanAttribute,\n  });\n\n  /** The state of the prompt composer submit. */\n  protected readonly state = ngpPromptComposerSubmit({ disabled: this.disabled });\n\n  /** Whether dictation is currently active */\n  readonly isDictating = this.state.isDictating;\n}\n","import { Directive, output } from '@angular/core';\nimport { ngpPromptComposer, providePromptComposerState } from './prompt-composer-state';\n\n@Directive({\n  selector: '[ngpPromptComposer]',\n  exportAs: 'ngpPromptComposer',\n  providers: [providePromptComposerState()],\n})\nexport class NgpPromptComposer {\n  /** Emits whenever the user submits the prompt. */\n  readonly submit = output<string>({ alias: 'ngpPromptComposerSubmit' });\n\n  /** The state of the prompt composer. */\n  protected readonly state = ngpPromptComposer({\n    onSubmit: prompt => this.submit.emit(prompt),\n  });\n\n  /** @internal The current prompt text. */\n  readonly prompt = this.state.prompt;\n\n  /** @internal Whether the prompt is currently being dictated. */\n  readonly isDictating = this.state.isDictating;\n\n  /** @internal Whether the prompt input has content. */\n  readonly hasPrompt = this.state.hasPrompt;\n\n  /** Whether dictation is supported by the browser. */\n  readonly dictationSupported = this.state.dictationSupported;\n\n  /**\n   * @internal\n   * Submits the current prompt if there is content, and clears the input.\n   */\n  submitPrompt(): void {\n    this.state.submitPrompt();\n  }\n}\n","import { fromMutationObserver, injectElementRef } from 'ng-primitives/internal';\nimport { createPrimitive, onDestroy } from 'ng-primitives/state';\nimport { safeTakeUntilDestroyed } from 'ng-primitives/utils';\nimport { animationFrameScheduler } from 'rxjs';\nimport { auditTime } from 'rxjs/operators';\nimport { injectThreadState } from '../thread/thread-state';\n\nexport interface NgpThreadMessageState {}\n\nexport const [\n  NgpThreadMessageStateToken,\n  ngpThreadMessage,\n  injectThreadMessageState,\n  provideThreadMessageState,\n] = createPrimitive('NgpThreadMessage', (): NgpThreadMessageState => {\n  const element = injectElementRef<HTMLElement>();\n  const thread = injectThreadState();\n\n  // Identity token for this message. The thread orders messages by registration order,\n  // so a stable per-message reference is all it needs.\n  const state: NgpThreadMessageState = {};\n\n  // Watch for content changes (like streaming text) and maintain scroll position\n  fromMutationObserver(element.nativeElement, {\n    childList: true, // Watch for new/removed child nodes\n    subtree: true, // Watch changes in all descendants\n    characterData: true, // Watch for text content changes in text nodes\n    attributes: false, // We don't care about attribute changes for content streaming\n  })\n    .pipe(auditTime(0, animationFrameScheduler), safeTakeUntilDestroyed())\n    .subscribe(() => {\n      // follow the stream only while the user is still at the bottom, so it does not pull\n      // them away from an earlier message they are reading\n      if (thread().isLastMessage(state)) {\n        thread().scrollToBottomIfNeeded('instant');\n      }\n    });\n\n  thread().registerMessage(state);\n  onDestroy(() => thread().unregisterMessage(state));\n\n  return state;\n});\n","import { Directive } from '@angular/core';\nimport { ngpThreadMessage, provideThreadMessageState } from './thread-message-state';\n\n@Directive({\n  selector: '[ngpThreadMessage]',\n  exportAs: 'ngpThreadMessage',\n  providers: [provideThreadMessageState()],\n})\nexport class NgpThreadMessage {\n  /** The state of the thread message. */\n  protected readonly state = ngpThreadMessage();\n}\n","import { Directive } from '@angular/core';\nimport { ngpThread, provideThreadState } from './thread-state';\n\n@Directive({\n  selector: '[ngpThread]',\n  exportAs: 'ngpThread',\n  providers: [provideThreadState()],\n})\nexport class NgpThread {\n  /** The state of the thread. */\n  protected readonly state = ngpThread();\n\n  /**\n   * Scroll the thread viewport to the bottom.\n   * @param behavior The scroll behavior to use.\n   */\n  scrollToBottom(behavior: ScrollBehavior): void {\n    this.state.scrollToBottom(behavior);\n  }\n\n  /**\n   * Set the prompt text in the associated prompt composer.\n   * @param value The prompt text.\n   */\n  setPrompt(value: string): void {\n    this.state.setPrompt(value);\n  }\n}\n","import { InjectionToken, Provider, inject } from '@angular/core';\n\nexport interface NgpAiConfig {\n  /**\n   * The BCP 47 language tag dictation transcribes in, e.g. `en-US` or `es-ES`.\n   * When undefined the page's own language is used: the document's `lang` attribute,\n   * falling back to the browser's language.\n   * @default undefined\n   */\n  dictationLanguage: string | undefined;\n}\n\nexport const defaultAiConfig: NgpAiConfig = {\n  dictationLanguage: undefined,\n};\n\nexport const NgpAiConfigToken = new InjectionToken<NgpAiConfig>('NgpAiConfigToken');\n\n/**\n * Provide the default Ai configuration\n * @param config The Ai configuration\n * @returns The provider\n */\nexport function provideAiConfig(config: Partial<NgpAiConfig>): Provider[] {\n  return [\n    {\n      provide: NgpAiConfigToken,\n      useValue: { ...defaultAiConfig, ...config },\n    },\n  ];\n}\n\n/**\n * Inject the Ai configuration\n * @returns The global Ai configuration\n */\nexport function injectAiConfig(): NgpAiConfig {\n  return inject(NgpAiConfigToken, { optional: true }) ?? defaultAiConfig;\n}\n","import { DOCUMENT } from '@angular/common';\nimport { computed, inject, signal, Signal } from '@angular/core';\nimport { ngpButton } from 'ng-primitives/button';\nimport { injectElementRef } from 'ng-primitives/internal';\nimport {\n  attrBinding,\n  createPrimitive,\n  dataBinding,\n  listener,\n  onDestroy,\n} from 'ng-primitives/state';\nimport { injectPromptComposerState } from '../prompt-composer/prompt-composer-state';\n\n/** Used only when neither the consumer nor the page states a language. */\nconst DEFAULT_DICTATION_LANGUAGE = 'en-US';\n\nexport interface NgpPromptComposerDictationState {\n  /**\n   * Whether dictation is currently active.\n   */\n  readonly isDictating: Signal<boolean>;\n}\n\nexport interface NgpPromptComposerDictationProps {\n  /**\n   * Whether the dictation button should be disabled.\n   */\n  readonly disabled?: Signal<boolean>;\n  /**\n   * The BCP 47 language tag dictation transcribes in. Falls back to the page's own language.\n   */\n  readonly language?: Signal<string | undefined>;\n}\n\nexport const [\n  NgpPromptComposerDictationStateToken,\n  ngpPromptComposerDictation,\n  injectPromptComposerDictationState,\n  providePromptComposerDictationState,\n] = createPrimitive(\n  'NgpPromptComposerDictation',\n  ({\n    disabled = signal(false),\n    language = signal(undefined),\n  }: NgpPromptComposerDictationProps): NgpPromptComposerDictationState => {\n    const element = injectElementRef<HTMLElement>();\n    const document = inject(DOCUMENT);\n    const composer = injectPromptComposerState();\n\n    const isDictating = computed(() => composer().isDictating());\n\n    let recognition: any = null;\n\n    // Store the prompt before dictation started\n    let basePrompt = '';\n\n    // The speech finalised so far this session, and how many results are already folded into it,\n    // so a result is never counted twice.\n    let finalTranscript = '';\n    let finalisedCount = 0;\n\n    // The last value dictation itself wrote, and how many results it was built from. Anything\n    // else in the prompt is the user's own edit.\n    let lastWritten: string | null = null;\n    let writtenCount = 0;\n\n    ngpButton({\n      disabled: computed(() => disabled() || composer().dictationSupported === false),\n    });\n\n    // Host bindings\n    attrBinding(element, 'type', 'button');\n    dataBinding(element, 'data-dictating', isDictating);\n    dataBinding(element, 'data-dictation-supported', () => composer().dictationSupported);\n    dataBinding(element, 'data-prompt', () => composer().hasPrompt());\n\n    // Listener\n    listener(element, 'click', onClick);\n    listener(document, 'keydown', onKeydown);\n\n    onDestroy(() => {\n      recognition?.stop();\n      recognition = null;\n    });\n\n    function onClick(): void {\n      if (!recognition) {\n        console.warn('Speech recognition is not supported in this browser');\n        return;\n      }\n\n      if (composer().isDictating()) {\n        stopDictation();\n      } else {\n        startDictation();\n      }\n    }\n\n    function onKeydown(event: KeyboardEvent): void {\n      if (event.key === 'Escape' && composer().isDictating()) {\n        event.preventDefault();\n        stopDictation();\n      }\n    }\n\n    function initializeSpeechRecognition(): void {\n      // read through globalThis, not window: this runs during construction, which is the one\n      // phase the server executes, and referencing an undeclared `window` there is a ReferenceError\n      const SpeechRecognition =\n        (globalThis as any).SpeechRecognition || (globalThis as any).webkitSpeechRecognition;\n\n      if (!SpeechRecognition) {\n        return;\n      }\n\n      recognition = new SpeechRecognition();\n      recognition.continuous = true; // Enable continuous listening\n      recognition.interimResults = true; // Enable interim results for live updates\n\n      recognition.onstart = () => {\n        composer().setDictating(true);\n        // Store the current prompt as the base\n        resetTranscript();\n        basePrompt = composer().prompt();\n        // counts as written, so an edit made before the first result is still detected below\n        lastWritten = basePrompt;\n      };\n\n      recognition.onresult = (event: any) => {\n        // a stray result after the session ended must not rewrite the field\n        if (!composer().isDictating()) {\n          return;\n        }\n\n        // The user has typed or deleted since we last wrote: take what they left as the new base\n        // and drop the speech accumulated so far, so their edit wins instead of being overwritten.\n        // Everything they had already seen counts as settled — including the phrase still in\n        // flight, which would otherwise be re-applied when it finalises and undo their deletion.\n        if (lastWritten !== null && composer().prompt() !== lastWritten) {\n          basePrompt = composer().prompt();\n          finalTranscript = '';\n          finalisedCount = writtenCount;\n        }\n\n        let interimTranscript = '';\n\n        // Fold in only the results not already accounted for. Re-reading the list from zero would\n        // re-apply every phrase of the session on top of a base that may have moved on.\n        for (let i = finalisedCount; i < event.results.length; i++) {\n          const transcript = event.results[i][0].transcript;\n\n          if (event.results[i].isFinal) {\n            finalTranscript += transcript;\n            finalisedCount = i + 1;\n          } else {\n            interimTranscript += transcript;\n          }\n        }\n\n        // Combine base prompt with final transcript and interim transcript\n        const separator = basePrompt ? ' ' : '';\n        const newPrompt = (basePrompt + separator + finalTranscript + interimTranscript).trim();\n\n        lastWritten = newPrompt;\n        writtenCount = event.results.length;\n        composer().setPrompt(newPrompt);\n      };\n\n      recognition.onend = () => {\n        composer().setDictating(false);\n        // the next session starts from whatever the prompt holds then, not from this one's base\n        resetTranscript();\n      };\n\n      recognition.onerror = (event: any) => {\n        console.error('Speech recognition error:', event.error);\n        composer().setDictating(false);\n      };\n    }\n\n    function resetTranscript(): void {\n      basePrompt = '';\n      finalTranscript = '';\n      finalisedCount = 0;\n      lastWritten = null;\n      writtenCount = 0;\n    }\n\n    /**\n     * The configured language, or the page's own: the document's `lang`, then the browser's.\n     * Resolved per session so a language bound after construction is picked up.\n     */\n    function resolveLanguage(): string {\n      return (\n        language() ||\n        document.documentElement.lang ||\n        globalThis.navigator?.language ||\n        DEFAULT_DICTATION_LANGUAGE\n      );\n    }\n\n    function startDictation(): void {\n      if (recognition && !composer().isDictating()) {\n        recognition.lang = resolveLanguage();\n        recognition.start();\n      }\n    }\n\n    function stopDictation(): void {\n      if (recognition && composer().isDictating()) {\n        recognition.stop();\n      }\n    }\n\n    initializeSpeechRecognition();\n\n    return { isDictating } satisfies NgpPromptComposerDictationState;\n  },\n);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input } from '@angular/core';\nimport { injectAiConfig } from '../config/ai-config';\nimport {\n  ngpPromptComposerDictation,\n  providePromptComposerDictationState,\n} from './prompt-composer-dictation-state';\n\n@Directive({\n  selector: 'button[ngpPromptComposerDictation]',\n  exportAs: 'ngpPromptComposerDictation',\n  providers: [providePromptComposerDictationState()],\n})\nexport class NgpPromptComposerDictation {\n  /** Access the global AI configuration. */\n  private readonly config = injectAiConfig();\n\n  /** Whether the dictation button should be disabled. */\n  readonly disabled = input<boolean, BooleanInput>(false, {\n    transform: booleanAttribute,\n  });\n\n  /**\n   * The BCP 47 language tag dictation transcribes in, e.g. `en-US` or `es-ES`.\n   * Defaults to the page's own language: the document's `lang` attribute, then the browser's.\n   */\n  readonly language = input<string | undefined>(this.config.dictationLanguage, {\n    alias: 'ngpPromptComposerDictationLanguage',\n  });\n\n  /** The state of the prompt composer dictation. */\n  protected readonly state = ngpPromptComposerDictation({\n    disabled: this.disabled,\n    language: this.language,\n  });\n\n  /** Whether dictation is currently active */\n  readonly isDictating = this.state.isDictating;\n}\n","export interface ClassifiedMutations {\n  readonly hasPrepended: boolean;\n  readonly hasAppended: boolean;\n  readonly firstPrepended?: HTMLElement;\n  readonly firstExisting?: HTMLElement;\n}\n\n/**\n * Extract added HTML elements from DOM mutation records.\n */\nexport function extractAddedElements(mutations: readonly MutationRecord[]): HTMLElement[] {\n  return mutations.flatMap(mutation =>\n    Array.from(mutation.addedNodes).filter(\n      (node): node is HTMLElement => node instanceof HTMLElement,\n    ),\n  );\n}\n\n// Document position bitmasks (Node.DOCUMENT_POSITION_PRECEDING = 2, Node.DOCUMENT_POSITION_FOLLOWING = 4)\nconst DOCUMENT_POSITION_PRECEDING = 2;\nconst DOCUMENT_POSITION_FOLLOWING = 4;\n\n/**\n * Classify added elements as prepended or appended relative to existing children.\n */\nexport function classifyAddedElements(\n  container: HTMLElement,\n  addedElements: readonly HTMLElement[],\n): ClassifiedMutations {\n  const addedSet = new Set(addedElements);\n  let firstExisting: HTMLElement | undefined;\n\n  for (let i = 0; i < container.children.length; i++) {\n    const child = container.children[i];\n    if (child instanceof HTMLElement && !addedSet.has(child)) {\n      firstExisting = child;\n      break;\n    }\n  }\n\n  if (firstExisting === undefined) {\n    return { hasPrepended: false, hasAppended: true };\n  }\n\n  const hasPrepended = addedElements.some(\n    el => (el.compareDocumentPosition(firstExisting) & DOCUMENT_POSITION_FOLLOWING) !== 0,\n  );\n  const hasAppended = addedElements.some(\n    el => (el.compareDocumentPosition(firstExisting) & DOCUMENT_POSITION_PRECEDING) !== 0,\n  );\n\n  let firstPrepended: HTMLElement | undefined;\n  if (hasPrepended) {\n    for (let i = 0; i < container.children.length; i++) {\n      const child = container.children[i];\n      if (child instanceof HTMLElement && addedSet.has(child)) {\n        firstPrepended = child;\n        break;\n      }\n    }\n  }\n\n  return {\n    hasPrepended,\n    hasAppended,\n    firstPrepended,\n    firstExisting,\n  };\n}\n\n/**\n * Adjust the viewport scroll position when content is prepended above existing messages.\n */\nexport function compensatePrependedScroll(\n  viewport: HTMLElement,\n  firstPrepended: HTMLElement,\n  firstExisting: HTMLElement,\n  lastScrollTop: number,\n): void {\n  const prependedHeight =\n    firstExisting.getBoundingClientRect().top - firstPrepended.getBoundingClientRect().top;\n\n  if (prependedHeight <= 0) {\n    return;\n  }\n\n  const nativeShift = Math.max(0, viewport.scrollTop - lastScrollTop);\n  const adjustment = prependedHeight - nativeShift;\n\n  if (adjustment > 0) {\n    viewport.scrollTop += adjustment;\n  }\n}\n","import { afterNextRender, linkedSignal, signal, Signal } from '@angular/core';\nimport {\n  explicitEffect,\n  fromMutationObserver,\n  fromResizeEvent,\n  injectElementRef,\n} from 'ng-primitives/internal';\nimport { createPrimitive, dataBinding, listener, onDestroy } from 'ng-primitives/state';\nimport { safeTakeUntilDestroyed } from 'ng-primitives/utils';\nimport { filter, skip } from 'rxjs/operators';\nimport { injectThreadState } from '../thread/thread-state';\nimport {\n  classifyAddedElements,\n  compensatePrependedScroll,\n  extractAddedElements,\n} from './thread-viewport-scroll';\n\nexport interface NgpThreadViewportState {\n  /**\n   * Whether the viewport is currently scrolled to the bottom (within threshold).\n   * Initially false for start until a scroll reaches the bottom.\n   */\n  readonly isAtBottom: Signal<boolean>;\n  /**\n   * @internal\n   * Scroll the viewport to the bottom.\n   */\n  scrollToBottom(behavior: ScrollBehavior): void;\n  /**\n   * @internal\n   * Scroll the viewport to the bottom, but only if it is already at the bottom, so content\n   * arriving while the user is reading further up does not pull them away from it.\n   */\n  scrollToBottomIfNeeded(behavior: ScrollBehavior): void;\n}\n\nexport interface NgpThreadViewportProps {\n  /**\n   * Whether the thread should automatically scroll to the bottom when new content is added.\n   */\n  readonly autoScroll?: Signal<boolean>;\n  /** The position at which the thread viewport initially opens. */\n  readonly initialScrollPosition?: Signal<'start' | 'end'>;\n  /**\n   * The distance in pixels from the bottom that is still considered \"at the bottom\".\n   */\n  readonly threshold?: Signal<number>;\n}\n\nexport const [\n  NgpThreadViewportStateToken,\n  ngpThreadViewport,\n  injectThreadViewportState,\n  provideThreadViewportState,\n] = createPrimitive(\n  'NgpThreadViewport',\n  ({\n    autoScroll = signal(true),\n    initialScrollPosition = signal('end'),\n    threshold = signal(70),\n  }: NgpThreadViewportProps): NgpThreadViewportState => {\n    const element = injectElementRef<HTMLElement>();\n    const thread = injectThreadState();\n\n    let lastScrollTop = 0;\n    const isAtBottom = linkedSignal(() => initialScrollPosition() === 'end');\n\n    let hasRendered = false;\n    let hasScrolledToBottom = false;\n\n    function scrollToBottom(behavior: ScrollBehavior): void {\n      if (!autoScroll()) {\n        return;\n      }\n\n      element.nativeElement.scrollTo({\n        top: element.nativeElement.scrollHeight,\n        behavior,\n      });\n    }\n\n    function scrollToBottomIfNeeded(behavior: ScrollBehavior): void {\n      if (!hasRendered || !isAtBottom()) {\n        return;\n      }\n\n      scrollToBottom(behavior);\n    }\n\n    function onScroll(fromScrollEvent = false): void {\n      const { scrollHeight, scrollTop, clientHeight } = element.nativeElement;\n      const atBottom = scrollHeight - scrollTop - clientHeight <= threshold();\n\n      if (fromScrollEvent && atBottom) {\n        hasScrolledToBottom = true;\n      }\n\n      isAtBottom.set(atBottom && (initialScrollPosition() === 'end' || hasScrolledToBottom));\n      lastScrollTop = scrollTop;\n    }\n\n    function handleMutations(mutations: MutationRecord[]): void {\n      const addedElements = extractAddedElements(mutations);\n\n      if (addedElements.length === 0) {\n        return;\n      }\n\n      const { hasPrepended, hasAppended, firstPrepended, firstExisting } = classifyAddedElements(\n        element.nativeElement,\n        addedElements,\n      );\n\n      if (hasPrepended && firstPrepended && firstExisting) {\n        compensatePrependedScroll(\n          element.nativeElement,\n          firstPrepended,\n          firstExisting,\n          lastScrollTop,\n        );\n      }\n\n      if (hasAppended) {\n        scrollToBottomIfNeeded('instant');\n      }\n\n      onScroll();\n    }\n\n    // Host bindings\n    dataBinding(element, 'data-at-bottom', isAtBottom);\n\n    // Listener\n    listener(element, 'scroll', () => onScroll(true));\n\n    // no scroll event fires when the threshold itself changes, so recompute against the new value\n    explicitEffect([threshold], () => {\n      if (hasRendered) {\n        onScroll();\n      }\n    });\n\n    afterNextRender({\n      write: () => {\n        if (initialScrollPosition() === 'end') {\n          element.nativeElement.scrollTo({\n            top: element.nativeElement.scrollHeight,\n            behavior: 'instant',\n          });\n        }\n\n        onScroll();\n        hasRendered = true;\n      },\n    });\n\n    // `skip(1)` drops the baseline measurement the observer emits on setup. Only an\n    // actual size *change* should pull the viewport back down — reacting to the\n    // baseline would scroll a thread the moment it renders, and running `onScroll`\n    // against it would read a viewport that is already full and conclude the user\n    // had scrolled away before they ever touched it.\n    fromResizeEvent(element.nativeElement)\n      .pipe(skip(1), safeTakeUntilDestroyed())\n      .subscribe(() => {\n        scrollToBottomIfNeeded('instant');\n        onScroll();\n      });\n\n    if (typeof MutationObserver !== 'undefined') {\n      fromMutationObserver(element.nativeElement, { childList: true })\n        .pipe(\n          filter(mutations => mutations.some(mutation => mutation.addedNodes.length > 0)),\n          safeTakeUntilDestroyed(),\n        )\n        .subscribe(handleMutations);\n    }\n\n    const state = {\n      isAtBottom: isAtBottom.asReadonly(),\n      scrollToBottom,\n      scrollToBottomIfNeeded,\n    } satisfies NgpThreadViewportState;\n\n    thread().setViewport(state);\n    onDestroy(() => thread().removeViewport(state));\n\n    return state;\n  },\n);\n","import { BooleanInput, NumberInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input, numberAttribute } from '@angular/core';\nimport { ngpThreadViewport, provideThreadViewportState } from './thread-viewport-state';\n\n@Directive({\n  selector: '[ngpThreadViewport]',\n  exportAs: 'ngpThreadViewport',\n  providers: [provideThreadViewportState()],\n})\nexport class NgpThreadViewport {\n  /**\n   * The distance in pixels from the bottom of the scrollable container that is considered \"at the bottom\".\n   * When the user scrolls within this threshold, the thread is treated as being at the bottom.\n   * This value is used to determine whether automatic scrolling to the bottom should occur,\n   * for example when new content is added or the container is resized.\n   *\n   * @default 70\n   */\n  readonly threshold = input<number, NumberInput>(70, {\n    alias: 'ngpThreadViewportThreshold',\n    transform: numberAttribute,\n  });\n\n  /**\n   * Whether the thread should automatically scroll to the bottom when new content is added.\n   */\n  readonly autoScroll = input<boolean, BooleanInput>(true, {\n    alias: 'ngpThreadViewportAutoScroll',\n    transform: booleanAttribute,\n  });\n\n  /**\n   * The initial scroll position. Start waits for a scroll to the bottom before following content.\n   * @default 'end'\n   */\n  readonly initialScrollPosition = input<'start' | 'end'>('end', {\n    alias: 'ngpThreadViewportInitialScrollPosition',\n  });\n\n  /** The state of the thread viewport. */\n  protected readonly state = ngpThreadViewport({\n    autoScroll: this.autoScroll,\n    initialScrollPosition: this.initialScrollPosition,\n    threshold: this.threshold,\n  });\n\n  /**\n   * Whether the thread viewport is currently scrolled to the bottom (within threshold).\n   * Initially false for start until a scroll reaches the bottom, even when the content fits.\n   */\n  readonly isAtBottom = this.state.isAtBottom;\n\n  /**\n   * Scroll the container to the bottom.\n   * @internal\n   */\n  scrollToBottom(behavior: ScrollBehavior): void {\n    this.state.scrollToBottom(behavior);\n  }\n}\n","import { signal, Signal } from '@angular/core';\nimport { injectElementRef } from 'ng-primitives/internal';\nimport { createPrimitive, listener } from 'ng-primitives/state';\nimport { injectThreadState } from '../thread/thread-state';\n\nexport interface NgpThreadSuggestionState {\n  /**\n   * Populate the prompt with this suggestion.\n   */\n  submitSuggestion(): void;\n}\n\nexport interface NgpThreadSuggestionProps {\n  /**\n   * The suggested text to display in the input field.\n   */\n  readonly suggestion?: Signal<string>;\n  /**\n   * Whether the suggestion should populate the prompt when clicked.\n   */\n  readonly setPromptOnClick?: Signal<boolean>;\n}\n\nexport const [\n  NgpThreadSuggestionStateToken,\n  ngpThreadSuggestion,\n  injectThreadSuggestionState,\n  provideThreadSuggestionState,\n] = createPrimitive(\n  'NgpThreadSuggestion',\n  ({\n    suggestion = signal(''),\n    setPromptOnClick = signal(true),\n  }: NgpThreadSuggestionProps): NgpThreadSuggestionState => {\n    const element = injectElementRef<HTMLElement>();\n    const thread = injectThreadState();\n\n    function submitSuggestion(): void {\n      if (setPromptOnClick() && suggestion().length > 0) {\n        thread().setPrompt(suggestion());\n      }\n    }\n\n    // Listener\n    listener(element, 'click', submitSuggestion);\n\n    return { submitSuggestion } satisfies NgpThreadSuggestionState;\n  },\n);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input } from '@angular/core';\nimport { ngpThreadSuggestion, provideThreadSuggestionState } from './thread-suggestion-state';\n\n@Directive({\n  selector: 'button[ngpThreadSuggestion]',\n  exportAs: 'ngpThreadSuggestion',\n  providers: [provideThreadSuggestionState()],\n})\nexport class NgpThreadSuggestion {\n  /** The suggested text to display in the input field. */\n  readonly suggestion = input<string>('', { alias: 'ngpThreadSuggestion' });\n\n  /** Whether the suggestion should populate the prompt when clicked. */\n  readonly setPromptOnClick = input<boolean, BooleanInput>(true, {\n    alias: 'ngpThreadSuggestionSetPromptOnClick',\n    transform: booleanAttribute,\n  });\n\n  /** The state of the thread suggestion. */\n  protected readonly state = ngpThreadSuggestion({\n    suggestion: this.suggestion,\n    setPromptOnClick: this.setPromptOnClick,\n  });\n\n  /** Populate the prompt with this suggestion. */\n  submitSuggestion(): void {\n    this.state.submitSuggestion();\n  }\n}\n","/**\n * Generated bundle index. Do not ed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