wecool-chat 0.10.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.ja.md +9 -3
  3. package/README.md +14 -3
  4. package/dist/CopyIndicator-DcJtCBYP.js +63 -0
  5. package/dist/{MarkdownBody-EIz0jnQy.js → MarkdownBody-DX0DoV4C.js} +901 -893
  6. package/dist/VoiceControls-B_kX2Uj3.js +160 -0
  7. package/dist/{VoiceRuntime-DrYjNkZK.js → VoiceRuntime-D1nURNly.js} +13 -13
  8. package/dist/blank-line-D-aLg3m0.js +213 -0
  9. package/dist/{browser-M7mS-hAN.js → browser-a2qIWP48.js} +1 -1
  10. package/dist/core/client.d.ts +5 -0
  11. package/dist/core/client.d.ts.map +1 -1
  12. package/dist/core/consume-stream.d.ts +18 -1
  13. package/dist/core/consume-stream.d.ts.map +1 -1
  14. package/dist/core/i18n/messages.d.ts +2 -0
  15. package/dist/core/i18n/messages.d.ts.map +1 -1
  16. package/dist/core/narration-round.d.ts +27 -0
  17. package/dist/core/narration-round.d.ts.map +1 -0
  18. package/dist/core/placeholder-manager.d.ts +30 -0
  19. package/dist/core/placeholder-manager.d.ts.map +1 -0
  20. package/dist/core/run-conversation.d.ts.map +1 -1
  21. package/dist/core/stream-state.d.ts +9 -1
  22. package/dist/core/stream-state.d.ts.map +1 -1
  23. package/dist/core/types.d.ts +21 -0
  24. package/dist/core/types.d.ts.map +1 -1
  25. package/dist/createLucideIcon-Dc6H577p.js +120 -0
  26. package/dist/index.css +2 -2
  27. package/dist/index.js +6514 -5325
  28. package/dist/{jsx-runtime-Cyy0mp0f.js → jsx-runtime-2MlY8uwR.js} +132 -122
  29. package/dist/{messages-FvtWi3lI.js → messages-ZLdeJx9N.js} +11 -31
  30. package/dist/observe/__tests__/widget-self-http.test.d.ts +2 -0
  31. package/dist/observe/__tests__/widget-self-http.test.d.ts.map +1 -0
  32. package/dist/observe/__tests__/widget-self.test.d.ts +2 -0
  33. package/dist/observe/__tests__/widget-self.test.d.ts.map +1 -0
  34. package/dist/observe/observers/http.d.ts.map +1 -1
  35. package/dist/observe/observers/js-error.d.ts +7 -2
  36. package/dist/observe/observers/js-error.d.ts.map +1 -1
  37. package/dist/observe/widget-self.d.ts +46 -0
  38. package/dist/observe/widget-self.d.ts.map +1 -0
  39. package/dist/plugin/logger.d.ts.map +1 -1
  40. package/dist/plugins/qrcode.js +7 -6
  41. package/dist/remark-gfm-DDNju7JY.js +2247 -0
  42. package/dist/{remark-parse-BnwSmQr-.js → remark-parse-B3YPcONN.js} +377 -445
  43. package/dist/rolldown-runtime-Csywlj8R.js +25 -0
  44. package/dist/ui/components/ChatFooter.d.ts +4 -3
  45. package/dist/ui/components/ChatFooter.d.ts.map +1 -1
  46. package/dist/ui/components/ChatHeader.d.ts +1 -1
  47. package/dist/ui/components/ChatHeaderMenu.d.ts +1 -1
  48. package/dist/ui/components/ChatPanel.d.ts +1 -1
  49. package/dist/ui/components/ChatWidget.d.ts.map +1 -1
  50. package/dist/ui/components/CommandConfirmationCard.d.ts +1 -1
  51. package/dist/ui/components/CommandOverlays.d.ts +1 -1
  52. package/dist/ui/components/CommandPalette.d.ts +1 -1
  53. package/dist/ui/components/ConversationSelect.d.ts +1 -1
  54. package/dist/ui/components/CopyIndicator.d.ts +1 -1
  55. package/dist/ui/components/FloatButton.d.ts +1 -1
  56. package/dist/ui/components/FooterActions.d.ts +1 -1
  57. package/dist/ui/components/HelpDialogContent.d.ts +1 -1
  58. package/dist/ui/components/MessageActionsPopover.d.ts +1 -1
  59. package/dist/ui/components/MessageAttachments.d.ts +1 -1
  60. package/dist/ui/components/MessageBubble.d.ts +1 -1
  61. package/dist/ui/components/MessageCopyButton.d.ts +1 -1
  62. package/dist/ui/components/MessageEditor.d.ts +1 -1
  63. package/dist/ui/components/MessageList.d.ts +1 -1
  64. package/dist/ui/components/MessagePopoverButton.d.ts +1 -1
  65. package/dist/ui/components/MessageRow.d.ts +1 -1
  66. package/dist/ui/components/MessageRowActions.d.ts +1 -1
  67. package/dist/ui/components/MicButton.d.ts +1 -1
  68. package/dist/ui/components/ResizeHandles.d.ts +1 -1
  69. package/dist/ui/components/ToolConfirmationCard.d.ts +1 -1
  70. package/dist/ui/components/ToolConfirmationRecord.d.ts +1 -1
  71. package/dist/ui/components/ToolsDialogContent.d.ts +1 -1
  72. package/dist/ui/components/VoiceControls.d.ts +1 -1
  73. package/dist/ui/components/VoiceControls.d.ts.map +1 -1
  74. package/dist/ui/components/VoiceLoopStatusBar.d.ts +1 -1
  75. package/dist/ui/components/VoiceLoopToggle.d.ts +1 -1
  76. package/dist/ui/components/VoiceRuntime.d.ts +1 -1
  77. package/dist/ui/components/WidgetDialog.d.ts +1 -1
  78. package/dist/ui/components/markdown/CodeBlock.d.ts +1 -1
  79. package/dist/ui/components/markdown/MarkdownBody.d.ts +1 -1
  80. package/dist/ui/components/markdown/MarkdownMessage.d.ts +1 -1
  81. package/dist/ui/hooks/use-mic-button.d.ts +2 -0
  82. package/dist/ui/hooks/use-mic-button.d.ts.map +1 -1
  83. package/dist/ui/hooks/use-send-message.d.ts.map +1 -1
  84. package/dist/{unified-DctkAd9P.js → unified-DvM6W8YC.js} +3 -3
  85. package/dist/{use-voice-input-LtJJz-zQ.js → use-voice-input-DJtyHnsT.js} +3 -3
  86. package/dist/{voice-support-BeOiOzcn.js → voice-support-DYXg7xML.js} +2 -2
  87. package/package.json +33 -33
  88. package/dist/CopyIndicator-RR3hSsBA.js +0 -51
  89. package/dist/VoiceControls-A7N4uPTo.js +0 -146
  90. package/dist/blank-line-CUDmZ-mX.js +0 -143
  91. package/dist/createLucideIcon-C7wGkK-Q.js +0 -43
  92. package/dist/remark-gfm-Bzy1u34W.js +0 -1962
