{"version":3,"file":"clipboard.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/cdk/clipboard/pending-copy.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/cdk/clipboard/clipboard.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/cdk/clipboard/copy-to-clipboard.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/cdk/clipboard/clipboard-module.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n/**\n * A pending copy-to-clipboard operation.\n *\n * The implementation of copying text to the clipboard modifies the DOM and\n * forces a re-layout. This re-layout can take too long if the string is large,\n * causing the execCommand('copy') to happen too long after the user clicked.\n * This results in the browser refusing to copy. This object lets the\n * re-layout happen in a separate tick from copying by providing a copy function\n * that can be called later.\n *\n * Destroy must be called when no longer in use, regardless of whether `copy` is\n * called.\n */\nexport class PendingCopy {\n  private _textarea: HTMLTextAreaElement | undefined;\n\n  constructor(\n    text: string,\n    private readonly _document: Document,\n  ) {\n    const textarea = (this._textarea = this._document.createElement('textarea'));\n    const styles = textarea.style;\n\n    // Hide the element for display and accessibility. Set a fixed position so the page layout\n    // isn't affected. We use `fixed` with `top: 0`, because focus is moved into the textarea\n    // for a split second and if it's off-screen, some browsers will attempt to scroll it into view.\n    styles.position = 'fixed';\n    styles.top = styles.opacity = '0';\n    styles.left = '-999em';\n    textarea.setAttribute('aria-hidden', 'true');\n    textarea.value = text;\n    // Making the textarea `readonly` prevents the screen from jumping on iOS Safari (see #25169).\n    textarea.readOnly = true;\n    // The element needs to be inserted into the fullscreen container, if the page\n    // is in fullscreen mode, otherwise the browser won't execute the copy command.\n    (this._document.fullscreenElement || this._document.body).appendChild(textarea);\n  }\n\n  /** Finishes copying the text. */\n  copy(): boolean {\n    const textarea = this._textarea;\n    let successful = false;\n\n    try {\n      // Older browsers could throw if copy is not supported.\n      if (textarea) {\n        const currentFocus = this._document.activeElement as HTMLOrSVGElement | null;\n\n        textarea.select();\n        textarea.setSelectionRange(0, textarea.value.length);\n        successful = this._document.execCommand('copy');\n\n        if (currentFocus) {\n          currentFocus.focus();\n        }\n      }\n    } catch {\n      // Discard error.\n      // Initial setting of {@code successful} will represent failure here.\n    }\n\n    return successful;\n  }\n\n  /** Cleans up DOM changes used to perform the copy operation. */\n  destroy() {\n    const textarea = this._textarea;\n\n    if (textarea) {\n      textarea.remove();\n      this._textarea = undefined;\n    }\n  }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {Injectable, inject, DOCUMENT} from '@angular/core';\nimport {PendingCopy} from './pending-copy';\n\n/**\n * A service for copying text to the clipboard.\n */\n@Injectable({providedIn: 'root'})\nexport class Clipboard {\n  private readonly _document = inject(DOCUMENT);\n\n  constructor(...args: unknown[]);\n  constructor() {}\n\n  /**\n   * Copies the provided text into the user's clipboard.\n   *\n   * @param text The string to copy.\n   * @returns Whether the operation was successful.\n   */\n  copy(text: string): boolean {\n    const pendingCopy = this.beginCopy(text);\n    const successful = pendingCopy.copy();\n    pendingCopy.destroy();\n\n    return successful;\n  }\n\n  /**\n   * Prepares a string to be copied later. This is useful for large strings\n   * which take too long to successfully render and be copied in the same tick.\n   *\n   * The caller must call `destroy` on the returned `PendingCopy`.\n   *\n   * @param text The string to copy.\n   * @returns the pending copy operation.\n   */\n  beginCopy(text: string): PendingCopy {\n    return new PendingCopy(text, this._document);\n  }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n  Directive,\n  EventEmitter,\n  Input,\n  Output,\n  NgZone,\n  InjectionToken,\n  OnDestroy,\n  inject,\n} from '@angular/core';\nimport {Clipboard} from './clipboard';\nimport {PendingCopy} from './pending-copy';\n\n/** Object that can be used to configure the default options for `CdkCopyToClipboard`. */\nexport interface CdkCopyToClipboardConfig {\n  /** Default number of attempts to make when copying text to the clipboard. */\n  attempts?: number;\n}\n\n/** Injection token that can be used to provide the default options to `CdkCopyToClipboard`. */\nexport const CDK_COPY_TO_CLIPBOARD_CONFIG = new InjectionToken<CdkCopyToClipboardConfig>(\n  'CDK_COPY_TO_CLIPBOARD_CONFIG',\n);\n\n/**\n * Provides behavior for a button that when clicked copies content into user's\n * clipboard.\n */\n@Directive({\n  selector: '[cdkCopyToClipboard]',\n  host: {\n    '(click)': 'copy()',\n  },\n})\nexport class CdkCopyToClipboard implements OnDestroy {\n  private _clipboard = inject(Clipboard);\n  private _ngZone = inject(NgZone);\n\n  /** Content to be copied. */\n  @Input('cdkCopyToClipboard') text: string = '';\n\n  /**\n   * How many times to attempt to copy the text. This may be necessary for longer text, because\n   * the browser needs time to fill an intermediate textarea element and copy the content.\n   */\n  @Input('cdkCopyToClipboardAttempts') attempts: number = 1;\n\n  /**\n   * Emits when some text is copied to the clipboard. The\n   * emitted value indicates whether copying was successful.\n   */\n  @Output('cdkCopyToClipboardCopied') readonly copied = new EventEmitter<boolean>();\n\n  /** Copies that are currently being attempted. */\n  private _pending = new Set<PendingCopy>();\n\n  /** Whether the directive has been destroyed. */\n  private _destroyed = false;\n\n  /** Timeout for the current copy attempt. */\n  private _currentTimeout: any;\n\n  constructor(...args: unknown[]);\n\n  constructor() {\n    const config = inject(CDK_COPY_TO_CLIPBOARD_CONFIG, {optional: true});\n\n    if (config && config.attempts != null) {\n      this.attempts = config.attempts;\n    }\n  }\n\n  /** Copies the current text to the clipboard. */\n  copy(attempts: number = this.attempts): void {\n    if (attempts > 1) {\n      let remainingAttempts = attempts;\n      const pending = this._clipboard.beginCopy(this.text);\n      this._pending.add(pending);\n\n      const attempt = () => {\n        const successful = pending.copy();\n        if (!successful && --remainingAttempts && !this._destroyed) {\n          // We use 1 for the timeout since it's more predictable when flushing in unit tests.\n          this._currentTimeout = this._ngZone.runOutsideAngular(() => setTimeout(attempt, 1));\n        } else {\n          this._currentTimeout = null;\n          this._pending.delete(pending);\n          pending.destroy();\n          this.copied.emit(successful);\n        }\n      };\n      attempt();\n    } else {\n      this.copied.emit(this._clipboard.copy(this.text));\n    }\n  }\n\n  ngOnDestroy() {\n    if (this._currentTimeout) {\n      clearTimeout(this._currentTimeout);\n    }\n\n    this._pending.forEach(copy => copy.destroy());\n    this._pending.clear();\n    this._destroyed = true;\n  }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {NgModule} from '@angular/core';\n\nimport {CdkCopyToClipboard} from './copy-to-clipboard';\n\n@NgModule({\n  imports: [CdkCopyToClipboard],\n  exports: [CdkCopyToClipboard],\n})\nexport class ClipboardModule {}\n"],"names":["PendingCopy","_document","_textarea","constructor","text","textarea","createElement","styles","style","position","top","opacity","left","setAttribute","value","readOnly","fullscreenElement","body","appendChild","copy","successful","currentFocus","activeElement","select","setSelectionRange","length","execCommand","focus","destroy","remove","undefined","Clipboard","inject","DOCUMENT","pendingCopy","beginCopy","deps","target","i0","ɵɵFactoryTarget","Injectable","ɵprov","ɵɵngDeclareInjectable","minVersion","version","ngImport","type","decorators","providedIn","CDK_COPY_TO_CLIPBOARD_CONFIG","InjectionToken","CdkCopyToClipboard","_clipboard","_ngZone","NgZone","attempts","copied","EventEmitter","_pending","Set","_destroyed","_currentTimeout","config","optional","remainingAttempts","pending","add","attempt","runOutsideAngular","setTimeout","delete","emit","ngOnDestroy","clearTimeout","forEach","clear","Directive","isStandalone","selector","inputs","outputs","host","listeners","args","Input","Output","ClipboardModule","NgModule","imports","exports"],"mappings":";;;MAqBaA,WAAW,CAAA;EAKHC,SAAA;EAJXC,SAAS;AAEjBC,EAAAA,WAAAA,CACEC,IAAY,EACKH,SAAmB,EAAA;IAAnB,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