react-smart-copy 1.14.1 → 1.16.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.
- package/README.md +132 -1
- package/dist/color.cjs +927 -0
- package/dist/color.cjs.map +1 -0
- package/dist/color.d.cts +198 -0
- package/dist/color.d.ts +198 -0
- package/dist/color.js +916 -0
- package/dist/color.js.map +1 -0
- package/dist/index.cjs +523 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +145 -1
- package/dist/index.d.ts +145 -1
- package/dist/index.js +523 -35
- package/dist/index.js.map +1 -1
- package/dist/link.cjs +2 -2
- package/dist/link.cjs.map +1 -1
- package/dist/link.js +2 -2
- package/dist/link.js.map +1 -1
- package/dist/markdown.cjs.map +1 -1
- package/dist/markdown.js.map +1 -1
- package/dist/share.cjs +641 -0
- package/dist/share.cjs.map +1 -0
- package/dist/share.d.cts +248 -0
- package/dist/share.d.ts +248 -0
- package/dist/share.js +638 -0
- package/dist/share.js.map +1 -0
- package/package.json +76 -4
package/dist/link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","names":["invalid","invalid"],"sources":["../src/core/errors.ts","../src/link/url.ts","../src/link/payload.ts","../src/link/fragment.ts","../src/core/text-field.ts","../src/link/paste.ts"],"sourcesContent":["import type { PasteSource } from './paste-reader';\n\n/**\n * Every way a clipboard operation can fail, as a closed union.\n *\n * `CopyError.message` is developer-facing (logs, telemetry). For user-facing\n * text use {@link describeCopyError} / {@link describePasteError}, or map\n * `type` through your own i18n layer.\n */\nexport type CopyErrorType =\n /** No Clipboard API (old browser, server, locked-down webview). Not retryable. */\n | 'unsupported'\n /** Page is not served over HTTPS/localhost. Not retryable. */\n | 'insecure-context'\n /** Browser or user blocked the operation. Also what Safari reports for a missing user gesture. */\n | 'permission-denied'\n /** The document lost focus mid-operation (Chromium). Retrying after refocus usually works. */\n | 'not-focused'\n /** Empty or malformed payload, or a lazy source that threw. Caught before touching the clipboard. */\n | 'invalid-payload'\n /** The browser cannot handle this MIME type (e.g. non-PNG image, HTML without ClipboardItem). */\n | 'unsupported-format'\n /** A lazy image source (or capture) threw, rejected or did not produce a Blob. */\n | 'blob-generation-failed'\n /** `retry()` was called after `maxRetries` was reached. Terminal. */\n | 'max-retries-exceeded'\n /** Paste: the clipboard held nothing matching `accept`. */\n | 'no-content'\n /** Content exceeded a configured safety limit (bytes, items or pixels). Not retryable. */\n | 'too-large'\n /** An operation did not settle within its deadline. Retryable. */\n | 'timeout'\n /** The caller aborted the operation through an `AbortSignal`. Not retryable. */\n | 'aborted'\n /** Anything the platform threw that we could not classify. */\n | 'unknown';\n\n/** Which clipboard direction failed; only changes developer-facing messages. */\nexport type ClipboardOperation = 'write' | 'read';\n\nexport interface CopyError {\n readonly type: CopyErrorType;\n readonly message: string;\n readonly cause?: unknown;\n}\n\nexport function createCopyError(type: CopyErrorType, message: string, cause?: unknown): CopyError {\n return cause === undefined ? { type, message } : { type, message, cause };\n}\n\nconst RETRYABLE_ERRORS: ReadonlySet<CopyErrorType> = /* @__PURE__ */ new Set<CopyErrorType>([\n 'permission-denied',\n 'not-focused',\n 'blob-generation-failed',\n 'timeout',\n 'unknown',\n]);\n\n/** Whether retrying the same payload could plausibly succeed. */\nexport function isRetryableError(error: CopyError): boolean {\n return RETRYABLE_ERRORS.has(error.type);\n}\n\n/**\n * Branded (not `instanceof`) so failures stay recognisable even when the core\n * is bundled twice, e.g. `react-smart-copy` and `react-smart-copy/core` together.\n */\nconst COPY_FAILURE_BRAND = Symbol.for('react-smart-copy.CopyFailure');\n\n/** Error thrown by adapters to carry a fully classified {@link CopyError}. */\nexport class CopyFailure extends Error {\n readonly copyError: CopyError;\n readonly [COPY_FAILURE_BRAND] = true;\n\n constructor(copyError: CopyError) {\n super(copyError.message);\n this.name = 'CopyFailure';\n this.copyError = copyError;\n }\n}\n\nexport function isCopyFailure(value: unknown): value is CopyFailure {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<PropertyKey, unknown>)[COPY_FAILURE_BRAND] === true\n );\n}\n\n/** Shorthand for throwing a classified failure. */\nexport function copyFailure(type: CopyErrorType, message: string, cause?: unknown): CopyFailure {\n return new CopyFailure(createCopyError(type, message, cause));\n}\n\nfunction readString(value: unknown, key: string): string | undefined {\n if (typeof value !== 'object' || value === null) return undefined;\n const field = (value as Record<string, unknown>)[key];\n return typeof field === 'string' ? field : undefined;\n}\n\n/**\n * Classifies anything thrown by the platform or an adapter into a {@link CopyError}.\n * `operation` only tailors the developer-facing message.\n */\nexport function toCopyError(cause: unknown, operation: ClipboardOperation = 'write'): CopyError {\n if (isCopyFailure(cause)) return cause.copyError;\n\n const name = readString(cause, 'name');\n const message = readString(cause, 'message') ?? '';\n const verb = operation === 'read' ? 'read' : 'write';\n\n switch (name) {\n case 'NotAllowedError':\n return /focus/i.test(message)\n ? createCopyError('not-focused', `The document was not focused during the clipboard ${verb}.`, cause)\n : createCopyError('permission-denied', `Clipboard ${verb} permission was denied.`, cause);\n case 'SecurityError':\n return createCopyError('insecure-context', 'The clipboard is blocked in this context.', cause);\n case 'NotSupportedError':\n case 'DataError':\n return createCopyError('unsupported-format', 'The browser rejected this clipboard format.', cause);\n case 'AbortError':\n return createCopyError('aborted', `The clipboard ${verb} was aborted.`, cause);\n case 'TimeoutError':\n return createCopyError('timeout', `The clipboard ${verb} timed out.`, cause);\n default:\n return createCopyError('unknown', message || `The clipboard ${verb} failed for an unknown reason.`, cause);\n }\n}\n\nconst COPY_DESCRIPTIONS: Readonly<Record<CopyErrorType, string>> = {\n unsupported: \"Copying isn't supported in this browser.\",\n 'insecure-context': 'Copying requires a secure (HTTPS) connection.',\n 'permission-denied': 'Clipboard access was blocked. Allow it and try again.',\n 'not-focused': 'The page lost focus while copying. Try again.',\n 'invalid-payload': 'There is nothing to copy.',\n 'unsupported-format': \"This content can't be copied in this browser.\",\n 'blob-generation-failed': \"The image couldn't be prepared for copying.\",\n 'max-retries-exceeded': 'Copying failed after several attempts.',\n 'no-content': 'There is nothing to copy.',\n 'too-large': 'This content is too large to copy.',\n timeout: 'Copying took too long. Try again.',\n aborted: 'Copying was cancelled.',\n unknown: \"Couldn't copy to the clipboard. Try again.\",\n};\n\nconst PASTE_DESCRIPTIONS: Readonly<Record<CopyErrorType, string>> = {\n unsupported: \"Pasting isn't supported in this browser.\",\n 'insecure-context': 'Pasting requires a secure (HTTPS) connection.',\n 'permission-denied': 'Clipboard access was blocked. Allow it and try again.',\n 'not-focused': 'The page lost focus while pasting. Try again.',\n 'invalid-payload': \"The clipboard content couldn't be read.\",\n 'unsupported-format': \"This clipboard content isn't supported here.\",\n 'blob-generation-failed': \"The pasted image couldn't be read.\",\n 'max-retries-exceeded': 'Pasting failed after several attempts.',\n 'no-content': \"The clipboard doesn't contain anything that can be pasted here.\",\n 'too-large': 'The clipboard content is too large to paste.',\n timeout: 'Pasting took too long. Try again.',\n aborted: 'Pasting was cancelled.',\n unknown: \"Couldn't read the clipboard. Try again.\",\n};\n\n/** Default English, user-facing sentence for a copy error. Replace for i18n. */\nexport function describeCopyError(error: CopyError): string {\n return COPY_DESCRIPTIONS[error.type];\n}\n\n/** Drops can only fail in these ways; the rest of the paste wording would mention the clipboard. */\nconst DROP_DESCRIPTIONS: Readonly<Partial<Record<CopyErrorType, string>>> = {\n 'invalid-payload': \"The dropped content couldn't be read.\",\n 'no-content': 'Nothing that was dropped can be used here.',\n 'too-large': 'The dropped content is too large.',\n unknown: \"Couldn't read the dropped content. Try again.\",\n};\n\n/**\n * Default English, user-facing sentence for a paste error. Pass the error\n * state's `source` to word drag-and-drop failures as drops. Replace for i18n.\n */\nexport function describePasteError(error: CopyError, source?: PasteSource): string {\n return (source === 'drop' ? DROP_DESCRIPTIONS[error.type] : undefined) ?? PASTE_DESCRIPTIONS[error.type];\n}\n","import { copyFailure } from '../core/errors';\n\n/** Schemes a copied or pasted link may use by default. Never `javascript:`, `data:`, `vbscript:` or `file:`. */\nexport const DEFAULT_LINK_PROTOCOLS: readonly string[] = Object.freeze(['https:', 'http:', 'mailto:', 'tel:']);\n\n/**\n * Query parameters that only track where a click came from: the defaults of\n * {@link cleanLinkUrl}. `utm_` matches every parameter starting with it.\n */\nexport const TRACKING_PARAMETERS: readonly string[] = Object.freeze([\n 'utm_',\n 'fbclid',\n 'gclid',\n 'gclsrc',\n 'dclid',\n 'gbraid',\n 'wbraid',\n 'msclkid',\n 'yclid',\n 'twclid',\n 'ttclid',\n 'li_fat_id',\n 'igshid',\n 'igsh',\n 'mc_cid',\n 'mc_eid',\n '_hsenc',\n '_hsmi',\n 'mkt_tok',\n 'oly_anon_id',\n 'oly_enc_id',\n 'vero_id',\n 'wickedid',\n '_gl',\n]);\n\nexport interface CleanLinkOptions {\n /**\n * Parameters to remove: exact names, names ending in `_` (a prefix, like\n * `utm_`), or regular expressions tested against the name. Default {@link TRACKING_PARAMETERS}.\n */\n readonly params?: readonly (string | RegExp)[];\n /** Parameters never removed, even when `params` matches them. */\n readonly keep?: readonly string[];\n}\n\nexport interface LinkUrlOptions {\n /** Resolves relative links. Default: the page's address in a browser; required elsewhere for relative links. */\n readonly base?: string | URL;\n /** Allowed schemes, with the colon. Default {@link DEFAULT_LINK_PROTOCOLS}. */\n readonly protocols?: readonly string[];\n /** Remove tracking parameters: `true` for {@link TRACKING_PARAMETERS}, or your own list. Default `false`. */\n readonly clean?: boolean | CleanLinkOptions;\n}\n\nconst invalid = (message: string) => copyFailure('invalid-payload', message);\n\nfunction baseUrl(base: LinkUrlOptions['base']): string | undefined {\n if (base !== undefined) {\n if (typeof base === 'string' || base instanceof URL) return String(base);\n throw invalid('`base` must be a string or a URL.');\n }\n return typeof location === 'undefined' ? undefined : location.href;\n}\n\nfunction protocolSet(protocols: LinkUrlOptions['protocols']): ReadonlySet<string> {\n const list: unknown = protocols ?? DEFAULT_LINK_PROTOCOLS;\n const valid = (protocol: unknown): protocol is string => typeof protocol === 'string' && /^[a-z][a-z\\d+.-]*:$/i.test(protocol);\n if (!Array.isArray(list) || list.length === 0 || !(list as readonly unknown[]).every(valid)) {\n throw invalid('`protocols` must be a non-empty list of schemes with their colon, like \"https:\".');\n }\n return new Set((list as readonly string[]).map((protocol) => protocol.toLowerCase()));\n}\n\nfunction matcher(params: CleanLinkOptions['params']): (name: string) => boolean {\n const list = params ?? TRACKING_PARAMETERS;\n if (!Array.isArray(list) || !list.every((param) => typeof param === 'string' || param instanceof RegExp)) {\n throw invalid('`clean.params` must be a list of strings and regular expressions.');\n }\n return (name) => {\n const lower = name.toLowerCase();\n return list.some((param) => {\n if (typeof param !== 'string') return new RegExp(param.source, param.flags.replace(/[gy]/g, '')).test(name);\n const wanted = param.toLowerCase();\n return wanted.endsWith('_') ? lower.startsWith(wanted) : lower === wanted;\n });\n };\n}\n\n/** The cleaning step `clean` asks for, or `null`. Throws for an invalid option. */\nfunction cleaner(option: LinkUrlOptions['clean']): ((url: URL) => void) | null {\n const cleaning: unknown = option ?? false; // Plain-JS callers can pass anything.\n if (cleaning === false) return null;\n if (cleaning !== true && (typeof cleaning !== 'object' || cleaning === null)) throw invalid('`clean` must be a boolean or an options object.');\n const settings: CleanLinkOptions = cleaning === true ? {} : cleaning;\n const tracking = matcher(settings.params);\n const keep = settings.keep ?? [];\n if (!Array.isArray(keep) || !keep.every((name: unknown) => typeof name === 'string')) throw invalid('`clean.keep` must be a list of strings.');\n const kept = new Set(keep.map((name) => name.toLowerCase()));\n return (url) => {\n for (const name of [...new Set(url.searchParams.keys())]) {\n if (tracking(name) && !kept.has(name.toLowerCase())) url.searchParams.delete(name);\n }\n };\n}\n\n/**\n * Validates `options` once (throwing a typed `invalid-payload` error for invalid\n * ones) and returns a resolver that throws only for invalid links.\n * @internal\n */\nexport function linkUrlResolver(options: LinkUrlOptions = {}): (input: string | URL) => string {\n const protocols = protocolSet(options.protocols);\n const base = baseUrl(options.base);\n const clean = cleaner(options.clean);\n return (input) => {\n if (typeof input !== 'string' && !(input instanceof URL)) throw invalid('A link must be a string or a URL.');\n const raw = String(input).trim();\n if (raw === '') throw invalid('A link must not be empty.');\n let url: URL;\n try {\n url = new URL(raw, base);\n } catch (cause) {\n throw copyFailure('invalid-payload', `Not a valid link: ${JSON.stringify(raw.slice(0, 200))}.`, cause);\n }\n if (!protocols.has(url.protocol)) {\n throw invalid(`Links with the scheme \"${url.protocol}\" are not allowed (allowed: ${[...protocols].join(', ')}).`);\n }\n // Never copy or paste credentials embedded in a link.\n url.username = '';\n url.password = '';\n clean?.(url);\n return url.href;\n };\n}\n\n/**\n * The link as an absolute, safe URL string, or a typed `invalid-payload` error:\n * relative links are resolved, the scheme must be allowed, user names and\n * passwords are always removed, and tracking parameters optionally.\n */\nexport function resolveLinkUrl(input: string | URL, options: LinkUrlOptions = {}): string {\n return linkUrlResolver(options)(input);\n}\n\n/**\n * Removes tracking parameters (`utm_*`, `fbclid`, `gclid`, ...) from a link, keeping\n * everything else, including the fragment. Also validates it like every link here.\n *\n * @example\n * cleanLinkUrl('https://shop.example/p/42?utm_source=news&color=red'); // 'https://shop.example/p/42?color=red'\n */\nexport function cleanLinkUrl(url: string | URL, options: CleanLinkOptions & Omit<LinkUrlOptions, 'clean'> = {}): string {\n const { params, keep, ...rest } = options;\n return resolveLinkUrl(url, { ...rest, clean: { ...(params === undefined ? {} : { params }), ...(keep === undefined ? {} : { keep }) } });\n}\n","import { copyFailure } from '../core/errors';\nimport type { HtmlPayload, MultiPayload } from '../core/payload';\nimport { resolveLinkUrl, type LinkUrlOptions } from './url';\n\n/** A link with an optional title. */\nexport interface Link {\n readonly url: string | URL;\n /** What the link says when pasted into a document or chat. Default: the URL. */\n readonly title?: string;\n}\n\n/** A link: a URL, a `{ url, title }` object, or an `<a>` element (its `href` and text). */\nexport type LinkSource = string | URL | Link | HTMLAnchorElement;\n\n/** A validated link: an absolute, safe URL and a clean title. */\nexport interface ResolvedLink {\n readonly url: string;\n /** Never empty: the URL when there is no title. */\n readonly title: string;\n /** Whether `title` came from the input (`false`: it is the URL). */\n readonly titled: boolean;\n}\n\n/**\n * What the plain-text flavour holds (editors, terminals and address bars paste it):\n * `'url'` (the default), `'title'`, `'title-and-url'` (the title, then the URL on\n * the next line) or `'markdown'` (`[Title](URL)`).\n */\nexport type LinkTextFormat = 'url' | 'title' | 'title-and-url' | 'markdown';\n\nexport interface LinkPayloadOptions extends LinkUrlOptions {\n /** Default `'url'`. */\n readonly text?: LinkTextFormat;\n /** Longest title kept, in characters; longer ones end in an ellipsis. Default {@link DEFAULT_LINK_TITLE_LENGTH}. */\n readonly maxTitleLength?: number;\n}\n\nexport interface LinkDragPayloadOptions extends LinkPayloadOptions {\n /**\n * `'drag'`: a multi-format payload that also carries `text/uri-list` and\n * Firefox's `text/x-moz-url`, for `useDragCopy` and `useCopyInterceptor` (a link\n * dropped on the tab bar opens). Clipboard writes skip those two where the\n * browser can't write them.\n */\n readonly target: 'drag';\n}\n\nexport const DEFAULT_LINK_TITLE_LENGTH = 300;\n\nconst invalid = (message: string) => copyFailure('invalid-payload', message);\n\n/**\n * Characters a title never keeps: controls, bidi overrides and isolates (which can\n * make a title read differently), and zero-width characters.\n */\n// eslint-disable-next-line no-control-regex -- matching control characters is the point\nconst HIDDEN = /[\\0-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f-\\x9f\\u061C\\u200B-\\u200F\\u202A-\\u202E\\u2060-\\u2064\\u2066-\\u2069\\uFEFF]/g;\n\n/** A title as one clean line: hidden characters removed, whitespace collapsed, length capped. */\nexport function cleanTitle(title: string, maxLength: number): string {\n const clean = title.replace(HIDDEN, '').replace(/\\s+/g, ' ').trim();\n if (clean.length <= maxLength) return clean;\n // Cut on a code point boundary and mark the cut.\n return `${Array.from(clean).slice(0, maxLength - 1).join('').trimEnd()}\\u2026`;\n}\n\nfunction maxTitle(value: number | undefined): number {\n if (value === undefined) return DEFAULT_LINK_TITLE_LENGTH;\n if (Number.isInteger(value) && value >= 1) return value;\n throw invalid(`\\`maxTitleLength\\` must be a positive integer (received ${String(value)}).`);\n}\n\nfunction isAnchor(source: unknown): source is HTMLAnchorElement {\n return typeof source === 'object' && source !== null && (source as { nodeName?: unknown }).nodeName === 'A' && typeof (source as { href?: unknown }).href === 'string';\n}\n\n/**\n * Validates a link and its title: see {@link resolveLinkUrl} for the URL rules.\n * An `<a>` element gives its `href` and its text (or `title` attribute).\n */\nexport function resolveLink(source: LinkSource, options: LinkPayloadOptions = {}): ResolvedLink {\n let url: string | URL;\n let title: unknown;\n if (typeof source === 'string' || source instanceof URL) {\n url = source;\n } else if (isAnchor(source)) {\n url = source.getAttribute('href') ?? '';\n title = source.textContent.trim() !== '' ? source.textContent : (source.getAttribute('title') ?? undefined);\n if (url !== '' && options.base === undefined) url = source.href; // Resolved against the anchor's own document.\n } else if (typeof (source as unknown) === 'object' && (source as unknown) !== null && 'url' in source) {\n url = source.url;\n title = source.title;\n } else {\n throw invalid('A link must be a URL, a { url, title } object or an <a> element.');\n }\n if (title !== undefined && typeof title !== 'string') throw invalid('A link title must be a string.');\n const href = resolveLinkUrl(url, options);\n const clean = title === undefined ? '' : cleanTitle(title, maxTitle(options.maxTitleLength));\n return { url: href, title: clean === '' ? href : clean, titled: clean !== '' };\n}\n\nexport const escapeHtml = (text: string): string =>\n text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"').replace(/'/g, ''');\n\n/** `[title](url)`, safe in every CommonMark renderer: brackets and backslashes escaped, parentheses and spaces encoded. */\nexport function markdownLink(link: ResolvedLink): string {\n const label = link.title.replace(/[\\\\[\\]]/g, '\\\\$&');\n const target = link.url.replace(/[()<> ]/g, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`);\n return `[${label}](${target})`;\n}\n\nfunction plainText(link: ResolvedLink, format: LinkTextFormat): string {\n switch (format) {\n case 'url':\n return link.url;\n case 'title':\n return link.title;\n case 'title-and-url':\n return link.titled ? `${link.title}\\n${link.url}` : link.url;\n case 'markdown':\n return markdownLink(link);\n default:\n throw invalid(`\\`text\\` must be \"url\", \"title\", \"title-and-url\" or \"markdown\" (received ${JSON.stringify(format)}).`);\n }\n}\n\n/**\n * A copy payload for a link: an HTML anchor, so Slack, Google Docs, Notion,\n * Teams, Word and mail paste a titled link, and plain text (the URL by default)\n * for editors and address bars. The URL is validated (allowed schemes only,\n * credentials removed, optionally cleaned of tracking) and the title is cleaned\n * of hidden characters; both are escaped.\n *\n * @example\n * copy(() => linkPayload({ url: location.href, title: document.title }, { clean: true }));\n * useDragCopy({ payload: () => linkPayload(anchor, { target: 'drag' }) });\n */\nexport function linkPayload(source: LinkSource, options: LinkDragPayloadOptions): MultiPayload;\nexport function linkPayload(source: LinkSource, options?: LinkPayloadOptions): HtmlPayload;\nexport function linkPayload(source: LinkSource, options: LinkPayloadOptions & { readonly target?: 'drag' | 'clipboard' } = {}): HtmlPayload | MultiPayload {\n const target: unknown = options.target ?? 'clipboard'; // Plain-JS callers can pass anything.\n if (target !== 'drag' && target !== 'clipboard') throw invalid('`target` must be \"clipboard\" or \"drag\".');\n const link = resolveLink(source, options);\n const text = plainText(link, options.text ?? 'url');\n const html = `<a href=\"${escapeHtml(link.url)}\">${escapeHtml(link.title)}</a>`;\n if (target === 'clipboard') return { kind: 'html', html, text };\n return {\n kind: 'multi',\n items: [\n { mimeType: 'text/plain', data: text },\n { mimeType: 'text/html', data: html },\n { mimeType: 'text/uri-list', data: link.url, optional: true },\n // Firefox's titled-link format: the URL, a line break, the title.\n { mimeType: 'text/x-moz-url', data: `${link.url}\\n${link.title}`, optional: true },\n ],\n };\n}\n","import { copyFailure } from '../core/errors';\nimport { resolveLinkUrl, type LinkUrlOptions } from './url';\n\n/**\n * A passage to link to: `start` alone, or `start` to `end` for a longer one.\n * `prefix` and `suffix` are the words around it, used to tell apart passages\n * that appear more than once. Each term must lie within one block of the page\n * (a paragraph, a list item, a heading).\n */\nexport interface TextFragment {\n readonly start: string;\n readonly end?: string;\n readonly prefix?: string;\n readonly suffix?: string;\n}\n\nexport interface TextFragmentOptions extends LinkUrlOptions {\n /** Passages longer than this many words link by their first and last words (`start,end`). Default 10. */\n readonly maxWords?: number;\n /** Words kept at each end of a long passage, and of prefix and suffix context. Default 4. */\n readonly contextWords?: number;\n /** Where to look for repeats of the passage, to decide whether context is needed. Default `document.body`. */\n readonly root?: Node;\n}\n\nconst invalid = (message: string) => copyFailure('invalid-payload', message);\n\nconst collapse = (text: string): string => text.replace(/\\s+/g, ' ').trim();\nconst words = (text: string): string[] => collapse(text).split(' ').filter((word) => word !== '');\n\n/**\n * Percent-encodes a directive term. `encodeURIComponent` leaves `-` alone, but the\n * directive syntax uses it (`prefix-,` and `,-suffix`), so it is encoded too.\n */\nexport function encodeTerm(term: string): string {\n return encodeURIComponent(term).replace(/-/g, '%2D');\n}\n\n/** The `text=` directive for a fragment. */\nexport function textDirective(fragment: TextFragment): string {\n const terms: string[] = [];\n if (fragment.prefix !== undefined && fragment.prefix !== '') terms.push(`${encodeTerm(fragment.prefix)}-`);\n terms.push(encodeTerm(fragment.start));\n if (fragment.end !== undefined && fragment.end !== '') terms.push(encodeTerm(fragment.end));\n if (fragment.suffix !== undefined && fragment.suffix !== '') terms.push(`-${encodeTerm(fragment.suffix)}`);\n return `text=${terms.join(',')}`;\n}\n\nfunction positive(value: number | undefined, fallback: number, name: string): number {\n if (value === undefined) return fallback;\n if (Number.isInteger(value) && value >= 1) return value;\n throw invalid(`\\`${name}\\` must be a positive integer (received ${String(value)}).`);\n}\n\n/** Elements that start a new block: text fragment terms never span them. */\nconst BLOCK = new Set([\n 'address', 'article', 'aside', 'blockquote', 'body', 'caption', 'dd', 'details', 'dialog', 'div', 'dl', 'dt', 'fieldset',\n 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'li', 'main', 'nav',\n 'ol', 'p', 'pre', 'section', 'summary', 'table', 'td', 'th', 'tr', 'ul',\n]);\n\n/** The nearest block around `node`, or the top of its tree (a detached node's fragment, or the page body). */\nfunction blockOf(node: Node): Node {\n let top = node;\n for (let current: Node | null = node; current !== null; current = current.parentNode) {\n if (current.nodeType === 1 && BLOCK.has((current as Element).localName)) return current;\n top = current;\n }\n if (top.nodeType !== 9) return top;\n const body: unknown = (top as Document).body; // Null in an XML document, despite its type.\n return body instanceof Node ? body : top;\n}\n\n/** The text of `block` from its start to (`before`) or from (`after`) a boundary point. */\nfunction around(block: Node, container: Node, offset: number, side: 'before' | 'after'): string {\n const range = (container.ownerDocument as Document).createRange();\n range.selectNodeContents(block);\n if (side === 'before') range.setEnd(container, offset);\n else range.setStart(container, offset);\n return range.toString();\n}\n\nconst count = (haystack: string, needle: string): number => {\n let found = 0;\n for (let at = haystack.indexOf(needle); at !== -1 && found < 2; at = haystack.indexOf(needle, at + 1)) found += 1;\n return found;\n};\n\nfunction rootText(root: Node | undefined): string | null {\n const node = root ?? (typeof document === 'undefined' ? undefined : document.body);\n if (node === undefined) return null;\n // A range reads the text of any node, a whole Document included (whose `textContent` is null).\n const range = ((node.ownerDocument ?? node) as Document).createRange();\n range.selectNodeContents(node);\n return collapse(range.toString()).toLowerCase();\n}\n\n/** Splits a passage into a directive: whole when short, first and last words when long. */\nfunction fromText(text: string, maxWords: number, contextWords: number): TextFragment {\n const all = words(text);\n if (all.length === 0) throw invalid('A text fragment needs some text.');\n if (all.length <= maxWords) return { start: all.join(' ') };\n return { start: all.slice(0, contextWords).join(' '), end: all.slice(-contextWords).join(' ') };\n}\n\n/** A fragment for a selected range: terms taken from within their own blocks, context added when the passage repeats. */\nfunction fromRange(range: Range, maxWords: number, contextWords: number, root: Node | undefined): TextFragment {\n const startBlock = blockOf(range.startContainer);\n const endBlock = blockOf(range.endContainer);\n const text = collapse(range.toString());\n if (text === '') throw invalid('A text fragment needs some text: the range is empty.');\n let fragment: TextFragment;\n if (startBlock === endBlock) {\n fragment = fromText(text, maxWords, contextWords);\n } else {\n // A passage across blocks: start in the first block, end in the last.\n const head = words(around(startBlock, range.startContainer, range.startOffset, 'after')).slice(0, contextWords);\n const tail = words(around(endBlock, range.endContainer, range.endOffset, 'before')).slice(-contextWords);\n fragment = head.length === 0 || tail.length === 0 ? fromText(text, maxWords, contextWords) : { start: head.join(' '), end: tail.join(' ') };\n }\n const page = rootText(root);\n if (page !== null && count(page, fragment.start.toLowerCase()) < 2) return fragment;\n // The start appears more than once (or the page can't be read): add the words around the passage.\n const prefix = words(around(startBlock, range.startContainer, range.startOffset, 'before')).slice(-contextWords).join(' ');\n const suffix = words(around(endBlock, range.endContainer, range.endOffset, 'after')).slice(0, contextWords).join(' ');\n return { ...fragment, prefix, suffix }; // Empty terms are left out of the directive.\n}\n\n/** A caller's fragment with each term on one line; empty optional terms are left out of the directive. */\nfunction fromObject(passage: TextFragment): TextFragment {\n const term = (value: unknown): string => (typeof value === 'string' ? collapse(value) : '');\n const start = term(passage.start);\n if (start === '') throw invalid('A text fragment needs a non-empty `start`.');\n return { start, end: term(passage.end), prefix: term(passage.prefix), suffix: term(passage.suffix) };\n}\n\nfunction isRange(value: unknown): value is Range {\n return typeof value === 'object' && value !== null && typeof (value as Range).cloneContents === 'function' && 'startContainer' in value;\n}\n\n/**\n * A link that scrolls to, and highlights, a passage of the page: the\n * [text fragment](https://wicg.github.io/scroll-to-text-fragment/) syntax\n * (`#:~:text=`), supported by Chromium, Safari and Firefox. Browsers without it\n * open the page at its normal position (or its existing `#section`).\n *\n * The passage is a string, a {@link TextFragment}, or a DOM `Range` (the user's\n * selection): long passages link by their first and last words, and the words\n * around a passage are added when it appears more than once on the page.\n *\n * @example\n * textFragmentUrl(location.href, window.getSelection()!.getRangeAt(0));\n * textFragmentUrl('https://example.com/docs#install', 'npm install react-smart-copy');\n */\nexport function textFragmentUrl(url: string | URL, passage: string | TextFragment | Range, options: TextFragmentOptions = {}): string {\n const maxWords = positive(options.maxWords, 10, 'maxWords');\n const contextWords = positive(options.contextWords, 4, 'contextWords');\n let fragment: TextFragment;\n if (typeof passage === 'string') {\n fragment = fromText(passage, maxWords, contextWords);\n } else if (isRange(passage)) {\n fragment = fromRange(passage, maxWords, contextWords, options.root);\n } else if (typeof passage === 'object' && (passage as unknown) !== null && typeof (passage as { start?: unknown }).start === 'string') {\n fragment = fromObject(passage);\n } else {\n throw invalid('The passage must be a string, a TextFragment or a Range.');\n }\n const href = resolveLinkUrl(url, options);\n const hashAt = href.indexOf('#');\n const base = hashAt === -1 ? href : href.slice(0, hashAt);\n // Keep an existing #section; replace any earlier directive.\n const section = hashAt === -1 ? '' : (href.slice(hashAt + 1).split(':~:')[0] as string);\n return `${base}#${section}:~:${textDirective(fragment)}`;\n}\n\n/** Whether this browser scrolls to text fragments (`document.fragmentDirective`). */\nexport function supportsTextFragments(): boolean {\n return typeof document !== 'undefined' && 'fragmentDirective' in document;\n}\n","/**\n * Text-field helpers shared by the paste handlers of the opt-in entry points.\n * Internal: not part of `react-smart-copy/core`'s public API.\n */\n\n/** Text fields `setRangeText` and `execCommand('insertText')` both support. */\nexport type TextField = HTMLTextAreaElement | HTMLInputElement;\n\nconst TEXT_INPUTS = new Set(['text', 'search', 'url', 'tel', 'password']);\n\nexport function asTextField(target: EventTarget | null): TextField | null {\n if (typeof target !== 'object' || target === null) return null;\n const element = target as Partial<Element> & { type?: unknown };\n if (element.nodeName === 'TEXTAREA') return target as HTMLTextAreaElement;\n if (element.nodeName === 'INPUT' && typeof element.type === 'string' && TEXT_INPUTS.has(element.type)) return target as HTMLInputElement;\n return null;\n}\n\n/**\n * Inserts text at the cursor of a `<textarea>` or text `<input>`, replacing the\n * selection, as typing or pasting would: the browser's undo (Ctrl/⌘+Z) still\n * works, `input` events fire (so React and other frameworks see the change),\n * and `maxlength` is respected. Returns `false` for disabled or read-only fields.\n */\nexport function insertText(field: TextField, text: string): boolean {\n if (field.disabled || field.readOnly) return false;\n // An <input> holds one line: each run of line breaks (a paragraph break too) becomes one space.\n const value = field.nodeName === 'INPUT' ? text.replace(/[ \\t]*(?:\\r\\n|\\r|\\n)+[ \\t]*/g, ' ') : text;\n const doc = field.ownerDocument;\n field.focus();\n // `null` for inputs without a selection API (email, number): the text is appended.\n const start = field.selectionStart;\n const end = field.selectionEnd;\n try {\n // Re-applying the selection ends the current typing run, so the paste gets its own undo step\n // (as a native paste does) instead of merging with what was typed just before.\n if (start !== null && end !== null) field.setSelectionRange(start, end);\n // The only way to keep the native undo stack; supported for text fields in every current browser.\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- no replacement keeps undo history\n if (doc.activeElement === field && doc.execCommand('insertText', false, value)) return true;\n } catch {\n // Fall through to the manual insertion.\n }\n const from = start ?? field.value.length;\n const to = end ?? from;\n let insert = value;\n if (field.maxLength >= 0) {\n const room = Math.max(0, field.maxLength - (field.value.length - (to - from)));\n insert = insert.slice(0, room);\n // Never leave half of a surrogate pair (an emoji) behind.\n if (/[\\ud800-\\udbff]$/.test(insert)) insert = insert.slice(0, -1);\n }\n if (start === null) setNativeValue(field, field.value + insert);\n else field.setRangeText(insert, from, to, 'end');\n const view = doc.defaultView;\n const event =\n view !== null && typeof view.InputEvent === 'function'\n ? new view.InputEvent('input', { bubbles: true, inputType: 'insertFromPaste', data: insert })\n : new Event('input', { bubbles: true });\n field.dispatchEvent(event);\n return true;\n}\n\n/**\n * Sets a field's value through the prototype's setter. React tracks the value\n * set on the element itself; going around it lets React see the change and\n * call `onChange` for the `input` event that follows.\n */\nfunction setNativeValue(field: TextField, next: string): void {\n const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(field) as object, 'value');\n // eslint-disable-next-line @typescript-eslint/unbound-method -- it is called right below with the field as `this`\n const setter = descriptor?.set;\n if (setter) setter.call(field, next);\n else field.value = next;\n}\n","import { copyFailure } from '../core/errors';\nimport { asTextField, insertText } from '../core/text-field';\nimport { cleanTitle, DEFAULT_LINK_TITLE_LENGTH, markdownLink, type ResolvedLink } from './payload';\nimport { textFragmentUrl, type TextFragmentOptions } from './fragment';\nimport { linkUrlResolver, type LinkUrlOptions } from './url';\n\n/** What was pasted or dropped: a `PasteResult` from `usePaste`, a `DataTransfer`-like source, or the flavours themselves. */\nexport interface LinkPasteSource {\n readonly text?: string | null;\n readonly html?: string | null;\n /** `text/uri-list`. */\n readonly uriList?: string | null;\n /** A `PasteResult`'s entries: a `text/uri-list` entry is read from here. */\n readonly items?: readonly { readonly type: string; readonly data: string | Blob }[];\n}\n\n/** One URL with no spaces, as a whole pasted text (surrounding whitespace allowed). */\nconst SINGLE_URL = /^\\s*<?([a-z][a-z\\d+.-]*:[^\\s<>]+?)>?\\s*$/i;\n\ntype Resolve = (input: string) => string;\n\n/** The URL, or `null` when the clipboard content is not a valid, allowed link. */\nfunction tryUrl(resolve: Resolve, candidate: string): string | null {\n try {\n return resolve(candidate);\n } catch {\n return null;\n }\n}\n\nfunction fromUriList(list: string, resolve: Resolve): string | null {\n // RFC 2483: one URI per line, lines starting with \"#\" are comments.\n const first = list.split(/\\r?\\n/).find((line) => line.trim() !== '' && !line.startsWith('#'));\n return first === undefined ? null : tryUrl(resolve, first.trim());\n}\n\n/** The single link in pasted HTML (one `<a href>` and nothing else visible besides its text), parsed inertly. */\nfunction fromHtml(html: string, resolve: Resolve): ResolvedLink | null {\n if (typeof DOMParser === 'undefined' || html.trim() === '') return null;\n const body = new DOMParser().parseFromString(html.slice(0, 100_000), 'text/html').body;\n const anchors = body.querySelectorAll('a[href]');\n if (anchors.length !== 1) return null;\n const anchor = anchors[0] as HTMLAnchorElement;\n const visible = body.textContent.replace(/\\s+/g, ' ').trim();\n const label = anchor.textContent.replace(/\\s+/g, ' ').trim();\n if (visible !== label) return null; // A link inside more text is not \"a link\".\n const url = tryUrl(resolve, String(anchor.getAttribute('href'))); // Matched by `a[href]`.\n if (url === null) return null;\n const title = cleanTitle(label, DEFAULT_LINK_TITLE_LENGTH);\n return { url, title: title === '' ? url : title, titled: title !== '' && title !== url };\n}\n\n/**\n * The link the clipboard (or a drop) holds, or `null`: from `text/uri-list`,\n * from HTML that is exactly one link (keeping its title), or from text that is\n * exactly one URL. Every URL is validated: allowed schemes only (never\n * `javascript:`), credentials removed. Never throws for clipboard content.\n *\n * @example\n * usePaste({ accept: ['text', 'html', 'text/uri-list'], onPaste: (result) => {\n * const link = readLink(result);\n * if (link) addBookmark(link.url, link.title);\n * } });\n */\nexport function readLink(source: LinkPasteSource, options: LinkUrlOptions = {}): ResolvedLink | null {\n return readWith(source, linkUrlResolver(options));\n}\n\nfunction readWith(source: LinkPasteSource, resolve: Resolve): ResolvedLink | null {\n const uriList = source.uriList ?? source.items?.find((item) => item.type === 'text/uri-list' && typeof item.data === 'string')?.data;\n if (typeof uriList === 'string') {\n const url = fromUriList(uriList, resolve);\n if (url !== null) {\n const fromMarkup = typeof source.html === 'string' ? fromHtml(source.html, resolve) : null;\n return fromMarkup?.url === url ? fromMarkup : { url, title: url, titled: false };\n }\n }\n if (typeof source.html === 'string') {\n const link = fromHtml(source.html, resolve);\n if (link !== null) return link;\n }\n const match = typeof source.text === 'string' ? SINGLE_URL.exec(source.text) : null;\n const url = match === null ? null : tryUrl(resolve, match[1] as string);\n return url === null ? null : { url, title: url, titled: false };\n}\n\n/** Structural paste event: a DOM `ClipboardEvent` and React's `onPaste` event both fit. */\nexport interface LinkPasteEvent {\n readonly clipboardData: { getData(format: string): string } | null;\n readonly currentTarget: EventTarget | null;\n readonly target: EventTarget | null;\n readonly defaultPrevented: boolean;\n preventDefault(): void;\n}\n\nexport interface PasteAsLinkOptions extends LinkUrlOptions {\n /**\n * What replaces the selection. Default: a Markdown link, `[selection](url)`.\n * Receives the selected text and the pasted link.\n */\n readonly format?: (selection: string, link: ResolvedLink) => string;\n}\n\n/**\n * A paste handler for text fields: pasting a link over selected text turns the\n * selection into a link (`[selected text](url)` by default), as GitHub, Slack\n * and Notion do. Everything else is left to the browser: pasting with nothing\n * selected, pasting over a URL, or pasting something that is not one link. The\n * browser's undo still works. Returns whether it handled the paste.\n *\n * @example\n * <textarea onPaste={pasteAsLink} />\n */\nexport function pasteAsLink(event: LinkPasteEvent, options: PasteAsLinkOptions = {}): boolean {\n const { format, ...urlOptions } = options;\n // Invalid options are a programming error: thrown before the paste is touched, so the native paste still happens.\n const resolve = linkUrlResolver(urlOptions);\n if (event.defaultPrevented || event.clipboardData === null) return false;\n const field = asTextField(event.currentTarget) ?? asTextField(event.target);\n if (field === null || field.disabled || field.readOnly || field.selectionStart === null || field.selectionEnd === null) return false;\n const selection = field.value.slice(field.selectionStart, field.selectionEnd);\n if (selection.trim() === '' || SINGLE_URL.test(selection)) return false;\n const data = event.clipboardData;\n const link = readWith({ text: data.getData('text/plain'), html: data.getData('text/html'), uriList: data.getData('text/uri-list') }, resolve);\n if (link === null) return false;\n const text = format === undefined ? markdownLink({ ...link, title: selection, titled: true }) : format(selection, link);\n if (typeof text !== 'string') throw copyFailure('invalid-payload', '`format` must return a string.');\n event.preventDefault();\n return insertText(field, text);\n}\n\n/** A link to the current selection, as returned by {@link selectionLink}. */\nexport interface SelectionLink extends ResolvedLink {\n /** The selected text, as one line. */\n readonly quote: string;\n}\n\nexport interface SelectionLinkOptions extends TextFragmentOptions {\n /** The page to link to. Default: `location.href`. */\n readonly url?: string | URL;\n /** Default: `document.title`. */\n readonly title?: string;\n}\n\n/**\n * A link to the passage the user has selected (a text fragment link), with the\n * page title and the quote, or `null` when nothing is selected. Pass it to\n * `linkPayload` to copy it.\n *\n * @example\n * const link = selectionLink();\n * if (link) copy(() => linkPayload(link));\n */\nexport function selectionLink(options: SelectionLinkOptions = {}): SelectionLink | null {\n if (typeof window === 'undefined' || typeof document === 'undefined') return null;\n const selection = window.getSelection();\n if (selection === null || selection.rangeCount === 0 || selection.isCollapsed) return null;\n const range = selection.getRangeAt(0);\n const quote = range.toString().replace(/\\s+/g, ' ').trim();\n if (quote === '') return null;\n const { url = location.href, title = document.title, ...fragmentOptions } = options;\n const href = textFragmentUrl(url, range, fragmentOptions);\n const clean = cleanTitle(title, DEFAULT_LINK_TITLE_LENGTH);\n return { url: href, title: clean === '' ? href : clean, titled: clean !== '', quote };\n}\n"],"mappings":";AA8CA,SAAgB,gBAAgB,MAAqB,SAAiB,OAA4B;CAChG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":["invalid","invalid"],"sources":["../src/core/errors.ts","../src/link/url.ts","../src/link/payload.ts","../src/link/fragment.ts","../src/core/text-field.ts","../src/link/paste.ts"],"sourcesContent":["import type { PasteSource } from './paste-reader';\n\n/**\n * Every way a clipboard operation can fail, as a closed union.\n *\n * `CopyError.message` is developer-facing (logs, telemetry). For user-facing\n * text use {@link describeCopyError} / {@link describePasteError}, or map\n * `type` through your own i18n layer.\n */\nexport type CopyErrorType =\n /** No Clipboard API (old browser, server, locked-down webview). Not retryable. */\n | 'unsupported'\n /** Page is not served over HTTPS/localhost. Not retryable. */\n | 'insecure-context'\n /** Browser or user blocked the operation. Also what Safari reports for a missing user gesture. */\n | 'permission-denied'\n /** The document lost focus mid-operation (Chromium). Retrying after refocus usually works. */\n | 'not-focused'\n /** Empty or malformed payload, or a lazy source that threw. Caught before touching the clipboard. */\n | 'invalid-payload'\n /** The browser cannot handle this MIME type (e.g. non-PNG image, HTML without ClipboardItem). */\n | 'unsupported-format'\n /** A lazy image source (or capture) threw, rejected or did not produce a Blob. */\n | 'blob-generation-failed'\n /** `retry()` was called after `maxRetries` was reached. Terminal. */\n | 'max-retries-exceeded'\n /** Paste: the clipboard held nothing matching `accept`. */\n | 'no-content'\n /** Content exceeded a configured safety limit (bytes, items or pixels). Not retryable. */\n | 'too-large'\n /** An operation did not settle within its deadline. Retryable. */\n | 'timeout'\n /** The caller aborted the operation through an `AbortSignal`. Not retryable. */\n | 'aborted'\n /** Anything the platform threw that we could not classify. */\n | 'unknown';\n\n/** Which clipboard direction failed; only changes developer-facing messages. */\nexport type ClipboardOperation = 'write' | 'read';\n\nexport interface CopyError {\n readonly type: CopyErrorType;\n readonly message: string;\n readonly cause?: unknown;\n}\n\nexport function createCopyError(type: CopyErrorType, message: string, cause?: unknown): CopyError {\n return cause === undefined ? { type, message } : { type, message, cause };\n}\n\nconst RETRYABLE_ERRORS: ReadonlySet<CopyErrorType> = /* @__PURE__ */ new Set<CopyErrorType>([\n 'permission-denied',\n 'not-focused',\n 'blob-generation-failed',\n 'timeout',\n 'unknown',\n]);\n\n/** Whether retrying the same payload could plausibly succeed. */\nexport function isRetryableError(error: CopyError): boolean {\n return RETRYABLE_ERRORS.has(error.type);\n}\n\n/**\n * Branded (not `instanceof`) so failures stay recognisable even when the core\n * is bundled twice, e.g. `react-smart-copy` and `react-smart-copy/core` together.\n */\nconst COPY_FAILURE_BRAND = Symbol.for('react-smart-copy.CopyFailure');\n\n/** Error thrown by adapters to carry a fully classified {@link CopyError}. */\nexport class CopyFailure extends Error {\n readonly copyError: CopyError;\n readonly [COPY_FAILURE_BRAND] = true;\n\n constructor(copyError: CopyError) {\n super(copyError.message);\n this.name = 'CopyFailure';\n this.copyError = copyError;\n }\n}\n\nexport function isCopyFailure(value: unknown): value is CopyFailure {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<PropertyKey, unknown>)[COPY_FAILURE_BRAND] === true\n );\n}\n\n/** Shorthand for throwing a classified failure. */\nexport function copyFailure(type: CopyErrorType, message: string, cause?: unknown): CopyFailure {\n return new CopyFailure(createCopyError(type, message, cause));\n}\n\nfunction readString(value: unknown, key: string): string | undefined {\n if (typeof value !== 'object' || value === null) return undefined;\n const field = (value as Record<string, unknown>)[key];\n return typeof field === 'string' ? field : undefined;\n}\n\n/**\n * Classifies anything thrown by the platform or an adapter into a {@link CopyError}.\n * `operation` only tailors the developer-facing message.\n */\nexport function toCopyError(cause: unknown, operation: ClipboardOperation = 'write'): CopyError {\n if (isCopyFailure(cause)) return cause.copyError;\n\n const name = readString(cause, 'name');\n const message = readString(cause, 'message') ?? '';\n const verb = operation === 'read' ? 'read' : 'write';\n\n switch (name) {\n case 'NotAllowedError':\n return /focus/i.test(message)\n ? createCopyError('not-focused', `The document was not focused during the clipboard ${verb}.`, cause)\n : createCopyError('permission-denied', `Clipboard ${verb} permission was denied.`, cause);\n case 'SecurityError':\n return createCopyError('insecure-context', 'The clipboard is blocked in this context.', cause);\n case 'NotSupportedError':\n case 'DataError':\n return createCopyError('unsupported-format', 'The browser rejected this clipboard format.', cause);\n case 'AbortError':\n return createCopyError('aborted', `The clipboard ${verb} was aborted.`, cause);\n case 'TimeoutError':\n return createCopyError('timeout', `The clipboard ${verb} timed out.`, cause);\n default:\n return createCopyError('unknown', message || `The clipboard ${verb} failed for an unknown reason.`, cause);\n }\n}\n\nconst COPY_DESCRIPTIONS: Readonly<Record<CopyErrorType, string>> = {\n unsupported: \"Copying isn't supported in this browser.\",\n 'insecure-context': 'Copying requires a secure (HTTPS) connection.',\n 'permission-denied': 'Clipboard access was blocked. Allow it and try again.',\n 'not-focused': 'The page lost focus while copying. Try again.',\n 'invalid-payload': 'There is nothing to copy.',\n 'unsupported-format': \"This content can't be copied in this browser.\",\n 'blob-generation-failed': \"The image couldn't be prepared for copying.\",\n 'max-retries-exceeded': 'Copying failed after several attempts.',\n 'no-content': 'There is nothing to copy.',\n 'too-large': 'This content is too large to copy.',\n timeout: 'Copying took too long. Try again.',\n aborted: 'Copying was cancelled.',\n unknown: \"Couldn't copy to the clipboard. Try again.\",\n};\n\nconst PASTE_DESCRIPTIONS: Readonly<Record<CopyErrorType, string>> = {\n unsupported: \"Pasting isn't supported in this browser.\",\n 'insecure-context': 'Pasting requires a secure (HTTPS) connection.',\n 'permission-denied': 'Clipboard access was blocked. Allow it and try again.',\n 'not-focused': 'The page lost focus while pasting. Try again.',\n 'invalid-payload': \"The clipboard content couldn't be read.\",\n 'unsupported-format': \"This clipboard content isn't supported here.\",\n 'blob-generation-failed': \"The pasted image couldn't be read.\",\n 'max-retries-exceeded': 'Pasting failed after several attempts.',\n 'no-content': \"The clipboard doesn't contain anything that can be pasted here.\",\n 'too-large': 'The clipboard content is too large to paste.',\n timeout: 'Pasting took too long. Try again.',\n aborted: 'Pasting was cancelled.',\n unknown: \"Couldn't read the clipboard. Try again.\",\n};\n\n/** Default English, user-facing sentence for a copy error. Replace for i18n. */\nexport function describeCopyError(error: CopyError): string {\n return COPY_DESCRIPTIONS[error.type];\n}\n\n/** Drops can only fail in these ways; the rest of the paste wording would mention the clipboard. */\nconst DROP_DESCRIPTIONS: Readonly<Partial<Record<CopyErrorType, string>>> = {\n 'invalid-payload': \"The dropped content couldn't be read.\",\n 'no-content': 'Nothing that was dropped can be used here.',\n 'too-large': 'The dropped content is too large.',\n unknown: \"Couldn't read the dropped content. Try again.\",\n};\n\n/**\n * Default English, user-facing sentence for a paste error. Pass the error\n * state's `source` to word drag-and-drop failures as drops. Replace for i18n.\n */\nexport function describePasteError(error: CopyError, source?: PasteSource): string {\n return (source === 'drop' ? DROP_DESCRIPTIONS[error.type] : undefined) ?? PASTE_DESCRIPTIONS[error.type];\n}\n","import { copyFailure } from '../core/errors';\n\n/** Schemes a copied or pasted link may use by default. Never `javascript:`, `data:`, `vbscript:` or `file:`. */\nexport const DEFAULT_LINK_PROTOCOLS: readonly string[] = /* @__PURE__ */ Object.freeze(['https:', 'http:', 'mailto:', 'tel:']);\n\n/**\n * Query parameters that only track where a click came from: the defaults of\n * {@link cleanLinkUrl}. `utm_` matches every parameter starting with it.\n */\nexport const TRACKING_PARAMETERS: readonly string[] = /* @__PURE__ */ Object.freeze([\n 'utm_',\n 'fbclid',\n 'gclid',\n 'gclsrc',\n 'dclid',\n 'gbraid',\n 'wbraid',\n 'msclkid',\n 'yclid',\n 'twclid',\n 'ttclid',\n 'li_fat_id',\n 'igshid',\n 'igsh',\n 'mc_cid',\n 'mc_eid',\n '_hsenc',\n '_hsmi',\n 'mkt_tok',\n 'oly_anon_id',\n 'oly_enc_id',\n 'vero_id',\n 'wickedid',\n '_gl',\n]);\n\nexport interface CleanLinkOptions {\n /**\n * Parameters to remove: exact names, names ending in `_` (a prefix, like\n * `utm_`), or regular expressions tested against the name. Default {@link TRACKING_PARAMETERS}.\n */\n readonly params?: readonly (string | RegExp)[];\n /** Parameters never removed, even when `params` matches them. */\n readonly keep?: readonly string[];\n}\n\nexport interface LinkUrlOptions {\n /** Resolves relative links. Default: the page's address in a browser; required elsewhere for relative links. */\n readonly base?: string | URL;\n /** Allowed schemes, with the colon. Default {@link DEFAULT_LINK_PROTOCOLS}. */\n readonly protocols?: readonly string[];\n /** Remove tracking parameters: `true` for {@link TRACKING_PARAMETERS}, or your own list. Default `false`. */\n readonly clean?: boolean | CleanLinkOptions;\n}\n\nconst invalid = (message: string) => copyFailure('invalid-payload', message);\n\nfunction baseUrl(base: LinkUrlOptions['base']): string | undefined {\n if (base !== undefined) {\n if (typeof base === 'string' || base instanceof URL) return String(base);\n throw invalid('`base` must be a string or a URL.');\n }\n return typeof location === 'undefined' ? undefined : location.href;\n}\n\nfunction protocolSet(protocols: LinkUrlOptions['protocols']): ReadonlySet<string> {\n const list: unknown = protocols ?? DEFAULT_LINK_PROTOCOLS;\n const valid = (protocol: unknown): protocol is string => typeof protocol === 'string' && /^[a-z][a-z\\d+.-]*:$/i.test(protocol);\n if (!Array.isArray(list) || list.length === 0 || !(list as readonly unknown[]).every(valid)) {\n throw invalid('`protocols` must be a non-empty list of schemes with their colon, like \"https:\".');\n }\n return new Set((list as readonly string[]).map((protocol) => protocol.toLowerCase()));\n}\n\nfunction matcher(params: CleanLinkOptions['params']): (name: string) => boolean {\n const list = params ?? TRACKING_PARAMETERS;\n if (!Array.isArray(list) || !list.every((param) => typeof param === 'string' || param instanceof RegExp)) {\n throw invalid('`clean.params` must be a list of strings and regular expressions.');\n }\n return (name) => {\n const lower = name.toLowerCase();\n return list.some((param) => {\n if (typeof param !== 'string') return new RegExp(param.source, param.flags.replace(/[gy]/g, '')).test(name);\n const wanted = param.toLowerCase();\n return wanted.endsWith('_') ? lower.startsWith(wanted) : lower === wanted;\n });\n };\n}\n\n/** The cleaning step `clean` asks for, or `null`. Throws for an invalid option. */\nfunction cleaner(option: LinkUrlOptions['clean']): ((url: URL) => void) | null {\n const cleaning: unknown = option ?? false; // Plain-JS callers can pass anything.\n if (cleaning === false) return null;\n if (cleaning !== true && (typeof cleaning !== 'object' || cleaning === null)) throw invalid('`clean` must be a boolean or an options object.');\n const settings: CleanLinkOptions = cleaning === true ? {} : cleaning;\n const tracking = matcher(settings.params);\n const keep = settings.keep ?? [];\n if (!Array.isArray(keep) || !keep.every((name: unknown) => typeof name === 'string')) throw invalid('`clean.keep` must be a list of strings.');\n const kept = new Set(keep.map((name) => name.toLowerCase()));\n return (url) => {\n for (const name of [...new Set(url.searchParams.keys())]) {\n if (tracking(name) && !kept.has(name.toLowerCase())) url.searchParams.delete(name);\n }\n };\n}\n\n/**\n * Validates `options` once (throwing a typed `invalid-payload` error for invalid\n * ones) and returns a resolver that throws only for invalid links.\n * @internal\n */\nexport function linkUrlResolver(options: LinkUrlOptions = {}): (input: string | URL) => string {\n const protocols = protocolSet(options.protocols);\n const base = baseUrl(options.base);\n const clean = cleaner(options.clean);\n return (input) => {\n if (typeof input !== 'string' && !(input instanceof URL)) throw invalid('A link must be a string or a URL.');\n const raw = String(input).trim();\n if (raw === '') throw invalid('A link must not be empty.');\n let url: URL;\n try {\n url = new URL(raw, base);\n } catch (cause) {\n throw copyFailure('invalid-payload', `Not a valid link: ${JSON.stringify(raw.slice(0, 200))}.`, cause);\n }\n if (!protocols.has(url.protocol)) {\n throw invalid(`Links with the scheme \"${url.protocol}\" are not allowed (allowed: ${[...protocols].join(', ')}).`);\n }\n // Never copy or paste credentials embedded in a link.\n url.username = '';\n url.password = '';\n clean?.(url);\n return url.href;\n };\n}\n\n/**\n * The link as an absolute, safe URL string, or a typed `invalid-payload` error:\n * relative links are resolved, the scheme must be allowed, user names and\n * passwords are always removed, and tracking parameters optionally.\n */\nexport function resolveLinkUrl(input: string | URL, options: LinkUrlOptions = {}): string {\n return linkUrlResolver(options)(input);\n}\n\n/**\n * Removes tracking parameters (`utm_*`, `fbclid`, `gclid`, ...) from a link, keeping\n * everything else, including the fragment. Also validates it like every link here.\n *\n * @example\n * cleanLinkUrl('https://shop.example/p/42?utm_source=news&color=red'); // 'https://shop.example/p/42?color=red'\n */\nexport function cleanLinkUrl(url: string | URL, options: CleanLinkOptions & Omit<LinkUrlOptions, 'clean'> = {}): string {\n const { params, keep, ...rest } = options;\n return resolveLinkUrl(url, { ...rest, clean: { ...(params === undefined ? {} : { params }), ...(keep === undefined ? {} : { keep }) } });\n}\n","import { copyFailure } from '../core/errors';\nimport type { HtmlPayload, MultiPayload } from '../core/payload';\nimport { resolveLinkUrl, type LinkUrlOptions } from './url';\n\n/** A link with an optional title. */\nexport interface Link {\n readonly url: string | URL;\n /** What the link says when pasted into a document or chat. Default: the URL. */\n readonly title?: string;\n}\n\n/** A link: a URL, a `{ url, title }` object, or an `<a>` element (its `href` and text). */\nexport type LinkSource = string | URL | Link | HTMLAnchorElement;\n\n/** A validated link: an absolute, safe URL and a clean title. */\nexport interface ResolvedLink {\n readonly url: string;\n /** Never empty: the URL when there is no title. */\n readonly title: string;\n /** Whether `title` came from the input (`false`: it is the URL). */\n readonly titled: boolean;\n}\n\n/**\n * What the plain-text flavour holds (editors, terminals and address bars paste it):\n * `'url'` (the default), `'title'`, `'title-and-url'` (the title, then the URL on\n * the next line) or `'markdown'` (`[Title](URL)`).\n */\nexport type LinkTextFormat = 'url' | 'title' | 'title-and-url' | 'markdown';\n\nexport interface LinkPayloadOptions extends LinkUrlOptions {\n /** Default `'url'`. */\n readonly text?: LinkTextFormat;\n /** Longest title kept, in characters; longer ones end in an ellipsis. Default {@link DEFAULT_LINK_TITLE_LENGTH}. */\n readonly maxTitleLength?: number;\n}\n\nexport interface LinkDragPayloadOptions extends LinkPayloadOptions {\n /**\n * `'drag'`: a multi-format payload that also carries `text/uri-list` and\n * Firefox's `text/x-moz-url`, for `useDragCopy` and `useCopyInterceptor` (a link\n * dropped on the tab bar opens). Clipboard writes skip those two where the\n * browser can't write them.\n */\n readonly target: 'drag';\n}\n\nexport const DEFAULT_LINK_TITLE_LENGTH = 300;\n\nconst invalid = (message: string) => copyFailure('invalid-payload', message);\n\n/**\n * Characters a title never keeps: controls, bidi overrides and isolates (which can\n * make a title read differently), and zero-width characters.\n */\n// eslint-disable-next-line no-control-regex -- matching control characters is the point\nconst HIDDEN = /[\\0-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f-\\x9f\\u061C\\u200B-\\u200F\\u202A-\\u202E\\u2060-\\u2064\\u2066-\\u2069\\uFEFF]/g;\n\n/** A title as one clean line: hidden characters removed, whitespace collapsed, length capped. */\nexport function cleanTitle(title: string, maxLength: number): string {\n const clean = title.replace(HIDDEN, '').replace(/\\s+/g, ' ').trim();\n if (clean.length <= maxLength) return clean;\n // Cut on a code point boundary and mark the cut.\n return `${Array.from(clean).slice(0, maxLength - 1).join('').trimEnd()}\\u2026`;\n}\n\nfunction maxTitle(value: number | undefined): number {\n if (value === undefined) return DEFAULT_LINK_TITLE_LENGTH;\n if (Number.isInteger(value) && value >= 1) return value;\n throw invalid(`\\`maxTitleLength\\` must be a positive integer (received ${String(value)}).`);\n}\n\nfunction isAnchor(source: unknown): source is HTMLAnchorElement {\n return typeof source === 'object' && source !== null && (source as { nodeName?: unknown }).nodeName === 'A' && typeof (source as { href?: unknown }).href === 'string';\n}\n\n/**\n * Validates a link and its title: see {@link resolveLinkUrl} for the URL rules.\n * An `<a>` element gives its `href` and its text (or `title` attribute).\n */\nexport function resolveLink(source: LinkSource, options: LinkPayloadOptions = {}): ResolvedLink {\n let url: string | URL;\n let title: unknown;\n if (typeof source === 'string' || source instanceof URL) {\n url = source;\n } else if (isAnchor(source)) {\n url = source.getAttribute('href') ?? '';\n title = source.textContent.trim() !== '' ? source.textContent : (source.getAttribute('title') ?? undefined);\n if (url !== '' && options.base === undefined) url = source.href; // Resolved against the anchor's own document.\n } else if (typeof (source as unknown) === 'object' && (source as unknown) !== null && 'url' in source) {\n url = source.url;\n title = source.title;\n } else {\n throw invalid('A link must be a URL, a { url, title } object or an <a> element.');\n }\n if (title !== undefined && typeof title !== 'string') throw invalid('A link title must be a string.');\n const href = resolveLinkUrl(url, options);\n const clean = title === undefined ? '' : cleanTitle(title, maxTitle(options.maxTitleLength));\n return { url: href, title: clean === '' ? href : clean, titled: clean !== '' };\n}\n\nexport const escapeHtml = (text: string): string =>\n text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"').replace(/'/g, ''');\n\n/** `[title](url)`, safe in every CommonMark renderer: brackets and backslashes escaped, parentheses and spaces encoded. */\nexport function markdownLink(link: ResolvedLink): string {\n const label = link.title.replace(/[\\\\[\\]]/g, '\\\\$&');\n const target = link.url.replace(/[()<> ]/g, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`);\n return `[${label}](${target})`;\n}\n\nfunction plainText(link: ResolvedLink, format: LinkTextFormat): string {\n switch (format) {\n case 'url':\n return link.url;\n case 'title':\n return link.title;\n case 'title-and-url':\n return link.titled ? `${link.title}\\n${link.url}` : link.url;\n case 'markdown':\n return markdownLink(link);\n default:\n throw invalid(`\\`text\\` must be \"url\", \"title\", \"title-and-url\" or \"markdown\" (received ${JSON.stringify(format)}).`);\n }\n}\n\n/**\n * A copy payload for a link: an HTML anchor, so Slack, Google Docs, Notion,\n * Teams, Word and mail paste a titled link, and plain text (the URL by default)\n * for editors and address bars. The URL is validated (allowed schemes only,\n * credentials removed, optionally cleaned of tracking) and the title is cleaned\n * of hidden characters; both are escaped.\n *\n * @example\n * copy(() => linkPayload({ url: location.href, title: document.title }, { clean: true }));\n * useDragCopy({ payload: () => linkPayload(anchor, { target: 'drag' }) });\n */\nexport function linkPayload(source: LinkSource, options: LinkDragPayloadOptions): MultiPayload;\nexport function linkPayload(source: LinkSource, options?: LinkPayloadOptions): HtmlPayload;\nexport function linkPayload(source: LinkSource, options: LinkPayloadOptions & { readonly target?: 'drag' | 'clipboard' } = {}): HtmlPayload | MultiPayload {\n const target: unknown = options.target ?? 'clipboard'; // Plain-JS callers can pass anything.\n if (target !== 'drag' && target !== 'clipboard') throw invalid('`target` must be \"clipboard\" or \"drag\".');\n const link = resolveLink(source, options);\n const text = plainText(link, options.text ?? 'url');\n const html = `<a href=\"${escapeHtml(link.url)}\">${escapeHtml(link.title)}</a>`;\n if (target === 'clipboard') return { kind: 'html', html, text };\n return {\n kind: 'multi',\n items: [\n { mimeType: 'text/plain', data: text },\n { mimeType: 'text/html', data: html },\n { mimeType: 'text/uri-list', data: link.url, optional: true },\n // Firefox's titled-link format: the URL, a line break, the title.\n { mimeType: 'text/x-moz-url', data: `${link.url}\\n${link.title}`, optional: true },\n ],\n };\n}\n","import { copyFailure } from '../core/errors';\nimport { resolveLinkUrl, type LinkUrlOptions } from './url';\n\n/**\n * A passage to link to: `start` alone, or `start` to `end` for a longer one.\n * `prefix` and `suffix` are the words around it, used to tell apart passages\n * that appear more than once. Each term must lie within one block of the page\n * (a paragraph, a list item, a heading).\n */\nexport interface TextFragment {\n readonly start: string;\n readonly end?: string;\n readonly prefix?: string;\n readonly suffix?: string;\n}\n\nexport interface TextFragmentOptions extends LinkUrlOptions {\n /** Passages longer than this many words link by their first and last words (`start,end`). Default 10. */\n readonly maxWords?: number;\n /** Words kept at each end of a long passage, and of prefix and suffix context. Default 4. */\n readonly contextWords?: number;\n /** Where to look for repeats of the passage, to decide whether context is needed. Default `document.body`. */\n readonly root?: Node;\n}\n\nconst invalid = (message: string) => copyFailure('invalid-payload', message);\n\nconst collapse = (text: string): string => text.replace(/\\s+/g, ' ').trim();\nconst words = (text: string): string[] => collapse(text).split(' ').filter((word) => word !== '');\n\n/**\n * Percent-encodes a directive term. `encodeURIComponent` leaves `-` alone, but the\n * directive syntax uses it (`prefix-,` and `,-suffix`), so it is encoded too.\n */\nexport function encodeTerm(term: string): string {\n return encodeURIComponent(term).replace(/-/g, '%2D');\n}\n\n/** The `text=` directive for a fragment. */\nexport function textDirective(fragment: TextFragment): string {\n const terms: string[] = [];\n if (fragment.prefix !== undefined && fragment.prefix !== '') terms.push(`${encodeTerm(fragment.prefix)}-`);\n terms.push(encodeTerm(fragment.start));\n if (fragment.end !== undefined && fragment.end !== '') terms.push(encodeTerm(fragment.end));\n if (fragment.suffix !== undefined && fragment.suffix !== '') terms.push(`-${encodeTerm(fragment.suffix)}`);\n return `text=${terms.join(',')}`;\n}\n\nfunction positive(value: number | undefined, fallback: number, name: string): number {\n if (value === undefined) return fallback;\n if (Number.isInteger(value) && value >= 1) return value;\n throw invalid(`\\`${name}\\` must be a positive integer (received ${String(value)}).`);\n}\n\n/** Elements that start a new block: text fragment terms never span them. */\nconst BLOCK = /* @__PURE__ */ new Set([\n 'address', 'article', 'aside', 'blockquote', 'body', 'caption', 'dd', 'details', 'dialog', 'div', 'dl', 'dt', 'fieldset',\n 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'li', 'main', 'nav',\n 'ol', 'p', 'pre', 'section', 'summary', 'table', 'td', 'th', 'tr', 'ul',\n]);\n\n/** The nearest block around `node`, or the top of its tree (a detached node's fragment, or the page body). */\nfunction blockOf(node: Node): Node {\n let top = node;\n for (let current: Node | null = node; current !== null; current = current.parentNode) {\n if (current.nodeType === 1 && BLOCK.has((current as Element).localName)) return current;\n top = current;\n }\n if (top.nodeType !== 9) return top;\n const body: unknown = (top as Document).body; // Null in an XML document, despite its type.\n return body instanceof Node ? body : top;\n}\n\n/** The text of `block` from its start to (`before`) or from (`after`) a boundary point. */\nfunction around(block: Node, container: Node, offset: number, side: 'before' | 'after'): string {\n const range = (container.ownerDocument as Document).createRange();\n range.selectNodeContents(block);\n if (side === 'before') range.setEnd(container, offset);\n else range.setStart(container, offset);\n return range.toString();\n}\n\nconst count = (haystack: string, needle: string): number => {\n let found = 0;\n for (let at = haystack.indexOf(needle); at !== -1 && found < 2; at = haystack.indexOf(needle, at + 1)) found += 1;\n return found;\n};\n\nfunction rootText(root: Node | undefined): string | null {\n const node = root ?? (typeof document === 'undefined' ? undefined : document.body);\n if (node === undefined) return null;\n // A range reads the text of any node, a whole Document included (whose `textContent` is null).\n const range = ((node.ownerDocument ?? node) as Document).createRange();\n range.selectNodeContents(node);\n return collapse(range.toString()).toLowerCase();\n}\n\n/** Splits a passage into a directive: whole when short, first and last words when long. */\nfunction fromText(text: string, maxWords: number, contextWords: number): TextFragment {\n const all = words(text);\n if (all.length === 0) throw invalid('A text fragment needs some text.');\n if (all.length <= maxWords) return { start: all.join(' ') };\n return { start: all.slice(0, contextWords).join(' '), end: all.slice(-contextWords).join(' ') };\n}\n\n/** A fragment for a selected range: terms taken from within their own blocks, context added when the passage repeats. */\nfunction fromRange(range: Range, maxWords: number, contextWords: number, root: Node | undefined): TextFragment {\n const startBlock = blockOf(range.startContainer);\n const endBlock = blockOf(range.endContainer);\n const text = collapse(range.toString());\n if (text === '') throw invalid('A text fragment needs some text: the range is empty.');\n let fragment: TextFragment;\n if (startBlock === endBlock) {\n fragment = fromText(text, maxWords, contextWords);\n } else {\n // A passage across blocks: start in the first block, end in the last.\n const head = words(around(startBlock, range.startContainer, range.startOffset, 'after')).slice(0, contextWords);\n const tail = words(around(endBlock, range.endContainer, range.endOffset, 'before')).slice(-contextWords);\n fragment = head.length === 0 || tail.length === 0 ? fromText(text, maxWords, contextWords) : { start: head.join(' '), end: tail.join(' ') };\n }\n const page = rootText(root);\n if (page !== null && count(page, fragment.start.toLowerCase()) < 2) return fragment;\n // The start appears more than once (or the page can't be read): add the words around the passage.\n const prefix = words(around(startBlock, range.startContainer, range.startOffset, 'before')).slice(-contextWords).join(' ');\n const suffix = words(around(endBlock, range.endContainer, range.endOffset, 'after')).slice(0, contextWords).join(' ');\n return { ...fragment, prefix, suffix }; // Empty terms are left out of the directive.\n}\n\n/** A caller's fragment with each term on one line; empty optional terms are left out of the directive. */\nfunction fromObject(passage: TextFragment): TextFragment {\n const term = (value: unknown): string => (typeof value === 'string' ? collapse(value) : '');\n const start = term(passage.start);\n if (start === '') throw invalid('A text fragment needs a non-empty `start`.');\n return { start, end: term(passage.end), prefix: term(passage.prefix), suffix: term(passage.suffix) };\n}\n\nfunction isRange(value: unknown): value is Range {\n return typeof value === 'object' && value !== null && typeof (value as Range).cloneContents === 'function' && 'startContainer' in value;\n}\n\n/**\n * A link that scrolls to, and highlights, a passage of the page: the\n * [text fragment](https://wicg.github.io/scroll-to-text-fragment/) syntax\n * (`#:~:text=`), supported by Chromium, Safari and Firefox. Browsers without it\n * open the page at its normal position (or its existing `#section`).\n *\n * The passage is a string, a {@link TextFragment}, or a DOM `Range` (the user's\n * selection): long passages link by their first and last words, and the words\n * around a passage are added when it appears more than once on the page.\n *\n * @example\n * textFragmentUrl(location.href, window.getSelection()!.getRangeAt(0));\n * textFragmentUrl('https://example.com/docs#install', 'npm install react-smart-copy');\n */\nexport function textFragmentUrl(url: string | URL, passage: string | TextFragment | Range, options: TextFragmentOptions = {}): string {\n const maxWords = positive(options.maxWords, 10, 'maxWords');\n const contextWords = positive(options.contextWords, 4, 'contextWords');\n let fragment: TextFragment;\n if (typeof passage === 'string') {\n fragment = fromText(passage, maxWords, contextWords);\n } else if (isRange(passage)) {\n fragment = fromRange(passage, maxWords, contextWords, options.root);\n } else if (typeof passage === 'object' && (passage as unknown) !== null && typeof (passage as { start?: unknown }).start === 'string') {\n fragment = fromObject(passage);\n } else {\n throw invalid('The passage must be a string, a TextFragment or a Range.');\n }\n const href = resolveLinkUrl(url, options);\n const hashAt = href.indexOf('#');\n const base = hashAt === -1 ? href : href.slice(0, hashAt);\n // Keep an existing #section; replace any earlier directive.\n const section = hashAt === -1 ? '' : (href.slice(hashAt + 1).split(':~:')[0] as string);\n return `${base}#${section}:~:${textDirective(fragment)}`;\n}\n\n/** Whether this browser scrolls to text fragments (`document.fragmentDirective`). */\nexport function supportsTextFragments(): boolean {\n return typeof document !== 'undefined' && 'fragmentDirective' in document;\n}\n","/**\n * Text-field helpers shared by the paste handlers of the opt-in entry points.\n * Internal: not part of `react-smart-copy/core`'s public API.\n */\n\n/** Text fields `setRangeText` and `execCommand('insertText')` both support. */\nexport type TextField = HTMLTextAreaElement | HTMLInputElement;\n\nconst TEXT_INPUTS = new Set(['text', 'search', 'url', 'tel', 'password']);\n\nexport function asTextField(target: EventTarget | null): TextField | null {\n if (typeof target !== 'object' || target === null) return null;\n const element = target as Partial<Element> & { type?: unknown };\n if (element.nodeName === 'TEXTAREA') return target as HTMLTextAreaElement;\n if (element.nodeName === 'INPUT' && typeof element.type === 'string' && TEXT_INPUTS.has(element.type)) return target as HTMLInputElement;\n return null;\n}\n\n/**\n * Inserts text at the cursor of a `<textarea>` or text `<input>`, replacing the\n * selection, as typing or pasting would: the browser's undo (Ctrl/⌘+Z) still\n * works, `input` events fire (so React and other frameworks see the change),\n * and `maxlength` is respected. Returns `false` for disabled or read-only fields.\n */\nexport function insertText(field: TextField, text: string): boolean {\n if (field.disabled || field.readOnly) return false;\n // An <input> holds one line: each run of line breaks (a paragraph break too) becomes one space.\n const value = field.nodeName === 'INPUT' ? text.replace(/[ \\t]*(?:\\r\\n|\\r|\\n)+[ \\t]*/g, ' ') : text;\n const doc = field.ownerDocument;\n field.focus();\n // `null` for inputs without a selection API (email, number): the text is appended.\n const start = field.selectionStart;\n const end = field.selectionEnd;\n try {\n // Re-applying the selection ends the current typing run, so the paste gets its own undo step\n // (as a native paste does) instead of merging with what was typed just before.\n if (start !== null && end !== null) field.setSelectionRange(start, end);\n // The only way to keep the native undo stack; supported for text fields in every current browser.\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- no replacement keeps undo history\n if (doc.activeElement === field && doc.execCommand('insertText', false, value)) return true;\n } catch {\n // Fall through to the manual insertion.\n }\n const from = start ?? field.value.length;\n const to = end ?? from;\n let insert = value;\n if (field.maxLength >= 0) {\n const room = Math.max(0, field.maxLength - (field.value.length - (to - from)));\n insert = insert.slice(0, room);\n // Never leave half of a surrogate pair (an emoji) behind.\n if (/[\\ud800-\\udbff]$/.test(insert)) insert = insert.slice(0, -1);\n }\n if (start === null) setNativeValue(field, field.value + insert);\n else field.setRangeText(insert, from, to, 'end');\n const view = doc.defaultView;\n const event =\n view !== null && typeof view.InputEvent === 'function'\n ? new view.InputEvent('input', { bubbles: true, inputType: 'insertFromPaste', data: insert })\n : new Event('input', { bubbles: true });\n field.dispatchEvent(event);\n return true;\n}\n\n/**\n * Sets a field's value through the prototype's setter. React tracks the value\n * set on the element itself; going around it lets React see the change and\n * call `onChange` for the `input` event that follows.\n */\nfunction setNativeValue(field: TextField, next: string): void {\n const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(field) as object, 'value');\n // eslint-disable-next-line @typescript-eslint/unbound-method -- it is called right below with the field as `this`\n const setter = descriptor?.set;\n if (setter) setter.call(field, next);\n else field.value = next;\n}\n","import { copyFailure } from '../core/errors';\nimport { asTextField, insertText } from '../core/text-field';\nimport { cleanTitle, DEFAULT_LINK_TITLE_LENGTH, markdownLink, type ResolvedLink } from './payload';\nimport { textFragmentUrl, type TextFragmentOptions } from './fragment';\nimport { linkUrlResolver, type LinkUrlOptions } from './url';\n\n/** What was pasted or dropped: a `PasteResult` from `usePaste`, a `DataTransfer`-like source, or the flavours themselves. */\nexport interface LinkPasteSource {\n readonly text?: string | null;\n readonly html?: string | null;\n /** `text/uri-list`. */\n readonly uriList?: string | null;\n /** A `PasteResult`'s entries: a `text/uri-list` entry is read from here. */\n readonly items?: readonly { readonly type: string; readonly data: string | Blob }[];\n}\n\n/** One URL with no spaces, as a whole pasted text (surrounding whitespace allowed). */\nconst SINGLE_URL = /^\\s*<?([a-z][a-z\\d+.-]*:[^\\s<>]+?)>?\\s*$/i;\n\ntype Resolve = (input: string) => string;\n\n/** The URL, or `null` when the clipboard content is not a valid, allowed link. */\nfunction tryUrl(resolve: Resolve, candidate: string): string | null {\n try {\n return resolve(candidate);\n } catch {\n return null;\n }\n}\n\nfunction fromUriList(list: string, resolve: Resolve): string | null {\n // RFC 2483: one URI per line, lines starting with \"#\" are comments.\n const first = list.split(/\\r?\\n/).find((line) => line.trim() !== '' && !line.startsWith('#'));\n return first === undefined ? null : tryUrl(resolve, first.trim());\n}\n\n/** The single link in pasted HTML (one `<a href>` and nothing else visible besides its text), parsed inertly. */\nfunction fromHtml(html: string, resolve: Resolve): ResolvedLink | null {\n if (typeof DOMParser === 'undefined' || html.trim() === '') return null;\n const body = new DOMParser().parseFromString(html.slice(0, 100_000), 'text/html').body;\n const anchors = body.querySelectorAll('a[href]');\n if (anchors.length !== 1) return null;\n const anchor = anchors[0] as HTMLAnchorElement;\n const visible = body.textContent.replace(/\\s+/g, ' ').trim();\n const label = anchor.textContent.replace(/\\s+/g, ' ').trim();\n if (visible !== label) return null; // A link inside more text is not \"a link\".\n const url = tryUrl(resolve, String(anchor.getAttribute('href'))); // Matched by `a[href]`.\n if (url === null) return null;\n const title = cleanTitle(label, DEFAULT_LINK_TITLE_LENGTH);\n return { url, title: title === '' ? url : title, titled: title !== '' && title !== url };\n}\n\n/**\n * The link the clipboard (or a drop) holds, or `null`: from `text/uri-list`,\n * from HTML that is exactly one link (keeping its title), or from text that is\n * exactly one URL. Every URL is validated: allowed schemes only (never\n * `javascript:`), credentials removed. Never throws for clipboard content.\n *\n * @example\n * usePaste({ accept: ['text', 'html', 'text/uri-list'], onPaste: (result) => {\n * const link = readLink(result);\n * if (link) addBookmark(link.url, link.title);\n * } });\n */\nexport function readLink(source: LinkPasteSource, options: LinkUrlOptions = {}): ResolvedLink | null {\n return readWith(source, linkUrlResolver(options));\n}\n\nfunction readWith(source: LinkPasteSource, resolve: Resolve): ResolvedLink | null {\n const uriList = source.uriList ?? source.items?.find((item) => item.type === 'text/uri-list' && typeof item.data === 'string')?.data;\n if (typeof uriList === 'string') {\n const url = fromUriList(uriList, resolve);\n if (url !== null) {\n const fromMarkup = typeof source.html === 'string' ? fromHtml(source.html, resolve) : null;\n return fromMarkup?.url === url ? fromMarkup : { url, title: url, titled: false };\n }\n }\n if (typeof source.html === 'string') {\n const link = fromHtml(source.html, resolve);\n if (link !== null) return link;\n }\n const match = typeof source.text === 'string' ? SINGLE_URL.exec(source.text) : null;\n const url = match === null ? null : tryUrl(resolve, match[1] as string);\n return url === null ? null : { url, title: url, titled: false };\n}\n\n/** Structural paste event: a DOM `ClipboardEvent` and React's `onPaste` event both fit. */\nexport interface LinkPasteEvent {\n readonly clipboardData: { getData(format: string): string } | null;\n readonly currentTarget: EventTarget | null;\n readonly target: EventTarget | null;\n readonly defaultPrevented: boolean;\n preventDefault(): void;\n}\n\nexport interface PasteAsLinkOptions extends LinkUrlOptions {\n /**\n * What replaces the selection. Default: a Markdown link, `[selection](url)`.\n * Receives the selected text and the pasted link.\n */\n readonly format?: (selection: string, link: ResolvedLink) => string;\n}\n\n/**\n * A paste handler for text fields: pasting a link over selected text turns the\n * selection into a link (`[selected text](url)` by default), as GitHub, Slack\n * and Notion do. Everything else is left to the browser: pasting with nothing\n * selected, pasting over a URL, or pasting something that is not one link. The\n * browser's undo still works. Returns whether it handled the paste.\n *\n * @example\n * <textarea onPaste={pasteAsLink} />\n */\nexport function pasteAsLink(event: LinkPasteEvent, options: PasteAsLinkOptions = {}): boolean {\n const { format, ...urlOptions } = options;\n // Invalid options are a programming error: thrown before the paste is touched, so the native paste still happens.\n const resolve = linkUrlResolver(urlOptions);\n if (event.defaultPrevented || event.clipboardData === null) return false;\n const field = asTextField(event.currentTarget) ?? asTextField(event.target);\n if (field === null || field.disabled || field.readOnly || field.selectionStart === null || field.selectionEnd === null) return false;\n const selection = field.value.slice(field.selectionStart, field.selectionEnd);\n if (selection.trim() === '' || SINGLE_URL.test(selection)) return false;\n const data = event.clipboardData;\n const link = readWith({ text: data.getData('text/plain'), html: data.getData('text/html'), uriList: data.getData('text/uri-list') }, resolve);\n if (link === null) return false;\n const text = format === undefined ? markdownLink({ ...link, title: selection, titled: true }) : format(selection, link);\n if (typeof text !== 'string') throw copyFailure('invalid-payload', '`format` must return a string.');\n event.preventDefault();\n return insertText(field, text);\n}\n\n/** A link to the current selection, as returned by {@link selectionLink}. */\nexport interface SelectionLink extends ResolvedLink {\n /** The selected text, as one line. */\n readonly quote: string;\n}\n\nexport interface SelectionLinkOptions extends TextFragmentOptions {\n /** The page to link to. Default: `location.href`. */\n readonly url?: string | URL;\n /** Default: `document.title`. */\n readonly title?: string;\n}\n\n/**\n * A link to the passage the user has selected (a text fragment link), with the\n * page title and the quote, or `null` when nothing is selected. Pass it to\n * `linkPayload` to copy it.\n *\n * @example\n * const link = selectionLink();\n * if (link) copy(() => linkPayload(link));\n */\nexport function selectionLink(options: SelectionLinkOptions = {}): SelectionLink | null {\n if (typeof window === 'undefined' || typeof document === 'undefined') return null;\n const selection = window.getSelection();\n if (selection === null || selection.rangeCount === 0 || selection.isCollapsed) return null;\n const range = selection.getRangeAt(0);\n const quote = range.toString().replace(/\\s+/g, ' ').trim();\n if (quote === '') return null;\n const { url = location.href, title = document.title, ...fragmentOptions } = options;\n const href = textFragmentUrl(url, range, fragmentOptions);\n const clean = cleanTitle(title, DEFAULT_LINK_TITLE_LENGTH);\n return { url: href, title: clean === '' ? href : clean, titled: clean !== '', quote };\n}\n"],"mappings":";AA8CA,SAAgB,gBAAgB,MAAqB,SAAiB,OAA4B;CAChG,OAAO,UAAU,KAAA,IAAY;EAAE;EAAM;CAAQ,IAAI;EAAE;EAAM;EAAS;CAAM;AAC1E;;;;;AAmBA,MAAM,qBAAqB,OAAO,IAAI,8BAA8B;;AAGpE,IAAa,cAAb,cAAiC,MAAM;CAIrC,YAAY,WAAsB;EAChC,MAAM,UAAU,OAAO;EAHzB,KAAU,sBAAsB;EAI9B,KAAK,OAAO;EACZ,KAAK,YAAY;CACnB;AACF;;AAWA,SAAgB,YAAY,MAAqB,SAAiB,OAA8B;CAC9F,OAAO,IAAI,YAAY,gBAAgB,MAAM,SAAS,KAAK,CAAC;AAC9D;;;;ACzFA,MAAa,yBAA4D,uBAAO,OAAO;CAAC;CAAU;CAAS;CAAW;AAAM,CAAC;;;;;AAM7H,MAAa,sBAAyD,uBAAO,OAAO;CAClF;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAqBD,MAAMA,aAAW,YAAoB,YAAY,mBAAmB,OAAO;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