package/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.1
4
+
5
+ **Bundle size**: Initial 127.1 KB gzip / 108.0 KB brotli · Total 274.3 KB gzip
6
+
7
+ ### Patch Changes
8
+
9
+ - 028a433: 依存パッケージの patch / minor 一括更新(dependabot #380)。ウィジェットに同梱される実行時の依存は react・react-dom 19.3.1 / lucide-react 1.70.0、wecool-cli の実行時の依存は @clack/prompts 1.8.1。外部仕様に変更はない。ウィジェットが使うアイコンの形は lucide-react 1.25.0 と同じ。
10
+
11
+ ## 0.11.0
12
+
13
+ **Bundle size**: Initial 116.2 KB gzip / 98.8 KB brotli · Total 260.3 KB gzip
14
+
15
+ ### Minor Changes
16
+
17
+ - 41b6d67: `layout: "input-only"` の入力欄から「新しい会話を始める」ボタン(吹き出し + アイコン)を取り除いた(issue #296)。このレイアウトはメッセージ列をホストが描画するため、ボタンを押してもウィジェット内部の会話と LLM の文脈だけが消え、ホストの画面には会話が残ったままになっていた(押しても変化が無いように見えて、実際は文脈が切れる)。
18
+
19
+ **挙動変更**: input-only を使っているホストでは、入力欄からこのボタンが消える。会話のリセットが必要な場合は、ホスト側 UI にボタンを置き、`controller.clear()` とホスト側スレッドの消去を合わせて呼ぶこと(README の input-only の節に記載)。継続音声モードのトグルも同じ理由で input-only では出さないことを README に明記した(従来から表示されておらず、挙動は変わらない)。他のレイアウト(floating / sidebar / inline 等)はヘッダーの設定メニューから従来どおり新しい会話を始められる。公開コンポーネント `ChatFooter` の `onNew` prop は残しており、直接組み込んでいる利用者への影響はない。
20
+
21
+ - 601b494: **サーバー側ツールの結果を正しく引き継ぐ・途中で途切れた応答を知らせる**(issue #362)
22
+
23
+ - AI がサーバー側ツール(現在時刻・Web 検索・Web 取得など)とホストのツールを 1 回の発話で同時に呼んだとき、ウィジェットがサーバー側ツールまで実行しようとして `Tool not found` を返し、AI が「確認できませんでした」と答えていた不具合を修正した。ウィジェットはサーバーが実行したツールを自分では実行せず、サーバーから届いた結果を次の問い合わせに添える。添えた結果はそのやり取りの中だけで使い、訪問者の次の発話からは履歴に含めない
24
+ - 応答が `done` も `error` も無いまま途切れたとき、途中までの本文は残したうえで、その下にエラー表示(「応答が途中で途切れました。もう一度お試しください。」/ "The response was cut off. Please try again.")を出すようにした。本文が 1 文字も届いていなければ空の吹き出しは出さない。途切れた応答に含まれていたツール呼び出しは実行せず、自動での再送もしない。やり直しは既存の再生成ボタンで行える。`onError` には `code` が `"RESPONSE_INCOMPLETE"` のエラーが渡り、エラー収集にもこの code で記録される
25
+ - `endpoint` を独自のバックエンドに向けている場合、正常に終わる応答の最後に `done` を送る必要がある。送らないと毎回途中終了として表示される
26
+ - **新しいイベント種別**: SSE イベント型 `ChatEvent` に `tool_result`(サーバーが実行したツールの結果)を追加し、`tool_use` に任意の `executedOnServer` を追加した。`ChatEvent` を switch で網羅チェックしているホストは型の追従が要る
27
+ - `Message` に任意の `executedOnServer` を追加した。サーバーが実行したツールの結果を運ぶ `tool` メッセージに付き、`onMessagesChange` にも届く。次の発話からは履歴に含めない
28
+ - サーバー側の対応(印とツール結果の送出)が入った API と組み合わせて効果が出る。古い API と組み合わせた場合、サーバー側ツールの扱いはこれまでと同じで、途切れの表示だけが効く
29
+
30
+ ### Patch Changes
31
+
32
+ - 4fe7a03: 単発マイクの認識失敗(「聞き取れませんでした」等)のアナウンスが、スクリーンリーダー向けの live region に残り続けていた問題を修正した(issue #328)。失敗表示が消える 4 秒後、および継続音声モードの開始時に、画面の失敗表示とアナウンスをあわせて消す。
33
+
34
+ あわせて、`/lang` で言語を切り替えたときに、すでに消えた失敗表示が新しい言語で出直し、アナウンスも繰り返される問題を修正した。表示中の失敗は新しい言語の文言に変わり、失敗から 4 秒で消える。設定項目・公開 API に変更はない。
35
+
36
+ - 601e1ac: ページ観測(`observe`)が、ウィジェット自身のエラーまでホストのページのエラーとして AI に渡していた問題を修正した(issue #367)。チャットが 1 回失敗すると、以後の発話にその失敗が「ページの JS エラー」として添えられ、AI がホストに問題が無いのにエラーの話を始めていた。
37
+
38
+ ウィジェットのチャット失敗ログ・プラグインのエラーログ・ウィジェットが自分の API(チャット・会話・エラー報告)に送った通信の `4xx`/`5xx` を観測から除く。ホストが `onError` の中で同期的に出したログも、ウィジェットの失敗についてのものとして除く。ホストのページ自身のエラー・通信・ログはこれまでどおり AI に渡る。ブラウザのコンソールへの出力は変わらない。設定項目・公開 API に変更はない。
39
+
3
40
  ## 0.10.0
4
41
 
5
42
  **Bundle size**: Initial 115.5 KB gzip / 98.2 KB brotli · Total 259.6 KB gzip
package/README.ja.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![npm version](https://img.shields.io/npm/v/wecool-chat.svg)](https://www.npmjs.com/package/wecool-chat)
6
6
  [![npm downloads](https://img.shields.io/npm/dm/wecool-chat.svg)](https://www.npmjs.com/package/wecool-chat)
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
- [![initial bundle](https://img.shields.io/badge/initial%20bundle-115.5_KB_gzip-brightgreen)](https://www.npmjs.com/package/wecool-chat)
8
+ [![initial bundle](https://img.shields.io/badge/initial%20bundle-127.1_KB_gzip-brightgreen)](https://www.npmjs.com/package/wecool-chat)
9
9
 
10
10
  > 自然言語で UI を操作できる、どんなフレームワークでも使える LLM チャットウィジェット。
11
11
 
@@ -248,6 +248,8 @@ controller.clear();
248
248
  controller();
249
249
  ```
250
250
 
251
+ **このレイアウトでは会話のリセットはホストが担います。** メッセージ列を描くのはホスト側 UI なので、入力欄には「新しい会話を始める」ボタンを出しません(ウィジェットだけが会話を捨てると、画面の会話は残ったまま LLM の文脈だけが切れるため)。ホスト側 UI にリセットボタンを置き、`controller.clear()` とホスト側スレッドの消去を合わせて呼んでください。同じ理由で継続音声モードのトグルもこのレイアウトでは出しません(`voice: true` なら単発のマイク入力は使えます)。
252
+
251
253
  `narrateToolResults`(後述)と組み合わせると、tool 実行ごとに短い説明テキストを差し挟めるので「次に何をするか」がユーザーに見えやすくなります。
252
254
 
253
255
  ### Controller API(`initWecoolChat` の戻り値)
@@ -347,7 +349,7 @@ LLM は `description` を読んで「いつこのツールを使うか」を判
347
349
  `handler` には次のようなコードも書けます:
348
350
 
349
351
  - **API を呼び出して結果を返す** — `handler: async (args) => { ... }` のように `async` で書けば、`fetch` の結果を待ってから返せます
350
- - **エラーをユーザーに伝える** — `throw new Error("メッセージ")` で投げると `config.onError` が発火します。`return { ok: false, message: "..." }` で返すと LLM が結果を読み取り、ユーザーへ自然な日本語で説明します
352
+ - **エラーをユーザーに伝える** — `throw new Error("メッセージ")` で投げると、メッセージがツールのエラー結果(`{ error: "メッセージ" }`)として LLM に渡ります(`config.onError` は呼ばれません)。`return { ok: false, message: "..." }` で返した場合も同様に、LLM が結果を読み取り、ユーザーへ自然な日本語で説明します
351
353
 
352
354
  ### タイムアウト(toolTimeout)
353
355
 
@@ -626,6 +628,7 @@ initWecoolChat({
626
628
  - **既定で有効**。ウィジェットを使えば観測も付いてきます(追加フラグ不要)。
627
629
  - 背景情報は **LLM への送信本文にのみ** 添えられ、訪問者のチャット履歴には素の発話だけが表示されます。
628
630
  - 記録するのは失敗の **事実のみ**(メソッド/URL/ステータス、エラー名/メッセージ)。**フォーム入力値は一切記録しません。** URL・エラー文言は送信前に **redact**(token / API キー / メールアドレス / トークン様文字列をマスク)します。
631
+ - **ウィジェット自身のエラーは含めません**。チャットの失敗ログ、プラグインのエラーログ、ウィジェットが自分の API(チャット・会話・エラー報告)に送った通信の `4xx`/`5xx` は、ホストのページの状況ではないため観測しません(ブラウザのコンソールには従来どおり出ます)。`onError` の中で**同期的に**出した `console.error` も同じ扱いです(`onError` に届くのはウィジェット自身のチャットの失敗だけのため)。`await` の後や `setTimeout` の中など、非同期に出したログは観測されます。
629
632
  - 観測データは **wecool のサーバーへ送りません**。送信時に LLM へ一度渡るだけです(=設定した LLM プロバイダには渡ります)。
630
633
 
631
634
  ```tsx
@@ -1008,7 +1011,10 @@ for await (const event of client.chat({
1008
1011
  }
1009
1012
  ```
1010
1013
 
1011
- `ChatEvent` は次の 6 種類のイベントのいずれかです:`thinking` / `tool_use` / `text` / `text_delta` / `error` / `done`。
1014
+ `ChatEvent` は次の 8 種類のイベントのいずれかです:`thinking` / `tool_use` / `tool_result` / `text` / `text_delta` / `error` / `max_turns` / `done`。
1015
+
1016
+ - `tool_use` に `executedOnServer: true` が付いている呼び出しは、サーバー側ツール(現在時刻・Web 検索など)でサーバーが実行済みです。自前で実行せず、同じ `toolCallId` の `tool_result` で届く結果を使ってください。印の無い呼び出しだけを自分のツールで実行します
1017
+ - 正常に終わった応答は必ず `done` で閉じます。`done` も `error` も無いままストリームが閉じたら、応答が途中で途切れています(`<ChatWidget>` はこのとき code `RESPONSE_INCOMPLETE` のエラーを表示し、`onError` に渡します)
1012
1018
 
1013
1019
  > **個別 export コンポーネント (`ChatPanel` / `ChatHeader` / `ChatFooter` / `MessageList` / `FloatButton`) を直接使う場合**、`config.locale` の自動配布は行われません。ja 以外のロケールで使うときは、これらのコンポーネントを自前の Provider 配下に置くか、`<ChatWidget>` を経由してください。
1014
1020
 
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![npm version](https://img.shields.io/npm/v/wecool-chat.svg)](https://www.npmjs.com/package/wecool-chat)
6
6
  [![npm downloads](https://img.shields.io/npm/dm/wecool-chat.svg)](https://www.npmjs.com/package/wecool-chat)
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
- [![initial bundle](https://img.shields.io/badge/initial%20bundle-115.5_KB_gzip-brightgreen)](https://www.npmjs.com/package/wecool-chat)
8
+ [![initial bundle](https://img.shields.io/badge/initial%20bundle-127.1_KB_gzip-brightgreen)](https://www.npmjs.com/package/wecool-chat)
9
9
 
10
10
  > A drop-in LLM chat widget that lets users operate your UI in natural language — works with any framework.
11
11
 
@@ -258,6 +258,8 @@ controller.clear();
258
258
  controller(); // unmount
259
259
  ```
260
260
 
261
+ **Resetting the conversation is the host's job in this layout.** Because your UI renders the thread, the input dock has no "start a new conversation" button — if the widget discarded the conversation on its own, your thread would stay on screen while the model silently lost its context. Put a reset control in your own UI and call `controller.clear()` there, clearing your own thread at the same time. For the same reason, the continuous voice mode toggle is not shown in this layout (single-shot mic input still works with `voice: true`).
262
+
261
263
  This pairs nicely with `narrateToolResults` (see below) when you want the model to send a short acknowledgement after every tool call.
262
264
 
263
265
  ### Controller API (return value of `initWecoolChat`)
@@ -384,7 +386,7 @@ Writing a `description` for each property as well makes it less likely for the L
384
386
  You can also write code like the following inside `handler`:
385
387
 
386
388
  - **Call an API and return the result** — write `handler: async (args) => { ... }` to await `fetch` results before returning
387
- - **Surface errors to the user** — `throw new Error("message")` triggers `config.onError`. Returning `{ ok: false, message: "..." }` lets the LLM read the result and explain it back to the user in natural language
389
+ - **Surface errors to the user** — `throw new Error("message")` passes the message to the LLM as the tool's error result (`{ error: "message" }`); it does not trigger `config.onError`. Returning `{ ok: false, message: "..." }` likewise lets the LLM read the result and explain it back to the user in natural language
388
390
 
389
391
  ### Timeout (toolTimeout)
390
392
 
@@ -671,6 +673,12 @@ questions.
671
673
  - Only the **fact** of a failure is recorded (method/URL/status, error name/message). **Form
672
674
  input values are never recorded.** URLs and error text are **redacted** (tokens, API keys,
673
675
  email addresses, and token-like strings are masked) before being sent.
676
+ - **The widget's own failures are excluded.** Its chat failure logs, plugin error logs, and
677
+ `4xx`/`5xx` responses from its own API (chat, conversations, error reports) are not part of
678
+ the host page's state, so they are not observed (they still appear in the browser console).
679
+ `console.error` calls you make **synchronously inside `onError`** are treated the same way,
680
+ since `onError` only reports the widget's own chat failures. Logs written asynchronously
681
+ (after an `await`, in `setTimeout`, etc.) are still observed.
674
682
  - Observation data is **not sent to any wecool server** — it is passed to the LLM once, at
675
683
  send time, together with the visitor's message. Note this means the observed signals **are
676
684
  sent to your configured LLM provider** as part of the chat request.
@@ -1197,7 +1205,10 @@ for await (const event of client.chat({
1197
1205
  }
1198
1206
  ```
1199
1207
 
1200
- `ChatEvent` is one of 6 event types: `thinking` / `tool_use` / `text` / `text_delta` / `error` / `done`.
1208
+ `ChatEvent` is one of 8 event types: `thinking` / `tool_use` / `tool_result` / `text` / `text_delta` / `error` / `max_turns` / `done`.
1209
+
1210
+ - A `tool_use` with `executedOnServer: true` is a server-side tool (current time, web search, etc.) that the server has already run. Do not run it yourself; use the result delivered by the `tool_result` with the same `toolCallId`. Run only the calls without this flag with your own tools
1211
+ - A response that finishes normally always ends with `done`. If the stream closes with neither `done` nor `error`, the response was cut off (`<ChatWidget>` then shows an error with code `RESPONSE_INCOMPLETE` and passes it to `onError`)
1201
1212
 
1202
1213
  > **When using individually exported components (`ChatPanel` / `ChatHeader` / `ChatFooter` / `MessageList` / `FloatButton`) directly**, `config.locale` is not auto-distributed. To use them in non-default locales, either wrap them with your own provider or go through `<ChatWidget>`.
1203
1214
 
@@ -0,0 +1,63 @@
1
+ import { r as u } from "./rolldown-runtime-Csywlj8R.js";
2
+ import { i as l, r as p, t as d } from "./jsx-runtime-2MlY8uwR.js";
3
+ import { t as i } from "./createLucideIcon-Dc6H577p.js";
4
+ var o = {
5
+ name: "check",
6
+ size: 24,
7
+ node: [["path", {
8
+ d: "M20 6 9 17l-5-5",
9
+ key: "1gmf2c"
10
+ }]]
11
+ };
12
+ o.node;
13
+ var _ = i(o), s = {
14
+ name: "copy",
15
+ size: 24,
16
+ node: [["rect", {
17
+ width: "14",
18
+ height: "14",
19
+ x: "8",
20
+ y: "8",
21
+ rx: "2",
22
+ ry: "2",
23
+ key: "17jyea"
24
+ }], ["path", {
25
+ d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",
26
+ key: "zix9uf"
27
+ }]]
28
+ };
29
+ s.node;
30
+ var m = i(s), f = /!\[[^\]]*\]\(\s*data:[^)]*\)/gi, x = /!\[[^\]]*\]\(\s*data:[A-Za-z0-9+/=,;_\-.%\s]*/gi, w = (r) => {
31
+ let e = r.replace(f, "");
32
+ return e = e.replace(x, ""), e;
33
+ }, t = /* @__PURE__ */ u(l(), 1), v = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, y = /[\u200b\u200c\u200d\u2060\ufeff]/g, g = (r) => r.replace(/\r\n?/g, `
34
+ `).replace(v, "").replace(y, ""), C = 2e3, A = () => {
35
+ const [r, e] = (0, t.useState)(!1), a = (0, t.useRef)(null);
36
+ return (0, t.useEffect)(() => () => {
37
+ a.current !== null && window.clearTimeout(a.current);
38
+ }, []), {
39
+ copied: r,
40
+ copy: (0, t.useCallback)(async (n) => {
41
+ if (navigator.clipboard)
42
+ try {
43
+ await navigator.clipboard.writeText(g(n)), e(!0), a.current !== null && window.clearTimeout(a.current), a.current = window.setTimeout(() => {
44
+ e(!1), a.current = null;
45
+ }, C);
46
+ } catch {
47
+ }
48
+ }, [])
49
+ };
50
+ }, c = d();
51
+ function E({ copied: r }) {
52
+ const e = p(), a = r ? _ : m, n = r ? e.copiedLabel : e.copyLabel;
53
+ return /* @__PURE__ */ (0, c.jsxs)(c.Fragment, { children: [/* @__PURE__ */ (0, c.jsx)(a, {
54
+ className: "wecool-icon--xs",
55
+ "aria-hidden": "true"
56
+ }), /* @__PURE__ */ (0, c.jsx)("span", { children: n })] });
57
+ }
58
+ export {
59
+ _ as i,
60
+ A as n,
61
+ w as r,
62
+ E as t
63
+ };