@opentiny/genui-sdk-vue 1.2.1 → 1.3.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +10 -2
  2. package/dist/ConfigProvider-BzxW9L3f.js +95 -0
  3. package/dist/ConfigProvider-BzxW9L3f.js.map +1 -0
  4. package/dist/GenuiRenderer-B9wcUl25.js +15164 -0
  5. package/dist/GenuiRenderer-B9wcUl25.js.map +1 -0
  6. package/dist/___vite-browser-external_commonjs-proxy-4gYZYw55.js +1 -0
  7. package/dist/___vite-browser-external_commonjs-proxy-4gYZYw55.js.map +1 -0
  8. package/dist/chat.d.ts +82 -2410
  9. package/dist/chat.js +18 -19
  10. package/dist/chat.js.map +1 -0
  11. package/dist/chat.types-BRLoMarP.js +1792 -0
  12. package/dist/chat.types-BRLoMarP.js.map +1 -0
  13. package/dist/config-provider.d.ts +9 -0
  14. package/dist/config-provider.js +6 -1
  15. package/dist/config-provider.js.map +1 -0
  16. package/dist/index.d.ts +89 -2407
  17. package/dist/index.js +28 -26
  18. package/dist/index.js.map +1 -0
  19. package/dist/{injection-tokens-D8CFCpjy.js → injection-tokens-CuDQs1ne.js} +49 -49
  20. package/dist/injection-tokens-CuDQs1ne.js.map +1 -0
  21. package/dist/legacy-chat.d.ts +1277 -0
  22. package/dist/legacy-chat.js +67 -0
  23. package/dist/legacy-chat.js.map +1 -0
  24. package/dist/legacy-renderer.d.ts +59 -0
  25. package/dist/legacy-renderer.js +41 -0
  26. package/dist/legacy-renderer.js.map +1 -0
  27. package/dist/renderer.d.ts +6 -2031
  28. package/dist/renderer.js +2 -1
  29. package/dist/renderer.js.map +1 -0
  30. package/dist/transform-jsx.d.ts +3 -1
  31. package/dist/transform-jsx.js +1 -0
  32. package/dist/transform-jsx.js.map +1 -0
  33. package/package.json +30 -33
  34. package/dist/ConfigProvider-BaJsiFgd.js +0 -86
  35. package/dist/SchemaCardRenderer-Bjn61C0M.js +0 -13440
  36. package/dist/chat.types-Cqd67Yp-.js +0 -1753
