import { _copy, _paste } from "agency-lang/stdlib-lib/clipboard.js"

/** @module Read and write the system clipboard.

  ```ts
  import { copy, paste } from "std::clipboard"

  node main() {
    copy("hello")
    const text = paste()
  }
  ```
*/

effect std::clipboardCopy {}
effect std::clipboardPaste {}

@capabilities(subprocess)
export def copy(text: string) raises <std::clipboardCopy> {
  """
  Copy text to the system clipboard.
  """
  return interrupt std::clipboardCopy("Are you sure you want to copy text to the clipboard?")

  destructive {
    _copy(text)
  }
}

@capabilities(subprocess)
export def paste(): string raises <std::clipboardPaste> {
  """
  Read text from the system clipboard.
  """
  return interrupt std::clipboardPaste("Are you sure you want to read from the clipboard? It may contain sensitive data such as passwords.")

  return _paste()
}
