@kitn.ai/ui 0.25.1 → 0.26.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 +5 -7
- package/dist/components/attachment-types.d.ts +46 -1
- package/dist/components/attachments.d.ts +31 -0
- package/dist/components/audio-visualizer/fit-scale.d.ts +50 -0
- package/dist/components/audio-visualizer/index.d.ts +15 -1
- package/dist/components/audio-visualizer/variant-bar.d.ts +24 -1
- package/dist/components/chat-thread.d.ts +3 -41
- package/dist/components/code-block.d.ts +22 -0
- package/dist/components/conversation-item.d.ts +54 -1
- package/dist/components/conversation-list.d.ts +65 -0
- package/dist/components/form.d.ts +42 -0
- package/dist/components/message.d.ts +7 -0
- package/dist/components/toast.d.ts +2 -1
- package/dist/components/voice-input.d.ts +8 -0
- package/dist/components/voice-output.d.ts +12 -1
- package/dist/components/workspace-shell.d.ts +87 -0
- package/dist/{create-tween-B5Y4Im8G.js → create-tween-BFT6c-Y8.js} +1 -1
- package/dist/{create-tween-4z1XYLkR.js → create-tween-CJNlzoaO.js} +1 -1
- package/dist/{create-tween-CUzOlaMS.js → create-tween-CQED4T0g.js} +1 -1
- package/dist/custom-elements.json +2931 -2572
- package/dist/diagnostics/hook.d.ts +81 -0
- package/dist/diagnostics/index.d.ts +7 -0
- package/dist/diagnostics/report-request.d.ts +61 -0
- package/dist/diagnostics.d.ts +5 -0
- package/dist/diagnostics.js +209 -0
- package/dist/elements/agent-card.js +1 -1
- package/dist/elements/artifact.js +1 -1
- package/dist/elements/attachments.js +1 -1
- package/dist/elements/audio-visualizer.js +1 -1
- package/dist/elements/autoloader.js +1 -1
- package/dist/elements/avatar.js +1 -1
- package/dist/elements/badge.js +1 -1
- package/dist/elements/button.js +1 -1
- package/dist/elements/card.js +1 -1
- package/dist/elements/cards.js +1 -1
- package/dist/elements/chain-of-thought.js +1 -1
- package/dist/elements/chat-scope-picker.js +1 -1
- package/dist/elements/chat-workspace.js +1 -1
- package/dist/elements/chat.js +1 -1
- package/dist/elements/checkpoint.js +1 -1
- package/dist/elements/choice.js +1 -1
- package/dist/elements/chunks/{Icon-b5A8hlHs.js → Icon--Y8vsFal.js} +1 -1
- package/dist/elements/chunks/action-icons-D9u3OzYW.js +1 -0
- package/dist/elements/chunks/arrow-left-CVh1TeN7.js +1 -0
- package/dist/elements/chunks/{artifact-BSuPYFHY.js → artifact-BkYcfIlZ.js} +1 -1
- package/dist/elements/chunks/attachments-DwfNlubq.js +1 -0
- package/dist/elements/chunks/audio-visualizer-D7lB6mvR.js +1 -0
- package/dist/elements/chunks/{badge-TIMiJFKc.js → badge-Q0-Cmwzz.js} +1 -1
- package/dist/elements/chunks/{button-B9okqG73.js → button-flUbeufF.js} +1 -1
- package/dist/elements/chunks/{card-renderer-CSoTL_e1.js → card-renderer-3Dyl-FpN.js} +1 -1
- package/dist/elements/chunks/check-B5kBPKeo.js +1 -0
- package/dist/elements/chunks/chevron-down-DZ1GS39h.js +1 -0
- package/dist/elements/chunks/chevron-right-CvP7OUd2.js +1 -0
- package/dist/elements/chunks/{choice-card-CGMc3kek.js → choice-card-D4QUIOWZ.js} +1 -1
- package/dist/elements/chunks/circle-CDf9g6MQ.js +1 -0
- package/dist/elements/chunks/circle-check-CA47Nqbz.js +1 -0
- package/dist/elements/chunks/{circle-x-mhH7pOK2.js → circle-x-CJ_HVbC8.js} +1 -1
- package/dist/elements/chunks/code-block-BdLiTitd.js +1 -0
- package/dist/elements/chunks/collapsible-BzbXpPzr.js +1 -0
- package/dist/elements/chunks/{composer-CZZmtYOT.js → composer-Byve-n8K.js} +2 -2
- package/dist/elements/chunks/{confirm-card-BWjf2-xo.js → confirm-card-B0flE3MN.js} +1 -1
- package/dist/elements/chunks/context-VLIL3sJ-.js +1 -0
- package/dist/elements/chunks/controllable-DTwTIlwp.js +1 -0
- package/dist/elements/chunks/conversation-item-BDztezOG.js +1 -0
- package/dist/elements/chunks/copy-Nf-kqxXH.js +1 -0
- package/dist/elements/chunks/{create-tween-CUrM6D_o.js → create-tween-c4Z8TDYz.js} +2 -2
- package/dist/elements/chunks/default-input-C2iLFq0b.js +1 -0
- package/dist/elements/chunks/define-wjHR1MkU.js +1 -0
- package/dist/elements/chunks/disclosure-CcNbyLy0.js +1 -0
- package/dist/elements/chunks/{download-DnCyWFJE.js → download-C4V7tBdb.js} +1 -1
- package/dist/elements/chunks/dropdown-BgWTthUx.js +1 -0
- package/dist/elements/chunks/{ellipsis-CVxqfsDZ.js → ellipsis-7gU33mL2.js} +1 -1
- package/dist/elements/chunks/embed-D3KewsIJ.js +1 -0
- package/dist/elements/chunks/{external-link-DG2sRdQL.js → external-link-CSOEsNlx.js} +1 -1
- package/dist/elements/chunks/{file-text-D0J9F6M7.js → file-text-D1G8khle.js} +1 -1
- package/dist/elements/chunks/{file-tree-yGWNK0Js.js → file-tree-zvB2i7P9.js} +1 -1
- package/dist/elements/chunks/{folder-NV1pi_ud.js → folder-WW2LGLid.js} +1 -1
- package/dist/elements/chunks/form-CQirdC4W.js +1 -0
- package/dist/elements/chunks/hover-card-CJJkfHTK.js +1 -0
- package/dist/elements/chunks/icon-Cfgmf4fa.js +1 -0
- package/dist/elements/chunks/{info-C8r5Q6cc.js → info-DX3YMOt6.js} +1 -1
- package/dist/elements/chunks/input-BtW9U6Sq.js +1 -0
- package/dist/elements/chunks/{kbd-OGJDUT-O.js → kbd-LGXwuT_V.js} +1 -1
- package/dist/elements/chunks/{link-BdsfLB7b.js → link-2My69BqT.js} +1 -1
- package/dist/elements/chunks/{link-preview-Cf5KOP-i.js → link-preview-OQ9IEq0f.js} +1 -1
- package/dist/elements/chunks/{loader-B5QzK_8_.js → loader-iOxc_Tu-.js} +1 -1
- package/dist/elements/chunks/{markdown-DbozyYqa.js → markdown-DgBFaGAz.js} +1 -1
- package/dist/elements/chunks/{message-DtXKPqiR.js → message-VMZohrXx.js} +1 -1
- package/dist/elements/chunks/message-circle-CpXMM-_n.js +1 -0
- package/dist/elements/chunks/message-square-DxcWtETQ.js +1 -0
- package/dist/elements/chunks/message-tZmV2A3p.js +1 -0
- package/dist/elements/chunks/{minimize-2-SegJ_oku.js → minimize-2-DPIUKTrT.js} +1 -1
- package/dist/elements/chunks/{model-switcher-D7JrFFHp.js → model-switcher-DsT8tFB0.js} +1 -1
- package/dist/elements/chunks/{overlay-CV7z2YuX.js → overlay-DuiwdXjm.js} +1 -1
- package/dist/elements/chunks/{paperclip-Bg0ITU3b.js → paperclip-CRZVp4z_.js} +1 -1
- package/dist/elements/chunks/{progress-bar-D1_rzt6N.js → progress-bar-DNy66e_E.js} +1 -1
- package/dist/elements/chunks/{prompt-suggestion-D5Sm8xF1.js → prompt-suggestion-Bn64Nl7L.js} +1 -1
- package/dist/elements/chunks/reasoning-Emn9N4-T.js +1 -0
- package/dist/elements/chunks/{resizable-Dpzjlvp4.js → resizable-D181b4fM.js} +1 -1
- package/dist/elements/chunks/{rotate-cw-DzVDJOA1.js → rotate-cw-CPWe37D9.js} +1 -1
- package/dist/elements/chunks/{scroll-area-93A1bbeG.js → scroll-area-ClZkZxIk.js} +1 -1
- package/dist/elements/chunks/scroll-button-DPE-t3x_.js +1 -0
- package/dist/elements/chunks/{separator-DH2r_ZSZ.js → separator-CeJHQqLW.js} +1 -1
- package/dist/elements/chunks/{settings-BFMOd6yB.js → settings-CqaHgJF9.js} +1 -1
- package/dist/elements/chunks/{settings-group-B3VZKIcz.js → settings-group-CjqjLCOn.js} +1 -1
- package/dist/elements/chunks/share-CyfnNEqp.js +1 -0
- package/dist/elements/chunks/{skeleton-N8BuWYmf.js → skeleton-D8akBnKS.js} +1 -1
- package/dist/elements/chunks/slots-DaNjX0rc.js +1 -0
- package/dist/elements/chunks/{source-w9V0NnBn.js → source-UWCvmVak.js} +1 -1
- package/dist/elements/chunks/{star-DHvACxtm.js → star-DoHFAikQ.js} +1 -1
- package/dist/elements/chunks/store-Cjq0qwYN.js +1 -0
- package/dist/elements/chunks/{tasks-card-lPxoodlA.js → tasks-card-CmZ5xh6v.js} +1 -1
- package/dist/elements/chunks/{text-shimmer-BY_rI3s5.js → text-shimmer-DYn09zrz.js} +1 -1
- package/dist/elements/chunks/textarea-skiGHURM.js +1 -0
- package/dist/elements/chunks/{thumbs-up-DQe0hvkZ.js → thumbs-up-DX2Ijk3H.js} +1 -1
- package/dist/elements/chunks/{toast-store-VUZZBhzH.js → toast-store-CFnQpThX.js} +1 -1
- package/dist/elements/chunks/{tool-C1YtxwPu.js → tool-DKQ2D1DP.js} +1 -1
- package/dist/elements/chunks/{tooltip-BqwnFWhn.js → tooltip-B0G99y8w.js} +1 -1
- package/dist/elements/chunks/{triangle-alert-B6or7F5u.js → triangle-alert-F9cyUEyy.js} +1 -1
- package/dist/elements/chunks/{use-card-resolution-DJg32jGH.js → use-card-resolution-DoA2f_EU.js} +1 -1
- package/dist/elements/chunks/{variant-aurora-QXTZPyST.js → variant-aurora-qt6Zct8M.js} +2 -2
- package/dist/elements/chunks/variant-custom-tJp22_BQ.js +1 -0
- package/dist/{variant-wave-BwzrHD1s.js → elements/chunks/variant-wave-CaQ5ti39.js} +2 -2
- package/dist/elements/chunks/x-B6UnOiLw.js +1 -0
- package/dist/elements/coachmark.js +1 -1
- package/dist/elements/code-block.js +1 -1
- package/dist/elements/command.js +1 -1
- package/dist/elements/compare.js +1 -1
- package/dist/elements/composer.js +1 -1
- package/dist/elements/confirm-card.js +1 -1
- package/dist/elements/context-meter.js +1 -1
- package/dist/elements/conversation-item.d.ts +1 -0
- package/dist/elements/conversation-item.js +1 -0
- package/dist/elements/conversation-list.js +1 -1
- package/dist/elements/default-input.d.ts +3 -3
- package/dist/elements/define.d.ts +27 -0
- package/dist/elements/diagnostic-events.d.ts +74 -0
- package/dist/elements/dialog.js +1 -1
- package/dist/elements/dock.d.ts +1 -0
- package/dist/elements/dock.js +149 -0
- package/dist/elements/dropdown.d.ts +1 -0
- package/dist/elements/dropdown.js +1 -0
- package/dist/elements/editable-label.js +1 -1
- package/dist/elements/element-diagnostics.d.ts +81 -0
- package/dist/elements/embed.js +1 -1
- package/dist/elements/empty.js +1 -1
- package/dist/elements/feedback-bar.js +1 -1
- package/dist/elements/file-tree.js +1 -1
- package/dist/elements/file-upload.js +1 -1
- package/dist/elements/form.js +1 -1
- package/dist/elements/hover-card.js +1 -1
- package/dist/elements/icon.js +1 -1
- package/dist/elements/image.js +1 -1
- package/dist/elements/input.js +1 -1
- package/dist/elements/kbd.js +1 -1
- package/dist/elements/link-preview.js +1 -1
- package/dist/elements/loader.js +1 -1
- package/dist/elements/markdown.js +1 -1
- package/dist/elements/menu.js +1 -1
- package/dist/elements/message-skills.js +1 -1
- package/dist/elements/message.js +1 -1
- package/dist/elements/model-switcher.js +1 -1
- package/dist/elements/nav.js +1 -1
- package/dist/elements/notice.js +1 -1
- package/dist/elements/pane-group.js +1 -1
- package/dist/elements/pane.js +1 -1
- package/dist/elements/popover.js +1 -1
- package/dist/elements/progress-bar.js +1 -1
- package/dist/elements/prompt-dock.js +1 -1
- package/dist/elements/prompt-input.js +1 -1
- package/dist/elements/prompt-suggestions.js +1 -1
- package/dist/elements/reasoning.js +1 -1
- package/dist/elements/register.d.ts +2 -0
- package/dist/elements/remote.js +1 -1
- package/dist/elements/resizable.js +1 -1
- package/dist/elements/response-stream.js +3 -3
- package/dist/elements/screen.js +1 -1
- package/dist/elements/scroll-area.js +1 -1
- package/dist/elements/scroll-button.js +1 -1
- package/dist/elements/search.js +1 -1
- package/dist/elements/segmented.js +1 -1
- package/dist/elements/separator.js +1 -1
- package/dist/elements/setting-item.js +1 -1
- package/dist/elements/settings-group.js +1 -1
- package/dist/elements/skeleton.js +1 -1
- package/dist/elements/slots.d.ts +35 -3
- package/dist/elements/source.js +1 -1
- package/dist/elements/status.js +1 -1
- package/dist/elements/switch.js +1 -1
- package/dist/elements/tabs.js +1 -1
- package/dist/elements/tasks.js +1 -1
- package/dist/elements/text-shimmer.js +1 -1
- package/dist/elements/thinking-bar.js +1 -1
- package/dist/elements/thread.js +1 -1
- package/dist/elements/toast.js +1 -1
- package/dist/elements/tool.js +1 -1
- package/dist/elements/tooltip.js +1 -1
- package/dist/elements/voice-input.js +1 -1
- package/dist/elements/voice-output.js +1 -1
- package/dist/elements.d.ts +232 -148
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5456 -4931
- package/dist/index.server.js +4142 -3669
- package/dist/kai-provider.es.js +40 -40
- package/dist/kai.es.js +1 -1
- package/dist/llms/llms-full.txt +184 -69
- package/dist/llms/llms.txt +3 -3
- package/dist/mcp.es.js +2669 -546
- package/dist/primitives/use-resize-observer.d.ts +23 -0
- package/dist/primitives/use-speech-recognition.d.ts +8 -0
- package/dist/primitives/use-text-stream.d.ts +5 -0
- package/dist/react/index.d.ts +115 -266
- package/dist/react.js +247 -221
- package/dist/register-impl-DpE7icIb.js +293 -0
- package/dist/schemas/index.d.ts +1 -1
- package/dist/schemas/tool-defs.d.ts +35 -0
- package/dist/schemas.js +403 -310
- package/dist/{solid-BMuDmFo_.js → solid-BtdqNZI7.js} +8435 -7394
- package/dist/{solid-CGYNdLRR.js → solid-CnavwBye.js} +5987 -5035
- package/dist/solid.d.ts +5 -0
- package/dist/solid.js +210 -203
- package/dist/solid.server.js +210 -203
- package/dist/state/index.d.ts +4 -0
- package/dist/state/persistence.d.ts +51 -0
- package/dist/state/stream.d.ts +50 -0
- package/dist/state/threads.d.ts +71 -0
- package/dist/state.js +269 -169
- package/dist/types.d.ts +4 -2
- package/dist/ui/dock.d.ts +109 -0
- package/dist/ui/hover-card.d.ts +44 -0
- package/dist/{variant-aurora-DwSOfraQ.js → variant-aurora-B8II3-I1.js} +27 -27
- package/dist/{variant-aurora-wKvAQ5wp.js → variant-aurora-CMNWOSJR.js} +28 -28
- package/dist/{variant-aurora-XEkPT0_z.js → variant-aurora-CcuDMWwQ.js} +2 -2
- package/dist/{variant-custom-eFIg2XWQ.js → variant-custom-BdvYC7af.js} +40 -40
- package/dist/{variant-custom-BhS9wIpU.js → variant-custom-C714mqKl.js} +65 -65
- package/dist/variant-custom-L16JLLZy.js +1 -0
- package/dist/{elements/chunks/variant-wave-DDCwhLas.js → variant-wave-2S4La2Ka.js} +2 -2
- package/dist/{variant-wave-CbVsmgwT.js → variant-wave-D7ruiA1W.js} +25 -25
- package/dist/{variant-wave-CUWGx9Bn.js → variant-wave-ecwykeyL.js} +21 -21
- package/dist/wire/chunk.d.ts +47 -0
- package/dist/wire/diagnostics.d.ts +575 -0
- package/dist/wire/encode-probe.d.ts +70 -0
- package/dist/wire/encode.d.ts +24 -0
- package/dist/wire/index.d.ts +2 -0
- package/dist/wire/sse.d.ts +10 -2
- package/dist/wire.js +917 -480
- package/frameworks/react/index.tsx +132 -93
- package/llms-full.txt +184 -69
- package/llms.txt +3 -3
- package/package.json +27 -7
- package/src/agent-tooling/archetypes.ts +41 -9
- package/src/agent-tooling/catalog/README.md +676 -0
- package/src/agent-tooling/catalog/catalog-types.ts +231 -0
- package/src/agent-tooling/catalog/fabrications.ts +96 -0
- package/src/agent-tooling/catalog/invariants.ts +284 -0
- package/src/agent-tooling/catalog/labs-titles.ts +114 -0
- package/src/agent-tooling/catalog/scenarios.ts +87 -0
- package/src/agent-tooling/catalog/surfaces.ts +275 -0
- package/src/agent-tooling/integrations/anthropic.ts +7 -1
- package/src/agent-tooling/integrations/cloudflare.ts +43 -2
- package/src/agent-tooling/integrations/langgraph.ts +7 -1
- package/src/agent-tooling/integrations/mastra.ts +7 -1
- package/src/agent-tooling/integrations/mock.ts +92 -17
- package/src/agent-tooling/integrations/ollama.ts +7 -1
- package/src/agent-tooling/integrations/openai.ts +7 -1
- package/src/agent-tooling/integrations/openrouter.ts +7 -1
- package/src/agent-tooling/integrations/pi.ts +56 -1
- package/src/agent-tooling/integrations/vercel-ai-sdk.ts +7 -1
- package/src/agent-tooling/mcp/css-raw.d.ts +12 -0
- package/src/agent-tooling/mcp/manifest.ts +100 -1
- package/src/agent-tooling/mcp/server.ts +61 -5
- package/src/agent-tooling/mcp/tools/reference.ts +440 -4
- package/src/agent-tooling/mcp/tools/scaffold.ts +1834 -307
- package/src/agent-tooling/mcp/tools/theme.ts +146 -30
- package/src/agent-tooling/mcp/validate-args.ts +141 -0
- package/src/agent-tooling/registry.ts +19 -7
- package/src/agent-tooling/route-emit.ts +26 -2
- package/src/components/attachment-types.ts +47 -1
- package/src/components/attachments.tsx +169 -22
- package/src/components/audio-visualizer/fit-scale.ts +112 -0
- package/src/components/audio-visualizer/index.tsx +80 -3
- package/src/components/audio-visualizer/variant-aurora.tsx +10 -4
- package/src/components/audio-visualizer/variant-bar.tsx +38 -6
- package/src/components/audio-visualizer/variant-custom.tsx +8 -2
- package/src/components/audio-visualizer/variant-grid.tsx +16 -11
- package/src/components/audio-visualizer/variant-radial.tsx +15 -10
- package/src/components/audio-visualizer/variant-wave.tsx +7 -2
- package/src/components/chat-container.tsx +4 -1
- package/src/components/chat-thread.tsx +36 -7
- package/src/components/code-block.tsx +79 -3
- package/src/components/composer.tsx +8 -1
- package/src/components/conversation-item.tsx +114 -4
- package/src/components/conversation-list.tsx +212 -12
- package/src/components/embed.tsx +4 -0
- package/src/components/form.tsx +41 -14
- package/src/components/message.tsx +75 -5
- package/src/components/response-stream.tsx +13 -7
- package/src/components/screen.tsx +5 -0
- package/src/components/scroll-button.tsx +7 -0
- package/src/components/toast.tsx +11 -5
- package/src/components/voice-input.tsx +35 -3
- package/src/components/voice-output.tsx +46 -6
- package/src/components/workspace-shell.tsx +285 -0
- package/src/diagnostics/hook.ts +352 -0
- package/src/diagnostics/index.ts +82 -0
- package/src/diagnostics/report-request.ts +296 -0
- package/src/elements/attachments.tsx +6 -7
- package/src/elements/audio-visualizer.tsx +48 -4
- package/src/elements/chat-workspace.tsx +159 -287
- package/src/elements/chat.tsx +12 -9
- package/src/elements/code-block.tsx +19 -1
- package/src/elements/command.tsx +4 -1
- package/src/elements/compiled.css +1 -1
- package/src/elements/conversation-item.tsx +80 -0
- package/src/elements/conversation-list.tsx +60 -11
- package/src/elements/default-input.tsx +5 -5
- package/src/elements/define.tsx +168 -8
- package/src/elements/diagnostic-events.ts +114 -0
- package/src/elements/dialog.tsx +47 -0
- package/src/elements/disclosure.ts +34 -12
- package/src/elements/dock.tsx +204 -0
- package/src/elements/dropdown.tsx +123 -0
- package/src/elements/element-diagnostics.ts +392 -0
- package/src/elements/element-manifest.json +12 -0
- package/src/elements/element-meta.json +672 -439
- package/src/elements/element-nonscalar.json +170 -0
- package/src/elements/element-types.d.ts +232 -148
- package/src/elements/menu.tsx +13 -0
- package/src/elements/prompt-dock.tsx +2 -1
- package/src/elements/prompt-input.tsx +8 -8
- package/src/elements/register-impl.ts +46 -0
- package/src/elements/register.ts +28 -0
- package/src/elements/resizable.tsx +52 -25
- package/src/elements/scroll-button.tsx +5 -0
- package/src/elements/slots.ts +107 -12
- package/src/elements/styles.css +30 -6
- package/src/elements/thinking-bar.tsx +16 -7
- package/src/elements/toast.tsx +3 -0
- package/src/elements/tool.tsx +26 -5
- package/src/elements/voice-input.tsx +11 -2
- package/src/elements/voice-output.tsx +16 -3
- package/src/index.ts +2 -0
- package/src/primitives/use-resize-observer.ts +33 -0
- package/src/primitives/use-speech-recognition.ts +12 -1
- package/src/primitives/use-stick-to-bottom.ts +34 -2
- package/src/primitives/use-text-stream.ts +33 -2
- package/src/remote/provider-runtime.ts +6 -3
- package/src/schemas/index.ts +1 -0
- package/src/schemas/tool-defs.ts +297 -6
- package/src/solid.ts +5 -0
- package/src/state/index.ts +12 -0
- package/src/state/persistence.ts +180 -0
- package/src/state/stream.ts +71 -4
- package/src/state/threads.ts +142 -0
- package/src/types.ts +4 -2
- package/src/ui/dialog.tsx +6 -0
- package/src/ui/dock.tsx +445 -0
- package/src/ui/dropdown.tsx +67 -23
- package/src/ui/hover-card.tsx +156 -6
- package/src/ui/input.tsx +29 -10
- package/src/ui/resizable.tsx +11 -0
- package/src/wire/chunk.ts +47 -0
- package/src/wire/consume.ts +185 -26
- package/src/wire/diagnostics.ts +727 -0
- package/src/wire/encode-probe.ts +214 -0
- package/src/wire/encode.ts +267 -14
- package/src/wire/formats/anthropic.ts +8 -1
- package/src/wire/formats/openai.ts +5 -0
- package/src/wire/index.ts +22 -0
- package/src/wire/read.ts +250 -6
- package/src/wire/sse.ts +16 -3
- package/dist/elements/chunks/action-icons-DW9muWrY.js +0 -1
- package/dist/elements/chunks/arrow-left-iJVnQmxA.js +0 -1
- package/dist/elements/chunks/attachments-CL6TaqIb.js +0 -1
- package/dist/elements/chunks/audio-visualizer-BuUqQmaO.js +0 -1
- package/dist/elements/chunks/chat-thread-DxoKaStk.js +0 -1
- package/dist/elements/chunks/check-MdLzbxrm.js +0 -1
- package/dist/elements/chunks/chevron-down-MK7IzDqe.js +0 -1
- package/dist/elements/chunks/chevron-right-C5jXhmtV.js +0 -1
- package/dist/elements/chunks/circle-BG7VkPep.js +0 -1
- package/dist/elements/chunks/circle-check-GqvO2UBs.js +0 -1
- package/dist/elements/chunks/code-block-ClhQO9RW.js +0 -1
- package/dist/elements/chunks/collapsible-DBcBkFPh.js +0 -1
- package/dist/elements/chunks/context-hKjNqiyQ.js +0 -1
- package/dist/elements/chunks/conversation-list-CsGJjSKG.js +0 -1
- package/dist/elements/chunks/default-input-B1Mem5wu.js +0 -1
- package/dist/elements/chunks/define-B_tXMYRm.js +0 -1
- package/dist/elements/chunks/disclosure-DAoYOKew.js +0 -1
- package/dist/elements/chunks/dropdown-CmNna5lT.js +0 -1
- package/dist/elements/chunks/embed-CjAD2jSi.js +0 -1
- package/dist/elements/chunks/form-Cp8Y00Wn.js +0 -1
- package/dist/elements/chunks/hover-card-6KtXpLwT.js +0 -1
- package/dist/elements/chunks/icon-97R8SR2p.js +0 -1
- package/dist/elements/chunks/input-DrseEjhp.js +0 -1
- package/dist/elements/chunks/message-CE4k-qaj.js +0 -1
- package/dist/elements/chunks/message-square-C9ovmtOo.js +0 -1
- package/dist/elements/chunks/reasoning-BrxQfpfI.js +0 -1
- package/dist/elements/chunks/scroll-button-CrTo7wm4.js +0 -1
- package/dist/elements/chunks/share-DgNbkJKY.js +0 -1
- package/dist/elements/chunks/slots-CIw9RlAe.js +0 -1
- package/dist/elements/chunks/store-HIPGhNz9.js +0 -1
- package/dist/elements/chunks/textarea-DPfuhswM.js +0 -1
- package/dist/elements/chunks/variant-custom-D5ZlmziF.js +0 -1
- package/dist/elements/chunks/video-Bb86fVYI.js +0 -1
- package/dist/elements/chunks/x-BOhjBeOd.js +0 -1
- package/dist/primitives/card-validate-generator.testlib.d.ts +0 -20
- package/dist/register-impl-DGmGzrEM.js +0 -145
- package/dist/variant-custom-MkTNTycd.js +0 -1
- package/src/primitives/card-validate-generator.testlib.ts +0 -38
package/src/wire/index.ts
CHANGED
|
@@ -52,6 +52,28 @@ export { anthropicMessagesFormat } from './formats/anthropic';
|
|
|
52
52
|
export { sseDataFrames, sseJson, readableToAsyncIterable } from './sse';
|
|
53
53
|
export type { ByteSource } from './sse';
|
|
54
54
|
|
|
55
|
+
// The diagnostic event stream: metadata about what the pipeline SAW.
|
|
56
|
+
//
|
|
57
|
+
// Only the subscription and the types are public. `emitWireDiagnostic`,
|
|
58
|
+
// `wireDiagnosticsActive` and `nextStreamId` stay internal on purpose -- they
|
|
59
|
+
// are the producer side, and a consumer that can forge events or reset the
|
|
60
|
+
// stream counter can make a panel lie about a stream that never happened.
|
|
61
|
+
export { subscribeWireDiagnostics } from './diagnostics';
|
|
62
|
+
export type {
|
|
63
|
+
AppRequestEvent,
|
|
64
|
+
EncodeAttachmentReport,
|
|
65
|
+
EncodeDroppedEvent,
|
|
66
|
+
EncodeRequestEvent,
|
|
67
|
+
WireCloseEvent,
|
|
68
|
+
WireDiagnosticBase,
|
|
69
|
+
WireDiagnosticEvent,
|
|
70
|
+
WireFailedEvent,
|
|
71
|
+
WireFrameEvent,
|
|
72
|
+
WireInterruptedEvent,
|
|
73
|
+
WireOpenEvent,
|
|
74
|
+
WirePartEvent,
|
|
75
|
+
} from './diagnostics';
|
|
76
|
+
|
|
55
77
|
export { normalizeStopReason } from './chunk';
|
|
56
78
|
export type {
|
|
57
79
|
AssistantStreamSink,
|
package/src/wire/read.ts
CHANGED
|
@@ -21,6 +21,85 @@ import type {
|
|
|
21
21
|
} from './chunk';
|
|
22
22
|
import { openaiChatFormat } from './formats/openai';
|
|
23
23
|
import { anthropicMessagesFormat } from './formats/anthropic';
|
|
24
|
+
import {
|
|
25
|
+
emitWireDiagnostic,
|
|
26
|
+
nextStreamId,
|
|
27
|
+
wireCorrelation,
|
|
28
|
+
wireDiagnosticsActive,
|
|
29
|
+
withPayload,
|
|
30
|
+
type WireCorrelation,
|
|
31
|
+
} from './diagnostics';
|
|
32
|
+
|
|
33
|
+
/** Byte length, not `String.length`: a multibyte frame is bigger than its
|
|
34
|
+
* character count and the number is meant to be comparable with what the socket
|
|
35
|
+
* carried.
|
|
36
|
+
*
|
|
37
|
+
* Built on first use and cached, never at module scope -- the same rule
|
|
38
|
+
* `sseJson` follows for its TextDecoder, so this module keeps importing cleanly
|
|
39
|
+
* in a runtime that lacks the global. Only ever reached from inside an
|
|
40
|
+
* active-diagnostics branch. */
|
|
41
|
+
let encoder: TextEncoder | undefined;
|
|
42
|
+
|
|
43
|
+
function byteLength(raw: string): number {
|
|
44
|
+
encoder ??= new TextEncoder();
|
|
45
|
+
return encoder.encode(raw).length;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** What the caller handed over, for `wire.open`. Duck-typed on the same terms as
|
|
49
|
+
* `isResponse`, because none of these globals is guaranteed to exist. */
|
|
50
|
+
function sourceKind(source: StreamSource): 'response' | 'stream' | 'iterable' {
|
|
51
|
+
if (isResponse(source)) return 'response';
|
|
52
|
+
return typeof (source as ReadableStream<Uint8Array>).getReader === 'function'
|
|
53
|
+
? 'stream'
|
|
54
|
+
: 'iterable';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The connection identity fields of `wire.open`, for a `Response` source.
|
|
59
|
+
*
|
|
60
|
+
* ORIGIN AND PATHNAME ONLY. The query string is dropped here and is reported
|
|
61
|
+
* nowhere, under no switch: `?api_key=sk-...` is a credential rather than
|
|
62
|
+
* conversation content, so it is not the payload key's business either. What a
|
|
63
|
+
* reader actually needs from it is one bit -- was there one -- and that is
|
|
64
|
+
* `hasQuery`.
|
|
65
|
+
*
|
|
66
|
+
* EVERY FIELD IS OMITTED RATHER THAN GUESSED. A `Response` constructed in a test
|
|
67
|
+
* or handed back by a service worker carries `url: ''`, and an empty string
|
|
68
|
+
* would read as "served from the origin root". Same for a missing content-type:
|
|
69
|
+
* absent means "the response did not say", which is a different fact from
|
|
70
|
+
* "it said nothing", and only one of them is true.
|
|
71
|
+
*
|
|
72
|
+
* Only ever called from inside an active-diagnostics branch.
|
|
73
|
+
*/
|
|
74
|
+
function connectionOf(res: Response): {
|
|
75
|
+
url?: string;
|
|
76
|
+
hasQuery?: boolean;
|
|
77
|
+
status?: number;
|
|
78
|
+
contentType?: string;
|
|
79
|
+
} {
|
|
80
|
+
const out: { url?: string; hasQuery?: boolean; status?: number; contentType?: string } = {};
|
|
81
|
+
|
|
82
|
+
if (typeof res.status === 'number') out.status = res.status;
|
|
83
|
+
|
|
84
|
+
// `headers` is duck-typed like the rest of this file: a Response-shaped object
|
|
85
|
+
// from a runtime we have not met may not carry a full Headers implementation.
|
|
86
|
+
const contentType = res.headers?.get?.('content-type');
|
|
87
|
+
if (typeof contentType === 'string' && contentType !== '') out.contentType = contentType;
|
|
88
|
+
|
|
89
|
+
const raw = typeof res.url === 'string' ? res.url : '';
|
|
90
|
+
if (raw !== '') {
|
|
91
|
+
try {
|
|
92
|
+
const parsed = new URL(raw);
|
|
93
|
+
out.url = `${parsed.origin}${parsed.pathname}`;
|
|
94
|
+
out.hasQuery = parsed.search !== '';
|
|
95
|
+
} catch {
|
|
96
|
+
// A relative or malformed URL. Reporting the raw string would leak the
|
|
97
|
+
// very query string this function exists to strip, so it is dropped whole.
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
24
103
|
|
|
25
104
|
export type StreamSource =
|
|
26
105
|
| Response
|
|
@@ -71,6 +150,21 @@ function providerMessage(body: unknown): string | undefined {
|
|
|
71
150
|
return typeof top === 'string' ? top : undefined;
|
|
72
151
|
}
|
|
73
152
|
|
|
153
|
+
/** The provider's error CODE, by the same walk `providerMessage` does for the
|
|
154
|
+
* message. The code is the half that can travel on a diagnostic event: it is a
|
|
155
|
+
* closed vocabulary a panel can key its own explanation off, while the message
|
|
156
|
+
* is free text some providers fill with echoed request content. */
|
|
157
|
+
function providerErrorCode(body: unknown): string | number | undefined {
|
|
158
|
+
if (typeof body !== 'object' || body === null) return undefined;
|
|
159
|
+
const error = (body as { error?: unknown }).error;
|
|
160
|
+
if (typeof error === 'object' && error !== null) {
|
|
161
|
+
const code = (error as { code?: unknown }).code;
|
|
162
|
+
if (typeof code === 'string' || typeof code === 'number') return code;
|
|
163
|
+
}
|
|
164
|
+
const top = (body as { code?: unknown }).code;
|
|
165
|
+
return typeof top === 'string' || typeof top === 'number' ? top : undefined;
|
|
166
|
+
}
|
|
167
|
+
|
|
74
168
|
function buildMessage(status: number, statusText: string, bodyText: string, body: unknown): string {
|
|
75
169
|
const head = `Model request failed: HTTP ${status}${statusText ? ` ${statusText}` : ''}`;
|
|
76
170
|
const provider = providerMessage(body);
|
|
@@ -79,6 +173,20 @@ function buildMessage(status: number, statusText: string, bodyText: string, body
|
|
|
79
173
|
return snippet ? `${head}: ${snippet}` : head;
|
|
80
174
|
}
|
|
81
175
|
|
|
176
|
+
/**
|
|
177
|
+
* The `name` of whatever was thrown, when there is one to read.
|
|
178
|
+
*
|
|
179
|
+
* Duck-typed rather than `instanceof Error`: a `DOMException` from a fetch
|
|
180
|
+
* abort, an error from another realm, and a host object that merely looks like
|
|
181
|
+
* an error all carry a usable `name`, and only the first of those is an `Error`
|
|
182
|
+
* in this realm. A bare string or number carries none, and that is reported as
|
|
183
|
+
* ABSENT -- filling in `'Error'` would invent a class the throw never claimed.
|
|
184
|
+
*/
|
|
185
|
+
function errorNameOf(err: unknown): string | undefined {
|
|
186
|
+
const name = (err as { name?: unknown } | null | undefined)?.name;
|
|
187
|
+
return typeof name === 'string' && name !== '' ? name : undefined;
|
|
188
|
+
}
|
|
189
|
+
|
|
82
190
|
/** Duck-typed, because `Response` may not be a global in every runtime the kit
|
|
83
191
|
* is imported into. A ReadableStream has no `ok`, and an async iterable that
|
|
84
192
|
* happens to have all three of these is not a shape any transport produces. */
|
|
@@ -103,9 +211,40 @@ async function wireErrorFrom(res: Response): Promise<WireError> {
|
|
|
103
211
|
return new WireError(res.status, res.statusText, bodyText, body);
|
|
104
212
|
}
|
|
105
213
|
|
|
106
|
-
async function toByteSource(
|
|
214
|
+
async function toByteSource(
|
|
215
|
+
source: StreamSource,
|
|
216
|
+
correlation?: WireCorrelation,
|
|
217
|
+
): Promise<ByteSource> {
|
|
107
218
|
if (!isResponse(source)) return source;
|
|
108
|
-
if (!source.ok)
|
|
219
|
+
if (!source.ok) {
|
|
220
|
+
const err = await wireErrorFrom(source);
|
|
221
|
+
if (wireDiagnosticsActive()) {
|
|
222
|
+
emitWireDiagnostic({
|
|
223
|
+
type: 'wire.failed',
|
|
224
|
+
t: Date.now(),
|
|
225
|
+
...correlation,
|
|
226
|
+
status: err.status,
|
|
227
|
+
statusText: err.statusText,
|
|
228
|
+
bodyBytes: byteLength(err.bodyText),
|
|
229
|
+
// `wireErrorFrom` leaves `body` undefined when the text was empty or did
|
|
230
|
+
// not parse, so this is exactly "the body was JSON".
|
|
231
|
+
bodyIsJson: err.body !== undefined,
|
|
232
|
+
// The code travels; `bodyText` and the provider's message do NOT.
|
|
233
|
+
...(providerErrorCode(err.body) !== undefined
|
|
234
|
+
? { providerCode: providerErrorCode(err.body) }
|
|
235
|
+
: {}),
|
|
236
|
+
// The message is the field that echoes request content back, which is
|
|
237
|
+
// precisely why it is here and not beside `providerCode`.
|
|
238
|
+
...withPayload(() => ({
|
|
239
|
+
bodyText: err.bodyText,
|
|
240
|
+
...(providerMessage(err.body) !== undefined
|
|
241
|
+
? { message: providerMessage(err.body) }
|
|
242
|
+
: {}),
|
|
243
|
+
})),
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
throw err;
|
|
247
|
+
}
|
|
109
248
|
if (!source.body) {
|
|
110
249
|
throw new Error(
|
|
111
250
|
'The model response has no body to stream. Check that the request set stream: true and that nothing between you and the provider buffered it.',
|
|
@@ -120,16 +259,121 @@ export async function readModelStream(
|
|
|
120
259
|
sink: AssistantStreamSink,
|
|
121
260
|
opts: ReadOptions,
|
|
122
261
|
): Promise<ModelTurn> {
|
|
123
|
-
|
|
262
|
+
// FIRST, before the source is even resolved: a failure inside `toByteSource`
|
|
263
|
+
// still needs an id to report itself under.
|
|
264
|
+
const streamId = opts.streamId ?? nextStreamId();
|
|
265
|
+
// Built once and spread onto every event this read emits, `wire.failed`
|
|
266
|
+
// included -- a read that dies before its first frame still belongs to the
|
|
267
|
+
// app's trace, and that is exactly the read someone is looking for.
|
|
268
|
+
const correlation = wireCorrelation(streamId, opts);
|
|
269
|
+
const bytes = await toByteSource(source, correlation);
|
|
270
|
+
if (wireDiagnosticsActive()) {
|
|
271
|
+
emitWireDiagnostic({
|
|
272
|
+
type: 'wire.open',
|
|
273
|
+
t: Date.now(),
|
|
274
|
+
...correlation,
|
|
275
|
+
format: opts.format.id,
|
|
276
|
+
source: sourceKind(source),
|
|
277
|
+
...(isResponse(source) ? connectionOf(source) : {}),
|
|
278
|
+
});
|
|
279
|
+
}
|
|
124
280
|
// Opened ONCE per stream, which is the whole point of the open()/push() shape:
|
|
125
281
|
// a stateful format (Anthropic) gets a fresh block map per call.
|
|
126
282
|
const reader = opts.format.open();
|
|
283
|
+
|
|
284
|
+
let frames = 0;
|
|
285
|
+
// Chunks YIELDED by this generator, counted here rather than read back off
|
|
286
|
+
// `consumeModelStream`: when the read dies, that function is mid-throw and
|
|
287
|
+
// has nothing to hand back.
|
|
288
|
+
let yielded = 0;
|
|
289
|
+
// The raw payload of the frame currently being handed over. `onRawFrame` fires
|
|
290
|
+
// immediately before `sseJson` yields, so this is always the frame the next
|
|
291
|
+
// loop iteration is about to push.
|
|
292
|
+
//
|
|
293
|
+
// ALWAYS INSTALLED, deliberately. Deciding this once at read entry meant a
|
|
294
|
+
// subscriber attaching mid-stream saw `bytes: 0` on every later frame -- a
|
|
295
|
+
// confident zero, and the forward-compat rule exists precisely so a consumer
|
|
296
|
+
// is never handed one. The capture is a reference stash and nothing else; the
|
|
297
|
+
// UTF-8 length is computed only inside the active-gated branch below, so with
|
|
298
|
+
// nobody listening the cost is one closure call and one assignment per frame.
|
|
299
|
+
let rawFrame = '';
|
|
300
|
+
const onRawFrame = (raw: string) => {
|
|
301
|
+
rawFrame = raw;
|
|
302
|
+
};
|
|
303
|
+
|
|
127
304
|
async function* chunks(): AsyncGenerator<ModelStreamChunk> {
|
|
128
|
-
for await (const frame of sseJson<unknown>(bytes)) {
|
|
129
|
-
|
|
305
|
+
for await (const frame of sseJson<unknown>(bytes, onRawFrame)) {
|
|
306
|
+
frames++;
|
|
307
|
+
const produced = reader.push(frame);
|
|
308
|
+
// Gated BEFORE the event object exists, and before the keys are walked.
|
|
309
|
+
if (wireDiagnosticsActive()) {
|
|
310
|
+
const fields = new Set<string>();
|
|
311
|
+
let model: string | undefined;
|
|
312
|
+
for (const chunk of produced) {
|
|
313
|
+
for (const key of Object.keys(chunk)) fields.add(key);
|
|
314
|
+
if (chunk.model) model = chunk.model;
|
|
315
|
+
}
|
|
316
|
+
emitWireDiagnostic({
|
|
317
|
+
type: 'wire.frame',
|
|
318
|
+
t: Date.now(),
|
|
319
|
+
...correlation,
|
|
320
|
+
seq: frames,
|
|
321
|
+
bytes: byteLength(rawFrame),
|
|
322
|
+
chunks: produced.length,
|
|
323
|
+
fields: [...fields],
|
|
324
|
+
...(model ? { model } : {}),
|
|
325
|
+
...withPayload(() => ({ raw: rawFrame })),
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
for (const chunk of produced) {
|
|
329
|
+
yielded++;
|
|
330
|
+
yield chunk;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
// `_frames` is INTERNAL and deliberately not on `ConsumeOptions`: it is read
|
|
335
|
+
// once, at the close event, and a public option would invite a caller to
|
|
336
|
+
// supply one. A direct `consumeModelStream` caller passes nothing and its
|
|
337
|
+
// `wire.close` correctly omits `frames` -- there were none.
|
|
338
|
+
//
|
|
339
|
+
// OBSERVE AND RETHROW. `wire.close` is emitted inside `consumeModelStream`, so
|
|
340
|
+
// a read that throws before reaching it ended with no terminal event at all --
|
|
341
|
+
// a stream a panel showed open forever. This is the terminal event for that
|
|
342
|
+
// case, and it is the ONLY thing this wrapper does: the error is not caught,
|
|
343
|
+
// not wrapped, not delayed and not swallowed. `return await` rather than a
|
|
344
|
+
// bare `return` is what puts the rejection inside this try at all.
|
|
345
|
+
//
|
|
346
|
+
// It covers a throw from anywhere under the read -- the byte source dying, the
|
|
347
|
+
// format reader, the host's own sink -- because from the outside all of them
|
|
348
|
+
// are the same fact: this read stopped and produced no turn.
|
|
349
|
+
try {
|
|
350
|
+
return await consumeModelStream(chunks(), sink, {
|
|
351
|
+
...opts,
|
|
352
|
+
streamId,
|
|
353
|
+
_frames: () => frames,
|
|
354
|
+
} as ConsumeOptions);
|
|
355
|
+
} catch (err) {
|
|
356
|
+
if (wireDiagnosticsActive()) {
|
|
357
|
+
const name = errorNameOf(err);
|
|
358
|
+
emitWireDiagnostic({
|
|
359
|
+
type: 'wire.interrupted',
|
|
360
|
+
t: Date.now(),
|
|
361
|
+
...correlation,
|
|
362
|
+
frames,
|
|
363
|
+
chunks: yielded,
|
|
364
|
+
// Only a self-identifying abort is called one. Guessing would turn "the
|
|
365
|
+
// provider dropped the connection" into "your user navigated away", and
|
|
366
|
+
// those two have opposite fixes.
|
|
367
|
+
reason: name === 'AbortError' ? 'abort' : 'error',
|
|
368
|
+
...(name !== undefined ? { errorName: name } : {}),
|
|
369
|
+
...withPayload(() => {
|
|
370
|
+
const message = (err as { message?: unknown } | null | undefined)?.message;
|
|
371
|
+
return typeof message === 'string' ? { message } : {};
|
|
372
|
+
}),
|
|
373
|
+
});
|
|
130
374
|
}
|
|
375
|
+
throw err;
|
|
131
376
|
}
|
|
132
|
-
return consumeModelStream(chunks(), sink, opts);
|
|
133
377
|
}
|
|
134
378
|
|
|
135
379
|
/** OpenAI chat-completions SSE. Also what all nine catalog integrations except
|
package/src/wire/sse.ts
CHANGED
|
@@ -122,8 +122,19 @@ export async function* sseDataFrames(source: ByteSource): AsyncGenerator<string>
|
|
|
122
122
|
* iteration, which is the only thing that makes `drained` mean what it says.
|
|
123
123
|
* In practice that costs exactly one more `read()`: a server that has sent
|
|
124
124
|
* `[DONE]` has finished the response body. Frames after the sentinel are
|
|
125
|
-
* dropped, so what a caller sees is unchanged.
|
|
126
|
-
|
|
125
|
+
* dropped, so what a caller sees is unchanged.
|
|
126
|
+
*
|
|
127
|
+
* `onRawFrame` is the diagnostics seam: it receives the raw `data:` payload
|
|
128
|
+
* STRING for each frame that parsed, immediately before that frame is yielded,
|
|
129
|
+
* because the payload is discarded here and its byte length cannot be recovered
|
|
130
|
+
* downstream. It is not called for `[DONE]`, for a keep-alive, or for a payload
|
|
131
|
+
* that failed to parse -- so a caller counting calls counts exactly the frames
|
|
132
|
+
* it will be handed. Default undefined: with no diagnostics subscriber nothing
|
|
133
|
+
* passes one in and this is a dead branch. */
|
|
134
|
+
export async function* sseJson<T>(
|
|
135
|
+
source: ByteSource,
|
|
136
|
+
onRawFrame?: (raw: string) => void,
|
|
137
|
+
): AsyncGenerator<T> {
|
|
127
138
|
let done = false;
|
|
128
139
|
for await (const payload of sseDataFrames(source)) {
|
|
129
140
|
if (done) continue; // drain the rest of the body; yield nothing more
|
|
@@ -132,7 +143,9 @@ export async function* sseJson<T>(source: ByteSource): AsyncGenerator<T> {
|
|
|
132
143
|
continue;
|
|
133
144
|
}
|
|
134
145
|
try {
|
|
135
|
-
|
|
146
|
+
const frame = JSON.parse(payload) as T;
|
|
147
|
+
onRawFrame?.(payload);
|
|
148
|
+
yield frame;
|
|
136
149
|
} catch {
|
|
137
150
|
// a keep-alive or a provider's stray line: ignore rather than throw
|
|
138
151
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as a}from"./Icon-b5A8hlHs.js";import{c as o,m as r}from"./define-B_tXMYRm.js";import{f as t,b as i,s,p,c as m}from"./share-DgNbkJKY.js";import{c as k}from"./check-MdLzbxrm.js";import{d}from"./download-DnCyWFJE.js";import{e as y}from"./ellipsis-CVxqfsDZ.js";import{l as n}from"./link-BdsfLB7b.js";import{s as c}from"./star-DHvACxtm.js";import{a as l,t as h}from"./thumbs-up-DQe0hvkZ.js";import{x as f}from"./x-BOhjBeOd.js";var v=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],M=e=>o(a,r(e,{name:"RefreshCw",iconNode:v})),u=M,x=[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]],g=e=>o(a,r(e,{name:"Reply",iconNode:x})),N=g,w=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],L=e=>o(a,r(e,{name:"Trash2",iconNode:w})),R=L,b=[["polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5",key:"16drj5"}],["path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07",key:"ltjumu"}],["path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14",key:"1kegas"}]],j=e=>o(a,r(e,{name:"Volume2",iconNode:b})),C=j;const H={copy:m,like:h,dislike:l,regenerate:u,edit:p,share:s,bookmark:i,download:d,link:n,trash:R,check:k,x:f,star:c,flag:t,reply:N,more:y,"volume-2":C};function V(e){if(e)return H[e]}const D={copy:"Copy",like:"Like",dislike:"Dislike",regenerate:"Regenerate",edit:"Edit"};export{D as B,V as a};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as o}from"./Icon-b5A8hlHs.js";import{c as m,m as r}from"./define-B_tXMYRm.js";var e=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],t=a=>m(o,r(a,{name:"ArrowLeft",iconNode:e})),p=t;export{p as a};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as n,m,s as h,q as p,i as u,S as w,j as R,t as g,z as C,A as I,a as k,d as y}from"./define-B_tXMYRm.js";import{c as d}from"./cn-CU7UAWzk.js";import{B as D}from"./button-B9okqG73.js";import{H as M,a as P,b as N}from"./hover-card-6KtXpLwT.js";import{x as S}from"./x-BOhjBeOd.js";import{f as q}from"./file-text-D0J9F6M7.js";import{p as B,g as E,i as H}from"./paperclip-Bg0ITU3b.js";import{I as V}from"./Icon-b5A8hlHs.js";import{v as F}from"./video-Bb86fVYI.js";var G=[["circle",{cx:"8",cy:"18",r:"4",key:"1fc0mg"}],["path",{d:"M12 18V2l7 4",key:"g04rme"}]],J=r=>n(V,m(r,{name:"Music2",iconNode:G})),K=J,b=g("<div>"),L=g('<img class="size-full object-cover"height=96 width=96>'),O=g('<img class="size-full rounded object-cover"height=20 width=20>'),Q=g('<video class="size-full object-cover"muted>'),U=g('<span class="text-muted-foreground text-caption block truncate">'),X=g('<div><span class="block truncate">'),Y=g("<span class=sr-only>");const _={audio:K,document:q,image:H,source:E,unknown:B,video:F},z=r=>{if(r.type==="source-document")return"source";const t=r.mediaType??"";return t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":t.startsWith("application/")||t.startsWith("text/")?"document":"unknown"},A=r=>{if(r.type==="source-document")return r.title||r.filename||"Source";const t=z(r);return r.filename||(t==="image"?"Image":"Attachment")},T=C(),W=C(),$=()=>I(T)??{variant:"grid"},j=()=>{const r=I(W);if(!r)throw new Error("Attachment components must be used within <Attachment>");return r};function Z(r){const[t,i]=h(r,["variant","class","children"]),e=()=>t.variant??"grid";return n(T.Provider,{value:{get variant(){return e()}},get children(){var a=b();return p(a,m({get class(){return d("flex items-start",e()==="list"?"flex-col gap-2":"flex-wrap gap-2",e()==="grid"&&"w-fit",t.class)}},i),!1,!0),u(a,()=>t.children),a}})}function ee(r){const[t,i]=h(r,["data","onRemove","class","children"]),e=$(),a=()=>z(t.data);return n(W.Provider,{value:{get data(){return t.data},get mediaCategory(){return a()},get onRemove(){return t.onRemove},get variant(){return e.variant}},get children(){var o=b();return p(o,m({get class(){return d("group relative",e.variant==="grid"&&"size-24 overflow-hidden rounded-lg",e.variant==="inline"&&["flex h-8 cursor-pointer select-none items-center gap-1.5","rounded-md bg-surface-strong px-1.5 text-foreground","font-medium text-sm transition-all","hover:bg-muted"],e.variant==="list"&&["flex w-full items-center gap-3 rounded-lg bg-surface p-3 text-foreground","hover:bg-muted/50"],t.class)}},i),!1,!0),u(o,()=>t.children),o}})}function re(r){const[t,i]=h(r,["fallbackIcon","class"]),e=j(),a=()=>e.variant==="inline"?"size-3":"size-4",o=c=>n(c,{get class(){return d(a(),"text-muted-foreground")}}),x=()=>{if(e.mediaCategory==="image"&&e.data.type==="file"&&e.data.url)return e.variant==="grid"?(()=>{var l=L();return k(s=>{var v=e.data.filename||"Image",f=e.data.url;return v!==s.e&&y(l,"alt",s.e=v),f!==s.t&&y(l,"src",s.t=f),s},{e:void 0,t:void 0}),l})():(()=>{var l=O();return k(s=>{var v=e.data.filename||"Image",f=e.data.url;return v!==s.e&&y(l,"alt",s.e=v),f!==s.t&&y(l,"src",s.t=f),s},{e:void 0,t:void 0}),l})();if(e.mediaCategory==="video"&&e.data.type==="file"&&e.data.url)return(()=>{var l=Q();return k(()=>y(l,"src",e.data.url)),l})();const c=_[e.mediaCategory];return t.fallbackIcon??o(c)};return(()=>{var c=b();return p(c,m({get class(){return d("flex shrink-0 items-center justify-center overflow-hidden",e.variant==="grid"&&"size-full bg-muted",e.variant==="inline"&&"size-5 rounded bg-background",e.variant==="list"&&"size-12 rounded bg-muted",t.class)}},i),!1,!0),u(c,x),c})()}function te(r){const[t,i]=h(r,["showMediaType","class"]),e=j(),a=()=>A(e.data);return n(w,{get when(){return e.variant!=="grid"},get children(){var o=X(),x=o.firstChild;return p(o,m({get class(){return d("min-w-0 flex-1",t.class)}},i),!1,!0),u(x,a),u(o,n(w,{get when(){return R(()=>!!(t.showMediaType&&e.variant==="list"))()&&e.data.mediaType},get children(){var c=U();return u(c,()=>e.data.mediaType),c}}),null),o}})}function ae(r){const t=j(),i=e=>{var a;e.stopPropagation(),(a=t.onRemove)==null||a.call(t)};return n(w,{get when(){return t.onRemove},get children(){return n(D,{get"aria-label"(){return r.label??"Remove"},get class(){return d(t.variant==="grid"&&["absolute top-2 right-2 size-6 rounded-full p-0","bg-background/80 backdrop-blur-sm","opacity-0 transition-opacity group-hover:opacity-100","hover:bg-background","[&>svg]:size-3"],t.variant==="inline"&&["size-5 rounded p-0","opacity-0 transition-opacity group-hover:opacity-100","[&>svg]:size-2.5"],t.variant==="list"&&["size-8 shrink-0 rounded p-0","[&>svg]:size-4"],r.class)},onClick:i,type:"button",variant:"ghost",get children(){return[R(()=>r.children??n(S,{})),(()=>{var e=Y();return u(e,()=>r.label??"Remove"),e})()]}})}})}function ne(r){return n(M,{get openDelay(){return r.openDelay??0},get closeDelay(){return r.closeDelay??0},get children(){return r.children}})}function ie(r){return n(P,{get class(){return r.class},get children(){return r.children}})}function se(r){return n(N,{get class(){return d("w-auto p-2",r.class)},get children(){return r.children}})}function oe(r){const[t,i]=h(r,["class","children"]);return(()=>{var e=b();return p(e,m({get class(){return d("flex items-center justify-center p-4 text-muted-foreground text-sm",t.class)}},i),!1,!0),u(e,()=>t.children??"No attachments"),e})()}export{Z as A,ee as a,ne as b,ie as c,re as d,te as e,se as f,A as g,z as h,ae as i,oe as j};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{g as z,k as W,h as V,l as ut,i as L,c as M,a as C,d as w,b as E,n as A,I as j,p as B,t as F,q as dt,m as D,M as U,S as ht,j as gt,r as ft,f as mt}from"./define-B_tXMYRm.js";import{c as q}from"./cn-CU7UAWzk.js";const vt=-100,pt=-10;function bt(t){if(t===-1/0)return 0;const e=Math.max(vt,Math.min(pt,t));return Math.sqrt(1-e*-1/100)}function xt(t,e,n,r){const a=t.slice(Math.max(0,n),Math.max(0,r)),s=a.length,c=[];for(let i=0;i<e;i++){const l=Math.floor(i*s/e),h=Math.floor((i+1)*s/e);if(h<=l){c.push(0);continue}let g=0;for(let u=l;u<h;u++)g+=bt(a[u]);c.push(g/(h-l))}return c}function yt(t){if(t.length===0)return 0;let e=0;for(let n=0;n<t.length;n++){const r=t[n];e+=r*r}return Math.sqrt(e/t.length)/255}function Y(t,e){if(t.length===e)return t;if(t.length>e)return t.slice(0,e);const n=t[t.length-1]??0;return[...t,...new Array(e-t.length).fill(n)]}function kt(t,e){const n=(e-1)/2,r=new Array(e);for(let a=0;a<e;a++){const s=Math.floor(Math.abs(a-n));r[a]=t[Math.min(s,t.length-1)]??0}return r}function Mt(t,e){const n=new Array(e);for(let r=0;r<e;r++){const a=Math.min(r,e-r);n[r]=t[Math.min(a,t.length-1)]??0}return n}const wt={bands:5,loPass:100,hiPass:200,updateInterval:32},Q={fftSize:2048,smoothingTimeConstant:.8},I={fftSize:512,smoothingTimeConstant:.55,minDecibels:-100,maxDecibels:-80};function R(t){return typeof t=="function"?t():t}let G;function At(){if(!(typeof AudioContext>"u"))return G??(G=new AudioContext),G}const X=new WeakMap,Z=new WeakMap;function zt(t){return"tagName"in t}function Ct(t){if(t.state!=="suspended")return()=>{};if(typeof document>"u")return()=>{};const e=()=>{t.resume().catch(()=>{})},n=["pointerdown","keydown","touchstart"];return n.forEach(r=>document.addEventListener(r,e,{once:!0,passive:!0})),()=>n.forEach(r=>document.removeEventListener(r,e))}function qt(t,e={}){const n={...wt,...e},[r,a]=z(new Array(R(n.bands)).fill(0)),[s,c]=z(0);return W(()=>{const i=t(),l=R(n.bands);if(a(new Array(l).fill(0)),c(0),!i)return;const h=At();if(!h||typeof requestAnimationFrame>"u"||typeof cancelAnimationFrame>"u")return;const g=cancelAnimationFrame.bind(globalThis),u=Ct(h);let o;if(zt(i)){const b=i;let k=X.get(b);k||(k=h.createMediaElementSource(b),k.connect(h.destination),X.set(b,k)),o=k}else{let b=Z.get(i);b||(b=h.createMediaStreamSource(i),Z.set(i,b)),o=b}const f=h.createAnalyser();f.fftSize=Q.fftSize,f.smoothingTimeConstant=Q.smoothingTimeConstant;const m=h.createAnalyser();m.fftSize=I.fftSize,m.smoothingTimeConstant=I.smoothingTimeConstant,m.minDecibels=I.minDecibels,m.maxDecibels=I.maxDecibels,o.connect(f),o.connect(m);const v=new Float32Array(f.frequencyBinCount),d=new Uint8Array(m.frequencyBinCount);let p=0,x=0;const y=b=>{b-x>=n.updateInterval&&(f.getFloatFrequencyData(v),m.getByteFrequencyData(d),a(xt(v,l,n.loPass,n.hiPass)),c(yt(d)),x=b),p=requestAnimationFrame(y)};p=requestAnimationFrame(y),V(()=>{g(p),u(),f.disconnect(),m.disconnect(),o.disconnect(f),o.disconnect(m)})}),{bands:r,volume:s}}const $t=["idle","connecting","listening","thinking","speaking","disconnected"],Et={failed:"disconnected",initializing:"connecting","pre-connect-buffering":"connecting"};function Ft(t){return t?$t.includes(t)?t:Et[t]??"idle":"idle"}function Dt(t,e){switch(t){case"connecting":{const n=[];for(let r=0;r<e;r++)n.push([r,e-1-r]);return n.length?n:[[]]}case"listening":case"thinking":return[[Math.floor(e/2)],[-1]];case"speaking":return[Array.from({length:e},(n,r)=>r)];case"disconnected":return[[]];default:return[[]]}}function Nt(t,e){switch(t){case"connecting":return 2e3/Math.max(1,e);case"listening":return 500;case"thinking":return 150;default:return 1e3}}function St(t,e,n){const r=[],a=Math.floor(e/2),s=Math.floor(t/2),c={x:Math.max(0,a-n),y:Math.max(0,s-n)},i={x:Math.min(e-1,a+n),y:Math.min(t-1,s+n)};for(let l=c.x;l<=i.x;l++)r.push({x:l,y:c.y});for(let l=c.y+1;l<=i.y;l++)r.push({x:i.x,y:l});for(let l=i.x-1;l>=c.x;l--)r.push({x:l,y:i.y});for(let l=i.y-1;l>c.y;l--)r.push({x:c.x,y:l});return r}function Tt(t,e,n,r){const a={x:Math.floor(n/2),y:Math.floor(e/2)};switch(t){case"connecting":{const s=Math.floor(Math.max(e,n)/2),c=r!==void 0?Math.min(r,s):s,i=St(e,n,c);return i.length?i:[a]}case"listening":{const s={x:-1,y:-1};return[a,s,s,s,s,s,s,s,s]}case"thinking":{const s=Math.floor(e/2),c=[];for(let i=0;i<n;i++)c.push({x:i,y:s});for(let i=n-1;i>=0;i--)c.push({x:i,y:s});return c.length?c:[a]}case"disconnected":return[a];default:return[a]}}function _(t,e){const n=(r,a)=>{for(;a!==0;){const s=a;a=r%a,r=s}return r};for(let r=e;r>=1;r--)if(n(t,r)===r)return r;return 1}function Wt(t){const e=t>8?t/_(t,4):_(t,2),n=Math.max(1,Math.floor(e)),r=Math.floor(t/n);return Array.from({length:n},(a,s)=>Array.from({length:r},(c,i)=>i*n+s))}function Vt(t,e){switch(t){case"connecting":{const n=Math.floor(e/2),r=[];for(let a=0;a<e;a++)r.push([a,(a+n)%e]);return r.length?r:[[]]}case"listening":case"thinking":{const n=Wt(e);return n.length?n:[[]]}case"speaking":return[Array.from({length:e},(n,r)=>r)];case"disconnected":return[[]];default:return[[]]}}function Lt(t){switch(t){case"connecting":case"listening":return 500;case"thinking":return 1/0;default:return 1e3}}function Pt(t){switch(t){case"listening":return{intensity:[.5,.8],speed:2.5};case"thinking":return{intensity:[.25,.5],speed:4};case"connecting":return{intensity:[.25,.5],speed:6};case"speaking":return{intensity:.3,speed:2.5};case"disconnected":return{intensity:.3,speed:.5};default:return{intensity:.3,speed:1}}}const P=5,H=.025,J=10;function It(t){switch(t){case"listening":return{speed:P,amplitude:H,frequency:J,opacity:[1,.3],pulseDuration:.75};case"thinking":case"connecting":return{speed:P*4,amplitude:H/4,frequency:J*4,opacity:[1,.3],pulseDuration:.4};case"speaking":case"idle":return{speed:P*2,amplitude:H,frequency:J,opacity:1,pulseDuration:0};case"disconnected":return{speed:P,amplitude:0,frequency:0,opacity:1,pulseDuration:0};default:return{speed:P,amplitude:0,frequency:0,opacity:1,pulseDuration:0}}}function K(t){const[e,n]=z(0),r=ut(()=>t());return W(()=>{const a=r();if(n(0),!Number.isFinite(a)||a<=0||typeof requestAnimationFrame>"u"||typeof cancelAnimationFrame>"u")return;const s=cancelAnimationFrame.bind(globalThis);let c=0,i=performance.now();const l=h=>{h-i>=a&&(n(g=>g+1),i=h),c=requestAnimationFrame(l)};c=requestAnimationFrame(l),V(()=>s(c))}),e}const O={icon:24,sm:56,md:112,lg:224,xl:448},jt={icon:2,sm:4,md:8,lg:16,xl:32},tt={icon:4,sm:8,md:16,lg:32,xl:64},et={icon:2,sm:4,md:8,lg:12,xl:16},Bt={icon:2,sm:4,md:8,lg:12,xl:16},Ut={icon:6,sm:16,md:32,lg:64,xl:128};function nt(t){return t==="icon"||t==="sm"?3:5}function rt(t){return t==="icon"||t==="sm"?12:24}function at(t){return t==="icon"?3:5}var it=F("<div>");function ot(t){const e=()=>t.barCount??nt(t.size),n=K(()=>t.frozen?1/0:Nt(t.state,e())),r=()=>Dt(t.state,e()),a=()=>r()[n()%r().length]??[],s=()=>t.state==="speaking"?Y(t.bands,e()):new Array(e()).fill(0);return(()=>{var c=it();return L(c,M(j,{get each(){return s()},children:(i,l)=>{var h;const g={index:l,highlighted:()=>a().includes(l),value:()=>i()};return((h=t.children)==null?void 0:h.call(t,g))??(()=>{var u=it();return C(o=>{var f=g.highlighted()?"bar highlighted":"bar",m=g.index,v=g.highlighted(),d=q("rounded-full bg-current/10","data-[kai-highlighted=true]:bg-current"),p=`${tt[t.size]}px`,x=`${tt[t.size]}px`,y=`${i()*100}%`,b=t.frozen?"none":"height 100ms ease-linear, background-color 250ms ease-linear";return f!==o.e&&w(u,"part",o.e=f),m!==o.t&&w(u,"data-kai-index",o.t=m),v!==o.a&&w(u,"data-kai-highlighted",o.a=v),d!==o.o&&E(u,o.o=d),p!==o.i&&A(u,"width",o.i=p),x!==o.n&&A(u,"min-height",o.n=x),y!==o.s&&A(u,"height",o.s=y),b!==o.h&&A(u,"transition",o.h=b),o},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),u})()}})),C(i=>{var l=t.state,h=q("relative flex items-center justify-center",t.class),g={height:`${O[t.size]}px`,gap:`${jt[t.size]}px`,...t.color?{color:t.color}:{}};return l!==i.e&&w(c,"data-kai-state",i.e=l),h!==i.t&&E(c,i.t=h),i.a=B(c,g,i.a),i},{e:void 0,t:void 0,a:void 0}),c})()}var st=F("<div>");const Yt=.65,Gt=.02;function Ht(t){const e=()=>t.count??at(t.size),n=()=>e(),r=()=>t.interval??100,a=()=>Array.from({length:e()*n()},(u,o)=>o),s=K(()=>t.frozen||t.state==="speaking"?1/0:r()),c=()=>Tt(t.state,e(),n(),t.spread),i=()=>c()[s()%c().length]??{x:-1,y:-1},l=()=>t.state==="speaking"?Y(t.bands,n()):new Array(n()).fill(0);function h(u){if(t.state==="speaking"){const o=Math.floor(u/n()),f=Math.floor(e()/2),m=Math.abs(f-o)/(f+1)*Yt,v=Math.max(m,Gt);return(l()[u%n()]??0)>=v}return t.state==="idle"||t.state==="disconnected"?!1:i().x===u%n()&&i().y===Math.floor(u/n())}function g(u){return t.state==="speaking"?"150ms":`${r()/(h(u)?1e3:100)}s`}return(()=>{var u=st();return L(u,M(j,{get each(){return a()},children:(o,f)=>{var m;const v={index:f,highlighted:()=>h(f),value:()=>l()[f%n()]??0};return((m=t.children)==null?void 0:m.call(t,v))??(()=>{var d=st();return C(p=>{var x=v.highlighted()?"cell highlighted":"cell",y=v.index,b=v.highlighted(),k=q("place-self-center rounded-full bg-current/10 transition-all ease-out","data-[kai-highlighted=true]:bg-current"),N=`${et[t.size]}px`,S=`${et[t.size]}px`,T=g(f);return x!==p.e&&w(d,"part",p.e=x),y!==p.t&&w(d,"data-kai-index",p.t=y),b!==p.a&&w(d,"data-kai-highlighted",p.a=b),k!==p.o&&E(d,p.o=k),N!==p.i&&A(d,"width",p.i=N),S!==p.n&&A(d,"height",p.n=S),T!==p.s&&A(d,"transition-duration",p.s=T),p},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),d})()}})),C(o=>{var f=t.state,m=q("grid",t.class),v={"grid-template-columns":`repeat(${n()}, 1fr)`,gap:`${Bt[t.size]}px`,...t.color?{color:t.color}:{}};return f!==o.e&&w(u,"data-kai-state",o.e=f),m!==o.t&&E(u,o.t=m),o.a=B(u,v,o.a),o},{e:void 0,t:void 0,a:void 0}),u})()}var Jt=F("<div style=aspect-ratio:1>"),Kt=F('<div data-kai-spoke class="absolute top-1/2 left-1/2 h-1 w-1 -translate-x-1/2 -translate-y-1/2"style=transform-origin:center>'),Ot=F("<div>");function Qt(t){const e=()=>Math.max(1,t.barCount??rt(t.size)),n=()=>t.radius??Ut[t.size];e()%4!==0&&console.warn(`<kai-audio-visualizer variant="radial">: barCount ${e()} is not divisible by 4. The ring will look asymmetric.`);const r=()=>n()*Math.PI/e(),a=K(()=>t.frozen?1/0:Lt(t.state)),s=()=>Vt(t.state,e()),c=()=>t.state==="thinking"?Array.from({length:e()},(h,g)=>g):s()[a()%s().length]??[],i=()=>t.state==="speaking"?Y(t.bands,e()):new Array(e()).fill(0),l=()=>t.state==="thinking"&&!t.frozen;return(()=>{var h=Jt();return L(h,M(j,{get each(){return i()},children:(g,u)=>{const o={index:u,highlighted:()=>c().includes(u),value:()=>g()};return(()=>{var f=Kt();return L(f,()=>{var m;return((m=t.children)==null?void 0:m.call(t,o))??(()=>{var v=Ot();return C(d=>{var p=o.highlighted()?"bar highlighted":"bar",x=o.index,y=o.highlighted(),b=q("origin-bottom rounded-full bg-current/10","data-[kai-highlighted=true]:bg-current"),k=`${r()}px`,N=`${r()}px`,S=`${r()*10*g()}px`,T=t.frozen?"none":"height 100ms ease-linear, background-color 150ms ease-linear";return p!==d.e&&w(v,"part",d.e=p),x!==d.t&&w(v,"data-kai-index",d.t=x),y!==d.a&&w(v,"data-kai-highlighted",d.a=y),b!==d.o&&E(v,d.o=b),k!==d.i&&A(v,"width",d.i=k),N!==d.n&&A(v,"min-height",d.n=N),S!==d.s&&A(v,"height",d.s=S),T!==d.h&&A(v,"transition",d.h=T),d},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),v})()}),C(m=>A(f,"transform",`rotate(${u/e()*Math.PI*2}rad) translateY(${n()}px)`)),f})()}})),C(g=>{var u=t.state,o=q("relative flex items-center justify-center",l()&&"animate-spin",t.class),f={height:`${O[t.size]}px`,...l()?{"animation-duration":"5s"}:{},...t.color?{color:t.color}:{}};return u!==g.e&&w(h,"data-kai-state",g.e=u),o!==g.t&&E(h,g.t=o),g.a=B(h,f,g.a),g},{e:void 0,t:void 0,a:void 0}),h})()}var Rt=F("<div>");const Xt=["bar","grid","radial","wave","aurora","custom"],Zt={aura:"aurora"};function _t(t){return t?Xt.includes(t)?t:Zt[t]??"bar":"bar"}function te(){const[t,e]=z(!1);return W(()=>{var n;if(typeof matchMedia!="function")return;const r=matchMedia("(prefers-reduced-motion: reduce)");e(r.matches);const a=s=>e(s.matches);(n=r.addEventListener)==null||n.call(r,"change",a),V(()=>{var s;return(s=r.removeEventListener)==null?void 0:s.call(r,"change",a)})}),t}function ee(t){const[e,n]=z(!1);return W(()=>{var r;if(typeof matchMedia!="function")return;const a=matchMedia("(prefers-color-scheme: dark)");n(a.matches);const s=c=>n(c.matches);(r=a.addEventListener)==null||r.call(a,"change",s),V(()=>{var c;return(c=a.removeEventListener)==null?void 0:c.call(a,"change",s)})}),()=>{const r=t()??"auto";return r==="dark"||r==="auto"&&e()}}const ct={wave:()=>import("./variant-wave-DDCwhLas.js"),aurora:()=>import("./variant-aurora-QXTZPyST.js"),custom:()=>import("./variant-custom-D5ZlmziF.js")};function ne(t){const e=()=>_t(t.variant),n=()=>t.size??"md",r=()=>Ft(t.state),a=te(),s=ee(()=>t.theme),c=()=>e()in ct,i=()=>e()==="grid"?t.count??at(n()):e()==="radial"?t.barCount??rt(n()):t.barCount??nt(n()),l=qt(()=>t.bands?void 0:t.stream??t.audioElement,{bands:()=>Math.ceil(i()/2)}),h=()=>t.bands?t.bands:e()==="radial"?Mt(l.bands(),i()):kt(l.bands(),i()),g=()=>{if(!t.bands)return l.volume();if(t.bands.length===0)return 0;let x=0;for(const y of t.bands)x+=y*y;return Math.sqrt(x/t.bands.length)},[u,o]=z(),[f,m]=z(!1);W(()=>{const x=e(),y=ct[x];if(o(void 0),m(!1),!y)return;let b=!1;y().then(k=>{b||o(()=>k.default)}).catch(k=>{b||console.warn(`<kai-audio-visualizer variant="${x}">: failed to load the shader chunk, falling back to bars.`,k)}),V(()=>{b=!0})});const v=()=>({state:r(),size:n(),frozen:a(),color:t.color}),d=()=>({...v(),children:t.children}),p=()=>t.label?{role:"img","aria-label":t.label}:{"aria-hidden":"true"};return(()=>{var x=Rt();return dt(x,D({get class(){return q("inline-flex",t.class)}},p),!1,!0),L(x,M(ft,{get fallback(){return M(ot,D(d,{get bands(){return h()},get barCount(){return t.barCount}}))},get children(){return[M(U,{get when(){return e()==="grid"},get children(){return M(Ht,D(d,{get bands(){return h()},get count(){return t.count},get spread(){return t.spread},get interval(){return t.interval}}))}}),M(U,{get when(){return e()==="radial"},get children(){return M(Qt,D(d,{get bands(){return h()},get barCount(){return t.barCount},get radius(){return t.radius}}))}}),M(U,{get when(){return c()},get children(){return M(ht,{get when(){return gt(()=>!f())()&&u()},get fallback(){return M(ot,D(d,{get bands(){return h()},get barCount(){return t.barCount}}))},children:y=>{const b=y();return M(b,D(v,{get bands(){return h()},get volume(){return g()},get complexity(){return t.complexity},get shader(){return t.shader},get dark(){return s()},get animateWhenNotVisible(){return t.animateWhenNotVisible},onUnavailable:()=>m(!0)}))}})}})]}})),x})()}function $(t){if(t==null||t==="")return;const e=Number(t);return Number.isFinite(e)?e:void 0}function lt(t,e){var n;const r=((n=e?.dark)==null?void 0:n.call(e))??!1,a=e!=null&&e.flag?e.flag("animateWhenNotVisible"):t.animateWhenNotVisible===!0;return M(ne,{get variant(){return t.variant},get state(){return t.state},get size(){return t.size},get barCount(){return $(t.barCount)},get count(){return $(t.count)},get radius(){return $(t.radius)},get spread(){return $(t.spread)},get interval(){return $(t.interval)},get color(){return t.color},get complexity(){return $(t.complexity)},get label(){return t.label},get stream(){return t.stream},get audioElement(){return t.audioElement},get bands(){return t.bands},get shader(){return t.shader},animateWhenNotVisible:a,theme:r?"dark":"light"})}mt("kai-audio-visualizer",{variant:"bar",state:"idle",size:"md",barCount:void 0,count:void 0,radius:void 0,spread:void 0,interval:void 0,color:void 0,complexity:void 0,label:void 0,stream:void 0,audioElement:void 0,bands:void 0,shader:void 0,animateWhenNotVisible:void 0},lt);export{lt as A,O as C,$ as n,Pt as s,It as w};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{y as D,l as E,g as M,k as U,o as G,c as r,v as J,i,S as u,u as g,j as K,F as L,a as _,b as A,C as N,t as d}from"./define-B_tXMYRm.js";import{s as O,n as P}from"./composer-CZZmtYOT.js";import{C as Q,a as W,b as X,S as Y}from"./scroll-button-CrTo7wm4.js";import{M as Z,a as j,b as ee}from"./message-CE4k-qaj.js";import{b as te}from"./message-DtXKPqiR.js";import{M as re}from"./model-switcher-D7JrFFHp.js";import{C as ne,a as ae,b as le,c as se,d as oe,e as ie,f as ce,g as ue}from"./context-hKjNqiyQ.js";import{D as de}from"./default-input-B1Mem5wu.js";var ge=d('<aside part=sidebar class="flex w-64 shrink-0 flex-col overflow-hidden border-r border-border"><slot name=sidebar>'),he=d("<header part=header class=shrink-0><slot name=header>"),me=d("<slot name=empty>"),ve=d('<div class="absolute bottom-4 left-1/2 flex w-full max-w-3xl -translate-x-1/2 justify-center px-5">'),fe=d('<div class="shrink-0 px-4"><div class="mx-auto flex max-w-3xl items-center gap-2 pb-2"><slot name=composer-actions>'),xe=d("<slot name=composer>"),pe=d('<div part=footer class="shrink-0 px-4 pb-3"><div class="mx-auto max-w-3xl text-center text-xs text-muted-foreground"><slot name=footer>'),be=d('<div><div class="flex h-full min-w-0 flex-1 flex-col"><div class="relative flex-1 overflow-hidden"></div><div class="shrink-0 px-4 pb-4"><div class="mx-auto max-w-3xl">'),we=d('<div class="text-sm font-semibold text-foreground">'),ke=d("<div class=space-y-1.5>"),Ce=d('<header part=header-bar class="flex h-14 shrink-0 items-center justify-between border-b border-border px-5"><div class="flex items-center gap-2"><slot name=header-start></slot></div><div class="flex items-center gap-2"><slot name=header-end>'),Se=d("<div>");function Te(e){const R=D(),k=()=>e.actionsReveal==="hover"?"hover":"always",V=E(()=>e.messages.map(n=>n.id));let h;const p=te({emit:n=>{var a;return(a=e.onMessageAction)==null?void 0:a.call(e,n)},target:()=>h}),[F,x]=M(e.value??""),[b,w]=M([]),C=()=>typeof e.value=="string"?e.value:F();U(()=>{const n=e.value;n!=null&&typeof n!="string"&&x(n)});const S=n=>{var a;x(n),(a=e.onValueChange)==null||a.call(e,n)},T=()=>{w([]),e.value===void 0&&x("")},y=()=>{var n;(n=e.onSubmit)==null||n.call(e,{value:O(P(C())),attachments:b()}),T()},I=n=>{var a,c;(e.suggestionMode??"submit")==="fill"?(S(n),(a=e.onSuggestionClick)==null||a.call(e,n)):((c=e.onSubmit)==null||c.call(e,{value:n,attachments:b()}),T())},H=()=>!!(e.chatTitle||e.models||e.context||e.headerStart||e.headerEnd),q=()=>e.persistSuggestions||e.messages.length===0?e.suggestions:void 0,z=()=>e.scrollButton!==!1;return G(()=>{var n;(n=e.controllerRef)==null||n.call(e,{focus:a=>{var c;return(c=h?.querySelector('[contenteditable]:not([contenteditable="false"]), textarea'))==null?void 0:c.focus(a)},clear:()=>{var a;x(""),w([]),(a=e.onValueChange)==null||a.call(e,"")},send:()=>y(),scrollToBottom:a=>{const c=h?.querySelector(".overflow-y-auto");c?.scrollTo({top:c.scrollHeight,behavior:a??"smooth"})}})}),r(N,{get proseSize(){return e.proseSize},get codeTheme(){return e.codeTheme},get codeHighlight(){return e.codeHighlight!==!1},get portalMount(){return R.portalMount()},get children(){var n=be(),a=n.firstChild,c=a.firstChild,$=c.nextSibling,B=$.firstChild;return J(t=>h=t,n),i(n,r(u,{get when(){return e.sidebar},get children(){var t=ge(),o=t.firstChild;return o._$owner=g(),t}}),a),i(a,r(u,{get when(){return e.headerFull},get fallback(){return r(u,{get when(){return H()},get children(){var t=Ce(),o=t.firstChild,l=o.firstChild,m=o.nextSibling,v=m.firstChild;return l._$owner=g(),i(o,r(u,{get when(){return e.chatTitle},get children(){var s=we();return i(s,()=>e.chatTitle),s}}),null),i(m,r(u,{get when(){return e.models},get children(){return r(re,{get models(){return e.models},get currentModelId(){var s;return e.currentModel??((s=e.models[0])==null?void 0:s.id)??""},onModelChange:s=>{var f;return(f=e.onModelChange)==null?void 0:f.call(e,s)}})}}),v),i(m,r(u,{get when(){return e.context},get children(){return r(ne,{get usedTokens(){return e.context.usedTokens},get maxTokens(){return e.context.maxTokens},get inputTokens(){return e.context.inputTokens},get outputTokens(){return e.context.outputTokens},get estimatedCost(){return e.context.estimatedCost},get children(){return[r(ae,{}),r(le,{get children(){return[r(se,{}),r(oe,{get children(){var s=ke();return i(s,r(ie,{}),null),i(s,r(ce,{}),null),s}}),r(ue,{})]}})]}})}}),v),v._$owner=g(),t}})},get children(){var t=he(),o=t.firstChild;return o._$owner=g(),t}}),c),i(c,r(Q,{class:"h-full px-4 py-3",get children(){return[r(W,{class:"mx-auto w-full max-w-3xl space-y-4",get children(){return[r(u,{get when(){return K(()=>!!e.empty)()&&e.messages.length===0},get children(){var t=me();return t._$owner=g(),t}}),r(L,{get each(){return V()},children:(t,o)=>r(u,{get when(){return e.messages[o()]},children:l=>{const m=r(Z,{get parts(){return l().parts},get cardTypes(){return e.cardTypes},get cardSchemas(){return e.cardSchemas},get isUser(){return l().role==="user"},get markdown(){return l().role==="assistant"},get actions(){return l().actions},get actionsReveal(){return k()},get activeFeedback(){return p.resolveFeedback(l())},get copied(){return p.isCopied(l().id)},onAction:s=>p.handleAction(l(),s)}),v=()=>k()==="hover"?"group ":"";return r(u,{get when(){return l().avatar},get fallback(){return r(j,{get role(){return l().role},get class(){return`${v()}${l().role==="user"?"flex-col items-end":"flex-col items-start"}`},children:m})},children:s=>r(j,{get role(){return l().role},get class(){return v()},get children(){return[r(ee,{get src(){return s().src??""},get alt(){return s().alt??""},get fallback(){return s().fallback}}),(()=>{var f=Se();return i(f,m),_(()=>A(f,`flex min-w-0 flex-1 flex-col ${l().role==="user"?"items-end":"items-start"}`)),f})()]}})})}})}),r(X,{})]}}),r(u,{get when(){return z()},get children(){var t=ve();return i(t,r(Y,{class:"shadow-sm"})),t}})]}})),i(a,r(u,{get when(){return e.composerActions},get children(){var t=fe(),o=t.firstChild,l=o.firstChild;return l._$owner=g(),t}}),$),i(B,r(u,{get when(){return e.composer},get fallback(){return r(de,{get value(){return C()},get placeholder(){return e.placeholder},get loading(){return e.loading===!0},get suggestions(){return q()},get attachments(){return b()},get accept(){return e.accept},get onAttachmentsRejected(){return e.onAttachmentsRejected},get search(){return e.search===!0},get voice(){return e.voice===!0},get triggers(){return e.triggers},get kindIcons(){return e.kindIcons},onValueChange:S,onSubmit:y,onSuggestionClick:I,onAttachmentsChange:t=>{var o;w(t),(o=e.onAttachmentsChange)==null||o.call(e,t)},onSearch:()=>{var t;return(t=e.onSearch)==null?void 0:t.call(e)},onVoice:()=>{var t;return(t=e.onVoice)==null?void 0:t.call(e)}})},get children(){var t=xe();return t._$owner=g(),t}})),i(a,r(u,{get when(){return e.footer},get children(){var t=pe(),o=t.firstChild,l=o.firstChild;return l._$owner=g(),t}}),null),_(()=>A(n,`flex h-full bg-background ${e.class??""}`)),n}})}export{Te as C};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as m}from"./Icon-b5A8hlHs.js";import{c as o,m as r}from"./define-B_tXMYRm.js";var c=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],e=a=>o(m,r(a,{name:"Check",iconNode:c})),f=e;export{f as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as r}from"./Icon-b5A8hlHs.js";import{c as a,m}from"./define-B_tXMYRm.js";var e=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],n=o=>a(r,m(o,{name:"ChevronDown",iconNode:e})),p=n;export{p as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as o}from"./Icon-b5A8hlHs.js";import{c as a,m as r}from"./define-B_tXMYRm.js";var t=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],e=m=>a(o,r(m,{name:"ChevronRight",iconNode:t})),h=e;export{h as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as c}from"./Icon-b5A8hlHs.js";import{c as m,m as o}from"./define-B_tXMYRm.js";var a=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],e=r=>m(c,o(r,{name:"Circle",iconNode:a})),i=e;export{i as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as c}from"./Icon-b5A8hlHs.js";import{c as r,m as a}from"./define-B_tXMYRm.js";var e=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],o=m=>r(c,a(m,{name:"CircleCheck",iconNode:e})),i=o;export{i as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as m,q as c,m as o,i as g,y as H,G as T,c as L,S as z,t as l}from"./define-B_tXMYRm.js";import{c as h}from"./cn-CU7UAWzk.js";const E={bash:()=>import("./bash-InADTalH.js"),javascript:()=>import("./javascript-C25yR2R2.js"),typescript:()=>import("./typescript-RycA9KXf.js"),tsx:()=>import("./tsx-B8rCNbgL.js"),html:()=>import("./html-CPZ3oZQ7.js"),css:()=>import("./css-M7EaDHN_.js"),json:()=>import("./json-DxJze_jm.js"),vue:()=>import("./vue-BmIZj4XD.js"),svelte:()=>import("./svelte--5p79yCD.js")},G={"github-dark-dimmed":()=>import("./github-dark-dimmed-DUshB20C.js"),"github-light":()=>import("./github-light-JYsPkUQd.js")},J={js:"javascript",ts:"typescript",jsx:"tsx",sh:"bash",shell:"bash"},f="github-dark-dimmed";let M={...E},P={...G},R={...J},u=null;const x=new Set,b=new Set;function $(){return u||(u=(async()=>{const[{createHighlighterCore:t},{createJavaScriptRegexEngine:e}]=await Promise.all([import("./core-AYMC6_lb.js"),import("./engine-javascript-vq0WuIJl.js")]);return t({themes:[],langs:[],engine:e()})})()),u}function v(t){return R[t]??t}async function q(t,e){const a=v(e);if(x.has(a))return!0;const r=M[a];return r?(await t.loadLanguage(r()),x.add(a),!0):!1}async function w(t,e){if(b.has(e))return!0;const a=P[e];return a?(await t.loadTheme(a()),b.add(e),!0):!1}function A(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function i(t){return`<pre><code>${A(t)}</code></pre>`}async function B(t,e,a){if(!t)return i(t);try{const r=await $();if(!await q(r,e))return i(t);const s=await w(r,a)?a:await w(r,f)?f:null;return s?r.codeToHtml(t,{lang:v(e),theme:s}):i(t)}catch{return i(t)}}var D=l("<div>"),F=l("<div tabindex=0>"),K=l("<div tabindex=0><pre><code>");function N(t){const[e,a]=m(t,["children","class"]);return(()=>{var r=D();return c(r,o({get class(){return h("not-prose flex w-full flex-col overflow-clip border","border-border bg-card text-card-foreground","rounded-[var(--kai-code-radius,0.75rem)]",e.class)}},a),!1,!0),g(r,()=>e.children),r})()}function U(t){const[e,a]=m(t,["code","language","theme","class"]),r=H(),s=()=>e.language??"tsx",y=()=>e.theme??r.codeTheme(),j=()=>r.codeHighlight(),[d]=T(()=>j()?{code:e.code,lang:s(),theme:y()}:null,n=>B(n.code,n.lang,n.theme)),S=()=>{switch(r.proseSize()){case"xs":return"text-[11px]";case"sm":return"text-[13px]";case"base":return"text-sm";case"lg":return"text-base"}},p=()=>h("w-full overflow-x-auto [&>pre]:px-4 [&>pre]:py-4",S(),e.class);return L(z,{get when(){return d()},get fallback(){return(()=>{var n=K(),k=n.firstChild,C=k.firstChild;return c(n,o({get class(){return p()}},a),!1,!0),g(C,()=>e.code),n})()},get children(){var n=F();return c(n,o({get class(){return p()},get innerHTML(){return d()}},a),!1,!1),n}})}export{N as C,U as a};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as c,g as k,w as I,c as y,q as p,m as u,i as v,j as h,a as R,N as q,b as z,t as g,z as A,A as E}from"./define-B_tXMYRm.js";import{c as C}from"./cn-CU7UAWzk.js";var N=g("<div>"),P=g("<button>"),j=g("<div><div>");const w=A(),m=()=>{const o=E(w);if(!o)throw new Error("Collapsible parts must be used within <Collapsible>");return o};function B(o){var n;const[e,l]=c(o,["open","defaultOpen","onOpenChange","disabled","controllerRef","children","class"]),[r,a]=k(e.defaultOpen??!1),s=()=>e.open!==void 0,t=()=>s()?!!e.open:r(),i=()=>!!e.disabled,f=d=>{var b;t()!==d&&(s()||a(d),(b=e.onOpenChange)==null||b.call(e,d))},x=()=>{i()||f(!t())};(n=e.controllerRef)==null||n.call(e,{open:t,setOpen:f});const O=I();return y(w.Provider,{value:{open:t,toggle:x,contentId:O,disabled:i},get children(){var d=N();return p(d,u({get class(){return e.class}},l,{get"data-expanded"(){return t()?"":void 0},get"data-closed"(){return t()?void 0:""},get"data-state"(){return t()?"open":"closed"}}),!1,!0),v(d,()=>e.children),d}})}function S(o){const n=m(),[e,l]=c(o,["children","class","as","onClick"]),r=()=>({type:"button","aria-expanded":n.open(),"aria-controls":n.contentId,disabled:n.disabled()||void 0,"data-expanded":n.open()?"":void 0,"data-closed":n.open()?void 0:"","data-state":n.open()?"open":"closed",onClick:a=>{n.disabled()||(typeof e.onClick=="function"&&e.onClick(a),n.toggle())},class:e.class,...l});return h(()=>h(()=>!!e.as)()?e.as(r()):(()=>{var a=P();return p(a,u(r),!1,!0),v(a,()=>e.children),a})())}function _(o){const n=m(),[e,l]=c(o,["children","class"]);return(()=>{var r=j(),a=r.firstChild;return p(r,u(l,{get id(){return n.contentId},get"data-expanded"(){return n.open()?"":void 0},get"data-closed"(){return n.open()?void 0:""},get class(){return C("grid transition-[grid-template-rows] duration-200 ease-out",n.open()?"grid-rows-[1fr]":"grid-rows-[0fr]")}}),!1,!0),v(a,()=>e.children),R(s=>{var t=!n.open(),i=C("overflow-hidden",e.class);return t!==s.e&&q(r,"inert",s.e=t),i!==s.t&&z(a,s.t=i),s},{e:void 0,t:void 0}),r})()}export{B as C,S as a,_ as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{l as o,c as n,S as a,i as s,a as d,b as f,z as N,A as P,t as u,d as j,j as B}from"./define-B_tXMYRm.js";import{H as M,a as $,b as z}from"./hover-card-6KtXpLwT.js";import{c as h}from"./cn-CU7UAWzk.js";import{B as A}from"./button-B9okqG73.js";import{P as E}from"./progress-bar-D1_rzt6N.js";var H=u('<svg aria-label="Model context usage"height=20 role=img viewBox="0 0 24 24"width=20 style=color:currentcolor><circle cx=12 cy=12 fill=none opacity=0.25 r=10 stroke=currentColor stroke-width=2></circle><circle cx=12 cy=12 fill=none opacity=0.7 r=10 stroke=currentColor stroke-linecap=round stroke-width=2 style=transform:rotate(-90deg);transform-origin:center>'),O=u('<span class="font-medium text-muted-foreground">'),R=u('<div class="flex items-center justify-between gap-3 text-xs"><p></p><p class="font-mono text-muted-foreground"> / '),q=u("<div class=space-y-2>"),T=u("<div>"),G=u("<span class=text-muted-foreground>Total cost"),S=u("<span>"),J=u("<div><span class=text-muted-foreground>Input"),K=u("<div><span class=text-muted-foreground>Output"),L=u("<div><span class=text-muted-foreground>Reasoning"),Q=u("<div><span class=text-muted-foreground>Cache");const V=10,v=.7,b=.9;function W(e,t=v,r=b){return e>r?"danger":e>t?"warn":"ok"}const I=N();function g(){const e=P(I);if(!e)throw new Error("Context components must be used within Context");return e}const y=new Intl.NumberFormat("en-US",{notation:"compact"}),D=new Intl.NumberFormat("en-US",{maximumFractionDigits:1,style:"percent"}),_=new Intl.NumberFormat("en-US",{currency:"USD",style:"currency"});function X(e){const t=o(()=>({usedTokens:e.usedTokens,maxTokens:e.maxTokens,inputTokens:e.inputTokens,outputTokens:e.outputTokens,reasoningTokens:e.reasoningTokens,cacheTokens:e.cacheTokens,estimatedCost:e.estimatedCost,warnThreshold:e.warnThreshold??v,dangerThreshold:e.dangerThreshold??b}));return n(I.Provider,{get value(){return t()},get children(){return n(M,{openDelay:0,get children(){return e.children}})}})}function Y(){const e=g(),t=2*Math.PI*V,r=o(()=>e.usedTokens/e.maxTokens),c=o(()=>t*(1-r()));return(()=>{var i=H(),p=i.firstChild,k=p.nextSibling;return j(k,"stroke-dasharray",`${t} ${t}`),d(()=>j(k,"stroke-dashoffset",c())),i})()}function Z(e){const t=g(),r=o(()=>t.usedTokens/t.maxTokens),c=o(()=>D.format(r()));return n($,{get children(){return n(a,{get when(){return!e.children},get fallback(){return e.children},get children(){return n(A,{type:"button",variant:"ghost",get class(){return e.class},get children(){return[(()=>{var i=O();return s(i,c),i})(),n(Y,{})]}})}})}})}function ee(e){return n(z,{get class(){return h("min-w-60 divide-y divide-border overflow-hidden",e.class)},get children(){return e.children}})}function te(e){const t=g(),r=o(()=>t.usedTokens/t.maxTokens),c=o(()=>D.format(r())),i=o(()=>y.format(t.usedTokens)),p=o(()=>y.format(t.maxTokens)),k=o(()=>{const l=r();return l>t.dangerThreshold?"danger":l>t.warnThreshold?"warn":"ok"}),F=o(()=>{const l=k();return l==="danger"?"error":l==="warn"?"warning":"primary"});return(()=>{var l=T();return s(l,n(a,{get when(){return!e.children},get fallback(){return e.children},get children(){return[(()=>{var m=R(),C=m.firstChild,w=C.nextSibling,U=w.firstChild;return s(C,c),s(w,i,U),s(w,p,null),m})(),(()=>{var m=q();return s(m,n(E,{get value(){return t.usedTokens},get max(){return t.maxTokens},get tone(){return F()},"aria-label":"Context usage"})),m})()]}})),d(()=>f(l,h("w-full space-y-2 p-3",e.class))),l})()}function re(e){return(()=>{var t=T();return s(t,()=>e.children),d(()=>f(t,h("w-full p-3",e.class))),t})()}function ne(e){const t=g(),r=o(()=>_.format(t.estimatedCost??0));return(()=>{var c=T();return s(c,n(a,{get when(){return!e.children},get fallback(){return e.children},get children(){return[G(),(()=>{var i=S();return s(i,r),i})()]}})),d(()=>f(c,h("flex w-full items-center justify-between gap-3 bg-muted p-3 text-xs",e.class))),c})()}function x(e){return(()=>{var t=S();return s(t,(()=>{var r=B(()=>e.tokens===void 0);return()=>r()?"\u2014":y.format(e.tokens)})()),t})()}function se(e){const t=g();return n(a,{get when(){return e.children||t.inputTokens},get children(){return n(a,{get when(){return!e.children},get fallback(){return e.children},get children(){var r=J();return r.firstChild,s(r,n(x,{get tokens(){return t.inputTokens}}),null),d(()=>f(r,h("flex items-center justify-between text-xs",e.class))),r}})}})}function oe(e){const t=g();return n(a,{get when(){return e.children||t.outputTokens},get children(){return n(a,{get when(){return!e.children},get fallback(){return e.children},get children(){var r=K();return r.firstChild,s(r,n(x,{get tokens(){return t.outputTokens}}),null),d(()=>f(r,h("flex items-center justify-between text-xs",e.class))),r}})}})}function ae(e){const t=g();return n(a,{get when(){return e.children||t.reasoningTokens},get children(){return n(a,{get when(){return!e.children},get fallback(){return e.children},get children(){var r=L();return r.firstChild,s(r,n(x,{get tokens(){return t.reasoningTokens}}),null),d(()=>f(r,h("flex items-center justify-between text-xs",e.class))),r}})}})}function ue(e){const t=g();return n(a,{get when(){return e.children||t.cacheTokens},get children(){return n(a,{get when(){return!e.children},get fallback(){return e.children},get children(){var r=Q();return r.firstChild,s(r,n(x,{get tokens(){return t.cacheTokens}}),null),d(()=>f(r,h("flex items-center justify-between text-xs",e.class))),r}})}})}export{X as C,v as D,Z as a,ee as b,te as c,re as d,se as e,oe as f,ne as g,W as h,ae as i,ue as j,b as k};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as n,m as L,g as k,s as M,l as p,i as c,S as h,a as v,b as x,d as C,t as l,e as N,o as O,v as D,F as S}from"./define-B_tXMYRm.js";import{c as f}from"./cn-CU7UAWzk.js";import{a as R,b as q,C as E}from"./collapsible-DBcBkFPh.js";import{B as A}from"./button-B9okqG73.js";import{B as F}from"./badge-TIMiJFKc.js";import{S as P}from"./scroll-area-93A1bbeG.js";import{m as U}from"./message-square-C9ovmtOo.js";import{I as G}from"./Icon-b5A8hlHs.js";var H=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],J=i=>n(G,L(i,{name:"PanelLeftOpen",iconNode:H})),K=J;function Q(i,e){const[d,o]=k(e);return[()=>i()??d(),t=>o(t)]}var $=l('<span part=trailing class="ml-auto shrink-0 text-xs text-muted-foreground">'),V=l('<div class="flex items-center gap-2.5"><span>'),W=l("<button>"),X=l('<div class="flex items-center gap-2"><div>'),Y=l("<div> messages");function Z(i,e=Date.now()){if(!i)return"";const d=Date.parse(i);if(Number.isNaN(d))return"";const o=Math.max(0,Math.round((e-d)/1e3));if(o<60)return"just now";const t=Math.floor(o/60);if(t<60)return`${t}m ago`;const s=Math.floor(t/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function B(i){const[e]=M(i,["conversation","isActive","onSelect","compact","class"]),d=p(()=>e.conversation.trailing??Z(e.conversation.updatedAt??e.conversation.lastMessageAt));return(()=>{var o=W();return o.$$click=()=>e.onSelect(e.conversation.id),c(o,n(h,{get when(){return e.compact},get fallback(){return[(()=>{var t=X(),s=t.firstChild;return c(s,()=>e.conversation.title),c(t,n(h,{get when(){return d()},get children(){var g=$();return c(g,d),g}}),null),v(()=>x(s,f("min-w-0 flex-1 truncate text-sm",e.isActive?"font-medium text-foreground":"text-foreground/80"))),t})(),(()=>{var t=Y(),s=t.firstChild;return c(t,()=>e.conversation.messageCount,s),v(()=>x(t,f("mt-0.5 truncate text-xs",e.isActive?"text-foreground/70":"text-muted-foreground"))),t})()]},get children(){var t=V(),s=t.firstChild;return c(t,n(U,{get class(){return f("size-3.5 shrink-0",e.isActive?"text-foreground":"text-muted-foreground")}}),s),c(s,()=>e.conversation.title),c(t,n(h,{get when(){return d()},get children(){var g=$();return c(g,d),g}}),null),v(()=>x(s,f("min-w-0 flex-1 truncate text-sm",e.isActive?"font-medium text-foreground":"text-foreground/80"))),t}})),v(t=>{var s=e.conversation.id,g=e.isActive?"true":void 0,m=f("w-full rounded-lg text-left transition-colors",e.compact?"px-2.5 py-1.5":"px-2.5 py-2",e.isActive?"bg-muted":"hover:bg-muted/50",e.class);return s!==t.e&&C(o,"data-conversation-id",t.e=s),g!==t.t&&C(o,"aria-current",t.t=g),m!==t.a&&x(o,t.a=m),t},{e:void 0,t:void 0,a:void 0}),o})()}N(["click"]);var _=l('<div class="px-3 pb-2"><div class="flex items-center gap-2 rounded-md bg-surface-strong px-2.5 py-1.5"><svg width=13 height=13 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 class=text-muted-foreground><circle cx=11 cy=11 r=8></circle><line x1=21 y1=21 x2=16.65 y2=16.65></line></svg><input type=text placeholder="Search chats..."aria-label="Search chats"class="bg-transparent text-[13px] text-foreground placeholder:text-muted-foreground rounded-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring w-full">'),ee=l('<div class="space-y-0.5 py-1">'),te=l('<div class="shrink-0 border-t border-border">'),re=l("<div>"),ne=l('<svg width=16 height=16 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2><line x1=3 y1=12 x2=21 y2=12></line><line x1=3 y1=6 x2=21 y2=6></line><line x1=3 y1=18 x2=21 y2=18>'),oe=l('<svg width=16 height=16 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2><line x1=12 y1=5 x2=12 y2=19></line><line x1=5 y1=12 x2=19 y2=12>'),ae=l('<div class="flex items-center justify-between p-3 pb-2"><div class="flex items-center gap-2"><span class="text-sm font-semibold text-foreground">Chats'),ie=l('<div class="flex flex-1 flex-col items-center justify-center gap-1 p-6 text-center text-sm text-muted-foreground">No conversations yet'),se=l('<svg width=10 height=10 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2><polyline points="6 9 12 15 18 9">'),ce=l("<span>"),le=l('<div class="pl-2 mt-0.5 space-y-0.5">');function ue(i){return n(A,{variant:"ghost",size:"icon-sm","aria-label":"Open sidebar",get class(){return f("rounded-full bg-card/80 shadow-sm backdrop-blur",i.class)},get onClick(){return i.onExpand},get children(){return n(K,{class:"size-4"})}})}function de(i){const[e]=M(i,["groups","conversations","activeId","onSelect","onNewChat","onToggleSidebar","header","footer","empty","compact","onSearchChange","controllerRef","class"]),[d,o]=k(""),t=p(()=>e.conversations.length===0);let s;const g=a=>{var r;o(a),(r=e.onSearchChange)==null||r.call(e,a)};O(()=>{var a;(a=e.controllerRef)==null||a.call(e,{focus:r=>s?.focus(r),clearSearch:()=>g("")})});const m=p(()=>{const a=d().toLowerCase();return a?e.conversations.filter(r=>r.title.toLowerCase().includes(a)):e.conversations}),T=p(()=>{const a=new Map;for(const r of m()){const u=r.groupId;a.has(u)||a.set(u,[]),a.get(u).push(r)}return a}),w=p(()=>{const a=new Set((e.groups??[]).map(r=>r.id));return m().filter(r=>r.groupId==null||!a.has(r.groupId))});return(()=>{var a=re();return c(a,n(h,{get when(){return e.header},get fallback(){return(()=>{var r=ae(),u=r.firstChild,y=u.firstChild;return c(u,n(A,{variant:"ghost",size:"icon-sm","aria-label":"Toggle sidebar",get onClick(){return e.onToggleSidebar},get children(){return ne()}}),y),c(r,n(A,{variant:"ghost",size:"icon-sm","aria-label":"New chat",get onClick(){return e.onNewChat},get children(){return oe()}}),null),r})()},get children(){return e.header}}),null),c(a,n(h,{get when(){return!t()},get children(){var r=_(),u=r.firstChild,y=u.firstChild,b=y.nextSibling;b.$$input=j=>g(j.currentTarget.value);var I=s;return typeof I=="function"?D(I,b):s=b,v(()=>b.value=d()),r}}),null),c(a,n(h,{get when(){return!t()},get fallback(){return n(h,{get when(){return e.empty},get fallback(){return ie()},get children(){return e.empty}})},get children(){return n(P,{class:"flex-1 px-2",get children(){return[n(S,{get each(){return e.groups},children:r=>{const u=p(()=>T().get(r.id)??[]);return n(h,{get when(){return u().length>0},get children(){return n(z,{get name(){return r.name},get count(){return u().length},get conversations(){return u()},get activeId(){return e.activeId},get onSelect(){return e.onSelect},get compact(){return e.compact}})}})}}),n(h,{get when(){return w().length>0},get children(){return n(h,{get when(){return e.compact},get fallback(){return n(z,{name:"Ungrouped",get count(){return w().length},get conversations(){return w()},get activeId(){return e.activeId},get onSelect(){return e.onSelect}})},get children(){var r=ee();return c(r,n(S,{get each(){return w()},children:u=>n(B,{conversation:u,get isActive(){return u.id===e.activeId},get onSelect(){return e.onSelect},compact:!0})})),r}})}})]}})}}),null),c(a,n(h,{get when(){return e.footer},get children(){var r=te();return c(r,()=>e.footer),r}}),null),v(()=>x(a,f("flex flex-col h-full bg-sidebar",e.class))),a})()}function z(i){const[e,d]=k(!0);return n(E,{get open(){return e()},onOpenChange:d,get children(){return[n(R,{class:"flex items-center gap-1.5 w-full px-1.5 py-1 rounded-md text-[13px] text-muted-foreground font-medium hover:bg-muted/30 transition-colors cursor-pointer mt-1.5",get children(){return[(()=>{var o=se();return v(()=>C(o,"class",f("transition-transform",!e()&&"-rotate-90"))),o})(),(()=>{var o=ce();return c(o,()=>i.name),o})(),n(F,{variant:"count",class:"ml-auto text-[11px]",get children(){return i.count}})]}}),n(q,{get children(){var o=le();return c(o,n(S,{get each(){return i.conversations},children:t=>n(B,{conversation:t,get isActive(){return t.id===i.activeId},get onSelect(){return i.onSelect},get compact(){return i.compact}})})),o}})]}})}N(["input"]);export{de as C,ue as a,Q as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as i,m as z,s as P,y as G,q as E,i as f,g as J,A as K,O as Q,t as b,z as X,e as Z,F,S as x,j as H,u as V,a as ee,d as te,v as ae}from"./define-B_tXMYRm.js";import{c as D}from"./cn-CU7UAWzk.js";import{C as ne,s as re,n as ie}from"./composer-CZZmtYOT.js";import{P as se}from"./prompt-suggestion-D5Sm8xF1.js";import{B as k}from"./button-B9okqG73.js";import{T as oe}from"./tooltip-BqwnFWhn.js";import{A as le,a as de,d as ue,e as ce,i as pe}from"./attachments-CL6TaqIb.js";import{a as he}from"./action-icons-DW9muWrY.js";import{p as ge,g as me}from"./paperclip-Bg0ITU3b.js";import{m as fe}from"./icon-97R8SR2p.js";import{I as be}from"./Icon-b5A8hlHs.js";var ye=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],ve=e=>i(be,z(e,{name:"Square",iconNode:ye})),we=ve,xe=b("<div data-prompt-input>"),ke=b("<div>");const O=X();function Ce(){const e=K(O);if(!e)throw new Error("PromptInput subcomponents must be used within PromptInput");return e}function Se(e){const[t,a]=P(e,["isLoading","value","onValueChange","maxHeight","onSubmit","children","disabled","class","onClick"]),[n,u]=J(t.value??"");let r;const o=p=>{var m;u(p),(m=t.onValueChange)==null||m.call(t,p)},c=p=>{t.disabled||r==null||r.focus(),typeof t.onClick=="function"&&t.onClick(p)};return i(O.Provider,{get value(){return{isLoading:t.isLoading??!1,value:()=>t.value??n(),setValue:t.onValueChange??o,maxHeight:t.maxHeight??240,onSubmit:t.onSubmit,get disabled(){return t.disabled},get textareaRef(){return r},setTextareaRef:p=>{r=p}}},get children(){var p=xe();return p.$$click=c,E(p,z({get class(){return D("bg-surface cursor-text rounded-xl p-2 shadow-xs","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-0",t.disabled&&"cursor-not-allowed opacity-60",t.class)}},a),!1,!0),f(p,()=>t.children),p}})}function Re(e){const[t]=P(e,["class","placeholder","aria-label","triggers","kindIcons","onComposerChange"]),a=Ce(),n=G(),u=()=>D("text-foreground min-h-[44px] w-full bg-transparent shadow-none outline-none focus-visible:ring-0 focus-visible:ring-offset-0 overflow-y-auto whitespace-pre-wrap break-words",Q(n.proseSize()),t.class);return i(ne,{bare:!0,get value(){return a.value()},get placeholder(){return t.placeholder},get ariaLabel(){return t["aria-label"]},get disabled(){return a.disabled},get maxHeight(){return a.maxHeight},get editableClass(){return u()},editableRef:r=>a.setTextareaRef(r),get triggers(){return t.triggers},get kindIcons(){return t.kindIcons},onChange:r=>{var o;(o=t.onComposerChange)==null||o.call(t,r),a.setValue(r.text.replace(/^\s+/,""))},onSubmit:()=>{var r;a.disabled||(r=a.onSubmit)==null||r.call(a)}})}function Ue(e){const[t,a]=P(e,["children","class"]);return(()=>{var n=ke();return E(n,z({get class(){return D("flex items-center gap-2",t.class)}},a),!1,!0),f(n,()=>t.children),n})()}Z(["click"]);const M=[{pattern:"image/jpeg",kind:"image"},{pattern:"image/png",kind:"image"},{pattern:"image/gif",kind:"image"},{pattern:"image/webp",kind:"image"},{pattern:"application/pdf",kind:"document"},{pattern:"text/*",kind:"text"},{pattern:"application/json",kind:"text"},{pattern:"application/xml",kind:"text"},{pattern:"application/x-yaml",kind:"text"},{pattern:"application/yaml",kind:"text"}],N="text/plain",$e=["","application/octet-stream"],j=e=>e.trim().toLowerCase(),B=e=>$e.includes(e===void 0?"":j(e)),Te=e=>{if(!e.startsWith("."))return e;throw new Error(`\`accept\` entry "${e}" is a file extension, and this kit takes media types only. HTML's own accept attribute does take extensions, which is exactly why this throws rather than quietly matching nothing. Use a media type instead -- "text/*" covers source files, "image/*" images, "application/pdf" PDFs, and \`encodableMediaTypes()\` is the full set. You lose nothing by dropping the extension: a file the browser cannot name is decided by decoding its bytes, which is stronger than matching its name.`)},Ie=e=>(typeof e=="string"?e.split(","):e).map(j).filter(t=>t!=="").map(Te),_=e=>{const t=e.indexOf("/");return t===-1?[e,""]:[e.slice(0,t),e.slice(t+1)]},R=(e,t)=>{const[a,n]=_(e),[u,r]=_(t);return a!=="*"&&a!==u?!1:n==="*"||n===r},Le=(e,t)=>{if(R(e,t))return t;if(R(t,e))return e};function q(e={}){const t=e.accept===void 0?void 0:Ie(e.accept),a=[];for(const n of M){if(t===void 0){a.push({...n});continue}for(const u of t){const r=Le(n.pattern,u);r!==void 0&&!a.some(o=>o.pattern===r)&&a.push({pattern:r,kind:n.kind})}}return{types:a.map(n=>n.pattern),accept:a.map(n=>n.pattern).join(","),decide(n){const u=n===void 0?"":j(n);if(B(u))return a.some(o=>R(o.pattern,N))?{status:"undetermined"}:{status:"unsupported"};const r=a.find(o=>R(o.pattern,u));return r?{status:"allowed",kind:r.kind}:M.some(o=>R(o.pattern,u))?{status:"filtered"}:{status:"unsupported"}}}}const Ae=q(),ze=/^data:([^;,]*);base64,([\s\S]*)$/,Pe=/^([a-z][a-z0-9+.-]*):/i,W=e=>e.map(t=>`"${t}"`).join(", ");function Y(e){try{const t=atob(e),a=new Uint8Array(t.length);for(let n=0;n<t.length;n++)a[n]=t.charCodeAt(n);return{ok:!0,text:new TextDecoder("utf-8",{fatal:!0}).decode(a),bytes:t.length}}catch{return{ok:!1}}}function Fe(e,t=Ae){var a,n,u;if(e.type==="source-document")return{status:"kit-side"};const r=e.url;if(r===void 0||r==="")return{status:"unencodable",reason:"it has no `url`, so there are no bytes and no address to send. Set `url` to a `data:` URI (read the File with FileReader.readAsDataURL before you stage it) or to an https URL the provider can fetch."};let o,c;const p=ze.exec(r);if(p){const d=p[1].toLowerCase();c=B(d)?((a=e.mediaType)==null?void 0:a.toLowerCase())??d:d,o={type:"base64",mediaType:c,data:p[2],dataUri:r}}else if(/^https?:\/\//i.test(r)){const d=(n=e.mediaType)==null?void 0:n.toLowerCase();if(d===void 0||d==="")return{status:"unencodable",reason:`its \`url\` is remote ("${r}") but it has no \`mediaType\`, so there is no way to tell an image from a document without fetching it -- and this layer does no I/O. Set \`mediaType\` when you stage the attachment.`};c=d,o={type:"remote",url:r}}else{if(r.startsWith("data:"))return{status:"unencodable",reason:"its `url` is a `data:` URI that is not base64-encoded with an explicit media type. Both APIs need `data:<media type>;base64,<data>`."};{const d=(u=Pe.exec(r))==null?void 0:u[1].toLowerCase(),L=d==="blob"?"a `blob:` URL resolves only inside the browser tab that created it, so a model can never fetch it. Read the File with FileReader.readAsDataURL and stage the `data:` URI instead, or upload it and stage the resulting https URL":`a "${d??r}" URL is not something a provider can fetch. Use a \`data:\` URI or an https URL`;return{status:"unencodable",reason:`its \`url\` is "${r}": ${L}.`}}}const m=t.decide(c);if(m.status==="undetermined"){if(o.type!=="base64")return{status:"unencodable",reason:`it is at a remote URL ("${o.url}") and its media type "${c}" says nothing about the bytes -- that is the label for "arbitrary binary", so it separates an image from a document not at all. Settling it by reading the bytes would need a fetch, and this layer does no I/O. Set \`mediaType\` to what the file actually is when you stage it.`};const d=Y(o.data);return d.ok?{status:"encodable",file:{kind:"text",mediaType:N,source:o,filename:e.filename,text:d.text}}:{status:"unencodable",reason:`nothing names it -- ${c===""?"it carries no media type":`its media type is "${c}"`}, so the only way to tell what it is was to read it -- and its bytes are not valid UTF-8, so it is binary of some unidentified kind. Neither API has an arbitrary-file block to carry that. Set \`mediaType\` if you know what it is, or hand the file to the model through a tool.`}}if(m.status==="filtered")return{status:"unencodable",reason:`its media type "${c}" is one this kit can encode, but your \`accept\` filter excludes it. The types you allowed are: ${W(t.types)}. Widen \`accept\` to include it, or stop staging it.`};if(m.status==="unsupported")return{status:"unencodable",reason:`its media type "${c}" is not one either API accepts as message content. Supported: ${W(t.types)}. Extract the content yourself and send it as text, or hand it to the model through a tool.`};if(m.kind==="text"){if(o.type!=="base64")return{status:"unencodable",reason:`it is a text file at a remote URL ("${o.url}"), and text has to ride as text CONTENT -- neither API has an arbitrary-file block to point at a URL with. Reading it here would put I/O in the encoder. Fetch it yourself and stage the \`data:\` URI, or paste the contents as a text part.`};const d=Y(o.data);return d.ok?{status:"encodable",file:{kind:"text",mediaType:c,source:o,filename:e.filename,text:d.text}}:{status:"unencodable",reason:`its media type "${c}" says text, but its bytes are not valid UTF-8 -- so it is binary wearing a text label, and inlining it would send the model garbage. Send it under its real media type, or extract the text yourself.`}}return{status:"encodable",file:{kind:m.kind,mediaType:c,source:o,filename:e.filename}}}var Ve=b('<div class="mb-2 flex flex-wrap gap-2">'),De=b('<div class="px-3 pt-3">'),je=b("<slot name=input-top>"),Ee=b("<input type=file multiple class=hidden>"),He=b('<div class="flex items-center gap-2"><slot name=toolbar-start style=display:contents>'),Oe=b('<div class="flex items-center gap-2"><slot name=toolbar-end>'),Me=b('<span class="px-1 text-xs">'),Ne=b('<svg width=16 height=16 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2><line x1=12 y1=19 x2=12 y2=5></line><polyline points="5 12 12 5 19 12">');const Be=e=>new Promise((t,a)=>{const n=new FileReader;n.onload=()=>t(String(n.result)),n.onerror=()=>a(n.error??new Error(`Could not read ${e.name}`)),n.readAsDataURL(e)});async function _e(e){return{id:typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`${e.name}-${e.size}-${e.lastModified}`,type:"file",filename:e.name,mediaType:e.type||void 0,url:await Be(e)}}function qe(e){let t;const a=()=>e.attachments??[],n=()=>!!e.onAttachmentsChange,u=()=>q({accept:e.accept}),r=async s=>{var h,l;if(!(s!=null&&s.length)||!e.onAttachmentsChange)return;const v=u(),w=Array.from(s),C=w.map(g=>e.accept===void 0?void 0:v.decide(g.type)),y=g=>g===void 0||g.status==="allowed"||g.status==="undetermined",A=await Promise.all(w.map((g,T)=>y(C[T])?_e(g):void 0)),U=[],$=[];w.forEach((g,T)=>{const I=C[T],S=A[T];if(I===void 0||I.status==="allowed"){S&&U.push(S);return}if(I.status==="undetermined"){S&&Fe(S,v).status==="encodable"?U.push(S):$.push({filename:g.name,mediaType:g.type,reason:"unsupported"});return}$.push({filename:g.name,mediaType:g.type,reason:I.status})}),$.length>0&&((h=e.onAttachmentsRejected)==null||h.call(e,$)),U.length!==0&&((l=e.onAttachmentsChange)==null||l.call(e,[...a(),...U]))},o=s=>{var h;return(h=e.onAttachmentsChange)==null?void 0:h.call(e,a().filter(l=>l.id!==s))},c=()=>re(ie(e.value)),p=()=>e.disabled||e.loading||!c().trim()&&a().length===0,m=()=>!!e.loading&&!!e.stoppable,d=()=>!!c().trim()||a().length>0,L=()=>{const s=e.submit??"always";return s==="always"||s==="auto"&&d()};return[i(x,{get when(){var s;return(s=e.suggestions)==null?void 0:s.length},get children(){var s=Ve();return f(s,i(F,{get each(){return e.suggestions},children:h=>i(se,{onClick:()=>e.onSuggestionClick(h),children:h})})),s}}),i(Se,{get value(){return e.value},get onValueChange(){return e.onValueChange},get onSubmit(){return e.onSubmit},get isLoading(){return e.loading},get disabled(){return e.disabled},class:"relative",get children(){return[i(x,{get when(){return H(()=>!!n())()&&a().length},get children(){var s=De();return f(s,i(le,{variant:"inline",get children(){return i(F,{get each(){return a()},children:h=>i(de,{data:h,onRemove:()=>o(h.id),get children(){return[i(ue,{}),i(ce,{}),i(pe,{})]}})})}})),s}}),(()=>{var s=je();return s._$owner=V(),s})(),i(Re,{get placeholder(){return e.placeholder},get"aria-label"(){return e.placeholder||"Message"},class:"min-h-[44px] pt-3 pl-4",get triggers(){return e.triggers},get kindIcons(){return e.kindIcons},get onComposerChange(){return e.onComposerChange}}),i(Ue,{class:"mt-2 flex w-full items-center justify-between gap-2 px-3 pb-0",get children(){return[(()=>{var s=He(),h=s.firstChild;return h._$owner=V(),f(s,i(x,{get when(){return H(()=>!!n())()&&e.attach!==!1},get children(){return[(()=>{var l=Ee();l.addEventListener("change",w=>{r(w.currentTarget.files),w.currentTarget.value=""});var v=t;return typeof v=="function"?ae(v,l):t=l,ee(()=>te(l,"accept",e.accept===void 0?void 0:u().accept)),l})(),i(k,{type:"button",variant:"outline",size:"icon-sm",class:"rounded-full","aria-label":"Attach files",get disabled(){return e.disabled},onClick:()=>t?.click(),get children(){return i(ge,{class:"size-4"})}})]}}),null),f(s,i(x,{get when(){return e.search},get children(){return i(k,{type:"button",variant:"outline",size:"sm",class:"rounded-full gap-1","aria-label":"Search the web",get disabled(){return e.disabled},onClick:()=>{var l;return(l=e.onSearch)==null?void 0:l.call(e)},get children(){return[i(me,{class:"size-4"}),"Search"]}})}}),null),f(s,i(x,{get when(){return e.voice},get children(){return i(k,{type:"button",variant:"outline",size:"icon-sm",class:"rounded-full","aria-label":"Voice input",get disabled(){return e.disabled},onClick:()=>{var l;return(l=e.onVoice)==null?void 0:l.call(e)},get children(){return i(fe,{class:"size-4"})}})}}),null),f(s,i(F,{get each(){return e.toolbarActions??[]},children:l=>{const v=he(l.icon),w=l.tooltip??l.label,C=i(k,{type:"button",variant:"outline",size:"icon-sm",class:"rounded-full",get"aria-label"(){return l.label},get"data-action"(){return l.id},get disabled(){return e.disabled},onClick:()=>{var y;return(y=e.onAction)==null?void 0:y.call(e,l.id)},get children(){return i(x,{when:v,get fallback(){return(()=>{var y=Me();return f(y,()=>l.label),y})()},children:y=>{const A=y();return i(A,{class:"size-4"})}})}});return v?i(oe,{content:w,children:C}):C}}),null),s})(),(()=>{var s=Oe(),h=s.firstChild;return h._$owner=V(),f(s,i(x,{get when(){return m()},get fallback(){return i(x,{get when(){return L()},get children(){return i(k,{size:"icon-sm",class:"rounded-full",part:"send","data-testid":"send","aria-label":"Send message",get disabled(){return p()},get onClick(){return e.onSubmit},get children(){return Ne()}})}})},get children(){return i(k,{size:"icon-sm",variant:"outline",class:"rounded-full","data-testid":"stop","aria-label":"Stop",get onClick(){return e.onStop},get children(){return i(we,{class:"size-3"})}})}}),null),s})()]}})]}})]}export{qe as D};
|