@@ -0,0 +1,1792 @@
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(`.attachments-renderer[data-v-63821ae8]{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px}.image-thumbnail[data-v-63821ae8]{position:relative;width:50px;height:50px;cursor:pointer;flex-shrink:0}.image-thumbnail .image-wrapper[data-v-63821ae8]{width:100%;height:100%;border-radius:6px;overflow:hidden;position:relative}.image-thumbnail img[data-v-63821ae8]{width:100%;height:100%;object-fit:cover;display:block}.image-thumbnail .delete-btn[data-v-63821ae8]{position:absolute;top:-8px;right:-8px;border-radius:50%;border:none;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .2s;padding:0;background-color:transparent}.image-thumbnail .delete-btn .delete-btn-icon[data-v-63821ae8]{width:14px;height:14px}.image-thumbnail .hover-overlay[data-v-63821ae8]{position:absolute;top:0;left:0;right:0;bottom:0;background-color:#00000080;border-radius:8px;display:flex;align-items:center;justify-content:center;opacity:0;visibility:hidden;transition:opacity .2s,visibility .2s}.image-thumbnail .hover-overlay .preview-text[data-v-63821ae8]{color:#fff;font-size:12px;font-weight:500}.image-thumbnail:hover .hover-overlay[data-v-63821ae8]{opacity:1;visibility:visible}.file-item[data-v-63821ae8]{padding:8px 12px;background-color:#f5f5f5;border-radius:4px;display:inline-flex;align-items:center}.file-item .file-name[data-v-63821ae8]{font-size:14px;color:#333;word-break:break-all}.fullscreen-overlay[data-v-63821ae8]{position:fixed;top:0;left:0;right:0;bottom:0;background-color:#000c;display:flex;align-items:center;justify-content:center;z-index:9999;cursor:pointer;padding:20px}.fullscreen-overlay img[data-v-63821ae8]{max-width:90%;max-height:90%;object-fit:contain;cursor:default;border-radius:8px}.fullscreen-fade-enter-active[data-v-63821ae8]{transition:opacity .3s ease}.fullscreen-fade-leave-active[data-v-63821ae8]{transition:opacity .25s ease}.fullscreen-fade-enter-from[data-v-63821ae8],.fullscreen-fade-leave-to[data-v-63821ae8]{opacity:0}.image-scale-enter-active[data-v-63821ae8]{transition:transform .4s cubic-bezier(.34,1.56,.64,1),opacity .4s ease}.image-scale-leave-active[data-v-63821ae8]{transition:transform .3s cubic-bezier(.55,.055,.675,.19),opacity .3s ease}.image-scale-enter-from[data-v-63821ae8]{transform:scale(.2);opacity:0}.image-scale-leave-to[data-v-63821ae8]{transform:scale(.9);opacity:0}.template-data-renderer[data-v-e158cad0]{display:inline;word-break:break-word}.text-item[data-v-e158cad0]{display:inline}.template-item[data-v-e158cad0]{position:relative;display:inline}.template-item .template-text[data-v-e158cad0]{display:inline;cursor:pointer;color:#1476ff;background-color:#1476ff1a;padding:2px 4px;border-radius:4px}.image-preview[data-v-e158cad0]{max-width:200px;cursor:pointer}.image-preview .image-preview-img[data-v-e158cad0]{width:100%;height:100%;object-fit:contain}.fullscreen-overlay[data-v-e158cad0]{position:fixed;top:0;left:0;right:0;bottom:0;background-color:#000c;display:flex;align-items:center;justify-content:center;z-index:9999;cursor:pointer;padding:20px}.fullscreen-overlay img[data-v-e158cad0]{max-width:90%;max-height:90%;object-fit:contain;cursor:default;border-radius:8px}.fullscreen-fade-enter-active[data-v-e158cad0]{transition:opacity .3s ease}.fullscreen-fade-leave-active[data-v-e158cad0]{transition:opacity .25s ease}.fullscreen-fade-enter-from[data-v-e158cad0],.fullscreen-fade-leave-to[data-v-e158cad0]{opacity:0}.image-scale-enter-active[data-v-e158cad0]{transition:transform .4s cubic-bezier(.34,1.56,.64,1),opacity .4s ease}.image-scale-leave-active[data-v-e158cad0]{transition:transform .3s cubic-bezier(.55,.055,.675,.19),opacity .3s ease}.image-scale-enter-from[data-v-e158cad0]{transform:scale(.2);opacity:0}.image-scale-leave-to[data-v-e158cad0]{transform:scale(.9);opacity:0}.tr-bubble__reasoning[data-v-1ffff0cd]:not(:last-child){margin-top:8px}.header[data-v-1ffff0cd]{font-size:16px;line-height:1.5;color:var(--tr-text-secondary);display:flex;align-items:center;gap:8px;cursor:pointer}.header[data-v-1ffff0cd]:hover{color:var(--tr-text-primary);fill:var(--tr-text-primary)}.header .icon-and-text[data-v-1ffff0cd]{display:flex;align-items:center;gap:8px}.header .expand-icon.-rotate-90[data-v-1ffff0cd]{transform:rotate(-90deg)}@keyframes thinking-pulse-1ffff0cd{20%{opacity:1}50%{opacity:.5}80%{opacity:1}}.thinking[data-v-1ffff0cd]{animation:thinking-pulse-1ffff0cd 1.5s infinite linear}.detail[data-v-1ffff0cd]{color:var(--tr-text-secondary);margin-block:8px;display:flex;gap:8px;align-items:center;font-size:14px}.detail .detail-content[data-v-1ffff0cd]{max-height:300px;overflow-y:auto}.detail .detail-content[data-v-1ffff0cd]>*:first-child{margin-top:0}.detail .detail-content[data-v-1ffff0cd]>*:last-child{margin-bottom:0}.detail .side-border[data-v-1ffff0cd]{width:16px;flex-shrink:0;align-self:stretch;display:flex;flex-direction:column;align-items:center}.detail .side-border .dot-wrapper[data-v-1ffff0cd]{width:4px;height:16px;display:flex;align-items:center;flex-shrink:0}.detail .side-border .dot[data-v-1ffff0cd]{width:4px;height:4px;border-radius:50%;background-color:var(--tr-text-primary)}.detail .side-border .border-line[data-v-1ffff0cd]{flex:1;width:1.5px;background-color:#c2c2c2;border-radius:1px}.tr-bubble__step-tool[data-v-398a0327]{font-size:14px;line-height:24px;padding:12px;color:var(--tr-text-secondary);background-color:var(--tr-container-bg-default-2);border-radius:12px}.tr-bubble__step-tool .tr-bubble__step-tool-header[data-v-398a0327]{display:flex;align-items:center;justify-content:space-between;gap:8px}.tr-bubble__step-tool .tr-bubble__step-tool-left[data-v-398a0327]{display:flex;align-items:center;gap:8px}.tr-bubble__step-tool .tr-bubble__step-tool-left .tr-bubble__step-tool-icon[data-v-398a0327]{font-size:20px;flex-shrink:0}.tr-bubble__step-tool .tr-bubble__step-tool-left .tr-bubble__step-tool-icon.icon-running[data-v-398a0327]{color:#898989;animation:spin 1s linear infinite}.tr-bubble__step-tool .tr-bubble__step-tool-left .tr-bubble__step-tool-icon.icon-success[data-v-398a0327]{color:#898989}.tr-bubble__step-tool .tr-bubble__step-tool-left .tr-bubble__step-tool-icon.icon-failed[data-v-398a0327],.tr-bubble__step-tool .tr-bubble__step-tool-left .tr-bubble__step-tool-icon.icon-cancelled[data-v-398a0327]{color:var(--tr-color-error)}.tr-bubble__step-tool .tr-bubble__step-tool-left .tr-bubble__step-tool-title[data-v-398a0327]{word-break:break-word}.tr-bubble__step-tool .tr-bubble__step-tool-left .tr-bubble__step-tool-name[data-v-398a0327]{color:var(--tr-text-primary);font-weight:600}.tr-bubble__step-tool .tr-bubble__step-tool-expand[data-v-398a0327]{display:flex;align-items:center;justify-content:center;cursor:pointer;flex-shrink:0}.tr-bubble__step-tool .tr-bubble__step-tool-expand .expand-icon[data-v-398a0327]{font-size:16px}.tr-bubble__step-tool .tr-bubble__step-tool-expand .expand-icon.-rotate-90[data-v-398a0327]{transform:rotate(-90deg)}.tr-bubble__step-tool .tr-bubble__step-tool-hr[data-v-398a0327]{margin:12px 0;color:#dbdbdb}.tr-bubble__step-tool .tr-bubble__step-tool-params-content[data-v-398a0327]{white-space:pre-wrap;word-break:break-word;font-family:monospace;max-height:300px;overflow-y:auto}._key_1b448_2{color:var(--tr-bubble-tool-key-color)}._number_1b448_6{color:var(--tr-bubble-tool-number-color)}._string_1b448_10{color:var(--tr-bubble-tool-string-color)}._boolean_1b448_14{color:var(--tr-bubble-tool-boolean-color)}._null_1b448_18{color:var(--tr-bubble-tool-null-color)}.loading-wrapper[data-v-e1124fd9]{width:fit-content;max-width:100%;overflow:hidden;direction:rtl}.loading-container[type=loading-text][data-v-e1124fd9]{margin:10px 0;color:#666;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;direction:ltr;display:inline-block}@supports ((background-clip: text)){.loading-container[type=loading-text][data-v-e1124fd9]{background:linear-gradient(90deg,#666,#666 45%,#999,#999,#666 60%,#666);background-size:200% 100%;-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent;animation:text-shimmer-e1124fd9 6s linear infinite}}@keyframes text-shimmer-e1124fd9{0%{background-position:200% 0}to{background-position:-200% 0}}.tg-playground-error-card[data-v-a0f77c05]{margin:8px 0;padding:16px 24px;border-radius:24px;background-color:var(--tv-color-error-bg-light);font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:var(--tr-bubble-text-font-size);line-height:var(--tr-bubble-text-line-height);overflow:hidden;color:var(--tr-text-primary)}.card-header[data-v-a0f77c05]{display:flex;position:relative;align-items:center;font-weight:500;gap:8px}.icon-error[data-v-a0f77c05]{width:18px;height:18px;fill:var(--tv-color-error-icon);transform:translateY(-1px)}.icon-right[data-v-a0f77c05]{width:16px;height:16px;position:absolute;fill:var(--tr-text-primary);right:0;top:50%;transform:translateY(-50%) rotate(0);cursor:pointer;transition:transform .2s ease-out}.icon-right.expanded[data-v-a0f77c05]{transform:translateY(-50%) rotate(90deg)}.card-title[data-v-a0f77c05]{white-space:nowrap}.card-body[data-v-a0f77c05]{margin:8px 0 0;background-color:var(--tr-bubble-content-bg);padding:8px 10px;border-radius:6px;max-height:60vh;overflow-x:auto;white-space:pre-wrap;word-break:break-all}.card-body.collapsed[data-v-a0f77c05]{height:0;padding:0;margin-top:0;overflow:hidden}.tg-chat-container[data-v-b02ae0d5]{--ti-gen-chat-container-bg-color: #f0f0f0;--thinking-display: initial;--sender-bg: url("data:image/svg+xml,%3csvg%20viewBox='0%200%201244%20186'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='1244.000000'%20height='186.000000'%20fill='none'%3e%3cdefs%3e%3cclipPath%20id='clipPath_0'%3e%3crect%20width='1083.000122'%20height='276.998108'%20x='81.000000'%20y='0.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cradialGradient%20id='paint_radial_0'%20cx='0'%20cy='0'%20r='1'%20gradientUnits='userSpaceOnUse'%20gradientTransform='matrix(-229.7,0,0,-152.751,410.969,285.331)'%3e%3cstop%20stop-color='rgb(255,239,248)'%20offset='0'%20stop-opacity='1'%20/%3e%3cstop%20stop-color='rgb(255,239,248)'%20offset='1'%20stop-opacity='0'%20/%3e%3c/radialGradient%3e%3cradialGradient%20id='paint_radial_1'%20cx='0'%20cy='0'%20r='1'%20gradientUnits='userSpaceOnUse'%20gradientTransform='matrix(372.771,0,0,193.995,774,236.999)'%3e%3cstop%20stop-color='rgb(230,240,255)'%20offset='0'%20stop-opacity='1'%20/%3e%3cstop%20stop-color='rgb(230,240,255)'%20offset='1'%20stop-opacity='0'%20/%3e%3c/radialGradient%3e%3c/defs%3e%3crect%20id='亮色背景'%20width='1244.000000'%20height='186.000000'%20x='0.000000'%20y='0.000000'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20/%3e%3cg%20id='对话框背景%201'%20clip-path='url(%23clipPath_0)'%20customFrame='url(%23clipPath_0)'%3e%3crect%20id='对话框背景%201'%20width='1083.000122'%20height='276.998108'%20x='81.000000'%20y='0.000000'%20/%3e%3crect%20id='容器%202'%20width='1083.000122'%20height='276.998108'%20x='81.000000'%20y='0.000000'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20/%3e%3crect%20id='show_mask_2'%20width='460.000000'%20height='305.501465'%20x='180.969238'%20y='132.583984'%20rx='152.750717'%20fill='url(%23paint_radial_0)'%20/%3e%3crect%20id='show_mask_1'%20width='912.000000'%20height='474.000000'%20x='318.000000'%20y='0.000000'%20rx='237.000000'%20fill='url(%23paint_radial_1)'%20/%3e%3c/g%3e%3c/svg%3e") no-repeat center;--sender-border-color: #e5e5e5;--generating-bg-before: linear-gradient(90deg, #fff, #a2c7f4);--generating-bg-after: #fff;box-sizing:border-box;height:100%;color:var(--tr-text-primary);background-color:var(--ti-gen-chat-container-bg-color);position:relative;display:flex;flex-direction:column;overflow:auto}.tg-chat-container.dark[data-v-b02ae0d5]{--ti-gen-chat-container-bg-color: #191919;--sender-bg: url("data:image/svg+xml,%3csvg%20viewBox='0%200%201244%20186'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='1244.000000'%20height='186.000000'%20fill='none'%3e%3cmask%20id='mask_3'%20width='528.384094'%20height='282.593811'%20x='111.420166'%20y='110.491211'%20maskUnits='userSpaceOnUse'%3e%3cg%20filter='url(%23pixso_custom_mask_type_outline)'%3e%3crect%20id='蒙版'%20width='528.384094'%20height='282.593811'%20x='111.420166'%20y='110.491211'%20rx='141.296906'%20fill='rgb(255,255,255)'%20/%3e%3c/g%3e%3c/mask%3e%3cmask%20id='mask_2'%20width='1047.578979'%20height='560.273071'%20x='276.827148'%20y='-104.525391'%20maskUnits='userSpaceOnUse'%3e%3cg%20filter='url(%23pixso_custom_mask_type_outline)'%3e%3crect%20id='蒙版'%20width='1047.578979'%20height='560.273071'%20x='276.827148'%20y='-104.525391'%20rx='235.379578'%20fill='rgb(255,255,255)'%20/%3e%3c/g%3e%3c/mask%3e%3cmask%20id='mask_1'%20width='639.804199'%20height='342.184357'%20x='374.463623'%20y='-30.191406'%20maskUnits='userSpaceOnUse'%3e%3cg%20filter='url(%23pixso_custom_mask_type_outline)'%3e%3crect%20id='蒙版'%20width='639.804199'%20height='342.184357'%20x='374.463623'%20y='-30.191406'%20rx='171.092178'%20fill='rgb(255,255,255)'%20/%3e%3c/g%3e%3c/mask%3e%3cmask%20id='mask_0'%20width='1244.000000'%20height='360.000000'%20x='0.000000'%20y='38.000000'%20maskUnits='userSpaceOnUse'%3e%3cg%20filter='url(%23pixso_custom_mask_type_alpha)'%3e%3cellipse%20id='椭圆形'%20rx='622.000000'%20ry='180.000000'%20cx='622'%20cy='218'%20fill='url(%23paint_radial_2)'%20/%3e%3cellipse%20id='椭圆形'%20rx='621.500000'%20ry='179.500000'%20cx='622'%20cy='218'%20stroke='rgb(151,151,151)'%20stroke-opacity='0'%20stroke-width='1'%20/%3e%3c/g%3e%3c/mask%3e%3cdefs%3e%3cclipPath%20id='clipPath_1'%3e%3crect%20width='1244.000000'%20height='148.000000'%20x='0.000000'%20y='38.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cradialGradient%20id='paint_radial_2'%20cx='0'%20cy='0'%20r='1'%20gradientUnits='userSpaceOnUse'%20gradientTransform='matrix(689.165,0,0,158.722,622,218)'%3e%3cstop%20stop-color='rgb(0,0,0)'%20offset='0'%20stop-opacity='1'%20/%3e%3cstop%20stop-color='rgb(68.3036,68.2353,68.2353)'%20offset='0.309297144'%20stop-opacity='1'%20/%3e%3cstop%20stop-color='rgb(0,0,0)'%20offset='1'%20stop-opacity='0'%20/%3e%3c/radialGradient%3e%3cfilter%20id='pixso_custom_mask_type_alpha'%3e%3cfeColorMatrix%20type='matrix'%20values='0%200%200%200%201%200%200%200%200%201%200%200%200%200%201%200%200%200%201%200%20'%20/%3e%3c/filter%3e%3cradialGradient%20id='paint_radial_3'%20cx='0'%20cy='0'%20r='1'%20gradientUnits='userSpaceOnUse'%20gradientTransform='matrix(319.485,0,0,171.092,694.366,140.901)'%3e%3cstop%20stop-color='rgb(144.576,104.098,32.8582)'%20offset='0'%20stop-opacity='1'%20/%3e%3cstop%20stop-color='rgb(129.777,92.7956,27.1351)'%20offset='1'%20stop-opacity='0'%20/%3e%3c/radialGradient%3e%3cfilter%20id='pixso_custom_mask_type_outline'%3e%3cfeColorMatrix%20type='matrix'%20values='0%200%200%200%201%200%200%200%200%201%200%200%200%200%201%200%200%200%201%200%20'%20/%3e%3c/filter%3e%3cradialGradient%20id='paint_radial_4'%20cx='0'%20cy='0'%20r='1'%20gradientUnits='userSpaceOnUse'%20gradientTransform='matrix(652.421,0,0,349.387,800.617,175.611)'%3e%3cstop%20stop-color='rgb(18.6076,39.3967,70.5804)'%20offset='0'%20stop-opacity='1'%20/%3e%3cstop%20stop-color='rgb(22.209,47.0218,84.2411)'%20offset='1'%20stop-opacity='0'%20/%3e%3c/radialGradient%3e%3cradialGradient%20id='paint_radial_5'%20cx='0'%20cy='0'%20r='1'%20gradientUnits='userSpaceOnUse'%20gradientTransform='matrix(263.848,0,0,141.297,375.612,251.788)'%3e%3cstop%20stop-color='rgb(75.1339,33.8103,57.0548)'%20offset='0'%20stop-opacity='1'%20/%3e%3cstop%20stop-color='rgb(75.1339,33.4688,56.9054)'%20offset='1'%20stop-opacity='0'%20/%3e%3c/radialGradient%3e%3c/defs%3e%3crect%20id='暗色背景'%20width='1244.000000'%20height='186.000000'%20x='0.000000'%20y='0.000000'%20fill='rgb(25,25,25)'%20fill-opacity='0'%20/%3e%3cg%20id='组合%205542'%3e%3cg%20id='容器%204'%20clip-path='url(%23clipPath_1)'%20customFrame='url(%23clipPath_1)'%3e%3crect%20id='容器%204'%20width='1244.000000'%20height='148.000000'%20x='0.000000'%20y='38.000000'%20fill='rgb(25,25,25)'%20fill-opacity='0'%20/%3e%3cg%20id='椭圆形%204'%20mask='url(%23mask_0)'%3e%3cg%20id='BLUE备份%202'%20opacity='0.100000001'%20showMaskRef='url(%23show_mask_0)'%20mask='url(%23mask_1)'%3e%3crect%20id='show_mask_0'%20width='639.804199'%20height='342.184357'%20x='374.463623'%20y='-30.191406'%20rx='171.092178'%20fill='url(%23paint_radial_3)'%20/%3e%3c/g%3e%3cg%20id='BLUE备份%203'%20showMaskRef='url(%23show_mask_1)'%20mask='url(%23mask_2)'%3e%3crect%20id='show_mask_1'%20width='1047.578979'%20height='560.273071'%20x='276.827148'%20y='-104.525391'%20rx='235.379578'%20fill='url(%23paint_radial_4)'%20/%3e%3c/g%3e%3cg%20id='BLUE备份%204'%20showMaskRef='url(%23show_mask_2)'%20mask='url(%23mask_3)'%3e%3crect%20id='show_mask_2'%20width='528.384094'%20height='282.593811'%20x='111.420166'%20y='110.491211'%20rx='141.296906'%20fill='url(%23paint_radial_5)'%20/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e") no-repeat center;--sender-border-color: #333;--generating-bg-before: linear-gradient(90deg, #262626, #808080);--generating-bg-after: #191919}.is-loading-in-top[data-v-b02ae0d5]{margin-top:-48px}.messages-container[data-v-b02ae0d5]{flex:1;overflow:auto;word-break:break-word}[data-v-b02ae0d5] .tr-bubble__loading{margin-top:8px}[data-v-b02ae0d5] .tr-bubble.placement-start .tr-bubble__content{padding:0;background:transparent;border-radius:0;box-shadow:none}[data-v-b02ae0d5] .tr-bubble[data-role=assistant] .tr-bubble__content-items>[type]:not([type=""]):not([type=schema-card]):not([type=loading-text]){display:var(--thinking-display, initial)}[data-v-b02ae0d5] .tr-bubble__step-tool+.tr-bubble__step-tool{margin-top:16px}[data-v-b02ae0d5] .tr-bubble.placement-end{width:100%}[data-v-b02ae0d5] .tr-bubble__content-wrapper{max-width:calc(100% - var(--ti-gen-chat-avatar-and-gap-width, 56px) * 2)}[data-v-b02ae0d5] .tr-bubble__content-wrapper .tr-bubble__content{max-width:100%}[data-v-b02ae0d5] .tr-bubble__content-wrapper .tr-bubble__content-items{overflow-x:auto}.sender-container[data-v-b02ae0d5]{position:relative;flex-shrink:0;padding:16px 0;background:var(--sender-bg)}.sender-container .attachments-container[data-v-b02ae0d5]{padding:0 20px}.scroll-to-bottom-button[data-v-b02ae0d5]{position:absolute;left:50%;transform:translate(-50%);top:-35px;width:40px;height:40px;background-color:var(--generating-bg-after);border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;border:1px solid var(--sender-border-color);z-index:1000}.scroll-to-bottom-button>svg[data-v-b02ae0d5]{width:20px;height:20px}.scroll-to-bottom-button[data-v-b02ae0d5]:hover{box-shadow:0 10px 20px #0000001a,0 0 1px #00000026}.scroll-to-bottom-button.is-generating[data-v-b02ae0d5]{border:none;background-color:transparent}.scroll-to-bottom-button.is-generating[data-v-b02ae0d5]:before{content:"";position:absolute;top:-2px;left:-2px;right:-2px;bottom:-2px;width:calc(100% + 4px);height:calc(100% + 4px);border-radius:50%;background:var(--generating-bg-before);z-index:0;animation:rotate-border-b02ae0d5 2s linear infinite}.scroll-to-bottom-button.is-generating[data-v-b02ae0d5]:after{content:"";position:absolute;top:0;left:0;width:100%;height:100%;border-radius:50%;background-color:var(--generating-bg-after);z-index:1}.scroll-to-bottom-button.is-generating>svg[data-v-b02ae0d5]{z-index:2}.footer-text[data-v-b02ae0d5]{font-size:12px;color:#999;text-align:center;margin-top:16px}[data-v-b02ae0d5] .schema-render-container{min-width:min(calc(var(--messages-container-width) - 250px),400px)}@keyframes rotate-border-b02ae0d5{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.tiny-sender[data-v-b02ae0d5]{width:80%;margin:0 auto}`)),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
+ import { ref as A, onMounted as ve, onUnmounted as nt, h as ee, nextTick as at, defineComponent as X, computed as O, createElementBlock as I, openBlock as E, createVNode as D, Fragment as le, renderList as he, createElementVNode as w, withModifiers as ot, unref as S, toDisplayString as H, Transition as ie, withCtx as j, createCommentVNode as V, withDirectives as Ae, normalizeClass as K, vShow as De, useCssModule as rt, createBlock as $e, resolveDynamicComponent as lt, createTextVNode as it, onBeforeUnmount as Oe, reactive as ue, toRaw as fe, isRef as Ne, isReactive as ct, watch as ce, readonly as te, inject as ut, normalizeStyle as Re, renderSlot as dt, createSlots as mt } from "vue";
3
+ import "@opentiny/tiny-robot/dist/style.css";
4
+ import { BubbleMarkdownContentRenderer as Be, TrBubbleProvider as pt, TrBubbleList as gt, TrSender as ht } from "@opentiny/tiny-robot";
5
+ import { BaseModelProvider as ft, STATUS as q, GeneratingStatus as ae, AIClient as vt } from "@opentiny/tiny-robot-kit";
6
+ import { IconFileRemove as yt, IconArrowDown as ye, IconLoading as _t, IconPlugin as ke, IconError as wt, IconCancelled as bt, IconUser as Ct, IconAi as Mt } from "@opentiny/tiny-robot-svgs";
7
+ import { TinyNotify as xe, TinyPopover as St } from "@opentiny/vue";
8
+ import { u as $, _ as Q, a as Rt } from "./injection-tokens-CuDQs1ne.js";
9
+ import { G as kt, c as xt } from "./GenuiRenderer-B9wcUl25.js";
10
+ import { iconChevronRight as Et, iconOperationfaild as It } from "@opentiny/vue-icon";
11
+ import { getPartialStartRegString as Ee, PatternExtractor as Ie } from "@opentiny/genui-sdk-core";
12
+ import { v4 as Tt } from "uuid";
13
+ const Ft = (t) => t.map((s) => ({
14
+ name: s.name,
15
+ description: s.description,
16
+ parameters: s.parameters,
17
+ return: s.return,
18
+ async: s.async
19
+ })), At = (t) => t.map((s) => {
20
+ const { ref: e, ...n } = s;
21
+ return n;
22
+ }), Dt = async (t) => {
23
+ const { url: s, messages: e, model: n, temperature: a, signal: p, customComponents: r, customSnippets: d, customExamples: l, customActions: i, customFetch: o } = t, m = {
24
+ customComponents: At(r),
25
+ customSnippets: d,
26
+ customExamples: l,
27
+ customActions: Ft(i)
28
+ }, b = {
29
+ tinygenui: JSON.stringify(m)
30
+ }, f = {
31
+ method: "POST",
32
+ headers: {
33
+ "Content-Type": "application/json"
34
+ },
35
+ signal: p,
36
+ body: JSON.stringify({
37
+ messages: e,
38
+ model: n,
39
+ temperature: a,
40
+ metadata: b
41
+ })
42
+ }, v = await (o || fetch)(s, f);
43
+ if (!v.ok) {
44
+ const T = await v.text();
45
+ throw new Error(`HTTP error! status: ${v.status}, details: ${T}`);
46
+ }
47
+ return v;
48
+ };
49
+ async function $t(t, s) {
50
+ let e = "";
51
+ const n = new TextDecoder("utf-8");
52
+ for (; ; ) {
53
+ const { done: a, value: p } = await t.read();
54
+ if (a) break;
55
+ for (e += n.decode(p, { stream: !0 }); ; ) {
56
+ const r = e.indexOf(`
57
+ `);
58
+ if (r === -1) break;
59
+ const d = e.slice(0, r).trim();
60
+ if (e = e.slice(r + 1), !d.startsWith("data:")) continue;
61
+ const l = d.slice(5).trim();
62
+ if (l === "[DONE]") break;
63
+ s(l);
64
+ }
65
+ }
66
+ return !0;
67
+ }
68
+ class Ot extends ft {
69
+ constructor({ getChatOptions: s }) {
70
+ super({ provider: "custom" }), this.responseHandlers = [], this.getChatOptions = s;
71
+ }
72
+ validateRequest(s) {
73
+ }
74
+ setResponseHandlers(s) {
75
+ this.responseHandlers = s;
76
+ }
77
+ async getData(s) {
78
+ var o;
79
+ const {
80
+ url: e,
81
+ model: n,
82
+ temperature: a,
83
+ customComponents: p,
84
+ customSnippets: r,
85
+ customExamples: d,
86
+ customActions: l,
87
+ customFetch: i
88
+ } = this.getChatOptions();
89
+ return await Dt({
90
+ url: e,
91
+ messages: s.messages,
92
+ model: n,
93
+ temperature: a,
94
+ signal: (o = s.options) == null ? void 0 : o.signal,
95
+ customComponents: p,
96
+ customSnippets: r,
97
+ customExamples: d,
98
+ customActions: l,
99
+ customFetch: i
100
+ });
101
+ }
102
+ async chat(s) {
103
+ return {};
104
+ }
105
+ async chatStream(s, e) {
106
+ var m;
107
+ const { onDone: n, onData: a, onError: p } = e;
108
+ let r;
109
+ try {
110
+ r = await this.getData(s);
111
+ } catch (b) {
112
+ n({ type: "error", error: b });
113
+ return;
114
+ }
115
+ const l = r.body.getReader(), i = {};
116
+ this.setupStreamContext(i, s);
117
+ const o = (m = s.options) == null ? void 0 : m.signal;
118
+ o == null || o.addEventListener(
119
+ "abort",
120
+ () => {
121
+ l.cancel(), this.handlerEnd(i);
122
+ },
123
+ { once: !0 }
124
+ ), this.handlerStart(i, e), await $t(l, (b) => {
125
+ this.handlerChunk(b, i);
126
+ }), this.handlerEnd(i);
127
+ }
128
+ setupStreamContext(s, e) {
129
+ const { chatConfig: n } = this.getChatOptions();
130
+ s.chatConfig = n;
131
+ }
132
+ handlerChunk(s, e) {
133
+ try {
134
+ const n = JSON.parse(s);
135
+ for (const a of this.responseHandlers)
136
+ if (a.match(n, e)) {
137
+ if (a.handler(n, e)) break;
138
+ } else if (a.notMatchHandler && a.notMatchHandler(n, e))
139
+ break;
140
+ } catch (n) {
141
+ console.error(n);
142
+ }
143
+ }
144
+ handlerStart(s, e) {
145
+ for (const n of this.responseHandlers)
146
+ n.start && n.start(s, e);
147
+ }
148
+ handlerEnd(s) {
149
+ for (const e of this.responseHandlers)
150
+ e.end && e.end(s);
151
+ }
152
+ }
153
+ function Nt(t, s) {
154
+ let e = null, n = 0;
155
+ return function(...a) {
156
+ const p = Date.now(), r = p - n;
157
+ if (r >= s)
158
+ e && (clearTimeout(e), e = null), n = p, t.apply(this, a);
159
+ else {
160
+ e && clearTimeout(e);
161
+ const d = s - r;
162
+ e = setTimeout(() => {
163
+ n = Date.now(), e = null, t.apply(this, a);
164
+ }, d);
165
+ }
166
+ };
167
+ }
168
+ const Bt = (t) => {
169
+ const s = A(!1), e = A(!1);
170
+ let n = null;
171
+ const a = () => {
172
+ t.value && (s.value = t.value.scrollTop + t.value.clientHeight + 130 >= t.value.scrollHeight);
173
+ }, p = () => {
174
+ t.value && at(() => {
175
+ var i;
176
+ (i = t.value) == null || i.scrollTo({
177
+ top: t.value.scrollHeight,
178
+ behavior: "smooth"
179
+ });
180
+ });
181
+ }, r = (i = 10, o = 150) => {
182
+ if (!t.value) return;
183
+ let m = 0, b = 0, f = 0;
184
+ const R = () => {
185
+ if (!t.value) return;
186
+ const v = t.value.scrollHeight, T = t.value.scrollTop, G = t.value.clientHeight, L = T + G + 10 >= v;
187
+ v !== b ? (b = v, f = 0, m = 0) : f++, !L && ((f >= 2 || m >= 2) && p(), !L && m < i && (m++, setTimeout(() => {
188
+ requestAnimationFrame(() => {
189
+ R();
190
+ });
191
+ }, o)));
192
+ };
193
+ setTimeout(() => {
194
+ R(), a();
195
+ }, 50);
196
+ }, d = () => {
197
+ !s.value || e.value || p();
198
+ }, l = () => {
199
+ e.value = !0, n && clearTimeout(n), n = setTimeout(() => {
200
+ e.value = !1, n = null;
201
+ }, 100);
202
+ };
203
+ return ve(() => {
204
+ a(), t.value && (t.value.addEventListener("scroll", a, { passive: !0 }), t.value.addEventListener("wheel", l, { passive: !0 }), t.value.addEventListener("touchmove", l, { passive: !0 }));
205
+ }), nt(() => {
206
+ t.value && (t.value.removeEventListener("scroll", a), t.value.removeEventListener("wheel", l), t.value.removeEventListener("touchmove", l));
207
+ }), {
208
+ scrollToBottom: p,
209
+ scrollToBottomWithRetry: r,
210
+ autoScrollToBottom: d,
211
+ isLastMessageInBottom: s,
212
+ updateIsLastMessageInBottom: a
213
+ };
214
+ }, ge = (t) => {
215
+ if (t)
216
+ return typeof t == "function" && !("__name" in t || "setup" in t || "render" in t) ? t : (s) => ee(t, s);
217
+ }, Pt = {
218
+ // 图片格式
219
+ jpg: "image/jpeg",
220
+ jpeg: "image/jpeg",
221
+ png: "image/png",
222
+ gif: "image/gif",
223
+ webp: "image/webp",
224
+ bmp: "image/bmp",
225
+ heic: "image/heic",
226
+ tiff: "image/tiff",
227
+ // 文档格式
228
+ pdf: "application/pdf",
229
+ doc: "application/msword",
230
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
231
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
232
+ txt: "text/plain",
233
+ md: "text/markdown",
234
+ csv: "text/csv",
235
+ json: "application/json",
236
+ epub: "application/epub+zip",
237
+ mobi: "application/x-mobipocket-ebook"
238
+ }, _e = [
239
+ "image/jpeg",
240
+ "image/png",
241
+ "image/gif",
242
+ "image/webp",
243
+ "image/bmp",
244
+ "image/heic",
245
+ "image/tiff"
246
+ ];
247
+ function Ht(t, s) {
248
+ const { t: e } = $(), n = s * 1024 * 1024;
249
+ if (t.size > n)
250
+ throw new Error(e("fileUpload.error.fileSizeExceeded", {
251
+ maxSizeMB: s,
252
+ currentSizeMB: (t.size / 1024 / 1024).toFixed(2)
253
+ }));
254
+ }
255
+ function Lt(t, s) {
256
+ var r, d, l;
257
+ const { t: e } = $();
258
+ if (!s)
259
+ return { valid: !1, error: e("fileUpload.error.unsupportedModel") };
260
+ const n = ((r = t.name.split(".").pop()) == null ? void 0 : r.toLowerCase()) || "";
261
+ if (!((d = s.supportImage) != null && d.supportedFileTypes.includes(n)))
262
+ return {
263
+ valid: !1,
264
+ error: e("fileUpload.error.unsupportedFormat", { extension: n })
265
+ };
266
+ const a = ((l = s.supportImage) == null ? void 0 : l.maxImageSize) || 0, p = a * 1024 * 1024;
267
+ return t.size > p ? {
268
+ valid: !1,
269
+ error: e("fileUpload.error.sizeLimitExceeded", { maxSize: a })
270
+ } : { valid: !0 };
271
+ }
272
+ function Ut(t) {
273
+ return _e.includes(t) ? "image" : "document";
274
+ }
275
+ const zt = async (t, s) => {
276
+ var a;
277
+ const { t: e } = $();
278
+ if (!s)
279
+ throw new Error(e("fileUpload.error.unsupportedModel"));
280
+ if ((a = s.supportImage) != null && a.maxFilesPerRequest && t.length > s.supportImage.maxFilesPerRequest)
281
+ throw new Error(e("fileUpload.error.maxFilesExceeded", { maxFiles: s.supportImage.maxFilesPerRequest }));
282
+ return await Promise.all(t.map((p) => qt(p, s)));
283
+ }, qt = async (t, s) => {
284
+ var r;
285
+ const { t: e } = $(), n = Ut(t.type), a = Lt(t, s);
286
+ if (!a.valid)
287
+ throw new Error(a.error);
288
+ const p = ((r = s.supportImage) == null ? void 0 : r.maxImageSize) || 0;
289
+ if (Ht(t, p), n === "image")
290
+ return {
291
+ type: "image",
292
+ image: t.base64,
293
+ filename: t.name
294
+ };
295
+ if (n === "document")
296
+ return {
297
+ type: "file",
298
+ mediaType: t.type,
299
+ data: t.base64,
300
+ filename: t.name
301
+ };
302
+ throw new Error(e("fileUpload.error.unsupportedFileType", { fileCategory: n }));
303
+ }, Gt = (t) => new Promise((s, e) => {
304
+ const n = new FileReader();
305
+ n.readAsDataURL(t), n.onload = () => {
306
+ const a = {
307
+ name: t.name,
308
+ type: t.type,
309
+ size: t.size,
310
+ lastModified: t.lastModified,
311
+ base64: n.result
312
+ };
313
+ s(a);
314
+ }, n.onerror = (a) => e(a);
315
+ }), Jt = () => {
316
+ const { t } = $(), s = A([]), e = A([]);
317
+ return {
318
+ attachments: s,
319
+ templateData: e,
320
+ processAttachments: async (d, l) => {
321
+ let i = [];
322
+ if (d.length === 0)
323
+ return { apiContent: i };
324
+ try {
325
+ return i = await zt(d, l), {
326
+ apiContent: i
327
+ };
328
+ } catch (o) {
329
+ return xe({
330
+ type: "error",
331
+ title: t("fileUpload.error.processFailed"),
332
+ message: o instanceof Error ? o.message : t("fileUpload.error.unknownError"),
333
+ position: "top-right"
334
+ }), null;
335
+ }
336
+ },
337
+ clearAttachments: () => {
338
+ s.value = [];
339
+ },
340
+ handleFilesSelected: async (d, l) => {
341
+ if (!(!d || d.length === 0)) {
342
+ e.value.length || e.value.unshift({
343
+ type: "text",
344
+ content: l
345
+ });
346
+ for (const i of d) {
347
+ e.value.push({
348
+ type: "template",
349
+ content: i.name || ""
350
+ });
351
+ try {
352
+ if (s.value.find((m) => m.name === i.name))
353
+ continue;
354
+ const o = await Gt(i);
355
+ s.value.push(o);
356
+ } catch (o) {
357
+ xe({
358
+ type: "error",
359
+ title: t("fileUpload.error.validationFailed"),
360
+ message: o instanceof Error ? o.message : t("fileUpload.error.unknownError"),
361
+ position: "top-right"
362
+ });
363
+ }
364
+ }
365
+ }
366
+ },
367
+ handleTemplateEdit: (d, l) => {
368
+ const i = d.value, o = new Set(
369
+ s.value.map((f) => f.name).filter((f) => !!f)
370
+ ), m = i.filter((f) => {
371
+ if (f.type === "template") {
372
+ const R = f.content;
373
+ return R && o.has(R);
374
+ }
375
+ return !0;
376
+ }), b = new Set(
377
+ m.filter((f) => f.type === "template" && f.content).map((f) => f.content)
378
+ );
379
+ for (let f = s.value.length - 1; f >= 0; f--) {
380
+ const v = s.value[f].name;
381
+ v && !b.has(v) && s.value.splice(f, 1);
382
+ }
383
+ return m;
384
+ }
385
+ };
386
+ }, Wt = { class: "attachments-renderer" }, jt = ["onClick"], Vt = { class: "image-wrapper" }, Kt = ["src", "alt"], Zt = ["onClick"], Yt = { class: "file-name" }, Xt = ["src", "alt"], Qt = /* @__PURE__ */ X({
387
+ __name: "AttachmentsRenderer",
388
+ props: {
389
+ attachments: {}
390
+ },
391
+ emits: ["remove"],
392
+ setup(t, { emit: s }) {
393
+ const e = t, n = s, a = A(null), p = (m) => _e.includes(m.type), r = O(() => e.attachments.filter((m) => p(m))), d = O(() => e.attachments.filter((m) => !p(m))), l = (m) => {
394
+ n("remove", m);
395
+ }, i = (m) => {
396
+ a.value = m, document.body.style.overflow = "hidden";
397
+ }, o = () => {
398
+ a.value = null, document.body.style.overflow = "";
399
+ };
400
+ return (m, b) => (E(), I("div", Wt, [
401
+ (E(!0), I(le, null, he(r.value, (f, R) => (E(), I("div", {
402
+ key: f.name,
403
+ class: "image-thumbnail",
404
+ onClick: (v) => i(f)
405
+ }, [
406
+ w("div", Vt, [
407
+ w("img", {
408
+ src: f.base64,
409
+ alt: f.name
410
+ }, null, 8, Kt)
411
+ ]),
412
+ w("button", {
413
+ class: "delete-btn",
414
+ onClick: ot((v) => l(f), ["stop"]),
415
+ type: "button"
416
+ }, [
417
+ D(S(yt), { class: "delete-btn-icon" })
418
+ ], 8, Zt),
419
+ b[0] || (b[0] = w("div", { class: "hover-overlay" }, [
420
+ w("span", { class: "preview-text" }, "预览")
421
+ ], -1))
422
+ ], 8, jt))), 128)),
423
+ (E(!0), I(le, null, he(d.value, (f) => (E(), I("div", {
424
+ key: f.name,
425
+ class: "file-item"
426
+ }, [
427
+ w("span", Yt, H(f.name), 1)
428
+ ]))), 128)),
429
+ D(ie, { name: "fullscreen-fade" }, {
430
+ default: j(() => [
431
+ a.value ? (E(), I("div", {
432
+ key: 0,
433
+ class: "fullscreen-overlay",
434
+ onClick: o
435
+ }, [
436
+ D(ie, { name: "image-scale" }, {
437
+ default: j(() => [
438
+ a.value ? (E(), I("img", {
439
+ key: 0,
440
+ src: a.value.base64,
441
+ alt: a.value.name
442
+ }, null, 8, Xt)) : V("", !0)
443
+ ]),
444
+ _: 1
445
+ })
446
+ ])) : V("", !0)
447
+ ]),
448
+ _: 1
449
+ })
450
+ ]));
451
+ }
452
+ }), es = /* @__PURE__ */ Q(Qt, [["__scopeId", "data-v-63821ae8"]]), ts = { class: "template-data-renderer" }, ss = {
453
+ key: 0,
454
+ class: "text-item"
455
+ }, ns = {
456
+ key: 1,
457
+ class: "template-item"
458
+ }, as = ["onClick"], os = {
459
+ key: 0,
460
+ class: "image-preview"
461
+ }, rs = ["src", "alt", "onClick"], ls = ["src", "alt"], is = /* @__PURE__ */ X({
462
+ __name: "TemplateDataRenderer",
463
+ props: {
464
+ templateData: { default: () => [] },
465
+ attachments: { default: () => [] }
466
+ },
467
+ setup(t) {
468
+ const s = t, e = A(null), n = (i) => {
469
+ if (i.type !== "template" || !i.content)
470
+ return !1;
471
+ const o = s.attachments.find((m) => m.name === i.content);
472
+ return o ? _e.includes(o.type) : !1;
473
+ }, a = (i) => {
474
+ if (i.type !== "template" || !i.content)
475
+ return "";
476
+ const o = s.attachments.find((m) => m.name === i.content);
477
+ return (o == null ? void 0 : o.base64) || "";
478
+ }, p = (i) => {
479
+ if (!(i.type !== "template" || !i.content))
480
+ return s.attachments.find((o) => o.name === i.content);
481
+ }, r = (i) => {
482
+ const o = p(i);
483
+ o && d(o);
484
+ }, d = (i) => {
485
+ e.value = i, document.body.style.overflow = "hidden";
486
+ }, l = () => {
487
+ e.value = null, document.body.style.overflow = "";
488
+ };
489
+ return (i, o) => (E(), I("div", ts, [
490
+ (E(!0), I(le, null, he(t.templateData, (m, b) => (E(), I(le, { key: b }, [
491
+ m.type === "text" ? (E(), I("span", ss, H(m.content), 1)) : m.type === "template" ? (E(), I("span", ns, [
492
+ D(S(St), {
493
+ width: "200",
494
+ trigger: "hover",
495
+ content: m.content,
496
+ placement: "top"
497
+ }, {
498
+ reference: j(() => [
499
+ w("span", {
500
+ class: "template-text",
501
+ onClick: (f) => r(m)
502
+ }, H(m.content), 9, as)
503
+ ]),
504
+ default: j(() => [
505
+ n(m) ? (E(), I("div", os, [
506
+ w("img", {
507
+ class: "image-preview-img",
508
+ src: a(m),
509
+ alt: m.content,
510
+ onClick: (f) => r(m)
511
+ }, null, 8, rs)
512
+ ])) : V("", !0)
513
+ ]),
514
+ _: 2
515
+ }, 1032, ["content"])
516
+ ])) : V("", !0)
517
+ ], 64))), 128)),
518
+ D(ie, { name: "fullscreen-fade" }, {
519
+ default: j(() => [
520
+ e.value ? (E(), I("div", {
521
+ key: 0,
522
+ class: "fullscreen-overlay",
523
+ onClick: l
524
+ }, [
525
+ D(ie, { name: "image-scale" }, {
526
+ default: j(() => [
527
+ e.value ? (E(), I("img", {
528
+ key: 0,
529
+ src: e.value.base64,
530
+ alt: e.value.name
531
+ }, null, 8, ls)) : V("", !0)
532
+ ]),
533
+ _: 1
534
+ })
535
+ ])) : V("", !0)
536
+ ]),
537
+ _: 1
538
+ })
539
+ ]));
540
+ }
541
+ }), cs = /* @__PURE__ */ Q(is, [["__scopeId", "data-v-e158cad0"]]), us = {
542
+ class: "tr-bubble__reasoning",
543
+ "data-type": "reasoning"
544
+ }, ds = { class: "title" }, ms = { class: "detail" }, ps = /* @__PURE__ */ X({
545
+ __name: "ReasoningRenderer",
546
+ props: {
547
+ content: {},
548
+ thinking: { type: Boolean }
549
+ },
550
+ setup(t) {
551
+ const s = t, e = A(!1), { t: n } = $(), a = () => {
552
+ e.value = !e.value;
553
+ }, p = new Be({
554
+ defaultAttrs: { class: "markdown-content" },
555
+ mdConfig: { html: !0 }
556
+ }), r = (d) => p.render({ content: d.content });
557
+ return (d, l) => (E(), I("div", us, [
558
+ w("div", {
559
+ class: "header",
560
+ onClick: a
561
+ }, [
562
+ w("div", {
563
+ class: K(["icon-and-text", { thinking: s.thinking }])
564
+ }, [
565
+ l[0] || (l[0] = w("svg", {
566
+ class: "thinking-icon",
567
+ width: "1em",
568
+ height: "1em",
569
+ viewBox: "0 0 24 24",
570
+ xmlns: "http://www.w3.org/2000/svg",
571
+ fill: "none",
572
+ stroke: "currentColor",
573
+ "stroke-width": "2",
574
+ "stroke-linecap": "round",
575
+ "stroke-linejoin": "round"
576
+ }, [
577
+ w("circle", {
578
+ cx: "12",
579
+ cy: "12",
580
+ r: "1"
581
+ }),
582
+ w("path", { d: "M20.2 20.2c2.04-2.03.02-7.36-4.5-11.9-4.54-4.52-9.87-6.54-11.9-4.5-2.04 2.03-.02 7.36 4.5 11.9 4.54 4.52 9.87 6.54 11.9 4.5Z" }),
583
+ w("path", { d: "M15.7 15.7c4.52-4.54 6.54-9.87 4.5-11.9-2.03-2.04-7.36-.02-11.9 4.5-4.52 4.54-6.54 9.87-4.5 11.9 2.03 2.04 7.36.02 11.9-4.5Z" })
584
+ ], -1)),
585
+ w("span", ds, H(s.thinking ? S(n)("reasoning.thinking") : S(n)("reasoning.thinkingEnd")), 1)
586
+ ], 2),
587
+ D(S(ye), {
588
+ class: K(["expand-icon", { "-rotate-90": !e.value }])
589
+ }, null, 8, ["class"])
590
+ ]),
591
+ Ae(w("div", ms, [
592
+ l[1] || (l[1] = w("div", { class: "side-border" }, [
593
+ w("div", { class: "dot-wrapper" }, [
594
+ w("div", { class: "dot" })
595
+ ]),
596
+ w("div", { class: "border-line" })
597
+ ], -1)),
598
+ D(r, {
599
+ content: s.content,
600
+ class: "detail-content"
601
+ }, null, 8, ["content"])
602
+ ], 512), [
603
+ [De, e.value]
604
+ ])
605
+ ]));
606
+ }
607
+ }), gs = /* @__PURE__ */ Q(ps, [["__scopeId", "data-v-1ffff0cd"]]), hs = { class: "tr-bubble__step-tool" }, fs = { class: "tr-bubble__step-tool-header" }, vs = { class: "tr-bubble__step-tool-left" }, ys = { class: "tr-bubble__step-tool-title" }, _s = { class: "tr-bubble__step-tool-name" }, ws = { class: "tr-bubble__step-tool-expand" }, bs = {
608
+ key: 0,
609
+ class: "tr-bubble__step-tool-params"
610
+ }, Cs = ["innerHTML"], Ms = 100, Ss = /* @__PURE__ */ X({
611
+ __name: "ToolRenderer",
612
+ props: {
613
+ name: {},
614
+ status: {},
615
+ content: {},
616
+ formatPretty: { type: Boolean },
617
+ defaultOpen: { type: Boolean }
618
+ },
619
+ setup(t) {
620
+ const s = (o, m) => {
621
+ let b = 0;
622
+ const f = (R) => {
623
+ if (!R || typeof R != "object")
624
+ return !1;
625
+ if (Array.isArray(R)) {
626
+ for (const v of R)
627
+ if (f(v))
628
+ return !0;
629
+ return !1;
630
+ }
631
+ for (const v of Object.values(R))
632
+ if (b += 1, b > m || f(v))
633
+ return !0;
634
+ return !1;
635
+ };
636
+ return f(o);
637
+ }, e = (o) => o.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), n = t, { t: a } = $(), p = A(n.defaultOpen ?? !1), r = /* @__PURE__ */ new Map([
638
+ ["running", { text: a("toolStatus.running"), icon: _t }],
639
+ ["success", { text: a("toolStatus.success"), icon: ke }],
640
+ ["failed", { text: a("toolStatus.failed"), icon: wt }],
641
+ ["cancelled", { text: a("toolStatus.cancelled"), icon: bt }]
642
+ ]), d = O(() => r.get(n.status) || { text: "", icon: ke }), l = rt(), i = (o) => {
643
+ if (!o)
644
+ return "";
645
+ let m = "", b = o;
646
+ const f = n.formatPretty ? 2 : 0;
647
+ try {
648
+ typeof o == "string" ? (b = JSON.parse(o), m = JSON.stringify(b, null, f)) : (b = o, m = JSON.stringify(o, null, f));
649
+ } catch (v) {
650
+ console.warn(v);
651
+ }
652
+ return s(b, Ms) ? e(m) : (m = m.replace(
653
+ /("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g,
654
+ (v) => {
655
+ let T = "number";
656
+ return /^"/.test(v) ? T = /:$/.test(v) ? "key" : "string" : /true|false/.test(v) ? T = "boolean" : /null/.test(v) && (T = "null"), `<span class="${l[T]}">${e(v)}</span>`;
657
+ }
658
+ ), m);
659
+ };
660
+ return (o, m) => (E(), I("div", hs, [
661
+ w("div", fs, [
662
+ w("div", vs, [
663
+ (E(), $e(lt(d.value.icon), {
664
+ class: K(["tr-bubble__step-tool-icon", `icon-${n.status}`])
665
+ }, null, 8, ["class"])),
666
+ w("span", ys, [
667
+ it(H(d.value.text) + " ", 1),
668
+ w("span", _s, H(n.name), 1)
669
+ ])
670
+ ]),
671
+ w("div", ws, [
672
+ D(S(ye), {
673
+ class: K(["expand-icon", { "-rotate-90": !p.value }]),
674
+ onClick: m[0] || (m[0] = (b) => p.value = !p.value)
675
+ }, null, 8, ["class"])
676
+ ])
677
+ ]),
678
+ p.value ? (E(), I("div", bs, [
679
+ m[1] || (m[1] = w("hr", { class: "tr-bubble__step-tool-hr" }, null, -1)),
680
+ w("div", {
681
+ class: "tr-bubble__step-tool-params-content",
682
+ innerHTML: i(n.content)
683
+ }, null, 8, Cs)
684
+ ])) : V("", !0)
685
+ ]));
686
+ }
687
+ }), Rs = "_key_1b448_2", ks = "_number_1b448_6", xs = "_string_1b448_10", Es = "_boolean_1b448_14", Is = {
688
+ key: Rs,
689
+ number: ks,
690
+ string: xs,
691
+ boolean: Es,
692
+ null: "_null_1b448_18"
693
+ }, Ts = {
694
+ $style: Is
695
+ }, Fs = /* @__PURE__ */ Q(Ss, [["__cssModules", Ts], ["__scopeId", "data-v-398a0327"]]);
696
+ class As {
697
+ constructor() {
698
+ this.events = {}, this.events = /* @__PURE__ */ Object.create(null);
699
+ }
700
+ /**
701
+ * @param {string} eventName - 事件名
702
+ * @param {Function} callback - 回调函数
703
+ * @param {boolean} [once=false] - 是否只触发一次
704
+ */
705
+ on(s, e, n = !1) {
706
+ if (typeof e != "function")
707
+ throw new TypeError("回调必须是函数");
708
+ this.events[s] || (this.events[s] = []), this.events[s].push({ callback: e, once: n });
709
+ }
710
+ /**
711
+ * @param {string} eventName - 事件名
712
+ * @param {Function} callback - 要移除的回调(必须是注册时的同一个函数引用)
713
+ */
714
+ off(s, e) {
715
+ this.events[s] && (this.events[s] = this.events[s].filter((n) => n.callback !== e), this.events[s].length === 0 && delete this.events[s]);
716
+ }
717
+ /**
718
+ * @param {string} eventName - 事件名
719
+ * @param {...any} args - 传递给回调的参数
720
+ */
721
+ emit(s, ...e) {
722
+ if (!this.events[s]) return;
723
+ [...this.events[s]].forEach((a, p) => {
724
+ const { callback: r, once: d } = a;
725
+ r.apply(this, e), d && this.events[s].splice(p, 1);
726
+ }), this.events[s].length === 0 && delete this.events[s];
727
+ }
728
+ /**
729
+ * @param {string} eventName - 事件名
730
+ * @param {Function} callback - 回调函数
731
+ */
732
+ once(s, e) {
733
+ this.on(s, e, !0);
734
+ }
735
+ }
736
+ const oe = new As(), Ds = {
737
+ key: 0,
738
+ class: "loading-wrapper"
739
+ }, $s = {
740
+ class: "loading-container",
741
+ type: "loading-text"
742
+ }, Os = /* @__PURE__ */ X({
743
+ __name: "GeneratingComponent",
744
+ props: {
745
+ emitter: {},
746
+ message: {},
747
+ showThinkingResult: { type: Boolean }
748
+ },
749
+ setup(t) {
750
+ const s = t, { t: e } = $(), n = A(e("loading.response")), a = /* @__PURE__ */ new Map([
751
+ ["running", { textKey: "toolStatus.running" }],
752
+ ["success", { textKey: "toolStatus.success" }],
753
+ ["failed", { textKey: "toolStatus.failed" }],
754
+ ["cancelled", { textKey: "toolStatus.cancelled" }]
755
+ ]), p = (r) => {
756
+ var l;
757
+ if (r.type === "done") {
758
+ n.value = "";
759
+ return;
760
+ }
761
+ if (r.type === "schema-card") {
762
+ n.value = e("loading.generatingCard");
763
+ return;
764
+ }
765
+ if (s.showThinkingResult) {
766
+ n.value = e("loading.response");
767
+ return;
768
+ }
769
+ if (r.type === "tool") {
770
+ const { toolCallData: i } = r, o = ((l = a.get(i.status)) == null ? void 0 : l.textKey) || "loading.response";
771
+ n.value = `${e(o)} ${i.name}...`;
772
+ return;
773
+ }
774
+ const d = r.chatMessage.messages[r.chatMessage.messages.length - 1];
775
+ d && (n.value = `${d.content}...`);
776
+ };
777
+ return ve(() => {
778
+ s.emitter.on("notification", p);
779
+ }), Oe(() => {
780
+ s.emitter.off("notification", p);
781
+ }), (r, d) => n.value ? (E(), I("div", Ds, [
782
+ w("div", $s, H(n.value), 1)
783
+ ])) : V("", !0);
784
+ }
785
+ }), Ns = /* @__PURE__ */ Q(Os, [["__scopeId", "data-v-e1124fd9"]]);
786
+ function Bs({
787
+ chat: t,
788
+ saveState: s
789
+ }) {
790
+ const { t: e } = $();
791
+ return {
792
+ continueChatAction: {
793
+ name: "continueChat",
794
+ description: e("continueChat.description"),
795
+ execute: (n, a) => {
796
+ t({
797
+ llmFriendlyMessage: `${n.message},${e("continueChat.messageParam")}${JSON.stringify(a.state || {})}`,
798
+ humanFriendlyMessage: n.message,
799
+ context: a
800
+ });
801
+ },
802
+ parameters: {
803
+ type: "object",
804
+ properties: {
805
+ message: {
806
+ type: "string",
807
+ description: e("continueChat.paramDescription")
808
+ }
809
+ }
810
+ }
811
+ },
812
+ saveStateAction: {
813
+ name: "saveState",
814
+ description: e("saveState.description"),
815
+ execute: (n, a) => {
816
+ s(a);
817
+ },
818
+ parameters: { type: "null" }
819
+ }
820
+ };
821
+ }
822
+ const Ps = { class: "tg-playground-error-card" }, Hs = { class: "card-title" }, Ls = /* @__PURE__ */ X({
823
+ __name: "ErrorText",
824
+ props: {
825
+ content: {}
826
+ },
827
+ setup(t) {
828
+ const s = Et(), e = It(), { t: n } = $(), a = A(!1), p = () => {
829
+ a.value = !a.value;
830
+ };
831
+ return (r, d) => (E(), I("div", Ps, [
832
+ w("div", {
833
+ class: "card-header",
834
+ onClick: p
835
+ }, [
836
+ D(S(e), { class: "icon-error" }),
837
+ w("span", Hs, H(S(n)("error.title")), 1),
838
+ D(S(s), {
839
+ class: K(["icon-right", { expanded: a.value }])
840
+ }, null, 8, ["class"])
841
+ ]),
842
+ w("pre", {
843
+ class: K(["card-body", { collapsed: !a.value }])
844
+ }, " " + H(t.content) + `
845
+ `, 3)
846
+ ]));
847
+ }
848
+ }), Us = /* @__PURE__ */ Q(Ls, [["__scopeId", "data-v-a0f77c05"]]);
849
+ function zs(t) {
850
+ const s = A(0), e = A(0);
851
+ let n = null, a = null;
852
+ const p = (l) => {
853
+ if (!l) {
854
+ s.value = 0, e.value = 0;
855
+ return;
856
+ }
857
+ const i = l.getBoundingClientRect();
858
+ s.value = i.width, e.value = i.height;
859
+ }, r = (l) => {
860
+ a !== null && cancelAnimationFrame(a), a = requestAnimationFrame(() => {
861
+ p(l), a = null;
862
+ });
863
+ }, d = () => {
864
+ n && t.value && n.unobserve(t.value), n = null, a !== null && (cancelAnimationFrame(a), a = null);
865
+ };
866
+ return ve(() => {
867
+ typeof ResizeObserver > "u" || !t.value || (n = new ResizeObserver((l) => {
868
+ const o = l[0].target;
869
+ r(o);
870
+ }), n.observe(t.value), p(t.value));
871
+ }), Oe(() => {
872
+ d();
873
+ }), {
874
+ width: s,
875
+ height: e
876
+ };
877
+ }
878
+ function Pe(t) {
879
+ const { t: s } = $(), { client: e, useStreamByDefault: n = !0, errorMessage: a = s("message.requestFailed"), initialMessages: p = [] } = t, r = A([...p]), d = A(""), l = A(n);
880
+ let i = null;
881
+ const o = ue({
882
+ status: q.INIT,
883
+ errorMsg: null
884
+ }), m = (C) => {
885
+ var y;
886
+ const g = (y = t.events) == null ? void 0 : y.onReceiveData;
887
+ let h = !1;
888
+ if (g && g(C, r, () => {
889
+ h = !0;
890
+ }), !h) {
891
+ const k = {
892
+ role: "assistant",
893
+ content: C.choices[0].message.content
894
+ };
895
+ r.value.push(k);
896
+ }
897
+ }, b = async (C) => {
898
+ const g = await e.chat({
899
+ messages: fe(r.value),
900
+ options: {
901
+ stream: !1,
902
+ signal: C.signal
903
+ }
904
+ });
905
+ m(g);
906
+ }, f = (C) => {
907
+ var y, k;
908
+ const g = (y = t.events) == null ? void 0 : y.onReceiveData;
909
+ let h = !1;
910
+ if (g && g(C, r, () => {
911
+ h = !0;
912
+ }), !h) {
913
+ r.value[r.value.length - 1].role === "user" && r.value.push({ role: "assistant", content: "" });
914
+ const B = (k = C.choices) == null ? void 0 : k[0];
915
+ B && B.delta.content && (r.value[r.value.length - 1].content += B.delta.content);
916
+ }
917
+ }, R = async (C) => {
918
+ await e.chatStream(
919
+ {
920
+ messages: fe(r.value),
921
+ options: {
922
+ stream: !0,
923
+ signal: C.signal
924
+ }
925
+ },
926
+ {
927
+ onData: (g) => {
928
+ o.status = q.STREAMING, f(g);
929
+ },
930
+ onError: (g) => {
931
+ o.status = q.ERROR, o.errorMsg = a, console.error("Stream request error:", g);
932
+ },
933
+ onDone: (g) => {
934
+ var k;
935
+ const h = (k = t.events) == null ? void 0 : k.onFinish;
936
+ let y = !1;
937
+ if (h && h(g, { messages: r, messageState: o }, () => {
938
+ y = !0;
939
+ }), !y) {
940
+ if (g === "aborted" || o.status === q.ABORTED)
941
+ return;
942
+ o.status = q.FINISHED;
943
+ }
944
+ }
945
+ }
946
+ );
947
+ }, v = async () => {
948
+ o.status = q.PROCESSING, o.errorMsg = null, i = new AbortController();
949
+ try {
950
+ l.value ? await R(i) : await b(i);
951
+ } catch (C) {
952
+ o.errorMsg = a, o.status = q.ERROR, console.error("Send message error:", C);
953
+ } finally {
954
+ i = null;
955
+ }
956
+ }, T = async (C = d.value, g = !0) => {
957
+ if (ae.includes(o.status) || !C || typeof C == "string" && !C.trim() || Array.isArray(C) && C.length === 0)
958
+ return;
959
+ const h = {
960
+ role: "user",
961
+ content: C
962
+ };
963
+ r.value.push(h), g && (d.value = ""), await v();
964
+ }, G = async () => {
965
+ ae.includes(o.status) || await v();
966
+ }, L = () => {
967
+ i && (i.abort(), i = null, o.status = q.ABORTED);
968
+ }, N = async (C) => {
969
+ C === 0 || !r.value[C] || r.value[C].role === "user" || (r.value.splice(C), await v());
970
+ }, J = () => {
971
+ r.value = [], o.errorMsg = null;
972
+ }, Z = (C) => {
973
+ Array.isArray(C) ? r.value.push(...C) : r.value.push(C);
974
+ };
975
+ return {
976
+ conversationId: t.conversationId,
977
+ messages: r,
978
+ messageState: o,
979
+ inputMessage: d,
980
+ useStream: l,
981
+ sendMessage: T,
982
+ send: G,
983
+ clearMessages: J,
984
+ addMessage: Z,
985
+ abortRequest: L,
986
+ retryRequest: N
987
+ };
988
+ }
989
+ class qs {
990
+ constructor(s, e) {
991
+ this.messageManagerMap = /* @__PURE__ */ new Map(), this.messageManagerMap = /* @__PURE__ */ new Map(), this.conversationState = s, this.options = e;
992
+ }
993
+ getMessageManager(s) {
994
+ const e = this.messageManagerMap.get(s);
995
+ if (e)
996
+ return e;
997
+ if (!this.conversationState.conversations.find(
998
+ (a) => a.id === s
999
+ ))
1000
+ throw new Error(`Conversation not found for id: ${s}`);
1001
+ return this.setMessageManager(s);
1002
+ }
1003
+ setMessageManager(s, e) {
1004
+ if (this.messageManagerMap.has(s))
1005
+ return this.messageManagerMap.get(s);
1006
+ const n = Pe(e ?? { ...this.options, conversationId: s });
1007
+ return this.messageManagerMap.set(s, n), n;
1008
+ }
1009
+ deleteMessageManager(s) {
1010
+ this.messageManagerMap.delete(s);
1011
+ }
1012
+ }
1013
+ const ne = (t) => Ne(t) ? ne(S(t)) : ct(t) ? ne(fe(t)) : Array.isArray(t) ? t.map(ne) : t && typeof t == "object" ? Object.keys(t).reduce((s, e) => (s[e] = ne(t[e]), s), {}) : t;
1014
+ class Gs {
1015
+ constructor(s = "genui-ai", e = "conversations", n = "conversations-list") {
1016
+ this.db = null, this.dbName = s, this.storeName = e, this.dataKey = n;
1017
+ }
1018
+ async openDB() {
1019
+ return this.db ? this.db : new Promise((s, e) => {
1020
+ const n = indexedDB.open(this.dbName, 1);
1021
+ n.onerror = () => {
1022
+ e(new Error("打开 IndexedDB 失败"));
1023
+ }, n.onsuccess = () => {
1024
+ this.db = n.result, s(this.db);
1025
+ }, n.onupgradeneeded = (a) => {
1026
+ const p = a.target.result;
1027
+ p.objectStoreNames.contains(this.storeName) || p.createObjectStore(this.storeName);
1028
+ };
1029
+ });
1030
+ }
1031
+ async saveConversations(s) {
1032
+ try {
1033
+ const a = (await this.openDB()).transaction([this.storeName], "readwrite").objectStore(this.storeName), p = ne(s);
1034
+ return new Promise((r, d) => {
1035
+ const l = a.put(p, this.dataKey);
1036
+ l.onsuccess = () => r(), l.onerror = () => {
1037
+ console.error("保存会话失败:", l.error), d(l.error);
1038
+ };
1039
+ });
1040
+ } catch (e) {
1041
+ throw console.error("保存会话失败:", e), e;
1042
+ }
1043
+ }
1044
+ async loadConversations() {
1045
+ try {
1046
+ const n = (await this.openDB()).transaction([this.storeName], "readonly").objectStore(this.storeName);
1047
+ return new Promise((a, p) => {
1048
+ const r = n.get(this.dataKey);
1049
+ r.onsuccess = () => {
1050
+ const d = r.result;
1051
+ if (!d) {
1052
+ a([]);
1053
+ return;
1054
+ }
1055
+ let l = [];
1056
+ if (typeof d == "string")
1057
+ try {
1058
+ l = JSON.parse(d);
1059
+ } catch (i) {
1060
+ console.error("解析会话数据失败:", i), a([]);
1061
+ return;
1062
+ }
1063
+ else
1064
+ l = Array.isArray(d) ? d : [];
1065
+ a(l);
1066
+ }, r.onerror = () => {
1067
+ console.error("加载会话失败:", r.error), p(r.error);
1068
+ };
1069
+ });
1070
+ } catch (s) {
1071
+ return console.error("加载会话失败:", s), [];
1072
+ }
1073
+ }
1074
+ }
1075
+ function Js() {
1076
+ return Date.now().toString(36) + Math.random().toString(36).substring(2, 9);
1077
+ }
1078
+ function Ws(t) {
1079
+ const { t: s } = $(), {
1080
+ client: e,
1081
+ storage: n = new Gs(),
1082
+ autoSave: a = !0,
1083
+ allowEmpty: p = !1,
1084
+ useStreamByDefault: r = !0,
1085
+ errorMessage: d,
1086
+ events: l
1087
+ } = t, i = d || s("message.requestFailed"), o = ue({
1088
+ conversations: [],
1089
+ currentId: null,
1090
+ loading: !1
1091
+ });
1092
+ let m = !1;
1093
+ const b = new qs(o, {
1094
+ client: e,
1095
+ useStreamByDefault: r,
1096
+ conversationId: "",
1097
+ errorMessage: i,
1098
+ initialMessages: [],
1099
+ events: {
1100
+ onReceiveData: l == null ? void 0 : l.onReceiveData,
1101
+ onFinish: l == null ? void 0 : l.onFinish
1102
+ }
1103
+ }), f = O(() => o.currentId ? b.getMessageManager(o.currentId) : Pe({
1104
+ client: e,
1105
+ useStreamByDefault: r,
1106
+ conversationId: "",
1107
+ errorMessage: i,
1108
+ initialMessages: [],
1109
+ events: {
1110
+ onReceiveData: l == null ? void 0 : l.onReceiveData,
1111
+ onFinish: l == null ? void 0 : l.onFinish
1112
+ }
1113
+ }));
1114
+ ce(
1115
+ () => f.value,
1116
+ () => {
1117
+ b.messageManagerMap.forEach((g) => {
1118
+ const h = g.messages.value;
1119
+ if (o.currentId && h.length > 0) {
1120
+ const y = o.conversations.findIndex((k) => k.id === g.conversationId);
1121
+ y !== -1 && (o.conversations[y].messages = [...h], o.conversations[y].updatedAt = Date.now(), a && N());
1122
+ }
1123
+ });
1124
+ },
1125
+ { deep: !0 }
1126
+ );
1127
+ const R = (g, h = {}) => {
1128
+ const y = g || s("conversation.newConversation");
1129
+ if (!p && f.value.messages.value.length === 0 && o.currentId)
1130
+ return o.currentId;
1131
+ const k = Js(), B = {
1132
+ id: k,
1133
+ title: y,
1134
+ createdAt: Date.now(),
1135
+ updatedAt: Date.now(),
1136
+ messages: [],
1137
+ metadata: h
1138
+ };
1139
+ return o.conversations.unshift(B), b.setMessageManager(k, { ...t, conversationId: k }), v(k), a && N(), k;
1140
+ }, v = (g) => {
1141
+ const h = o.conversations.find((y) => y.id === g);
1142
+ h && (o.currentId = g, b.setMessageManager(g, { ...t, initialMessages: h.messages, conversationId: g }));
1143
+ }, T = (g) => {
1144
+ const h = o.conversations.findIndex((y) => y.id === g);
1145
+ h !== -1 && (b.deleteMessageManager(g), o.conversations.splice(h, 1), o.currentId === g && (o.conversations.length > 0 ? v(o.conversations[0].id) : o.currentId = null), a && N());
1146
+ }, G = (g, h) => {
1147
+ const y = o.conversations.find((k) => k.id === g);
1148
+ y && (y.title = h, y.updatedAt = Date.now(), a && N());
1149
+ }, L = (g, h) => {
1150
+ const y = o.conversations.find((k) => k.id === g);
1151
+ y && (y.metadata = { ...y.metadata, ...h }, y.updatedAt = Date.now(), a && N());
1152
+ }, N = async () => {
1153
+ try {
1154
+ await n.saveConversations(o.conversations);
1155
+ } catch (g) {
1156
+ console.error("保存会话失败:", g);
1157
+ }
1158
+ }, J = async () => {
1159
+ o.loading = !0;
1160
+ try {
1161
+ const g = await n.loadConversations();
1162
+ o.conversations = g, g.length > 0 && !o.currentId && v(g[0].id), !m && (l != null && l.onLoaded) && (m = !0, l.onLoaded(g));
1163
+ } catch (g) {
1164
+ console.error("加载会话失败:", g);
1165
+ } finally {
1166
+ o.loading = !1;
1167
+ }
1168
+ }, Z = async (g) => {
1169
+ const h = o.conversations.find((y) => y.id === g);
1170
+ if (!h || h.messages.length < 2)
1171
+ return (h == null ? void 0 : h.title) || s("conversation.newConversation");
1172
+ try {
1173
+ const y = {
1174
+ role: "system",
1175
+ content: "请根据以下对话内容,生成一个简短的标题(不超过20个字符)。只需要返回标题文本,不需要任何解释或额外内容。"
1176
+ }, k = h.messages.slice(0, Math.min(4, h.messages.length)), U = (await e.chat({
1177
+ messages: [y, ...k],
1178
+ options: {
1179
+ stream: !1,
1180
+ max_tokens: 30
1181
+ }
1182
+ })).choices[0].message.content.trim();
1183
+ return G(g, U), U;
1184
+ } catch (y) {
1185
+ return console.error("生成标题失败:", y), h.title;
1186
+ }
1187
+ }, C = () => o.currentId && o.conversations.find((g) => g.id === o.currentId) || null;
1188
+ return J(), {
1189
+ state: o,
1190
+ messageManager: f,
1191
+ createConversation: R,
1192
+ switchConversation: v,
1193
+ deleteConversation: T,
1194
+ updateTitle: G,
1195
+ updateMetadata: L,
1196
+ saveConversations: N,
1197
+ loadConversations: J,
1198
+ generateTitle: Z,
1199
+ getCurrentConversation: C
1200
+ };
1201
+ }
1202
+ class js {
1203
+ constructor() {
1204
+ this.thinkStartFlag = "<think>", this.thinkEndFlag = "</think>", this.startRegex = new RegExp(`${this.thinkStartFlag}`), this.endRegex = new RegExp(`${this.thinkEndFlag}`), this.partialStartRegex = new RegExp(`${Ee(this.thinkStartFlag)}$`), this.partialEndRegex = new RegExp(`${Ee(this.thinkEndFlag)}$`);
1205
+ }
1206
+ get regExpMap() {
1207
+ return {
1208
+ start: {
1209
+ full: this.startRegex,
1210
+ partial: this.partialStartRegex
1211
+ },
1212
+ end: {
1213
+ full: this.endRegex,
1214
+ partial: this.partialEndRegex
1215
+ }
1216
+ };
1217
+ }
1218
+ }
1219
+ const W = (t) => {
1220
+ var s, e;
1221
+ return ((e = (s = t.choices) == null ? void 0 : s[0]) == null ? void 0 : e.delta) ?? {};
1222
+ };
1223
+ function Vs(t, s, e, n, a) {
1224
+ const {
1225
+ id: p,
1226
+ function: { arguments: r, result: d }
1227
+ } = t[0], l = e[p];
1228
+ if (l && (l.status = "success", l.content = JSON.stringify({ arguments: r, result: d }, null, 2), oe.emit("notification", {
1229
+ type: "tool",
1230
+ delta: s,
1231
+ toolCallData: te(l),
1232
+ chatMessage: te(n)
1233
+ }), a)) {
1234
+ const { t: i } = $();
1235
+ n.content += i("toolCall.context", {
1236
+ toolName: l.name,
1237
+ toolParams: JSON.stringify(r),
1238
+ toolResult: JSON.stringify(d)
1239
+ }) + `
1240
+
1241
+ `;
1242
+ }
1243
+ }
1244
+ function Ks(t, s, e, n, a) {
1245
+ t.forEach((p) => {
1246
+ const {
1247
+ id: r,
1248
+ function: { name: d, arguments: l }
1249
+ } = p;
1250
+ let i;
1251
+ if (r)
1252
+ a.inProcessToolCallId = r, i = ue({
1253
+ type: "tool",
1254
+ name: d,
1255
+ formatPretty: !0,
1256
+ status: "running",
1257
+ content: JSON.stringify({ arguments: l || "" }, null, 2),
1258
+ id: r
1259
+ }), e[r] = i, n.messages.push(i);
1260
+ else {
1261
+ i = e[a.inProcessToolCallId];
1262
+ const m = JSON.parse(i.content).arguments + (l || "");
1263
+ i.content = JSON.stringify({ arguments: m }, null, 2);
1264
+ }
1265
+ oe.emit("notification", {
1266
+ type: "tool",
1267
+ delta: s,
1268
+ toolCallData: te(i),
1269
+ chatMessage: te(n)
1270
+ });
1271
+ });
1272
+ }
1273
+ function Te(t, s, e) {
1274
+ let a = e.messages[e.messages.length - 1];
1275
+ return (a == null ? void 0 : a.type) === "reasoning" ? a.content += t : (a = {
1276
+ type: "reasoning",
1277
+ content: t,
1278
+ thinking: !0
1279
+ }, e.messages.push(a)), we(s, e), a;
1280
+ }
1281
+ function He(t) {
1282
+ (t == null ? void 0 : t.type) === "reasoning" && (t.thinking = !1);
1283
+ }
1284
+ function we(t, s) {
1285
+ const e = s.messages[s.messages.length - 1];
1286
+ e && oe.emit("notification", {
1287
+ type: e.type,
1288
+ delta: t,
1289
+ chatMessage: te(s)
1290
+ });
1291
+ }
1292
+ function Zs(t, s, e) {
1293
+ e.messages.length > 0 && e.messages[e.messages.length - 1].type === "markdown" ? e.messages[e.messages.length - 1].content += t : e.messages.push({
1294
+ type: "markdown",
1295
+ content: t
1296
+ }), we(s, e);
1297
+ }
1298
+ function Ys(t, s, e) {
1299
+ e.messages.length > 0 && e.messages[e.messages.length - 1].type === "schema-card" ? e.messages[e.messages.length - 1].content += t : e.messages.push({
1300
+ type: "schema-card",
1301
+ content: t,
1302
+ id: Tt()
1303
+ }), we(s, e);
1304
+ }
1305
+ function Fe(t) {
1306
+ t.unWatchReasoning = ce(
1307
+ () => [...t.chatMessage.messages],
1308
+ (s) => {
1309
+ var e, n;
1310
+ t.handleReasoning && ((e = s[s.length - 1]) == null ? void 0 : e.type) !== "reasoning" && (t.handleReasoning = !1, He(t.reasoningMessage), (n = t.unWatchReasoning) == null || n.call(t));
1311
+ },
1312
+ { flush: "sync" }
1313
+ );
1314
+ }
1315
+ const Xs = [
1316
+ {
1317
+ name: "init",
1318
+ match: (t, s) => !1,
1319
+ handler: (t, s) => !1,
1320
+ start: (t, s) => {
1321
+ const e = ue({
1322
+ role: "assistant",
1323
+ content: "",
1324
+ messages: []
1325
+ });
1326
+ return t.chatMessage = e, t.handlers = s, s.onData(e), !1;
1327
+ },
1328
+ end: (t) => {
1329
+ t.handlers.onDone(), oe.emit("notification", {
1330
+ type: "done",
1331
+ delta: {},
1332
+ chatMessage: te(t.chatMessage)
1333
+ });
1334
+ }
1335
+ },
1336
+ {
1337
+ name: "finish-info",
1338
+ match: (t, s) => {
1339
+ var a;
1340
+ const { choices: e, usage: n } = t;
1341
+ return ((a = e == null ? void 0 : e[0]) == null ? void 0 : a.finish_reason) && !!n;
1342
+ },
1343
+ handler: (t, s) => (s.chatMessage.finishInfo = t, !0)
1344
+ },
1345
+ {
1346
+ name: "reasoning",
1347
+ match: (t, s) => !!W(t).reasoning_content,
1348
+ handler: (t, s) => {
1349
+ const e = W(t);
1350
+ return s.reasoningMessage = Te(e.reasoning_content, e, s.chatMessage), s.handleReasoning || (Fe(s), s.handleReasoning = !0), !0;
1351
+ },
1352
+ start: (t, s) => {
1353
+ t.handleReasoning = !1;
1354
+ },
1355
+ end: (t) => {
1356
+ var s;
1357
+ (s = t.unWatchReasoning) == null || s.call(t), t.handleReasoning && (t.handleReasoning = !1, He(t.reasoningMessage));
1358
+ }
1359
+ },
1360
+ {
1361
+ name: "toolCall",
1362
+ match: (t, s) => {
1363
+ var n;
1364
+ return ((n = W(t).tool_calls) == null ? void 0 : n.length) > 0;
1365
+ },
1366
+ handler: (t, s) => {
1367
+ const e = W(t);
1368
+ return Ks(e.tool_calls, e, s.toolCallIdMap, s.chatMessage, s.toolCallStatus), !0;
1369
+ },
1370
+ start: (t, s) => {
1371
+ t.toolCallIdMap = {}, t.toolCallStatus = { inProcessToolCallId: null };
1372
+ }
1373
+ },
1374
+ {
1375
+ name: "toolResult",
1376
+ match: (t, s) => {
1377
+ var n;
1378
+ return ((n = W(t).tool_calls_result) == null ? void 0 : n.length) > 0;
1379
+ },
1380
+ handler: (t, s) => {
1381
+ const e = W(t);
1382
+ return Vs(
1383
+ e.tool_calls_result,
1384
+ e,
1385
+ s.toolCallIdMap,
1386
+ s.chatMessage,
1387
+ s.chatConfig.addToolCallContext
1388
+ ), !0;
1389
+ }
1390
+ },
1391
+ {
1392
+ name: "content",
1393
+ match: (t, s) => !!W(t).content,
1394
+ handler: (t, s) => {
1395
+ const e = W(t);
1396
+ return s.delta = e, s.patternExtractor.handleContent(e.content), s.chatMessage.content += e.content, !0;
1397
+ },
1398
+ start: (t, s) => {
1399
+ const e = new Ie({
1400
+ onNormalWrite: (n) => Zs(n, t.delta, t.chatMessage),
1401
+ onHandledWrite: (n) => {
1402
+ t.reasoningMessage = Te(n, t.delta, t.chatMessage), t.handleReasoning || (Fe(t), t.handleReasoning = !0);
1403
+ },
1404
+ regExpMap: new js().regExpMap
1405
+ });
1406
+ t.patternExtractor = new Ie({
1407
+ onNormalWrite: (n) => e.handleContent(n),
1408
+ onHandledWrite: (n) => Ys(n, t.delta, t.chatMessage)
1409
+ });
1410
+ }
1411
+ }
1412
+ ], Qs = { class: "sender-container" }, en = { class: "attachments-container" }, tn = { class: "footer-text" }, sn = /* @__PURE__ */ X({
1413
+ __name: "GenuiChat",
1414
+ props: {
1415
+ url: {},
1416
+ model: {},
1417
+ temperature: {},
1418
+ messages: {},
1419
+ chatConfig: {},
1420
+ requiredCompleteFieldSelectors: {},
1421
+ customComponents: {},
1422
+ customSnippets: {},
1423
+ customExamples: {},
1424
+ customActions: {},
1425
+ rendererSlots: {},
1426
+ thinkComponent: { type: [Object, Function] },
1427
+ roles: {},
1428
+ features: {},
1429
+ customFetch: { type: Function }
1430
+ },
1431
+ setup(t, { expose: s }) {
1432
+ var Me;
1433
+ const e = t, n = ut(Rt, null), { t: a } = $(), p = O(() => {
1434
+ var u;
1435
+ const c = (u = e.features) == null ? void 0 : u.supportImage;
1436
+ return !!(c && (c == null ? void 0 : c.enabled) !== !1);
1437
+ }), r = O(() => {
1438
+ var _, M;
1439
+ const c = (M = (_ = e.features) == null ? void 0 : _.supportImage) == null ? void 0 : M.supportedFileTypes;
1440
+ return {
1441
+ file: {
1442
+ disabled: !1,
1443
+ accept: c == null ? void 0 : c.map((x) => Pt[x.toLowerCase()]).join(",")
1444
+ }
1445
+ };
1446
+ }), d = {
1447
+ assistant: {
1448
+ placement: "start",
1449
+ avatar: ee(Mt, { style: { fontSize: "32px" } }),
1450
+ maxWidth: "100%",
1451
+ customContentField: "messages"
1452
+ },
1453
+ user: {
1454
+ placement: "end",
1455
+ maxWidth: "90%",
1456
+ avatar: ee(Ct, { style: { fontSize: "32px" } }),
1457
+ customContentField: "messages"
1458
+ }
1459
+ }, l = (c) => {
1460
+ if (!c)
1461
+ return;
1462
+ const u = {};
1463
+ return Object.keys(c).forEach((_) => {
1464
+ u[_] = (M) => {
1465
+ const x = O(() => M.bubbleProps.role !== "assistant" ? !0 : M.index !== h.value.messages.value.length - 1 || !T.value), F = ge(c[_]);
1466
+ return F ? F({ ...M, isFinished: x.value, messageManager: h.value, chatMessage: h.value.messages.value[M.index] }) : null;
1467
+ };
1468
+ }), u;
1469
+ }, i = O(() => {
1470
+ var u;
1471
+ const c = { ...d };
1472
+ for (const _ in e.roles) {
1473
+ const M = _;
1474
+ c[M] = {
1475
+ ...d[M],
1476
+ ...e.roles[M],
1477
+ slots: l((u = e.roles[M]) == null ? void 0 : u.slots)
1478
+ };
1479
+ }
1480
+ return c;
1481
+ }), o = (c) => c.filter((u) => u.role === "assistant").reduce((u, _) => {
1482
+ const M = _.messages;
1483
+ return Array.isArray(M) ? u.concat(...M) : u;
1484
+ }, []), m = (c) => o(P.value).find((_) => "id" in _ && _.id === c), b = (c) => {
1485
+ const u = c[xt], _ = m(u);
1486
+ _ && (_.state = JSON.parse(JSON.stringify(c.state || {}))), U();
1487
+ }, f = ({ llmFriendlyMessage: c, humanFriendlyMessage: u, context: _ }) => {
1488
+ b(_), h.value.addMessage({
1489
+ role: "user",
1490
+ content: c,
1491
+ messages: [{ type: "text", content: u }]
1492
+ }), h.value.send();
1493
+ }, { continueChatAction: R, saveStateAction: v } = Bs({ chat: f, saveState: b }), T = O(() => ae.includes(h.value.messageState.status)), G = new Be({
1494
+ defaultAttrs: { class: "markdown-content" },
1495
+ mdConfig: { html: !0 }
1496
+ }), L = O(() => {
1497
+ const c = P.value[P.value.length - 1];
1498
+ if ((c == null ? void 0 : c.role) !== "assistant")
1499
+ return null;
1500
+ const u = c == null ? void 0 : c.messages;
1501
+ return !Array.isArray(u) || !(u != null && u.length) ? null : u[u.length - 1].id;
1502
+ }), N = {
1503
+ "custom-text": (c) => ee("span", { class: "tr-bubble__body-text" }, c.content),
1504
+ "schema-card": (c) => {
1505
+ var M, x;
1506
+ const u = {};
1507
+ e.customComponents && e.customComponents.forEach((F) => {
1508
+ F.ref && F.component && (u[F.component] = F.ref);
1509
+ });
1510
+ const _ = {};
1511
+ return e.customActions && e.customActions.forEach((F) => {
1512
+ F.name && (_[F.name] = F);
1513
+ }), ee(
1514
+ "div",
1515
+ {},
1516
+ ee(
1517
+ kt,
1518
+ {
1519
+ ...c,
1520
+ requiredCompleteFieldSelectors: e.requiredCompleteFieldSelectors || [],
1521
+ generating: L.value === c.id ? T.value : !1,
1522
+ customComponents: u,
1523
+ customActions: {
1524
+ ..._,
1525
+ continueChat: R,
1526
+ saveState: v
1527
+ },
1528
+ key: c.id
1529
+ },
1530
+ {
1531
+ header: ge((M = e.rendererSlots) == null ? void 0 : M.header),
1532
+ footer: ge((x = e.rendererSlots) == null ? void 0 : x.footer)
1533
+ }
1534
+ )
1535
+ );
1536
+ },
1537
+ tool: Fs,
1538
+ reasoning: gs,
1539
+ markdown: G,
1540
+ templateData: cs,
1541
+ "loading-text": e.thinkComponent || Ns,
1542
+ "error-text": Us
1543
+ }, J = A(Xs), Z = new Ot({
1544
+ getChatOptions: () => ({
1545
+ url: e.url,
1546
+ model: e.model || "",
1547
+ temperature: e.temperature ?? 0.3,
1548
+ chatConfig: e.chatConfig || { addToolCallContext: !1, showThinkingResult: !1 },
1549
+ customComponents: e.customComponents || [],
1550
+ customSnippets: e.customSnippets || [],
1551
+ customExamples: e.customExamples || [],
1552
+ customActions: [...e.customActions || [], R, v],
1553
+ customFetch: e.customFetch
1554
+ })
1555
+ });
1556
+ Z.setResponseHandlers(J.value);
1557
+ const C = new vt({
1558
+ provider: "custom",
1559
+ providerImplementation: Z
1560
+ });
1561
+ let g = Ws({
1562
+ client: C,
1563
+ autoSave: !1,
1564
+ events: {
1565
+ onReceiveData(c, u, _) {
1566
+ u.value.push(c), _();
1567
+ },
1568
+ onLoaded(c) {
1569
+ var u;
1570
+ if (c.length || (y(), U()), (u = e.messages) != null && u.length) {
1571
+ const _ = h.value.messages.value;
1572
+ _.splice(0, _.length, ...e.messages);
1573
+ }
1574
+ },
1575
+ onFinish(c, u) {
1576
+ (c == null ? void 0 : c.type) === "error" && u.messages.value.push({
1577
+ role: "assistant",
1578
+ content: "",
1579
+ messages: [{ type: "error-text", content: c.error.message }]
1580
+ }), U();
1581
+ }
1582
+ }
1583
+ });
1584
+ const { messageManager: h, createConversation: y, updateTitle: k, state: B, saveConversations: U } = g, P = O(() => h.value.messages.value), Y = O({
1585
+ get: () => h.value.inputMessage.value,
1586
+ set: (c) => {
1587
+ h.value.inputMessage.value = c;
1588
+ }
1589
+ }), Le = (c) => {
1590
+ Y.value = c;
1591
+ };
1592
+ (Me = e.messages) != null && Me.length && P.value.splice(0, P.value.length, ...e.messages);
1593
+ const { attachments: se, templateData: z, clearAttachments: Ue, processAttachments: ze, handleFilesSelected: qe, handleTemplateEdit: Ge } = Jt(), Je = (c) => {
1594
+ const u = Ge(z, Y.value);
1595
+ Y.value = "", z.value = u;
1596
+ }, be = O(() => {
1597
+ var _;
1598
+ let c = P.value;
1599
+ if (h.value.messageState.status === q.PROCESSING)
1600
+ return [
1601
+ ...c,
1602
+ {
1603
+ role: "assistant",
1604
+ content: a("loading.thinking"),
1605
+ loading: !0
1606
+ }
1607
+ ];
1608
+ const u = P.value[P.value.length - 1];
1609
+ if (T.value && (u == null ? void 0 : u.role) === "assistant") {
1610
+ const M = Array.isArray(u == null ? void 0 : u.messages) ? u.messages : [];
1611
+ if (!M.some((F) => F.type === "loading-text"))
1612
+ return [
1613
+ ...c.slice(0, -1),
1614
+ {
1615
+ ...u,
1616
+ messages: [
1617
+ ...M,
1618
+ {
1619
+ type: "loading-text",
1620
+ emitter: oe,
1621
+ message: u,
1622
+ showThinkingResult: (_ = e.chatConfig) == null ? void 0 : _.showThinkingResult
1623
+ }
1624
+ ]
1625
+ }
1626
+ ];
1627
+ }
1628
+ return c;
1629
+ }), We = (c) => {
1630
+ var M;
1631
+ const u = (M = B.conversations.find(
1632
+ (x) => x.id === B.currentId
1633
+ )) == null ? void 0 : M.title, _ = a("conversation.newConversation");
1634
+ if (u === _ && B.currentId) {
1635
+ const x = typeof c == "string" ? c : JSON.stringify(c);
1636
+ k(B.currentId, x.substring(0, 20));
1637
+ }
1638
+ }, Ce = () => {
1639
+ Y.value = "", z.value = [], Ue();
1640
+ }, je = (c) => {
1641
+ c && (se.value = se.value.filter((u) => c.name !== u.name), z.value = z.value.filter((u) => u.type !== "template" || u.content !== c.name));
1642
+ }, Ve = async (c) => {
1643
+ const u = c, _ = [];
1644
+ let M = [];
1645
+ const x = se.value.slice(), F = z.value.slice(), me = {
1646
+ role: "user",
1647
+ content: u
1648
+ };
1649
+ if (P.value.push(me), x.length > 0) {
1650
+ const Se = await ze(x, e.features || {});
1651
+ if (!Se) {
1652
+ h.value.send(), re();
1653
+ return;
1654
+ }
1655
+ M = F.map((pe) => pe.type === "template" ? Se.apiContent.find((st) => st.filename === pe.content) : {
1656
+ type: "text",
1657
+ text: pe.content
1658
+ }), F.length > 0 && _.push({
1659
+ type: "templateData",
1660
+ templateData: F,
1661
+ attachments: x
1662
+ }), me.content = M, me.messages = _;
1663
+ }
1664
+ h.value.send(), Ce(), We(u), U(), re();
1665
+ }, Ke = () => {
1666
+ y(), U();
1667
+ }, Ze = () => {
1668
+ h.value.abortRequest(), U();
1669
+ }, de = A(), { width: Ye } = zs(de), { scrollToBottom: re, scrollToBottomWithRetry: Xe, autoScrollToBottom: Qe, isLastMessageInBottom: et } = Bt(de), tt = Nt(Qe, 400);
1670
+ return ce(() => P.value, tt, { deep: !0 }), ce(
1671
+ () => B.currentId,
1672
+ () => {
1673
+ Xe(10, 150);
1674
+ }
1675
+ ), s({
1676
+ setInputMessage: Le,
1677
+ handleNewConversation: Ke,
1678
+ // @experimental
1679
+ getProps: () => e,
1680
+ getConversation: () => g,
1681
+ // experimental, not stable
1682
+ getResponseHandlers: () => J.value,
1683
+ // experimental, not stable
1684
+ setResponseHandlers: (c) => {
1685
+ J.value = c, Z.setResponseHandlers(c);
1686
+ },
1687
+ getMessageRenderers: () => N,
1688
+ setMessageRenderer: (c, u) => {
1689
+ N[c] = u;
1690
+ },
1691
+ generating: T,
1692
+ // @experimental
1693
+ lastSchemaCardId: L,
1694
+ continueChatAction: R,
1695
+ saveStateAction: v
1696
+ }), (c, u) => {
1697
+ var _, M;
1698
+ return E(), I("div", {
1699
+ class: K(["tg-chat-container", { dark: ((_ = S(n)) == null ? void 0 : _.theme) === "dark" }]),
1700
+ style: Re((M = e.chatConfig) != null && M.showThinkingResult ? {} : { "--thinking-display": "none" })
1701
+ }, [
1702
+ w("div", {
1703
+ class: "messages-container",
1704
+ ref_key: "messagesContainer",
1705
+ ref: de,
1706
+ style: Re({ "--messages-container-width": S(Ye) + "px" })
1707
+ }, [
1708
+ be.value.length ? (E(), $e(S(pt), {
1709
+ key: 0,
1710
+ "content-renderers": N
1711
+ }, {
1712
+ default: j(() => [
1713
+ D(S(gt), {
1714
+ items: be.value,
1715
+ roles: i.value,
1716
+ "auto-scroll": ""
1717
+ }, null, 8, ["items", "roles"])
1718
+ ]),
1719
+ _: 1
1720
+ })) : dt(c.$slots, "empty", { key: 1 }, void 0, !0)
1721
+ ], 4),
1722
+ w("div", Qs, [
1723
+ Ae(w("div", {
1724
+ class: K(["scroll-to-bottom-button", { "is-generating": T.value }]),
1725
+ onClick: u[0] || (u[0] = //@ts-ignore
1726
+ (...x) => S(re) && S(re)(...x))
1727
+ }, [
1728
+ D(S(ye), { class: "icon-arrow-down" })
1729
+ ], 2), [
1730
+ [De, !S(et)]
1731
+ ]),
1732
+ D(S(ht), {
1733
+ modelValue: Y.value,
1734
+ "onUpdate:modelValue": u[1] || (u[1] = (x) => Y.value = x),
1735
+ placeholder: S(ae).includes(S(h).messageState.status) ? S(a)("placeholder.thinking") : S(a)("placeholder.input"),
1736
+ clearable: !0,
1737
+ "allow-files": p.value,
1738
+ buttonGroup: r.value,
1739
+ loading: S(ae).includes(S(h).messageState.status),
1740
+ onFilesSelected: u[2] || (u[2] = (x) => S(qe)(x, Y.value)),
1741
+ "template-data": S(z),
1742
+ "onUpdate:templateData": [
1743
+ u[3] || (u[3] = (x) => Ne(z) ? z.value = x : null),
1744
+ Je
1745
+ ],
1746
+ showWordLimit: !0,
1747
+ maxLength: 1e3,
1748
+ onClear: Ce,
1749
+ onSubmit: Ve,
1750
+ onCancel: Ze
1751
+ }, mt({ _: 2 }, [
1752
+ S(se).length > 0 ? {
1753
+ name: "header",
1754
+ fn: j(() => [
1755
+ w("div", en, [
1756
+ D(es, {
1757
+ attachments: S(se),
1758
+ onRemove: je
1759
+ }, null, 8, ["attachments"])
1760
+ ])
1761
+ ]),
1762
+ key: "0"
1763
+ } : void 0
1764
+ ]), 1032, ["modelValue", "placeholder", "allow-files", "buttonGroup", "loading", "template-data"]),
1765
+ w("div", tn, H(S(a)("footer.aiGenerated")), 1)
1766
+ ])
1767
+ ], 6);
1768
+ };
1769
+ }
1770
+ }), hn = /* @__PURE__ */ Q(sn, [["__scopeId", "data-v-b02ae0d5"]]), fn = {
1771
+ enabled: !0,
1772
+ maxImageSize: 10,
1773
+ maxFilesPerRequest: 3,
1774
+ supportedFileTypes: ["jpg", "jpeg", "png", "gif", "webp", "bmp", "heic", "tiff"]
1775
+ };
1776
+ export {
1777
+ Ot as C,
1778
+ fn as D,
1779
+ As as E,
1780
+ hn as G,
1781
+ Gs as I,
1782
+ qs as M,
1783
+ js as T,
1784
+ Pe as a,
1785
+ Nt as b,
1786
+ Xs as d,
1787
+ oe as e,
1788
+ Bt as s,
1789
+ ge as t,
1790
+ Ws as u
1791
+ };
1792
+ //# sourceMappingURL=chat.types-BRLoMarP.js.map