@szjy/ai-coms 0.1.10 → 0.1.13
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 +43 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +1809 -3425
- package/dist/index.umd.js +3 -2
- package/dist/packages/api/ai.d.ts +12 -7
- package/dist/packages/api/mock.d.ts +16 -0
- package/dist/packages/common/audio/recorder.d.ts +13 -4
- package/dist/packages/common/audio/transcript-sanitize.d.ts +16 -0
- package/dist/packages/common/audio/voice-manager.d.ts +5 -15
- package/dist/packages/components/AiChat/src/components/plugins/markdown.d.ts +2 -2
- package/dist/packages/components/AiChat/src/composables/useChatDeps.d.ts +6 -0
- package/dist/packages/components/AiChat/src/custom-ui/actions/postMessage.d.ts +12 -0
- package/dist/packages/components/AiChat/src/custom-ui/components/button.d.ts +9 -0
- package/dist/packages/components/AiChat/src/custom-ui/components/list.d.ts +8 -0
- package/dist/packages/components/AiChat/src/custom-ui/events.d.ts +27 -0
- package/dist/packages/components/AiChat/src/custom-ui/index.d.ts +7 -0
- package/dist/packages/components/AiChat/src/custom-ui/parse.d.ts +11 -0
- package/dist/packages/components/AiChat/src/custom-ui/registry.d.ts +8 -0
- package/dist/packages/components/AiChat/src/custom-ui/render.d.ts +18 -0
- package/dist/packages/components/AiChat/src/custom-ui/types.d.ts +84 -0
- package/dist/packages/components/AiChat/src/index.vue.d.ts +87 -4
- package/dist/packages/components/AiChat/src/transform/index.d.ts +14 -1
- package/dist/packages/components/AiChatPlain/index.d.ts +3 -0
- package/dist/packages/components/AiChatPlain/src/index.vue.d.ts +213 -0
- package/dist/packages/components/components.d.ts +1 -0
- package/dist/scripts/ai/README.md +8 -1
- package/dist/scripts/ai/whisper.worker.js +104 -13
- package/dist/style.css +2 -2
- package/package.json +1 -1
- package/dist/packages/common/audio/zh-simplified.d.ts +0 -8
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
`)).getReader();console.log("reader from response:",n),r({error:0,reader:n})}else r({error:1,reader:null})}).catch(a=>{r({error:1,reader:null})})}):{error:1,reader:null}}let W=null;function et(){return W||(window.markdownit?W=new window.markdownit({html:!0,linkify:!0,typographer:!0}):console.log("markdownit is not loaded"),W)}const ve=(o,t)=>{const s=o.__vccOpts||o;for(const[r,a]of t)s[r]=a;return s},tt=["src","alt"],Y=ve({__name:"SvgIcon",props:{name:{type:String,required:!0},size:{type:[Number,String],default:16},color:{type:String,default:""},className:{type:String,default:""},basePath:{type:String,default:"/icons/"}},setup(o){const t=o,s=e.computed(()=>{if(t.name.startsWith("http://")||t.name.startsWith("https://")||t.name.startsWith("/"))return t.name;const n=t.name.endsWith(".svg")?t.name:`${t.name}.svg`;return`${t.basePath}${n}`}),r=e.computed(()=>{const n=typeof t.size=="number"?`${t.size}px`:t.size;return{width:n,height:n,display:"inline-flex",justifyContent:"center",alignItems:"center"}}),a=e.computed(()=>{const n={width:"100%",height:"100%"};return t.color&&(n.filter=`drop-shadow(0 0 0 ${t.color})`),n});return(n,i)=>(e.openBlock(),e.createElementBlock("div",{class:"svg-icon-wrapper",style:e.normalizeStyle(r.value)},[e.createElementVNode("img",{src:s.value,alt:o.name,class:e.normalizeClass(["svg-icon",o.className]),style:e.normalizeStyle(a.value)},null,14,tt)],4))}},[["__scopeId","data-v-490b11c1"]]),nt=async o=>{if(navigator.clipboard&&navigator.permissions)await navigator.clipboard.writeText(o);else{const t=document.createElement("textArea");t.value=o,t.style.width=0,t.style.position="fixed",t.style.left="-999px",t.style.top="10px",t.setAttribute("readonly","readonly"),document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}},rt=["innerHTML"],ot={__name:"Previewer",props:{reader:null,model:"szjy",scrollToBottomFn:null,displayText:"",messagePostRender:{type:Function,default:null}},emits:["failed","completed","updating"],setup(o,{expose:t,emit:s}){const{appContext:r}=e.getCurrentInstance(),{$message:a}=r.config.globalProperties,n=o,i=e.ref(n.displayText||""),l=e.ref(""),c=e.ref(!0),m=e.ref(!1),S=e.ref(!!n.displayText),P=s,V=e.ref(null);let E=null;const F=e.computed(()=>W?W.render(i.value):i.value),x=()=>{n.reader&&n.reader.cancel(),m.value=!0,d.value=!1,y(),S.value=!0,P("completed",i.value),c.value=!1,E&&(cancelAnimationFrame(E),E=null)},A=e.computed(()=>`${F.value}`),w=e.ref(!1),g=()=>{w.value=!0},y=()=>{w.value=!1},d=e.ref(!1),u=async()=>{if(!n.reader)return;const v=new TextDecoder("utf-8");for(c.value=!0;!m.value;)try{if(!n.reader){d.value=!0;break}const{value:h,done:L}=await n.reader.read();if(!n.reader){d.value=!0;break}if(L){d.value=!0;break}const I=be[n.model];if(!I)break;const O=I.call(be,h,v);if(O.done){d.value=!0;break}l.value+=O.content,E===null&&_()}catch(h){d.value=!0,console.log(3333,h),P("failed",h),x();break}finally{y()}},C=async()=>{n.scrollToBottomFn&&n.scrollToBottomFn()},k=(v=()=>{},h=()=>{})=>{if(l.value.length>0){const L=l.value.substring(0,10);i.value+=L,l.value=l.value.substring(10),v()}else h()},_=()=>{if(m.value&&E){cancelAnimationFrame(E),E=null,c.value=!1;return}d.value?k(()=>{E=requestAnimationFrame(_),P("updating",null)},()=>{P("completed",i.value),c.value=!1,S.value=!0,e.nextTick(()=>{if(d.value=!1,n.messagePostRender&&V.value)try{n.messagePostRender(V.value,i.value)}catch(v){console.error("messagePostRender 执行失败:",v)}}),E=null}):(k(),E=requestAnimationFrame(_)),C()};e.watch(()=>n.reader,()=>{n.reader&&u()},{immediate:!0,deep:!0}),e.onUnmounted(()=>{x()}),t({abortReader:x,initializeStart:g,initializeEnd:y}),e.computed(()=>w.value?!0:(!n.reader||!c||i.value,!1));const N=async()=>{try{const v=i.value;await nt(v),a.success("复制成功")}catch(v){console.error("复制失败:",v),a.error("复制失败")}};return(v,h)=>(e.openBlock(),e.createBlock(e.Transition,{name:"fade"},{default:e.withCtx(()=>[A.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"refWrapperContent",ref:V,"text-16":"",class:"w-full h-full overflow-y-auto relative","p-24px":""},[e.createElementVNode("div",{class:"markdown-wrapper",innerHTML:A.value},null,8,rt),S.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"ai-copy-btn-wrapper",onClick:N},[e.createVNode(Y,{name:"/images/svg/copy.svg",color:"#666666"}),h[0]||(h[0]=e.createElementVNode("span",{class:"copy-text"},"复制",-1))])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0)]),_:1}))}};class Ne{constructor(t={}){T(this,"targetSampleRate");T(this,"audioContext",null);T(this,"mediaStream",null);T(this,"sourceNode",null);T(this,"processorNode",null);T(this,"audioChunks",[]);T(this,"onVolumeChange");T(this,"onAudioChunk");T(this,"_isRecording",!1);this.targetSampleRate=t.sampleRate||16e3,this.onVolumeChange=t.onVolumeChange,this.onAudioChunk=t.onAudioChunk}get isRecording(){return this._isRecording}async start(){if(this._isRecording)return;if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("当前浏览器环境不支持获取麦克风音频,请使用现代浏览器并确保在 HTTPS/localhost 环境下运行。");try{this.mediaStream=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}})}catch(r){throw r.name==="NotAllowedError"||r.name==="PermissionDeniedError"?new Error("麦克风权限被拒绝,请在浏览器地址栏允许麦克风访问权限。"):r.name==="NotFoundError"||r.name==="DevicesNotFoundError"?new Error("未检测到可用的麦克风输入设备。"):new Error(`无法启动麦克风: ${r.message||r}`)}const t=window.AudioContext||window.webkitAudioContext;this.audioContext=new t,this.audioContext.state==="suspended"&&await this.audioContext.resume(),this.audioChunks=[],this.sourceNode=this.audioContext.createMediaStreamSource(this.mediaStream);const s=4096;this.processorNode=this.audioContext.createScriptProcessor(s,1,1),this.processorNode.onaudioprocess=r=>{var i;if(!this._isRecording)return;const a=r.inputBuffer.getChannelData(0);if(this.onVolumeChange){let l=0;for(let S=0;S<a.length;S++)l+=a[S]*a[S];const c=Math.sqrt(l/a.length),m=Math.min(100,Math.round(c*100*5));this.onVolumeChange(m)}const n=this.resampleAudio(a,this.audioContext.sampleRate,this.targetSampleRate);this.audioChunks.push(n),(i=this.onAudioChunk)==null||i.call(this,n)},this.sourceNode.connect(this.processorNode),this.processorNode.connect(this.audioContext.destination),this._isRecording=!0}async stop(){if(!this._isRecording)return new Float32Array(0);this._isRecording=!1,this.cleanup();const t=this.audioChunks.reduce((a,n)=>a+n.length,0),s=new Float32Array(t);let r=0;for(const a of this.audioChunks)s.set(a,r),r+=a.length;return this.audioChunks=[],s}cancel(){this._isRecording=!1,this.audioChunks=[],this.cleanup()}cleanup(){this.processorNode&&(this.processorNode.disconnect(),this.processorNode.onaudioprocess=null,this.processorNode=null),this.sourceNode&&(this.sourceNode.disconnect(),this.sourceNode=null),this.mediaStream&&(this.mediaStream.getTracks().forEach(t=>t.stop()),this.mediaStream=null),this.audioContext&&this.audioContext.state!=="closed"&&(this.audioContext.close().catch(()=>{}),this.audioContext=null)}resampleAudio(t,s,r){return ie(t,s,r)}}function ie(o,t,s){if(t===s)return new Float32Array(o);const r=t/s,a=Math.round(o.length/r),n=new Float32Array(a);for(let i=0;i<a;i++){const l=i*r,c=Math.floor(l),m=l-c,S=o[c]??0,P=o[c+1]??S;n[i]=S+m*(P-S)}return n}async function xe(o,t=16e3){const s=await o.arrayBuffer(),r=window.AudioContext||window.webkitAudioContext,a=new r;try{const n=await a.decodeAudioData(s);let i;if(n.numberOfChannels>1){i=new Float32Array(n.length);for(let l=0;l<n.numberOfChannels;l++){const c=n.getChannelData(l);for(let m=0;m<n.length;m++)i[m]+=c[m]/n.numberOfChannels}}else i=n.getChannelData(0);return ie(i,n.sampleRate,t)}finally{a.state!=="closed"&&await a.close().catch(()=>{})}}function ee(o,t=16e3){const s=new ArrayBuffer(44+o.length*2),r=new DataView(s),a=(i,l)=>{for(let c=0;c<l.length;c++)r.setUint8(i+c,l.charCodeAt(c))};a(0,"RIFF"),r.setUint32(4,36+o.length*2,!0),a(8,"WAVE"),a(12,"fmt "),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,1,!0),r.setUint32(24,t,!0),r.setUint32(28,t*2,!0),r.setUint16(32,2,!0),r.setUint16(34,16,!0),a(36,"data"),r.setUint32(40,o.length*2,!0);let n=44;for(let i=0;i<o.length;i++,n+=2){const l=Math.max(-1,Math.min(1,o[i]));r.setInt16(n,l<0?l*32768:l*32767,!0)}return new Blob([r],{type:"audio/wav"})}const at=[["網際網路","互联网"],["應用程式","应用程序"],["作業系統","操作系统"],["重新載入","重新加载"],["重新整理","刷新"],["開啟檔案","打开文件"],["電子郵件","电子邮件"],["品質管理","质量管理"],["印表機","打印机"],["伺服器","服务器"],["使用者","用户"],["記憶體","内存"],["資料庫","数据库"],["演算法","算法"],["資料夾","文件夹"],["剪貼簿","剪贴板"],["關鍵字","关键字"],["解析度","分辨率"],["執行緒","线程"],["軟體","软件"],["硬體","硬件"],["資訊","信息"],["網路","网络"],["視訊","视频"],["影片","视频"],["預設","默认"],["設定","设置"],["檔案","文件"],["資料","数据"],["程式","程序"],["螢幕","屏幕"],["硬碟","硬盘"],["滑鼠","鼠标"],["鍵盤","键盘"],["專案","项目"],["品質","质量"],["監控","监控"],["監測","监测"],["報警","报警"],["訊息","消息"],["簡訊","短信"],["物件","对象"],["元件","组件"],["模組","模块"],["函式","函数"],["迴圈","循环"],["陣列","数组"],["字串","字符串"],["畫素","像素"],["畫質","画质"],["相簿","相册"],["相冊","相册"],["登入","登录"],["登出","退出"],["註冊","注册"],["佈署","部署"],["組態","配置"],["介面","界面"],["互動","交互"],["連結","链接"],["連線","连接"],["斷線","断线"],["載入","加载"],["列印","打印"],["匯出","导出"],["匯入","导入"],["備份","备份"],["還原","还原"],["復原","恢复"],["佇列","队列"],["啟動","启动"],["開啟","打开"],["儲存","保存"],["存檔","存档"],["複製","复制"],["貼上","粘贴"],["選取","选择"],["選項","选项"],["標籤","标签"],["標題","标题"],["目錄","目录"],["路徑","路径"],["位址","地址"],["網址","网址"],["帳號","账号"],["帳戶","账户"],["密碼","密码"],["權限","权限"],["授權","授权"],["認證","认证"],["識別","识别"],["語音","语音"],["錄音","录音"],["錄製","录制"],["轉寫","转写"],["轉譯","转译"],["轉換","转换"],["繁體","繁体"],["簡體","简体"],["臺灣","台湾"],["台灣","台湾"],["裡面","里面"],["裡頭","里头"],["甚麼","什么"],["什麼","什么"],["這麼","这么"],["那麼","那么"],["怎麼","怎么"]],st=[["萬","万"],["與","与"],["醜","丑"],["專","专"],["業","业"],["叢","丛"],["東","东"],["絲","丝"],["丟","丢"],["兩","两"],["嚴","严"],["喪","丧"],["個","个"],["豐","丰"],["臨","临"],["為","为"],["麗","丽"],["舉","举"],["麼","么"],["義","义"],["烏","乌"],["樂","乐"],["喬","乔"],["習","习"],["鄉","乡"],["書","书"],["買","买"],["亂","乱"],["爭","争"],["於","于"],["虧","亏"],["雲","云"],["亙","亘"],["亞","亚"],["產","产"],["畝","亩"],["親","亲"],["褻","亵"],["億","亿"],["僅","仅"],["從","从"],["侖","仑"],["倉","仓"],["儀","仪"],["們","们"],["價","价"],["眾","众"],["優","优"],["夥","伙"],["會","会"],["傴","伛"],["傘","伞"],["偉","伟"],["傳","传"],["傷","伤"],["倀","伥"],["倫","伦"],["傖","伧"],["偽","伪"],["佇","伫"],["體","体"],["餘","余"],["傭","佣"],["僉","佥"],["俠","侠"],["侶","侣"],["僥","侥"],["偵","侦"],["側","侧"],["僑","侨"],["儈","侩"],["儕","侪"],["儂","侬"],["俁","俣"],["儔","俦"],["儼","俨"],["倆","俩"],["儷","俪"],["儉","俭"],["債","债"],["傾","倾"],["傯","偬"],["僂","偻"],["僨","偾"],["償","偿"],["儻","傥"],["儐","傧"],["儲","储"],["儺","傩"],["兒","儿"],["兌","兑"],["兗","兖"],["黨","党"],["蘭","兰"],["關","关"],["興","兴"],["茲","兹"],["養","养"],["獸","兽"],["內","内"],["岡","冈"],["冊","册"],["寫","写"],["軍","军"],["農","农"],["馮","冯"],["沖","冲"],["決","决"],["況","况"],["凍","冻"],["淨","净"],["淒","凄"],["淩","凌"],["減","减"],["湊","凑"],["凜","凛"],["幾","几"],["鳳","凤"],["鳧","凫"],["憑","凭"],["凱","凯"],["擊","击"],["鑿","凿"],["芻","刍"],["劃","划"],["劉","刘"],["則","则"],["剛","刚"],["創","创"],["刪","删"],["別","别"],["剗","刬"],["剄","刭"],["劊","刽"],["劌","刿"],["剴","剀"],["劑","剂"],["剮","剐"],["劍","剑"],["剝","剥"],["劇","剧"],["勸","劝"],["辦","办"],["務","务"],["勱","劢"],["動","动"],["勵","励"],["勁","劲"],["勞","劳"],["勢","势"],["勳","勋"],["勩","勚"],["勻","匀"],["匭","匦"],["匱","匮"],["區","区"],["醫","医"],["華","华"],["協","协"],["單","单"],["賣","卖"],["盧","卢"],["鹵","卤"],["臥","卧"],["衛","卫"],["卻","却"],["廠","厂"],["廳","厅"],["歷","历"],["厲","厉"],["壓","压"],["厭","厌"],["厙","厍"],["廁","厕"],["廂","厢"],["厴","厣"],["廈","厦"],["廚","厨"],["廄","厩"],["廝","厮"],["縣","县"],["參","参"],["雙","双"],["發","发"],["變","变"],["敘","叙"],["疊","叠"],["隻","只"],["葉","叶"],["號","号"],["歎","叹"],["嘰","叽"],["籲","吁"],["後","后"],["嚇","吓"],["呂","吕"],["嗎","吗"],["唚","吣"],["噸","吨"],["聽","听"],["啟","启"],["吳","吴"],["嘸","呒"],["囈","呓"],["嘔","呕"],["嚦","呖"],["唄","呗"],["員","员"],["咼","呙"],["嗆","呛"],["嗚","呜"],["詠","咏"],["哢","咔"],["嚨","咙"],["嚀","咛"],["噝","咝"],["吒","咤"],["響","响"],["啞","哑"],["噠","哒"],["嘵","哓"],["嗶","哔"],["噦","哕"],["嘩","哗"],["噲","哙"],["嚌","哜"],["噥","哝"],["喲","哟"],["嘜","唛"],["嗊","唝"],["嘮","唠"],["啢","唡"],["嗩","唢"],["喚","唤"],["嘖","啧"],["嗇","啬"],["囀","啭"],["齧","啮"],["囉","啰"],["嘯","啸"],["噴","喷"],["嘍","喽"],["嚳","喾"],["囁","嗫"],["噓","嘘"],["嚶","嘤"],["囑","嘱"],["嚕","噜"],["囂","嚣"],["團","团"],["園","园"],["囪","囱"],["圍","围"],["圇","囵"],["國","国"],["圖","图"],["圓","圆"],["聖","圣"],["壙","圹"],["場","场"],["壞","坏"],["塊","块"],["堅","坚"],["壇","坛"],["壢","坜"],["壩","坝"],["塢","坞"],["墳","坟"],["墜","坠"],["壟","垄"],["壘","垒"],["墾","垦"],["堊","垩"],["墊","垫"],["埡","垭"],["墶","垯"],["壋","垱"],["塏","垲"],["堖","垴"],["塒","埘"],["塤","埙"],["堝","埚"],["塹","堑"],["墮","堕"],["牆","墙"],["壯","壮"],["聲","声"],["殼","壳"],["壺","壶"],["處","处"],["備","备"],["複","复"],["夠","够"],["頭","头"],["誇","夸"],["夾","夹"],["奪","夺"],["奩","奁"],["奐","奂"],["奮","奋"],["獎","奖"],["奧","奥"],["姦","奸"],["妝","妆"],["婦","妇"],["媽","妈"],["嫵","妩"],["嫗","妪"],["媯","妫"],["姍","姗"],["薑","姜"],["婁","娄"],["婭","娅"],["嬈","娆"],["嬌","娇"],["孌","娈"],["娛","娱"],["媧","娲"],["嫻","娴"],["嬰","婴"],["嬋","婵"],["嬸","婶"],["媼","媪"],["嬡","嫒"],["嬪","嫔"],["嬙","嫱"],["嬤","嬷"],["孫","孙"],["學","学"],["孿","孪"],["寧","宁"],["寶","宝"],["實","实"],["寵","宠"],["審","审"],["憲","宪"],["宮","宫"],["寬","宽"],["賓","宾"],["寢","寝"],["對","对"],["尋","寻"],["導","导"],["壽","寿"],["將","将"],["爾","尔"],["塵","尘"],["嘗","尝"],["堯","尧"],["尷","尴"],["屍","尸"],["盡","尽"],["層","层"],["屭","屃"],["屜","屉"],["屆","届"],["屬","属"],["屢","屡"],["屨","屦"],["嶼","屿"],["歲","岁"],["豈","岂"],["嶇","岖"],["崗","岗"],["峴","岘"],["嶴","岙"],["嵐","岚"],["島","岛"],["嶺","岭"],["嶽","岳"],["巋","岿"],["嶨","峃"],["嶧","峄"],["峽","峡"],["嶢","峣"],["嶠","峤"],["崢","峥"],["巒","峦"],["嶗","崂"],["崍","崃"],["嶮","崄"],["嶄","崭"],["嶸","嵘"],["嶔","嵚"],["崳","嵛"],["嶁","嵝"],["巔","巅"],["鞏","巩"],["幣","币"],["帥","帅"],["師","师"],["幃","帏"],["帳","帐"],["簾","帘"],["幟","帜"],["帶","带"],["幀","帧"],["幫","帮"],["幬","帱"],["幘","帻"],["幗","帼"],["冪","幂"],["幹","干"],["並","并"],["廣","广"],["莊","庄"],["慶","庆"],["廬","庐"],["廡","庑"],["庫","库"],["應","应"],["廟","庙"],["龐","庞"],["廢","废"],["廎","庼"],["廩","廪"],["開","开"],["異","异"],["棄","弃"],["張","张"],["彌","弥"],["弳","弪"],["彎","弯"],["彈","弹"],["強","强"],["歸","归"],["當","当"],["錄","录"],["彥","彦"],["徹","彻"],["徑","径"],["徠","徕"],["禦","御"],["憶","忆"],["懺","忏"],["憂","忧"],["愾","忾"],["懷","怀"],["態","态"],["慫","怂"],["憮","怃"],["慪","怄"],["悵","怅"],["愴","怆"],["憐","怜"],["總","总"],["懟","怼"],["懌","怿"],["戀","恋"],["恆","恒"],["懇","恳"],["惡","恶"],["慟","恸"],["懨","恹"],["愷","恺"],["惻","恻"],["惱","恼"],["惲","恽"],["悅","悦"],["愨","悫"],["懸","悬"],["慳","悭"],["憫","悯"],["驚","惊"],["懼","惧"],["慘","惨"],["懲","惩"],["憊","惫"],["愜","惬"],["慚","惭"],["憚","惮"],["慣","惯"],["湣","悯"],["慍","愠"],["憤","愤"],["憒","愦"],["願","愿"],["懾","慑"],["懣","懑"],["懶","懒"],["懍","懔"],["戇","戆"],["戔","戋"],["戲","戏"],["戧","戗"],["戰","战"],["戩","戬"],["戶","户"],["紮","扎"],["撲","扑"],["執","执"],["擴","扩"],["捫","扪"],["掃","扫"],["揚","扬"],["擾","扰"],["撫","抚"],["拋","抛"],["摶","抟"],["摳","抠"],["掄","抡"],["搶","抢"],["護","护"],["報","报"],["擔","担"],["擬","拟"],["攏","拢"],["揀","拣"],["擁","拥"],["攔","拦"],["擰","拧"],["撥","拨"],["擇","择"],["掛","挂"],["摯","挚"],["攣","挛"],["掗","挜"],["撾","挝"],["撻","挞"],["挾","挟"],["撓","挠"],["擋","挡"],["撟","挢"],["掙","挣"],["擠","挤"],["揮","挥"],["撏","挦"],["撈","捞"],["損","损"],["撿","捡"],["換","换"],["搗","捣"],["據","据"],["撚","捻"],["擄","掳"],["摑","掴"],["擲","掷"],["撣","掸"],["摻","掺"],["摜","掼"],["摣","揸"],["擼","撸"],["擕","携"],["撳","揿"],["攙","搀"],["擱","搁"],["攬","揽"],["攤","摊"],["攪","搅"],["敵","敌"],["敗","败"],["敘","叙"],["斂","敛"],["數","数"],["齋","斋"],["斕","斓"],["鬥","斗"],["斬","斩"],["斷","断"],["無","无"],["舊","旧"],["時","时"],["曠","旷"],["暘","旸"],["曇","昙"],["晝","昼"],["曨","昽"],["顯","显"],["晉","晋"],["曬","晒"],["曉","晓"],["曄","晔"],["暈","晕"],["暉","晖"],["暫","暂"],["曖","暧"],["術","术"],["樸","朴"],["機","机"],["殺","杀"],["雜","杂"],["權","权"],["條","条"],["來","来"],["楊","杨"],["榪","杩"],["傑","杰"],["鬆","松"],["極","极"],["構","构"],["樅","枞"],["樞","枢"],["棗","枣"],["櫪","枥"],["梘","枧"],["棖","枨"],["槍","枪"],["楓","枫"],["梟","枭"],["櫃","柜"],["檸","柠"],["檉","柽"],["梔","栀"],["柵","栅"],["標","标"],["棧","栈"],["櫛","栉"],["櫳","栊"],["棟","栋"],["櫨","栌"],["櫟","栎"],["欄","栏"],["樹","树"],["棲","栖"],["樣","样"],["欒","栾"],["棬","桊"],["椏","桠"],["橈","桡"],["楨","桢"],["檔","档"],["榿","桤"],["橋","桥"],["樺","桦"],["檜","桧"],["槳","桨"],["樁","桩"],["夢","梦"],["檮","梼"],["棶","梾"],["檢","检"],["欞","棂"],["槨","椁"],["櫝","椟"],["槧","椠"],["欏","椤"],["櫓","橹"],["櫚","榈"],["櫸","榉"],["檟","槚"],["檻","槛"],["檳","槟"],["櫧","槠"],["橫","横"],["檣","樯"],["櫻","樱"],["櫫","橥"],["櫥","橱"],["櫞","橼"],["簷","檐"],["檁","檩"],["歡","欢"],["歟","欤"],["歐","欧"],["殲","歼"],["歿","殁"],["殤","殇"],["殘","残"],["殞","殒"],["殮","殓"],["殫","殚"],["殯","殡"],["毆","殴"],["毀","毁"],["轂","毂"],["畢","毕"],["斃","毙"],["氈","毡"],["毿","毵"],["氣","气"],["氫","氢"],["氬","氩"],["氳","氲"],["汙","污"],["湯","汤"],["洶","汹"],["溝","沟"],["沒","没"],["灃","沣"],["漚","沤"],["瀝","沥"],["淪","沦"],["滄","沧"],["渢","沨"],["溈","沩"],["滬","沪"],["濔","沵"],["濘","泞"],["淚","泪"],["澩","泶"],["瀧","泷"],["瀘","泸"],["濼","泺"],["瀉","泻"],["潑","泼"],["澤","泽"],["涇","泾"],["潔","洁"],["灑","洒"],["洩","泄"],["窪","洼"],["浹","浃"],["淺","浅"],["漿","浆"],["澆","浇"],["湞","浈"],["溮","浉"],["濁","浊"],["測","测"],["澮","浍"],["濟","济"],["瀏","浏"],["滻","浐"],["渾","浑"],["滸","浒"],["濃","浓"],["潯","浔"],["濜","浕"],["塗","涂"],["湧","涌"],["濤","涛"],["澇","涝"],["淶","涞"],["漣","涟"],["潿","涠"],["渦","涡"],["溳","涢"],["渙","涣"],["滌","涤"],["潤","润"],["澗","涧"],["漲","涨"],["澀","涩"],["澱","淀"],["淵","渊"],["淥","渌"],["漬","渍"],["瀆","渎"],["漸","渐"],["澠","渑"],["漁","渔"],["瀋","沈"],["滲","渗"],["溫","温"],["遊","游"],["灣","湾"],["濕","湿"],["潰","溃"],["濺","溅"],["漵","溆"],["漊","溇"],["潷","滗"],["滾","滚"],["滯","滞"],["灩","滟"],["灄","滠"],["滿","满"],["瀅","滢"],["濾","滤"],["濫","滥"],["灤","滦"],["濱","滨"],["灘","滩"],["澦","滪"],["灠","漤"],["瀠","潆"],["瀟","潇"],["瀲","潋"],["濰","潍"],["潛","潜"],["瀦","潴"],["瀾","澜"],["瀨","濑"],["瀕","濒"],["灝","灏"],["滅","灭"],["燈","灯"],["靈","灵"],["災","灾"],["燦","灿"],["煬","炀"],["爐","炉"],["燉","炖"],["煒","炜"],["熗","炝"],["點","点"],["煉","炼"],["熾","炽"],["爍","烁"],["爛","烂"],["烴","烃"],["燭","烛"],["煙","烟"],["煩","烦"],["燒","烧"],["燁","烨"],["燴","烩"],["燙","烫"],["燼","烬"],["熱","热"],["煥","焕"],["燜","焖"],["燾","焘"],["愛","爱"],["爺","爷"],["牘","牍"],["犛","牦"],["牽","牵"],["犧","牺"],["犢","犊"],["狀","状"],["獷","犷"],["獁","犸"],["猶","犹"],["狽","狈"],["獮","狝"],["獰","狞"],["獨","独"],["狹","狭"],["獅","狮"],["獪","狯"],["猙","狰"],["獄","狱"],["猻","狲"],["獫","猃"],["獵","猎"],["獼","猕"],["玀","猡"],["豬","猪"],["貓","猫"],["蝟","猬"],["獻","献"],["獺","獭"],["璣","玑"],["璵","玙"],["瑒","玚"],["瑪","玛"],["瑋","玮"],["環","环"],["現","现"],["瑲","玱"],["璽","玺"],["玨","珏"],["琺","珐"],["瓏","珑"],["璫","珰"],["琿","珲"],["璡","琎"],["璦","瑷"],["瓔","璎"],["瓚","瓒"],["甌","瓯"],["產","产"],["畫","画"],["疊","叠"],["痙","痉"],["癱","瘫"],["瘓","痪"],["皺","皱"],["盞","盏"],["鹽","盐"],["監","监"],["蓋","盖"],["盜","盗"],["盤","盘"],["瞘","眍"],["眥","眦"],["矓","眬"],["著","着"],["睜","睁"],["睞","睐"],["瞼","睑"],["瞞","瞒"],["矚","瞩"],["矯","矫"],["磯","矶"],["礬","矾"],["礦","矿"],["碭","砀"],["碼","码"],["磚","砖"],["硨","砗"],["硯","砚"],["碸","砜"],["礪","砺"],["礱","砻"],["礫","砾"],["礎","础"],["硜","硁"],["碩","硕"],["硤","硖"],["磽","硗"],["磑","硙"],["礄","硚"],["確","确"],["鹼","碱"],["礙","碍"],["磧","碛"],["磣","碜"],["禮","礼"],["禕","祎"],["禰","祢"],["禎","祯"],["禱","祷"],["穢","秽"],["積","积"],["穎","颖"],["穠","秾"],["穡","穑"],["窩","窝"],["窪","洼"],["窯","窑"],["竄","窜"],["竅","窍"],["竇","窦"],["竈","灶"],["竊","窃"],["豎","竖"],["競","竞"],["篤","笃"],["筍","笋"],["筆","笔"],["筧","笕"],["箋","笺"],["籠","笼"],["籩","笾"],["築","筑"],["篳","筚"],["篩","筛"],["簹","筜"],["箏","筝"],["籌","筹"],["簽","签"],["簡","简"],["籙","箓"],["簀","箦"],["篋","箧"],["籜","箨"],["籮","箩"],["簞","箪"],["簫","箫"],["簣","篑"],["簍","篓"],["籃","篮"],["籬","篱"],["籪","簖"],["籟","籁"],["糴","籴"],["類","类"],["秈","籼"],["糶","粜"],["糲","粝"],["粵","粤"],["糞","粪"],["糧","粮"],["糝","糁"],["緊","紧"],["縶","絷"],["糾","纠"],["紆","纡"],["紅","红"],["紂","纣"],["纖","纤"],["紇","纥"],["約","约"],["級","级"],["紈","纨"],["纊","纩"],["紀","纪"],["紉","纫"],["緯","纬"],["紜","纭"],["紘","纮"],["純","纯"],["紕","纰"],["紗","纱"],["綱","纲"],["納","纳"],["紝","纴"],["縱","纵"],["綸","纶"],["紛","纷"],["紙","纸"],["紋","纹"],["紡","纺"],["紵","纻"],["紖","纼"],["紐","纽"],["紓","纾"],["線","线"],["紺","绀"],["絏","绁"],["紱","绂"],["練","练"],["組","组"],["紳","绅"],["細","细"],["織","织"],["終","终"],["縐","绉"],["絆","绊"],["紼","绋"],["絀","绌"],["紹","绍"],["繹","绎"],["經","经"],["紿","绐"],["綁","绑"],["絨","绒"],["結","结"],["絝","绔"],["繞","绕"],["絰","绖"],["絎","绗"],["繪","绘"],["給","给"],["絢","绚"],["絳","绛"],["絡","络"],["絕","绝"],["絞","绞"],["統","统"],["綆","绠"],["綃","绡"],["絹","绢"],["繡","绣"],["綌","绤"],["綏","绥"],["絛","绦"],["繼","继"],["綈","绨"],["績","绩"],["緒","绪"],["綾","绫"],["緓","绬"],["續","续"],["綺","绮"],["緋","绯"],["綽","绰"],["緔","绱"],["緄","绲"],["繩","绳"],["維","维"],["綿","绵"],["綬","绶"],["繃","绷"],["綢","绸"],["綯","绹"],["綹","绺"],["綣","绻"],["綜","综"],["綻","绽"],["綰","绾"],["綠","绿"],["綴","缀"],["緇","缁"],["緙","缂"],["緗","缃"],["緘","缄"],["緬","缅"],["纜","缆"],["緹","缇"],["緲","缈"],["緝","缉"],["縕","缊"],["繢","缋"],["緦","缌"],["綞","缍"],["緞","缎"],["緶","缏"],["緱","缑"],["縋","缒"],["緩","缓"],["締","缔"],["縷","缕"],["編","编"],["緡","缗"],["緣","缘"],["縉","缙"],["縛","缚"],["縟","缛"],["縝","缜"],["縫","缝"],["縗","缞"],["縞","缟"],["纏","缠"],["縭","缡"],["縊","缢"],["縑","缣"],["繽","缤"],["縹","缥"],["縵","缦"],["縲","缧"],["纓","缨"],["縮","缩"],["繆","缪"],["繅","缫"],["纈","缬"],["繚","缭"],["繕","缮"],["繒","缯"],["韁","缰"],["繾","缱"],["繰","缲"],["繯","缳"],["繳","缴"],["纘","缵"],["罌","罂"],["網","网"],["羅","罗"],["罰","罚"],["罷","罢"],["羆","罴"],["羈","羁"],["羥","羟"],["羨","羡"],["翹","翘"],["耮","耢"],["耬","耧"],["聳","耸"],["恥","耻"],["聶","聂"],["聾","聋"],["職","职"],["聹","聍"],["聯","联"],["聵","聩"],["聰","聪"],["肅","肃"],["腸","肠"],["膚","肤"],["腎","肾"],["腫","肿"],["脹","胀"],["脅","胁"],["膽","胆"],["勝","胜"],["朧","胧"],["腖","胨"],["臚","胪"],["脛","胫"],["膠","胶"],["脈","脉"],["膾","脍"],["髒","脏"],["臍","脐"],["腦","脑"],["膿","脓"],["臠","脔"],["腳","脚"],["脫","脱"],["腡","脶"],["臉","脸"],["臘","腊"],["醃","腌"],["膕","腘"],["齶","腭"],["膩","腻"],["靦","腼"],["膃","腽"],["騰","腾"],["臏","膑"],["輿","舆"],["艤","舣"],["艦","舰"],["艙","舱"],["艫","舻"],["艱","艰"],["豔","艳"],["藝","艺"],["節","节"],["羋","芈"],["薌","芗"],["蕪","芜"],["蘆","芦"],["蓯","苁"],["葦","苇"],["藶","苈"],["莧","苋"],["萇","苌"],["蒼","苍"],["苧","苎"],["蘇","苏"],["蘋","苹"],["莖","茎"],["蘢","茏"],["蔦","茑"],["塋","茔"],["煢","茕"],["繭","茧"],["荊","荆"],["薦","荐"],["薘","荙"],["莢","荚"],["蕘","荛"],["蓽","荜"],["蕎","荞"],["薈","荟"],["薺","荠"],["蕩","荡"],["榮","荣"],["葷","荤"],["滎","荥"],["犖","荦"],["熒","荧"],["蕁","荨"],["藎","荩"],["蓀","荪"],["蔭","荫"],["蕒","荬"],["葒","荭"],["葤","荮"],["藥","药"],["蒞","莅"],["蓧","莜"],["萊","莱"],["蓮","莲"],["蒔","莳"],["萵","莴"],["薟","莶"],["穫","获"],["蕕","莸"],["瑩","莹"],["鶯","莺"],["蓴","莼"],["蘿","萝"],["螢","萤"],["營","营"],["縈","萦"],["蕭","萧"],["薩","萨"],["蔥","葱"],["蕆","蒇"],["蕢","蒉"],["蔣","蒋"],["蔞","蒌"],["藍","蓝"],["薊","蓟"],["蘺","蓠"],["蕷","蓣"],["鎣","蓥"],["驀","蓦"],["虆","蔂"],["薔","蔷"],["蘞","蔹"],["藺","蔺"],["藹","蔼"],["蘄","蕲"],["蘊","蕴"],["藪","薮"],["藁","藁"],["蘚","藓"],["虜","虏"],["慮","虑"],["虛","虚"],["蟲","虫"],["虯","虬"],["蟣","虮"],["雖","虽"],["蝦","虾"],["蠆","虿"],["蝕","蚀"],["蟻","蚁"],["螞","蚂"],["蠶","蚕"],["蠔","蚝"],["蜆","蚬"],["蠱","蛊"],["蠣","蛎"],["蟶","蛏"],["蠻","蛮"],["蟄","蛰"],["蛺","蛱"],["蟯","蛲"],["螄","蛳"],["蠐","蛴"],["蛻","蜕"],["蝸","蜗"],["蠟","蜡"],["蠅","蝇"],["蟈","蝈"],["蟬","蝉"],["蠍","蝎"],["蟎","螨"],["蠨","蟏"],["釁","衅"],["銜","衔"],["補","补"],["襯","衬"],["袞","衮"],["襖","袄"],["褘","袆"],["襪","袜"],["襲","袭"],["襏","袯"],["裝","装"],["襠","裆"],["褌","裈"],["褳","裢"],["襝","裣"],["褲","裤"],["襇","裥"],["褸","褛"],["襤","褴"],["見","见"],["觀","观"],["覎","觃"],["規","规"],["覓","觅"],["視","视"],["覘","觇"],["覽","览"],["覺","觉"],["覬","觊"],["覡","觋"],["覿","觌"],["覦","觎"],["覯","觏"],["覲","觐"],["覷","觑"],["觴","觞"],["觸","触"],["觶","觯"],["讋","詟"],["譽","誉"],["謄","誊"],["計","计"],["訂","订"],["訃","讣"],["認","认"],["譏","讥"],["訐","讦"],["訌","讧"],["討","讨"],["讓","让"],["訕","讪"],["訖","讫"],["訓","训"],["議","议"],["訊","讯"],["記","记"],["訒","讱"],["講","讲"],["諱","讳"],["謳","讴"],["詎","讵"],["訝","讶"],["訥","讷"],["許","许"],["訛","讹"],["論","论"],["訩","讻"],["訟","讼"],["諷","讽"],["設","设"],["訪","访"],["訣","诀"],["證","证"],["詁","诂"],["訶","诃"],["評","评"],["詛","诅"],["識","识"],["詗","诇"],["詐","诈"],["訴","诉"],["診","诊"],["詆","诋"],["謅","诌"],["詞","词"],["詘","诎"],["詔","诏"],["詖","诐"],["譯","译"],["詒","诒"],["誆","诓"],["誄","诔"],["試","试"],["詿","诖"],["詩","诗"],["詰","诘"],["詼","诙"],["誠","诚"],["誅","诛"],["詵","诜"],["話","话"],["誕","诞"],["詬","诟"],["詮","诠"],["詭","诡"],["詢","询"],["詣","诣"],["諍","诤"],["該","该"],["詳","详"],["詫","诧"],["諢","诨"],["詡","诩"],["譸","诪"],["誡","诫"],["誣","诬"],["語","语"],["誚","诮"],["誤","误"],["誥","诰"],["誘","诱"],["誨","诲"],["誑","诳"],["說","说"],["誦","诵"],["誒","诶"],["請","请"],["諸","诸"],["諏","诹"],["諾","诺"],["讀","读"],["諑","诼"],["誹","诽"],["課","课"],["諉","诿"],["諛","谀"],["誰","谁"],["諗","谂"],["調","调"],["諂","谄"],["諒","谅"],["諄","谆"],["誶","谇"],["談","谈"],["誼","谊"],["謀","谋"],["諶","谌"],["諜","谍"],["謊","谎"],["諫","谏"],["諧","谐"],["謔","谑"],["謁","谒"],["謂","谓"],["諤","谔"],["諭","谕"],["諼","谖"],["讒","谗"],["諮","谘"],["諳","谙"],["諺","谚"],["諦","谛"],["謎","谜"],["諞","谝"],["謨","谟"],["讜","谠"],["謖","谡"],["謝","谢"],["謠","谣"],["謗","谤"],["諡","谥"],["謙","谦"],["謐","谧"],["謹","谨"],["謾","谩"],["謫","谪"],["譾","谫"],["謬","谬"],["譚","谭"],["譖","谮"],["譙","谯"],["讕","谰"],["譜","谱"],["譎","谲"],["讞","谳"],["譴","谴"],["譫","谵"],["讖","谶"],["穀","谷"],["貝","贝"],["貞","贞"],["負","负"],["貟","贠"],["貢","贡"],["財","财"],["責","责"],["賢","贤"],["敗","败"],["賬","账"],["貨","货"],["質","质"],["販","贩"],["貪","贪"],["貧","贫"],["貶","贬"],["購","购"],["貯","贮"],["貫","贯"],["貳","贰"],["賤","贱"],["賁","贲"],["貰","贳"],["貼","贴"],["貴","贵"],["貺","贶"],["貸","贷"],["貿","贸"],["費","费"],["賀","贺"],["貽","贻"],["賊","贼"],["贄","贽"],["賈","贾"],["賄","贿"],["貲","赀"],["賃","赁"],["賂","赂"],["贓","赃"],["資","资"],["賅","赅"],["贐","赆"],["賕","赇"],["賑","赈"],["賚","赉"],["賒","赊"],["賦","赋"],["賭","赌"],["齎","赍"],["贖","赎"],["賞","赏"],["賜","赐"],["贔","赑"],["賙","赒"],["賡","赓"],["賠","赔"],["賧","赕"],["賴","赖"],["賵","赗"],["贅","赘"],["賻","赙"],["賺","赚"],["賽","赛"],["賾","赜"],["贊","赞"],["贇","赟"],["贈","赠"],["贍","赡"],["贏","赢"],["贛","赣"],["趙","赵"],["趕","赶"],["趨","趋"],["趲","趱"],["躉","趸"],["躍","跃"],["蹌","跄"],["蹠","跖"],["躒","跞"],["跡","迹"],["踐","践"],["躂","跶"],["蹺","跷"],["蹕","跸"],["躚","跹"],["躋","跻"],["踴","踊"],["躊","踌"],["蹤","踪"],["躓","踬"],["躑","踯"],["躡","蹑"],["蹣","蹒"],["躕","蹰"],["躥","蹿"],["躪","躏"],["躦","躜"],["軀","躯"],["車","车"],["軋","轧"],["軌","轨"],["軒","轩"],["軔","轫"],["轉","转"],["軛","轭"],["輪","轮"],["軟","软"],["轟","轰"],["軲","轱"],["軻","轲"],["轤","轳"],["軸","轴"],["軹","轵"],["軼","轶"],["軤","轷"],["軫","轸"],["轢","轹"],["軺","轺"],["輕","轻"],["軾","轼"],["載","载"],["輊","轾"],["轎","轿"],["輈","辀"],["輇","辁"],["輅","辂"],["較","较"],["輒","辄"],["輔","辅"],["輛","辆"],["輦","辇"],["輩","辈"],["輝","辉"],["輥","辊"],["輞","辋"],["輬","辌"],["輟","辍"],["輜","辎"],["輳","辏"],["輻","辐"],["輯","辑"],["轀","辒"],["輸","输"],["轡","辔"],["轅","辕"],["轄","辖"],["輾","辗"],["轆","辘"],["轍","辙"],["轔","辚"],["辭","辞"],["辯","辩"],["辮","辫"],["邊","边"],["遼","辽"],["達","达"],["遷","迁"],["過","过"],["邁","迈"],["運","运"],["還","还"],["這","这"],["進","进"],["遠","远"],["違","违"],["連","连"],["遲","迟"],["邇","迩"],["逕","迳"],["適","适"],["選","选"],["遜","逊"],["遞","递"],["邐","逦"],["邏","逻"],["遺","遗"],["遙","遥"],["鄧","邓"],["鄺","邝"],["鄔","邬"],["郵","邮"],["鄒","邹"],["鄴","邺"],["鄰","邻"],["鬱","郁"],["郟","郏"],["鄶","郐"],["鄭","郑"],["鄆","郓"],["酈","郦"],["鄖","郧"],["鄲","郸"],["醞","酝"],["醱","酦"],["醬","酱"],["釅","酽"],["釃","酾"],["釀","酿"],["釋","释"],["裡","里"],["裏","里"],["鍾","钟"],["鐘","钟"],["鐵","铁"],["銀","银"],["銅","铜"],["鋁","铝"],["鋼","钢"],["鍵","键"],["鎖","锁"],["鎮","镇"],["鏡","镜"],["長","长"],["門","门"],["閃","闪"],["閉","闭"],["問","问"],["閏","闰"],["閑","闲"],["間","间"],["閔","闵"],["閘","闸"],["鬧","闹"],["閨","闺"],["聞","闻"],["闥","闼"],["閩","闽"],["閭","闾"],["閫","阃"],["閬","阆"],["閱","阅"],["閶","阊"],["閹","阉"],["閻","阎"],["閼","阏"],["閽","阍"],["閾","阈"],["閿","阌"],["闃","阒"],["闈","闱"],["闊","阔"],["闋","阕"],["闌","阑"],["闍","阇"],["闐","阗"],["闒","阘"],["闓","闿"],["闔","阖"],["闕","阙"],["闖","闯"],["關","关"],["闞","阚"],["闡","阐"],["闢","辟"],["闥","闼"],["隊","队"],["陽","阳"],["陰","阴"],["陣","阵"],["階","阶"],["際","际"],["陸","陆"],["隴","陇"],["陳","陈"],["陘","陉"],["陝","陕"],["隉","陧"],["隕","陨"],["險","险"],["隨","随"],["隱","隐"],["隸","隶"],["雋","隽"],["難","难"],["雛","雏"],["離","离"],["難","难"],["電","电"],["霧","雾"],["霽","霁"],["靂","雳"],["靄","霭"],["靚","靓"],["靜","静"],["麵","面"],["靨","靥"],["韃","鞑"],["鞽","鞒"],["韉","鞯"],["韋","韦"],["韌","韧"],["韍","韨"],["韓","韩"],["韙","韪"],["韜","韬"],["韞","韫"],["韻","韵"],["頁","页"],["頂","顶"],["頃","顷"],["頇","顸"],["項","项"],["順","顺"],["須","须"],["頊","顼"],["頌","颂"],["頎","颀"],["頏","颃"],["預","预"],["頑","顽"],["頒","颁"],["頓","顿"],["頗","颇"],["領","领"],["頜","颌"],["頡","颉"],["頤","颐"],["頦","颏"],["頭","头"],["頮","颒"],["頰","颊"],["頲","颋"],["頴","颕"],["頷","颔"],["頸","颈"],["頹","颓"],["頻","频"],["顢","颟"],["顆","颗"],["題","题"],["額","额"],["顎","颚"],["顏","颜"],["顒","颙"],["顓","颛"],["願","愿"],["顙","颡"],["顛","颠"],["類","类"],["顥","颢"],["顧","顾"],["顫","颤"],["顬","颥"],["顯","显"],["顰","颦"],["顱","颅"],["顳","颞"],["顴","颧"],["風","风"],["颭","飐"],["颮","飑"],["颯","飒"],["颶","飓"],["颸","飔"],["颼","飕"],["颻","飖"],["飀","飗"],["飄","飘"],["飆","飙"],["飈","飚"],["飛","飞"],["饗","飨"],["饜","餍"],["饑","饥"],["饒","饶"],["饈","馐"],["饉","馑"],["饊","馓"],["饌","馔"],["饢","馕"],["馬","马"],["馭","驭"],["馮","冯"],["馱","驮"],["馳","驰"],["馴","驯"],["馹","驲"],["駁","驳"],["駐","驻"],["駑","驽"],["駒","驹"],["駔","驵"],["駕","驾"],["駘","骀"],["駙","驸"],["駛","驶"],["駝","驼"],["駟","驷"],["駡","骂"],["駢","骈"],["駭","骇"],["駮","驳"],["駱","骆"],["駸","骎"],["駿","骏"],["騁","骋"],["騂","骍"],["騅","骓"],["騌","骔"],["騍","骒"],["騎","骑"],["騏","骐"],["騖","骛"],["騙","骗"],["騤","骙"],["騧","䯄"],["騫","骞"],["騭","骘"],["騮","骝"],["騰","腾"],["騶","驺"],["騷","骚"],["騸","骟"],["騾","骡"],["驀","蓦"],["驁","骜"],["驂","骖"],["驃","骠"],["驄","骢"],["驅","驱"],["驊","骅"],["驌","骕"],["驍","骁"],["驏","骣"],["驕","骄"],["驗","验"],["驚","惊"],["驛","驿"],["驟","骤"],["驢","驴"],["驤","骧"],["驥","骥"],["驦","骦"],["驪","骊"],["驫","骉"],["骯","肮"],["髏","髅"],["髖","髋"],["髕","髌"],["鬢","鬓"],["鬥","斗"],["鬧","闹"],["鬨","哄"],["鬩","阋"],["鬮","阄"],["鬱","郁"],["魎","魉"],["魘","魇"],["魚","鱼"],["魛","鱽"],["魢","鱾"],["魨","鲀"],["魯","鲁"],["魴","鲂"],["魷","鱿"],["魺","鲄"],["鮁","鲅"],["鮃","鲆"],["鮊","鲌"],["鮋","鲉"],["鮍","鲏"],["鮎","鲇"],["鮐","鲐"],["鮑","鲍"],["鮒","鲋"],["鮓","鲊"],["鮚","鲒"],["鮜","鲘"],["鮞","鲕"],["鮦","鲖"],["鮪","鲔"],["鮫","鲛"],["鮭","鲑"],["鮮","鲜"],["鮳","鲓"],["鮶","鲪"],["鮺","鲝"],["鯀","鲧"],["鯁","鲠"],["鯇","鲩"],["鯉","鲤"],["鯊","鲨"],["鯒","鲬"],["鯔","鲻"],["鯕","鲯"],["鯖","鲭"],["鯗","鲞"],["鯛","鲷"],["鯝","鲴"],["鯡","鲱"],["鯢","鲵"],["鯤","鲲"],["鯧","鲳"],["鯨","鲸"],["鯪","鲮"],["鯫","鲰"],["鯴","鲺"],["鯽","鲫"],["鯿","鳊"],["鰁","鳈"],["鰂","鲗"],["鰃","鳂"],["鰈","鲽"],["鰉","鳇"],["鰍","鳅"],["鰏","鲾"],["鰐","鳄"],["鰒","鳆"],["鰓","鳃"],["鰜","鳒"],["鰟","鳑"],["鰠","鳋"],["鰣","鲥"],["鰥","鳏"],["鰨","鳎"],["鰩","鳐"],["鰭","鳍"],["鰮","鳁"],["鰱","鲢"],["鰲","鳌"],["鰳","鳓"],["鰵","鳘"],["鰷","鲦"],["鰹","鲣"],["鰺","鲹"],["鰻","鳗"],["鰼","鳛"],["鰾","鳔"],["鱂","鳉"],["鱅","鳙"],["鱈","鳕"],["鱉","鳖"],["鱒","鳟"],["鱔","鳝"],["鱖","鳜"],["鱗","鳞"],["鱘","鲟"],["鱝","鲼"],["鱟","鲎"],["鱠","鲙"],["鱣","鳣"],["鱤","鳡"],["鱧","鳢"],["鱨","鲿"],["鱭","鲚"],["鱯","鳠"],["鱷","鳄"],["鱸","鲈"],["鱺","鲡"],["鳥","鸟"],["鳧","凫"],["鳩","鸠"],["鳲","鸤"],["鳳","凤"],["鳴","鸣"],["鳶","鸢"],["鴆","鸩"],["鴇","鸨"],["鴉","鸦"],["鴒","鸰"],["鴕","鸵"],["鴛","鸳"],["鴝","鸲"],["鴟","鸱"],["鴣","鸪"],["鴦","鸯"],["鴨","鸭"],["鴯","鸸"],["鴰","鸹"],["鴴","鸻"],["鴻","鸿"],["鴿","鸽"],["鵂","鸺"],["鵃","鸼"],["鵐","鹀"],["鵑","鹃"],["鵒","鹆"],["鵓","鹁"],["鵜","鹈"],["鵝","鹅"],["鵠","鹄"],["鵡","鹉"],["鵪","鹌"],["鵬","鹏"],["鵯","鹎"],["鵲","鹊"],["鵷","鹓"],["鵾","鹍"],["鶇","鸫"],["鶉","鹑"],["鶊","鹒"],["鶓","鹋"],["鶖","鹙"],["鶘","鹕"],["鶚","鹗"],["鶡","鹖"],["鶥","鹛"],["鶩","鹜"],["鶬","鸧"],["鶯","莺"],["鶲","鹟"],["鶴","鹤"],["鶹","鹠"],["鶺","鹡"],["鶻","鹘"],["鶼","鹣"],["鶿","鹚"],["鷀","鹚"],["鷁","鹢"],["鷂","鹞"],["鷊","鹝"],["鷓","鹧"],["鷖","鹥"],["鷗","鸥"],["鷙","鸷"],["鷚","鹨"],["鷥","鸶"],["鷦","鹪"],["鷫","鹔"],["鷯","鹩"],["鷲","鹫"],["鷳","鹇"],["鷸","鹬"],["鷹","鹰"],["鷺","鹭"],["鷽","鸴"],["鸇","鹯"],["鸌","鹱"],["鸏","鹲"],["鸕","鸬"],["鸚","鹦"],["鸛","鹳"],["鸝","鹂"],["鸞","鸾"],["鹵","卤"],["鹹","咸"],["鹺","鹾"],["鹼","碱"],["鹽","盐"],["麗","丽"],["麥","麦"],["麩","麸"],["麵","面"],["麼","么"],["黃","黄"],["黌","黉"],["點","点"],["黨","党"],["黲","黪"],["黴","霉"],["黶","黡"],["黷","黩"],["黽","黾"],["黿","鼋"],["鼂","鼌"],["鼉","鼍"],["鼴","鼹"],["齊","齐"],["齋","斋"],["齎","赍"],["齏","齑"],["齒","齿"],["齔","龀"],["齕","龁"],["齗","龂"],["齙","龅"],["齜","龇"],["齟","龃"],["齠","龆"],["齡","龄"],["齣","出"],["齦","龈"],["齪","龊"],["齬","龉"],["齲","龋"],["齶","腭"],["齷","龌"],["龍","龙"],["龐","庞"],["龔","龚"],["龕","龛"],["龜","龟"],["係","系"],["佈","布"],["佔","占"],["併","并"],["來","来"],["例","例"],["係","系"],["臺","台"],["檯","台"],["颱","台"],["裡","里"],["纔","才"],["祇","只"],["祇","只"],["甚","甚"],["麼","么"],["衹","只"],["佈","布"],["佔","占"]];let le=null,ce=null;function it(){return le||(le=new Map(st)),le}function lt(){return ce||(ce=[...at].sort((o,t)=>t[0].length-o[0].length)),ce}function Te(o){if(!o)return o;let t=o;for(const[n,i]of lt())t.includes(n)&&(t=t.split(n).join(i));const s=it();let r=!1;const a=Array.from(t);for(let n=0;n<a.length;n++){const i=s.get(a[n]);i&&i!==a[n]&&(a[n]=i,r=!0)}return r?a.join(""):t}const te=16e3,ct=1.2,dt=2,ut=Math.round(te*2.5),ht=Math.round(te*ct),mt=Math.round(te*dt),de=Math.round(te*.4),ft=200;function Re(o,t){const s=(o||"").trim(),r=(t||"").trim();return r?s?/[A-Za-z0-9]$/.test(s)&&/[A-Za-z0-9]/.test(r.charAt(0))?`${s} ${r}`:`${s}${r}`:r:s}const ue="/scripts/ai/whisper.worker.js";function pt(){return new Worker(he(ue),{type:"module"})}function he(o){return/^https?:\/\//i.test(o)?o:typeof location<"u"?new URL(o,location.origin).href:o}function _e(o){if(!o.ok)return!1;const t=(o.headers.get("content-type")||"").toLowerCase();return!(t.includes("text/html")||t.includes("application/xhtml+xml"))}async function gt(o){try{const t=await fetch(o,{method:"HEAD"});if(_e(t))return!0}catch{}try{const t=await fetch(o,{headers:{Range:"bytes=0-64"}});if(_e(t))return!0}catch{}return!1}async function yt(o){const t=[];o&&t.push(he(o)),t.push(he(ue));const s=[...new Set(t.filter(Boolean))];for(const r of s)if(await gt(r))return console.log("[VoiceInputManager] 使用语音 Worker:",r),r;return console.warn("[VoiceInputManager] 未探测到可访问的 Worker 脚本,将回退到 Vite 打包注入地址。已尝试:",s.join(" , ")),null}class Ve{constructor(t={}){T(this,"recorder",null);T(this,"worker",null);T(this,"status","idle");T(this,"options");T(this,"isReady",!1);T(this,"initPromise",null);T(this,"currentTaskId",0);T(this,"pcmParts",[]);T(this,"pcmLength",0);T(this,"pcmSent",0);T(this,"streamBusy",!1);T(this,"streamFinalPending",!1);T(this,"streamChunkIndex",0);T(this,"committedText","");T(this,"chunkPartialText","");T(this,"streamPumpTimer",null);this.options={soundBaseUrl:"/sounds/",remoteHost:"https://hf-mirror.com",modelId:"onnx-community/whisper-base",language:"chinese",...t}}get currentStatus(){return this.status}get ready(){return this.isReady}async init(t){if(!this.isReady)return this.initPromise?this.initPromise:(t&&(this.options.soundBaseUrl=t),this.initPromise=new Promise((s,r)=>{this.setStatus("loading","正在准备语音识别引擎..."),(async()=>{var n,i;try{const l=await yt(this.options.workerUrl);this.worker=l?new Worker(l,{type:"module"}):pt(),this.worker.onmessage=c=>{this.handleWorkerMessage(c,s,r)},this.worker.onerror=c=>{var P,V;const S=`语音后台线程异常: ${c.message||c.filename||l||"未知错误"}`;this.initPromise=null,this.setStatus("error",S),(V=(P=this.options).onError)==null||V.call(P,S),r(c)},this.worker.postMessage({type:"INIT",data:{modelId:this.options.modelId,soundBaseUrl:this.options.soundBaseUrl,remoteHost:this.options.remoteHost}})}catch(l){const c=`创建语音 Worker 失败: ${l.message||l}`;this.initPromise=null,this.setStatus("error",c),(i=(n=this.options).onError)==null||i.call(n,c),r(l)}})()}),this.initPromise)}async startRecording(){var t,s,r,a;if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){const n=window.isSecureContext?"当前浏览器环境不支持获取麦克风音频,请使用现代浏览器。":"当前页面不是安全上下文,浏览器禁止调用麦克风。请使用 https:// 或 http://localhost / http://127.0.0.1 访问(通过局域网 IP 的 http 地址无法录音)。";throw this.setStatus("error",n),(s=(t=this.options).onError)==null||s.call(t,n),new Error(n)}this.isReady||await this.init(),this.recorder||(this.recorder=new Ne({onVolumeChange:n=>{var i,l;(l=(i=this.options).onVolumeChange)==null||l.call(i,n)},onAudioChunk:n=>{this.appendPcm(n)}}));try{this.currentTaskId++,this.resetStreamState(),await this.recorder.start(),this.startStreamPump(),this.setStatus("recording","正在录音,边说边识别...")}catch(n){throw this.setStatus("error",n.message||"启动录音失败"),(a=(r=this.options).onError)==null||a.call(r,n.message||"启动录音失败"),n}}async stopAndTranscribe(){var t,s,r,a;if(!(!this.recorder||!this.recorder.isRecording)){this.setStatus("transcribing","正在识别剩余语音..."),this.stopStreamPump();try{await this.recorder.stop();const n=this.mergePcm();if(n.length===0&&!this.committedText){this.setStatus("idle");return}try{const i=ee(n.length?n:new Float32Array(0)),l=URL.createObjectURL(i);(s=(t=this.options).onAudioRecorded)==null||s.call(t,l,i)}catch(i){console.warn("生成录音回放音频失败:",i)}this.tryDispatchStreamChunk(!0)}catch(n){this.setStatus("error",n.message||"音频处理失败"),(a=(r=this.options).onError)==null||a.call(r,n.message||"音频处理失败")}}}async transcribeAudioData(t,s){var r,a,n,i,l,c;this.isReady||await this.init(),this.setStatus("transcribing","正在流式识别音频...");try{if(s)(a=(r=this.options).onAudioRecorded)==null||a.call(r,s,ee(t));else{const m=ee(t),S=URL.createObjectURL(m);(i=(n=this.options).onAudioRecorded)==null||i.call(n,S,m)}this.currentTaskId++,this.resetStreamState(),this.appendPcm(t),this.tryDispatchStreamChunk(!0)}catch(m){this.setStatus("error",m.message||"音频处理失败"),(c=(l=this.options).onError)==null||c.call(l,m.message||"音频处理失败")}}async transcribeFile(t){var s,r;this.isReady||await this.init(),this.setStatus("loading","正在解析音频文件...");try{const a=await xe(t);if(a.length===0)throw new Error("未能从该文件中提取出有效音频");const n=URL.createObjectURL(t);await this.transcribeAudioData(a,n)}catch(a){this.setStatus("error",a.message||"音频文件解析失败"),(r=(s=this.options).onError)==null||r.call(s,a.message||"音频文件解析失败")}}cancelRecording(){this.currentTaskId++,this.stopStreamPump(),this.resetStreamState(),this.recorder&&this.recorder.cancel(),this.setStatus("idle")}cancelTranscribe(){this.currentTaskId++,this.stopStreamPump(),this.resetStreamState(),(this.status==="transcribing"||this.status==="recording")&&this.setStatus("idle")}async clearCache(){this.worker&&(this.worker.postMessage({type:"CLEAR_CACHE"}),this.isReady=!1,this.initPromise=null)}destroy(){this.currentTaskId++,this.stopStreamPump(),this.resetStreamState(),this.recorder&&(this.recorder.cancel(),this.recorder=null),this.worker&&(this.worker.terminate(),this.worker=null),this.isReady=!1,this.initPromise=null,this.setStatus("idle")}startStreamPump(){this.stopStreamPump(),this.streamPumpTimer=setInterval(()=>{this.tryDispatchStreamChunk(!1)},ft),this.tryDispatchStreamChunk(!1)}stopStreamPump(){this.streamPumpTimer!=null&&(clearInterval(this.streamPumpTimer),this.streamPumpTimer=null)}getNextChunkSize(){return this.streamFinalPending?ut:this.streamChunkIndex===0?ht:mt}resetStreamState(){this.pcmParts=[],this.pcmLength=0,this.pcmSent=0,this.streamBusy=!1,this.streamFinalPending=!1,this.streamChunkIndex=0,this.committedText="",this.chunkPartialText=""}appendPcm(t){!t||t.length===0||(this.pcmParts.push(new Float32Array(t)),this.pcmLength+=t.length)}mergePcm(){const t=new Float32Array(this.pcmLength);let s=0;for(const r of this.pcmParts)t.set(r,s),s+=r.length;return t}copyPcm(t,s){const r=new Float32Array(s);let a=0,n=0;for(const i of this.pcmParts){if(n>=s)break;if(a+i.length<=t){a+=i.length;continue}const l=Math.max(0,t-a),c=Math.min(i.length-l,s-n);r.set(i.subarray(l,l+c),n),n+=c,a+=i.length}return r}emitLiveText(){var s,r;const t=Te(Re(this.committedText,this.chunkPartialText));(r=(s=this.options).onPartial)==null||r.call(s,t)}finishStream(t){var r,a;const s=Te((t??this.committedText).trim());this.streamBusy=!1,this.streamFinalPending=!1,this.setStatus("idle"),(a=(r=this.options).onResult)==null||a.call(r,s)}tryDispatchStreamChunk(t){if(t&&(this.streamFinalPending=!0),!this.worker){this.streamFinalPending&&this.finishStream();return}if(this.streamBusy)return;const s=this.pcmLength-this.pcmSent,r=this.getNextChunkSize(),a=s>=r,n=this.streamFinalPending&&s>=de;if(!a&&!n){this.streamFinalPending&&this.finishStream();return}const i=a?r:s,l=s-i,c=this.streamFinalPending&&l<de,m=this.copyPcm(this.pcmSent,i);this.pcmSent+=i,this.streamBusy=!0,this.chunkPartialText="";const S=this.currentTaskId;this.worker.postMessage({type:"TRANSCRIBE",data:{taskId:S,audio:m,language:this.options.language,stream:!0,chunkIndex:this.streamChunkIndex++,isFinal:c}},[m.buffer])}handleWorkerMessage(t,s,r){var m,S,P,V,E;const{type:a,data:n,taskId:i,text:l,error:c}=t.data;switch(a){case"READY":this.isReady=!0,this.setStatus("ready","语音引擎就绪"),s==null||s();break;case"PROGRESS":if(n){const F=typeof n.progress=="number"?Math.round(n.progress):0;this.setStatus("downloading",`正在下载语音模型... ${F}%`),(S=(m=this.options).onProgress)==null||S.call(m,{status:n.status||"progress",progress:F,file:n.file,loaded:n.loaded,total:n.total})}break;case"TRANSCRIBING":if(i&&i!==this.currentTaskId)return;this.status!=="recording"&&this.setStatus("transcribing","正在流式转写文字...");break;case"PARTIAL":if(i&&i!==this.currentTaskId)return;this.chunkPartialText=l||"",this.emitLiveText();break;case"RESULT":if(i&&i!==this.currentTaskId)return;if(this.committedText=Re(this.committedText,l||""),this.chunkPartialText="",this.emitLiveText(),this.streamBusy=!1,(P=t.data)!=null&&P.isFinal||this.streamFinalPending&&this.pcmLength-this.pcmSent<de){this.finishStream(this.committedText);return}this.tryDispatchStreamChunk(this.streamFinalPending);break;case"CACHE_CLEARED":this.setStatus("idle","语音模型缓存已清空");break;case"ERROR":if(i&&i!==this.currentTaskId)return;this.streamBusy=!1,this.setStatus("error",c||"语音服务异常"),(E=(V=this.options).onError)==null||E.call(V,c||"语音服务异常"),r==null||r(new Error(c));break}}setStatus(t,s){var r,a;this.status=t,(a=(r=this.options).onStatusChange)==null||a.call(r,t,s)}}const wt={class:"panel-header"},kt={class:"header-actions"},St={class:"header-title"},Ct={class:"action-icons"},bt={class:"body-content"},Et={key:0,class:"welcome-content"},vt={class:"subtitle"},Nt={class:"highlight"},xt={class:"quick-questions"},Tt=["onClick"],Rt={key:1,class:"message-content user-content"},_t={class:"panel-footer"},Vt={key:0,src:je,alt:"加载中",class:"loading-icon"},Pt={key:0,class:"voice-progress-banner"},At={class:"progress-info"},Bt={class:"progress-text"},Lt={key:0,class:"progress-percent"},Mt={key:0,class:"progress-track"},Ut={key:0,class:"voice-recording-panel has-transcript"},Ft={class:"recording-main"},It={class:"recording-status"},Ot={key:0,class:"recording-time"},Dt={class:"recording-hint"},zt={key:1,class:"volume-waves"},$t={class:"recording-actions"},jt=["title"],Ht={key:0,class:"voice-playback-bar"},qt=["title"],Wt={class:"playback-play-icon"},Kt={key:0,viewBox:"0 0 24 24",width:"14",height:"14",fill:"currentColor"},Jt={key:1,viewBox:"0 0 24 24",width:"14",height:"14",fill:"currentColor"},Zt={class:"playback-title"},Qt={key:0,class:"playback-time"},Gt={key:1,class:"playback-waves"},Xt={class:"input-box"},Yt={class:"input-actions-box"},en=["src"],tn={__name:"ChatPanel",props:{modelValue:{type:Boolean,default:!1},token:{type:String,default:""},identifier:{type:String,default:""},baseUrl:{type:String,default:""},title:{type:String,default:"数智AI助理"},llmName:{type:String,default:"szjy"},messagePostRender:{type:Function,default:null},extraConfig:{type:Object,default:()=>({})},soundBaseUrl:{type:String,default:"/sounds/"},workerUrl:{type:String,default:""}},emits:["update:modelValue","submit"],setup(o,{emit:t}){const{appContext:s}=e.getCurrentInstance(),{$message:r}=s.config.globalProperties,a=o;let n=null;const i=e.ref("idle"),l=e.ref(""),c=e.ref(0),m=e.ref(0),S=e.ref(0);let P=null;const V=e.ref(""),E=e.ref(!1),F=e.ref(0);let x=null;const A=e.ref(""),w=e.ref(""),g=e.computed(()=>i.value==="downloading"),y=e.computed(()=>i.value==="loading"),d=e.computed(()=>i.value==="recording"),u=e.computed(()=>i.value==="transcribing"),C=e.computed(()=>d.value?A.value?"正在边说边识别...":"正在倾听,请说话...":A.value?"正在流式转写...":"正在识别语音中..."),k=(p,f)=>{const R=(p||"").trim(),B=(f||"").trim();return B?R?/[A-Za-z0-9]$/.test(R)&&/[A-Za-z0-9]/.test(B.charAt(0))?`${R} ${B}`:`${R}${B}`:B:R},_=p=>{const f=Math.floor(p/60),R=p%60;return`${f.toString().padStart(2,"0")}:${R.toString().padStart(2,"0")}`},N=()=>(n||(n=new Ve({soundBaseUrl:a.soundBaseUrl||"/sounds/",workerUrl:a.workerUrl||void 0,onStatusChange:(p,f)=>{i.value=p,f&&(l.value=f)},onProgress:p=>{typeof p.progress=="number"&&(c.value=p.progress)},onVolumeChange:p=>{m.value=p},onAudioRecorded:p=>{V.value&&URL.revokeObjectURL(V.value),V.value=p,F.value=S.value},onPartial:p=>{A.value=p||"",M.value=k(w.value,p)},onResult:p=>{A.value=p||"",M.value=k(w.value,p),p?r.success("语音识别完成"):r.warning("未能识别出有效语音,请重试"),setTimeout(()=>{A.value="",z.value&&z.value.focus()},100)},onError:p=>{r.error(p||"语音输入服务出错"),h()}})),n),v=()=>{h(),S.value=0,P=setInterval(()=>{S.value+=1},1e3)},h=()=>{P&&(clearInterval(P),P=null)},L=async()=>{if(d.value){await I();return}E.value&&x&&(x.pause(),E.value=!1);const p=N();try{w.value=M.value,A.value="",v(),await p.startRecording()}catch(f){h(),console.error("启动录音失败:",f)}},I=async()=>{h(),n&&await n.stopAndTranscribe()},O=e.ref(null),G=()=>{O.value&&(O.value.value="",O.value.click())},oe=async p=>{var D;const f=p.target,R=(D=f==null?void 0:f.files)==null?void 0:D[0];if(!R)return;E.value&&x&&(x.pause(),E.value=!1);const B=N();try{w.value=M.value,A.value="",r.info(`正在流式识别文件: ${R.name}`),await B.transcribeFile(R)}catch(U){r.error(`文件识别失败: ${U.message||U}`)}},ae=()=>{h(),A.value="",M.value=w.value,n&&n.cancelRecording()},se=()=>{A.value="",M.value=w.value,n&&n.cancelTranscribe(),r.info("已取消本次语音识别")},fe=()=>{if(V.value){if(E.value&&x){x.pause(),E.value=!1;return}x&&(x.pause(),x=null),x=new Audio(V.value),x.onloadedmetadata=()=>{x&&!isNaN(x.duration)&&(F.value=Math.round(x.duration))},x.onended=()=>{E.value=!1},x.onerror=()=>{E.value=!1,r.error("音频试听播放失败")},x.play().then(()=>{E.value=!0}).catch(p=>{console.error("音频播放出错:",p),E.value=!1})}},Ie=()=>{x&&(x.pause(),x=null),E.value=!1,V.value&&(URL.revokeObjectURL(V.value),V.value="")};e.onBeforeUnmount(()=>{h(),Ie(),n&&(n.destroy(),n=null)});const wn=e.computed(()=>Ce.find(p=>p.modelName===a.llmName)??Ce.find(p=>p.modelName==="szjy")),Oe=t,M=e.ref(""),z=e.ref(null),pe=e.ref(!1),$=e.ref([]),kn=e.ref(["什么是AI助理,能做什么?","当前项目的基本情况?","当前项目的进度情况?","当前项目的参建方有哪些?","数智建管平台有哪些功能?能做什么?"]),J=e.ref([]),X=e.ref(!1),ge=e.ref(null),ye=()=>{e.nextTick(()=>{if(ge.value){const p=ge.value,f=p.scrollHeight,R=p.scrollTop,B=p.clientHeight;f-R-B<100?p.scrollTop=f:p.scrollTo({top:f})}})},H=e.ref(!1),Sn=e.computed(()=>H.value?"/images/ai-stop.png":"/images/ai-send.png"),De=(p,f)=>{console.log("onFailedReader",p,f),X.value=!1;const R=ze();R&&R.initializeEnd(),r.error("转换失败,请重试"),H.value=!1,setTimeout(()=>{z.value&&z.value.focus()})},Cn=(p,f)=>{X.value=!1,H.value=!1,ye(),f&&$.value[p]&&($.value[p].displayText=f),setTimeout(()=>{z.value&&z.value.focus()})},bn=p=>{H.value=!0},En=()=>{H.value=!1,Oe("update:modelValue",!1),pe.value=!1,$.value=[]},we=e.ref(!1),vn=()=>{we.value=!we.value},Nn=p=>{M.value=p,ke()},ze=()=>{for(let p=J.value.length-1;p>=0;p--)if(J.value[p])return J.value[p];return null},ke=async()=>{if(console.log("stylizingLoading:",X.value),X.value){const D=ze();console.log("lastPreviewer:",D),D&&(console.log("abortReader"),D.abortReader());return}if(!M.value.trim()){console.log("no input, return"),z.value.focus();return}$.value.push({type:"user",content:M.value}),H.value=!0,pe.value=!0,Oe("submit",M.value),ye();const p=M.value;M.value="";const f=$.value.length;J.value[f]&&J.value[f].initializeStart(),X.value=!0,$.value.push({type:"ai"});const{error:R,reader:B}=await Ye(wn.value,{text:p,token:a.token,identifier:a.identifier,baseUrl:a.baseUrl,extraConfig:a.extraConfig});if(R){console.log(45455,R),De(f,R);return}B&&($.value[f].reader=B)};return(p,f)=>{const R=e.resolveComponent("el-icon"),B=e.resolveComponent("el-button"),D=e.resolveComponent("el-input");return e.openBlock(),e.createBlock(e.Transition,{name:"slide"},{default:e.withCtx(()=>[o.modelValue?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["ai-panel",{"drawer-mode":we.value}])},[e.createElementVNode("div",wt,[e.createElementVNode("div",kt,[e.createElementVNode("div",St,e.toDisplayString(o.title),1),e.createElementVNode("div",Ct,[e.createVNode(R,{class:"action-icon",onClick:vn},{default:e.withCtx(()=>[e.createVNode(Y,{name:"/images/svg/drawer-layout.svg",color:"#999999"})]),_:1}),e.createVNode(R,{class:"action-icon",onClick:En},{default:e.withCtx(()=>[e.createVNode(Y,{name:"/images/svg/close.svg",color:"#999999"})]),_:1})])])]),e.createElementVNode("div",bt,[pe.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"chat-messages",ref_key:"messageContainerRef",ref:ge},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList($.value,(U,Z)=>(e.openBlock(),e.createElementBlock("div",{key:Z,class:e.normalizeClass(["message-item",U.type==="user"?"user-message":"ai-message"])},[U.type==="ai"?(e.openBlock(),e.createBlock(ot,{key:0,ref_for:!0,ref:j=>J.value[Z]=j,reader:U.reader,"onUpdate:reader":j=>U.reader=j,model:a.llmName,displayText:U.displayText,scrollToBottomFn:ye,messagePostRender:o.messagePostRender,onFailed:j=>De(Z,j),onCompleted:j=>Cn(Z,j),onUpdating:()=>bn()},null,8,["reader","onUpdate:reader","model","displayText","messagePostRender","onFailed","onCompleted","onUpdating"])):(e.openBlock(),e.createElementBlock("div",Rt,e.toDisplayString(U.content),1))],2))),128))],512)):(e.openBlock(),e.createElementBlock("div",Et,[f[2]||(f[2]=e.createElementVNode("div",{class:"title"},[e.createElementVNode("img",{src:$e,alt:"AI助手",class:"panel-icon"}),e.createElementVNode("h3",{class:"title-text"},"Hi, 您好")],-1)),e.createElementVNode("div",vt,[f[1]||(f[1]=e.createTextVNode(" 我是",-1)),e.createElementVNode("span",Nt,e.toDisplayString(o.title),1)]),e.createElementVNode("div",xt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(kn.value,(U,Z)=>(e.openBlock(),e.createElementBlock("div",{key:Z,class:"question-item",onClick:j=>Nn(U)},[e.createElementVNode("span",null,e.toDisplayString(U),1),e.createVNode(R,null,{default:e.withCtx(()=>[e.createVNode(Y,{name:"/images/svg/arrow-right.svg",color:"#999999"})]),_:1})],8,Tt))),128))])]))]),e.createElementVNode("div",_t,[H.value?(e.openBlock(),e.createElementBlock("img",Vt)):e.createCommentVNode("",!0),e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[g.value||y.value?(e.openBlock(),e.createElementBlock("div",Pt,[e.createElementVNode("div",At,[f[3]||(f[3]=e.createElementVNode("span",{class:"progress-icon"},"⏳",-1)),e.createElementVNode("span",Bt,e.toDisplayString(l.value),1),c.value>0?(e.openBlock(),e.createElementBlock("span",Lt,e.toDisplayString(c.value)+"%",1)):e.createCommentVNode("",!0)]),c.value>0?(e.openBlock(),e.createElementBlock("div",Mt,[e.createElementVNode("div",{class:"progress-bar",style:e.normalizeStyle({width:c.value+"%"})},null,4)])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[d.value||u.value?(e.openBlock(),e.createElementBlock("div",Ut,[e.createElementVNode("div",Ft,[e.createElementVNode("div",It,[e.createElementVNode("span",{class:e.normalizeClass(["recording-pulse",{transcribing:u.value}])},null,2),d.value?(e.openBlock(),e.createElementBlock("span",Ot,e.toDisplayString(_(S.value)),1)):e.createCommentVNode("",!0),e.createElementVNode("span",Dt,e.toDisplayString(C.value),1),d.value?(e.openBlock(),e.createElementBlock("div",zt,[e.createElementVNode("span",{class:"wave",style:e.normalizeStyle({height:Math.max(4,Math.min(22,m.value*.3))+"px"})},null,4),e.createElementVNode("span",{class:"wave",style:e.normalizeStyle({height:Math.max(4,Math.min(30,m.value*.5))+"px"})},null,4),e.createElementVNode("span",{class:"wave",style:e.normalizeStyle({height:Math.max(4,Math.min(18,m.value*.25))+"px"})},null,4)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",$t,[d.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(B,{size:"small",circle:"",onClick:ae,title:"取消录音",class:"voice-cancel-btn"},{default:e.withCtx(()=>[...f[4]||(f[4]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"12",height:"12"},[e.createElementVNode("path",{d:"M512 456.310154L94.247385 38.557538a39.384615 39.384615 0 0 0-55.689847 55.689847L456.310154 512 38.557538 929.752615a39.384615 39.384615 0 0 0 55.689847 55.689847L512 567.689846l417.752615 417.752616c15.163077 15.163077 40.526769 15.163077 55.689847 0s15.163077-40.526769 0-55.689847L567.689846 512l417.752616-417.752615a39.384615 39.384615 0 0 0-55.689847-55.689847L512 456.310154z",fill:"currentColor"})],-1)])]),_:1}),e.createVNode(B,{type:"primary",size:"small",round:"",onClick:I,class:"voice-finish-btn"},{default:e.withCtx(()=>[...f[5]||(f[5]=[e.createTextVNode(" 完成 ",-1)])]),_:1})],64)):u.value?(e.openBlock(),e.createBlock(B,{key:1,size:"small",round:"",onClick:se,class:"voice-cancel-transcribe-btn"},{default:e.withCtx(()=>[...f[6]||(f[6]=[e.createTextVNode(" 取消识别 ",-1)])]),_:1})):e.createCommentVNode("",!0)])]),e.createElementVNode("div",{class:e.normalizeClass(["live-transcript",{empty:!A.value}]),title:A.value},[A.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(A.value),1),f[7]||(f[7]=e.createElementVNode("span",{class:"caret"},"|",-1))],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(d.value?"正在聆听,识别文字会实时显示在这里...":"正在识别,文字将实时显示..."),1)],64))],10,jt)])):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[V.value&&!d.value&&!u.value?(e.openBlock(),e.createElementBlock("div",Ht,[e.createElementVNode("div",{class:"playback-main",onClick:fe,title:E.value?"点击暂停":"点击播放录音"},[e.createElementVNode("div",Wt,[E.value?(e.openBlock(),e.createElementBlock("svg",Jt,[...f[9]||(f[9]=[e.createElementVNode("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",Kt,[...f[8]||(f[8]=[e.createElementVNode("path",{d:"M8 5v14l11-7z"},null,-1)])]))]),e.createElementVNode("span",Zt,e.toDisplayString(E.value?"正在播放录音...":"点击试听本次录音"),1),F.value>0?(e.openBlock(),e.createElementBlock("span",Qt,e.toDisplayString(_(F.value)),1)):e.createCommentVNode("",!0),E.value?(e.openBlock(),e.createElementBlock("div",Gt,[...f[10]||(f[10]=[e.createElementVNode("span",{class:"wave-bar"},null,-1),e.createElementVNode("span",{class:"wave-bar"},null,-1),e.createElementVNode("span",{class:"wave-bar"},null,-1),e.createElementVNode("span",{class:"wave-bar"},null,-1)])])):e.createCommentVNode("",!0)],8,qt),e.createElementVNode("div",{class:"playback-close",onClick:Ie,title:"清除试听"},[...f[11]||(f[11]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"12",height:"12"},[e.createElementVNode("path",{d:"M512 456.310154L94.247385 38.557538a39.384615 39.384615 0 0 0-55.689847 55.689847L456.310154 512 38.557538 929.752615a39.384615 39.384615 0 0 0 55.689847 55.689847L512 567.689846l417.752615 417.752616c15.163077 15.163077 40.526769 15.163077 55.689847 0s15.163077-40.526769 0-55.689847L567.689846 512l417.752616-417.752615a39.384615 39.384615 0 0 0-55.689847-55.689847L512 456.310154z",fill:"currentColor"})],-1)])])])):e.createCommentVNode("",!0)]),_:1}),e.withDirectives(e.createElementVNode("div",Xt,[e.createVNode(D,{modelValue:M.value,"onUpdate:modelValue":f[0]||(f[0]=U=>M.value=U),ref_key:"refInputTextString",ref:z,placeholder:"请输入您的问题或点击麦克风语音输入",autofocus:"",onKeyup:e.withKeys(ke,["enter"])},{append:e.withCtx(()=>[e.createElementVNode("div",Yt,[e.createElementVNode("div",{class:"voice-upload-btn",onClick:G,title:"上传音频/视频文件识别 (支持 .wav, .mp4, .mp3, .m4a)"},[...f[12]||(f[12]=[e.createElementVNode("svg",{viewBox:"0 0 24 24",width:"17",height:"17",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.createElementVNode("polyline",{points:"17 8 12 3 7 8"}),e.createElementVNode("line",{x1:"12",y1:"3",x2:"12",y2:"15"})],-1)])]),e.createElementVNode("input",{type:"file",ref_key:"refAudioFileInput",ref:O,accept:"audio/*,video/mp4,.wav,.mp4,.mp3,.m4a",style:{display:"none"},onChange:oe},null,544),e.createElementVNode("div",{class:e.normalizeClass(["voice-mic-btn",{"loading-anim":g.value||y.value}]),onClick:L,title:"语音输入"},[...f[13]||(f[13]=[e.createElementVNode("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",fill:"currentColor",opacity:"0.2"}),e.createElementVNode("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"}),e.createElementVNode("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),e.createElementVNode("line",{x1:"12",y1:"19",x2:"12",y2:"22"})],-1)])],2),e.createElementVNode("div",{class:"send-icon-box",onClick:ke},[e.createElementVNode("img",{src:Sn.value,alt:"发送",class:"send-icon"},null,8,en)])])]),_:1},8,["modelValue"])],512),[[e.vShow,!d.value&&!u.value]])])],2)):e.createCommentVNode("",!0)]),_:1})}}};var Pe={exports:{}};(function(o,t){(function(s,r){o.exports=r()})(window,function(){return function(s){var r={};function a(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return s[n].call(i.exports,i,i.exports,a),i.l=!0,i.exports}return a.m=s,a.c=r,a.d=function(n,i,l){a.o(n,i)||Object.defineProperty(n,i,{enumerable:!0,get:l})},a.r=function(n){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},a.t=function(n,i){if(1&i&&(n=a(n)),8&i||4&i&&typeof n=="object"&&n&&n.__esModule)return n;var l=Object.create(null);if(a.r(l),Object.defineProperty(l,"default",{enumerable:!0,value:n}),2&i&&typeof n!="string")for(var c in n)a.d(l,c,(function(m){return n[m]}).bind(null,c));return l},a.n=function(n){var i=n&&n.__esModule?function(){return n.default}:function(){return n};return a.d(i,"a",i),i},a.o=function(n,i){return Object.prototype.hasOwnProperty.call(n,i)},a.p="",a(a.s=0)}([function(s,r,a){function n(w,g,y,d){y.push(w),d.push([].concat(g[w]||[]))}function i(w,g){if(!w)throw new Error("[getMaxDepsChain] dep 参数不能为空");var y=[],d=[],u=[];for(n(w,g,d,u);d.length;){var C=u.pop();if(C&&C.length){var k=C.shift();if(u.push(C),~d.indexOf(k))throw new Error("[getMaxDepsChain][loop] 存在循环依赖,请检查依赖关系; nextName: "+k+", mainStack: "+d);n(k,g,d,u)}else y.push([].concat(d)),d.pop()}return y.reduce(function(_,N){return N.length>_.length?N:_},[])}function l(w){if(!w)throw new Error("[depsParser] 入参不能为空");var g={};w.forEach(function(d){g[d.name]=d.deps||[]});var y=[];return w.forEach(function(d){var u=i(d.name,g).length-1;d.priority=u,y[u]=(y[u]||[]).concat(d)}),y}a.r(r),a.d(r,"loadScript",function(){return V}),a.d(r,"loadScripts",function(){return E}),a.d(r,"dynamicLoadScripts",function(){return F}),a.d(r,"createScriptsLoadIterator",function(){return x}),a.d(r,"loadScriptsQueue",function(){return A}),a.d(r,"getMaxDepsChain",function(){return i}),a.d(r,"depsParser",function(){return l});var c=function(){return(c=Object.assign||function(w){for(var g,y=1,d=arguments.length;y<d;y++)for(var u in g=arguments[y])Object.prototype.hasOwnProperty.call(g,u)&&(w[u]=g[u]);return w}).apply(this,arguments)},m=function(w,g,y,d){return new(y||(y=Promise))(function(u,C){function k(v){try{N(d.next(v))}catch(h){C(h)}}function _(v){try{N(d.throw(v))}catch(h){C(h)}}function N(v){var h;v.done?u(v.value):(h=v.value,h instanceof y?h:new y(function(L){L(h)})).then(k,_)}N((d=d.apply(w,[])).next())})},S=function(w,g){var y,d,u,C,k={label:0,sent:function(){if(1&u[0])throw u[1];return u[1]},trys:[],ops:[]};return C={next:_(0),throw:_(1),return:_(2)},typeof Symbol=="function"&&(C[Symbol.iterator]=function(){return this}),C;function _(N){return function(v){return function(h){if(y)throw new TypeError("Generator is already executing.");for(;k;)try{if(y=1,d&&(u=2&h[0]?d.return:h[0]?d.throw||((u=d.return)&&u.call(d),0):d.next)&&!(u=u.call(d,h[1])).done)return u;switch(d=0,u&&(h=[2&h[0],u.value]),h[0]){case 0:case 1:u=h;break;case 4:return k.label++,{value:h[1],done:!1};case 5:k.label++,d=h[1],h=[0];continue;case 7:h=k.ops.pop(),k.trys.pop();continue;default:if(u=k.trys,!((u=u.length>0&&u[u.length-1])||h[0]!==6&&h[0]!==2)){k=0;continue}if(h[0]===3&&(!u||h[1]>u[0]&&h[1]<u[3])){k.label=h[1];break}if(h[0]===6&&k.label<u[1]){k.label=u[1],u=h;break}if(u&&k.label<u[2]){k.label=u[2],k.ops.push(h);break}u[2]&&k.ops.pop(),k.trys.pop();continue}h=g.call(w,k)}catch(L){h=[6,L],d=0}finally{y=u=0}if(5&h[0])throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}([N,v])}}},P=function(w){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var g,y=w[Symbol.asyncIterator];return y?y.call(w):(w=typeof __values=="function"?__values(w):w[Symbol.iterator](),g={},d("next"),d("throw"),d("return"),g[Symbol.asyncIterator]=function(){return this},g);function d(u){g[u]=w[u]&&function(C){return new Promise(function(k,_){(function(N,v,h,L){Promise.resolve(L).then(function(I){N({value:I,done:h})},v)})(k,_,(C=w[u](C)).done,C.value)})}}};function V(w,g){return g===void 0&&(g=!1),new Promise(function(y,d){var u=g?document.head:document.body,C=document.createElement("script");C.type="text/javascript",C.src=w,C.crossOrigin="anonymous",C.onreadystatechange=y,C.onload=y,C.onerror=d,u.appendChild(C)})}var E=function(w,g){return g===void 0&&(g={}),m(void 0,void 0,void 0,function(){var y,d,u,C,k;return S(this,function(_){switch(_.label){case 0:return y=g.baseUrl,d=y===void 0?"":y,u=g.lastLoadResult,C=g.inHead,k=C!==void 0&&C,[4,Promise.all(w.map(function(N){return m(void 0,void 0,void 0,function(){var v,h,L,I,O,G,oe,ae;return S(this,function(se){switch(se.label){case 0:return v=N.name,h=N.path,L=N.deps,(oe={})[v]=!0,I=oe,(ae={})[v]=!1,O=ae,window[v]?[2,I]:[3,1];case 1:return G=!0,L&&u&&[].concat(L).forEach(function(fe){u[fe]!==!1&&(G=!0)}),G?[4,V(h.indexOf("http")===0||h.indexOf("//:")===0?h:d+h,k).then(function(){return I}).catch(function(){return O})]:[3,3];case 2:return[2,se.sent()];case 3:return[2,O]}})})}))];case 1:return[2,_.sent()]}})})},F=function(w,g){return g===void 0&&(g={}),function(){var y=[].concat(l(w));return{next:function(){if(y.length){var d=y.shift();return E(d,g).then(function(u){return{value:u,done:!1}})}return Promise.resolve({done:!0})}}}},x=function(w,g){var y;return g===void 0&&(g={}),(y={})[Symbol.asyncIterator]=F(w,g),y},A=function(w,g){return g===void 0&&(g={}),m(void 0,void 0,void 0,function(){var y,d,u,C,k,_;return S(this,function(N){switch(N.label){case 0:N.trys.push([0,5,6,11]),y=P(x(w,g)),N.label=1;case 1:return[4,y.next()];case 2:if((d=N.sent()).done)return[3,4];u=d.value,g.lastLoadResult=g.lastLoadResult||{},console.log("current load: ",u),u.forEach(function(v){g.lastLoadResult=c(c({},g.lastLoadResult),v)}),N.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return C=N.sent(),k={error:C},[3,11];case 6:return N.trys.push([6,,9,10]),d&&!d.done&&(_=y.return)?[4,_.call(y)]:[3,8];case 7:N.sent(),N.label=8;case 8:return[3,10];case 9:if(k)throw k.error;return[7];case 10:return[7];case 11:return[2,g.lastLoadResult]}})})}}])})})(Pe);var nn=Pe.exports;const rn={key:0,class:"ai-assistant"},on={name:"AiChat"},an=e.defineComponent({...on,props:{token:{type:String,default:""},identifier:{type:String,default:""},baseUrl:{type:String,default:""},title:{type:String,default:"数智AI助理"},llmName:{type:String,default:"szjy"},messagePostRender:{type:Function,default:null},extraConfig:{type:Object,default:()=>({})},soundBaseUrl:{type:String,default:"/sounds/"},workerUrl:{type:String,default:""}},setup(o){const t=e.ref(!1),s=e.ref(!1),r=()=>{t.value=!t.value},a=()=>{s.value=!0,t.value=!1},n=c=>{console.log("用户输入:",c)},i=[{name:"markdownit",path:"markdown-it.min.js"},{name:"hljs",path:"highlight.11.11.1.min.js"}];let l={};return nn.loadScriptsQueue(i,{baseUrl:"/scripts/ai/",lastLoadResult:l,inHead:!1}).then(c=>{if(console.log("load ai deps: ",c),window.markdownit){const m=window.markdownit();console.log("markdownit: ",m),et()}}),(c,m)=>s.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",rn,[e.createVNode(tn,{modelValue:t.value,"onUpdate:modelValue":m[0]||(m[0]=S=>t.value=S),onSubmit:n,token:o.token,identifier:o.identifier,baseUrl:o.baseUrl,title:o.title,llmName:o.llmName,messagePostRender:o.messagePostRender,extraConfig:o.extraConfig,soundBaseUrl:o.soundBaseUrl,workerUrl:o.workerUrl},null,8,["modelValue","token","identifier","baseUrl","title","llmName","messagePostRender","extraConfig","soundBaseUrl","workerUrl"]),e.createElementVNode("div",{class:"ai-icon",onClick:r},[e.createElementVNode("div",{class:"close-icon",onClick:e.withModifiers(a,["stop"])},[...m[1]||(m[1]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"8",height:"8"},[e.createElementVNode("path",{d:"M512 456.310154L94.247385 38.557538a39.384615 39.384615 0 0 0-55.689847 55.689847L456.310154 512 38.557538 929.752615a39.384615 39.384615 0 0 0 55.689847 55.689847L512 567.689846l417.752615 417.752616c15.163077 15.163077 40.526769 15.163077 55.689847 0s15.163077-40.526769 0-55.689847L567.689846 512l417.752616-417.752615a39.384615 39.384615 0 0 0-55.689847-55.689847L512 456.310154z",fill:"currentColor"})],-1)])]),m[2]||(m[2]=e.createElementVNode("img",{src:q,alt:"AI助手"},null,-1)),m[3]||(m[3]=e.createElementVNode("span",{class:"ai-icon-text"},"AI助手",-1))])]))}}),Ae=ve(an,[["__scopeId","data-v-0c5630f1"]]),Be=Object.freeze(Object.defineProperty({__proto__:null,SzAiChat:Ae},Symbol.toStringTag,{value:"Module"})),me=function(o){if(!me.installed){me.installed=!0;for(let t in Be){const s=Reflect.get(Be,t);o.component(s.name,s)}}},sn=(o,t)=>{const s=t?`?${new URLSearchParams(t).toString()}`:"";console.log(`点击了路由链接: ${o}${s}`)},Le=o=>{const t=o.indexOf("?");if(t===-1)return{routeName:o};const s=o.substring(0,t),r=o.substring(t+1),a={};return new URLSearchParams(r).forEach((i,l)=>{a[l]=i}),{routeName:s,queryParams:Object.keys(a).length>0?a:void 0}},ln={color:"#536fec",fontWeight:"bold",textDecoration:"underline",cursor:"pointer",padding:"0 3px"},Me=o=>{const t=/#router:([^#]+)#/g,s=[];let r=0,a;for(;(a=t.exec(o))!==null;){a.index>r&&s.push({text:o.substring(r,a.index)});const n=a[1],{routeName:i,queryParams:l}=Le(n);s.push({text:i,routeName:i,queryParams:l}),r=t.lastIndex}return r<o.length&&s.push({text:o.substring(r)}),s},Ue=(o,t,s={},r)=>{const{onRouteClick:a=sn,linkStyle:n={}}=s,i=document.createElement("a");i.href="#",i.textContent=o;const l={...ln,...n};return Object.assign(i.style,l),i.addEventListener("click",c=>{c.preventDefault(),a(t,r)}),i},Fe=o=>{const t=/#router:([^#]+)#/g,s=[],r=document.createTreeWalker(o,NodeFilter.SHOW_TEXT,null);let a=r.nextNode();for(;a;){const n=a,i=n.textContent||"";if(t.test(i)){t.lastIndex=0;const l=Me(i);l.length>0&&s.push({node:n,replacements:l})}a=r.nextNode()}return s},cn=(o,t,s={})=>{const r=Fe(o);r.forEach(({node:a,replacements:n})=>{var l;const i=document.createDocumentFragment();n.forEach(({text:c,routeName:m,queryParams:S})=>{if(m){const P=Ue(c,m,s,S);i.appendChild(P)}else i.appendChild(document.createTextNode(c))}),(l=a.parentNode)==null||l.replaceChild(i,a)}),s!=null&&s.nodeCallback&&r.forEach(({node:a,replacements:n})=>{var i;(i=s.nodeCallback)==null||i.call(s,a,n)})},Q="szjy-voice-models",ne="szjy-voice-cache-v1";function K(){return typeof navigator<"u"&&!!navigator.storage&&typeof navigator.storage.getDirectory=="function"}async function re(o=Q){if(!K())return null;try{return await(await navigator.storage.getDirectory()).getDirectoryHandle(o,{create:!0})}catch(t){return console.warn("[OPFS] 获取目录失败,将使用降级缓存:",t),null}}async function dn(o,t,s=Q){if(K())try{const r=await re(s);if(r){const n=await(await r.getFileHandle(o,{create:!0})).createWritable();return await n.write(t),await n.close(),!0}}catch(r){console.warn(`[OPFS] 写入文件 ${o} 失败:`,r)}if(typeof caches<"u")try{const r=await caches.open(ne),a=new Response(t,{headers:{"Content-Type":"application/octet-stream"}});return await r.put(`/${s}/${o}`,a),!0}catch(r){console.warn(`[CacheStorage] 缓存写入 ${o} 失败:`,r)}return!1}async function un(o,t=Q){if(K())try{const s=await re(t);if(s)return await(await(await s.getFileHandle(o,{create:!1})).getFile()).arrayBuffer()}catch{}if(typeof caches<"u")try{const r=await(await caches.open(ne)).match(`/${t}/${o}`);if(r)return await r.arrayBuffer()}catch{}return null}async function hn(o,t=Q){if(K())try{const s=await re(t);if(s)return(await(await s.getFileHandle(o,{create:!1})).getFile()).size>0}catch{}if(typeof caches<"u")try{return!!await(await caches.open(ne)).match(`/${t}/${o}`)}catch{}return!1}async function mn(o=Q){let t=!1;if(K())try{await(await navigator.storage.getDirectory()).removeEntry(o,{recursive:!0}),t=!0,console.log(`[OPFS] 成功清空语音模型缓存目录: ${o}`)}catch(s){s.name==="NotFoundError"?t=!0:console.warn(`[OPFS] 清理目录 ${o} 异常:`,s)}if(typeof caches<"u")try{const s=await caches.keys();for(const r of s)(r.includes("transformers")||r.includes("szjy-voice")||r===ne)&&(await caches.delete(r),t=!0)}catch(s){console.warn("[CacheStorage] 清除缓存异常:",s)}return t}const fn="0.1.10",pn="Sz";function gn({componentPrefix:o=pn,components:t=[]}={}){const s=[];function r(n,i,l){n.component(o+i)||n.component(o+i,l)}function a(n){s.includes(n)||(s.push(n),t.forEach(i=>{const{name:l,alias:c}=i;r(n,l,i),c&&c.forEach(m=>{r(n,m,i)})}))}return{version:fn,componentPrefix:o,install:a}}const yn={install(o){me(o)}};b.AudioRecorder=Ne,b.DEFAULT_WHISPER_WORKER_URL=ue,b.SzAiChat=Ae,b.VoiceInputManager=Ve,b.clearVoiceModelCache=mn,b.create=gn,b.createRouteLink=Ue,b.decodeAudioFile=xe,b.default=yn,b.findRouteTextNodes=Fe,b.float32ToWav=ee,b.getFileFromCache=un,b.getOPFSDirectory=re,b.hasFileInCache=hn,b.isOPFSSupported=K,b.parseRouteMarkerContent=Le,b.parseRouteMarkers=Me,b.resampleAudioData=ie,b.routeLinkRender=cn,b.saveFileToCache=dn,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(y,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(y=typeof globalThis<"u"?globalThis:y||self,e(y["szjy-ai-coms"]={},y.Vue))})(this,function(y,e){"use strict";var ho=Object.defineProperty;var po=(y,e,Z)=>e in y?ho(y,e,{enumerable:!0,configurable:!0,writable:!0,value:Z}):y[e]=Z;var V=(y,e,Z)=>po(y,typeof e!="symbol"?e+"":e,Z);const Z="/images/ai-round.png",mt="/images/ai-sqrt.png",ht="/images/bars-loading.svg";function Ve(t){return t.startsWith("http://")||t.startsWith("https://")?t:`${location.protocol}//${location.host}${t}`}async function pt(t,n,a,r="",s={}){const{projectId:o}=s,i=Ve(r),l=new URL(`${i}/v1/chat/completions`),c=(s==null?void 0:s.authToken)||"app-oLZVFFdYyJX2QK3rdOLWsC2u";s!=null&&s.authToken||console.error("缺少 authToken!现在默认使用内网的 authToken");const u=new Request(l,{method:"post",headers:{"Content-Type":"application/json",Authorization:`Bearer ${c}`},body:JSON.stringify({model:"dify",stream:!0,inputs:{token:n,projectCode:a,...o?{projectId:o}:{}},messages:[{role:"system",content:"你是一个专业的AI助手,请用中文回答问题。"},{role:"user",content:t}]})});return fetch(u)}async function gt(t,n,a,r="",s={}){const o=new URL("http://localhost:11434/api/chat"),i={};Object.keys(i).forEach(c=>{o.searchParams.append(c,i[c])});const l=new Request(o,{mode:"cors",method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:"llama3",stream:!0,messages:[{role:"system",content:"全程使用中文回答问题。"},{role:"user",content:t}]})});return fetch(l)}async function yt(t,n,a,r="",s={}){const o=new URL(`${location.origin}/spark/v1/chat/completions`),i={};Object.keys(i).forEach(c=>{o.searchParams.append(c,i[c])});const l=new Request(o,{method:"post",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({model:"generalv4.0Ultra",stream:!0,messages:[{role:"user",content:t}]})});return fetch(l)}async function kt(t,n,a,r="",s={}){const o=new URL(`${location.origin}/siliconflow/v1/chat/completions`),i={};Object.keys(i).forEach(c=>{o.searchParams.append(c,i[c])});const l=new Request(o,{method:"post",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({model:"Qwen/Qwen1.5-110B-Chat",stream:!0,messages:[{role:"user",content:t}]})});return fetch(l)}async function wt(t,n,a,r="",s={}){const o=new URL(`${location.origin}/moonshot/v1/chat/completions`),i={};Object.keys(i).forEach(c=>{o.searchParams.append(c,i[c])});const l=new Request(o,{method:"post",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({model:"moonshot-v1-8k",stream:!0,messages:[{role:"system",content:"你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。"},{role:"user",content:t}]})});return fetch(l)}async function bt(t,n,a,r="",s={}){const o=new URL(`${location.origin}/dashscope/compatible-mode/v1/chat/completions`),i={};Object.keys(i).forEach(c=>{o.searchParams.append(c,i[c])});const l=new Request(o,{method:"post",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({model:"qwq-32b-preview",stream:!0,messages:[{role:"system",content:"全程使用中文回答问题"},{role:"user",content:t}]})});return fetch(l)}async function St(t,n,a,r="",s={}){const o=Ve(r),i=new URL(`${o}/support/${a}/a`),l={};Object.keys(l).forEach(u=>{i.searchParams.append(u,l[u])});const c=new Request(i,{method:"post",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({content:t})});return fetch(c)}const xe=["根据您的问题,我为您整理了以下构件:","","```szjy-ui",JSON.stringify({title:"构件列表",type:"list",gap:12,items:[{type:"button",props:{type:"primary",content:"查看构件1(CHKS-TJ01-02-01-01-01-01)"},action:"postMessage",actionParams:{type:"BIM_SANDBOX",action:"locateComponent",payload:{wbsCode:"CHKS-TJ01-02-01-01-01-01"}}},{type:"button",props:{type:"primary",content:"查看构件2(CHKS-TJ01-02-01-01-04-02)"},action:"postMessage",actionParams:{type:"BIM_SANDBOX",action:"locateComponent",payload:{wbsCode:"CHKS-TJ01-02-01-01-04-02"}}},{type:"button",props:{type:"default",content:"查看构件3(不存在的编码,演示失败反馈)"},action:"postMessage",actionParams:{type:"BIM_SANDBOX",action:"locateComponent",payload:{wbsCode:"CHKS-NOT-EXIST"}}}]},null,2),"```","","点击上方按钮即可在 BIM 沙盘中定位对应构件。"].join(`
|
|
2
|
+
`),Ct=8,Et=80,vt=t=>new Promise(n=>setTimeout(n,t));function Nt(t,n){const a=Math.ceil(t.length/n),r=[];for(let s=0;s<t.length;s+=a)r.push(t.slice(s,s+a));return r.length?r:[""]}async function Ue(t,n,a,r="",s={}){const i=(s&&typeof s.mockResponse=="string"?s.mockResponse.trim():"")||xe,l=new TextEncoder,c=new ReadableStream({async start(u){for(const S of Nt(i,Ct))u.enqueue(l.encode(S)),await vt(Et);u.close()}});return new Response(c,{status:200,headers:{"Content-Type":"text/plain; charset=utf-8"}})}const At=t=>{if(t.startsWith("data:")){const n=t.substring(5).trim();if(n==="[DONE]")return{done:!0};try{return JSON.parse(n)}catch(a){console.error("JSON parsing error:",a)}}return null},he="<think>",ce="</think>",pe=(t,n)=>{const a=Math.max(0,t.length-(n.length-1));for(let r=a;r<t.length;r++)if(n.startsWith(t.slice(r)))return t.length-r;return 0},Tt=t=>{let n="",a="",r=t||"",s=!1;for(;r;){const o=r.indexOf(he),i=r.indexOf(ce);if(o>=0&&(i<0||o<i))a+=r.slice(0,o),r=r.slice(o+he.length),s=!0;else if(i>=0&&(o<0||i<o))n+=r.slice(0,i),r=r.slice(i+ce.length),s=!1;else if(s){const l=pe(r,ce);n+=r.slice(0,r.length-l),r=""}else{const l=Math.max(pe(r,he),pe(r,ce));a+=r.slice(0,r.length-l),r=""}}return{thinking:n.trim(),content:a.trim(),isThinkingStreaming:s}},Be=[{label:"模拟数据模型",modelName:"standard",api:Ue},{label:"Spark 星火大模型",modelName:"spark",api:yt},{label:"Ollama 3 大模型",modelName:"ollama3",api:gt},{label:"SiliconFlow 硅基流动大模型",modelName:"siliconflow",api:kt},{label:"Kimi Moonshot 月之暗面大模型",modelName:"moonshot",api:wt},{label:"通义千问大模型",modelName:"dashscope",api:bt},{label:"数智建管大模型",modelName:"szjy",api:St},{label:"Dify (OpenAI 兼容)",modelName:"dify-openai",api:pt}],_e={standard(t,n){let a="";return t instanceof Uint8Array?a=n.decode(t,{stream:!0}):a=t,{content:a}},spark(t){const n=At(t);if(n.done)return{done:!0};const a=n.choices[0].delta,r=a.reasoning_content||a.reasoning;let s=a.content||"";return r&&(s=`<think>${r}</think>${s}`),{content:s}},siliconflow(t){return this.spark(t)},moonshot(t){return this.spark(t)},dashscope(t){return this.spark(t)},szjy(t){return this.spark(t)},"dify-openai"(t){return this.spark(t)},ollama3(t){return{content:JSON.parse(t).message.content}}},ze=(t,n,a)=>{const r=t.split(a);return r.slice(0,-1).forEach(s=>{s.trim()!==""&&n.enqueue(s)}),r[r.length-1]},Rt=t=>{let n="";return new TransformStream({transform(a,r){if(n+=a,n.trim().startsWith("data:"))n=ze(n,r,t);else try{JSON.parse(n),n=ze(n,r,t)}catch{r.enqueue(a),n=""}},flush(a){n.trim()!==""&&a.enqueue(n)}})};async function Vt(t,n){const a=t.api;return a?new Promise(r=>{a(n.text,n.token,n.identifier,n.baseUrl,n.extraConfig).then(s=>{if(s.body){const o=s.body.pipeThrough(new TextDecoderStream).pipeThrough(Rt(`
|
|
3
|
+
`)).getReader();console.log("reader from response:",o),r({error:0,reader:o})}else r({error:1,reader:null})}).catch(()=>{r({error:1,reader:null})})}):{error:1,reader:null}}const ge=new Map,ye=new Map;function ke(t,n){ge.set(t,n)}function Pe(t,n){ye.set(t,n)}function Me(t){return ge.get(t)}function je(t){return ge.has(t)}function Ie(t){return ye.get(t)}function Le(t){return ye.has(t)}const xt={"&":"&","<":"<",">":">",'"':""","'":"'"};function X(t){return String(t??"").replace(/[&<>"']/g,n=>xt[n])}function $e(t){const a=we(t,{block:t});return a?`<div class="szjy-ui" data-szjy-ui="1">${a}</div>`:""}function we(t,n){if(!t||typeof t!="object"||typeof t.type!="string")return"";const a=Me(t.type);return a?a(t,n):""}function Fe(t){const n=t.action;if(!n||typeof n!="string")return"";if(!Le(n))return` disabled title="未知动作:${X(n)}"`;const a=t.actionParams===void 0?"":encodeURIComponent(JSON.stringify(t.actionParams??null));return` data-szjy-ui-action="${X(n)}" data-szjy-ui-params="${a}"`}function Ut(t){return typeof t=="number"&&Number.isFinite(t)&&t>=0?`${t}px`:typeof t=="string"&&/^\d+(\.\d+)?(px|rem|em|%)?$/.test(t.trim())?/^\d+(\.\d+)?$/.test(t.trim())?`${t.trim()}px`:t.trim():"12px"}function Bt(t,n){const a=typeof t.title=="string"&&t.title?`<div class="szjy-ui-list__title">${X(t.title)}</div>`:"",s=(Array.isArray(t.items)?t.items:[]).map(i=>we(i,n)).filter(Boolean).map(i=>`<div class="szjy-ui-list__item">${i}</div>`).join(""),o=X(Ut(t.gap));return'<div class="szjy-ui-list">'+a+`<div class="szjy-ui-list__items" style="gap:${o}">${s}</div></div>`}ke("list",Bt);const _t=["default","primary","success","warning","danger","info","text"],zt=["small","default","large"];function Pt(t,n){const a=t.props,r=a&&typeof a=="object"?a:{},s=_t.includes(r.type)?r.type:"default",o=zt.includes(r.size)?r.size:"default",i=X(r.content??r.text??"按钮"),l=Fe(t);return`<button type="button" class="${["szjy-ui-btn",`szjy-ui-btn--${s}`,`szjy-ui-btn--${o}`].join(" ")}"${l}><span class="szjy-ui-btn__text">${i}</span><span class="szjy-ui-btn__status" aria-live="polite"></span></button>`}ke("button",Pt);const Mt=15e3,Oe=/未就绪|未加载/,jt="BIM_SANDBOX",It={locateComponent:t=>[t==null?void 0:t.wbsCode],openPDFSearch:()=>[]};let Lt=0;function $t(t,n){let a;if(!t||t==="self")a=[window];else if(t==="parent")a=[window.parent];else if(t==="top")a=[window.top];else if(typeof t=="function")try{a=t(n)}catch(o){console.error("[szjy-ui] 解析 postMessage 目标窗口失败:",o),a=[]}else Array.isArray(t)?a=t:a=[t];const r=[],s=o=>{if(o){if(Array.isArray(o)){o.forEach(s);return}typeof o.postMessage=="function"&&!r.includes(o)&&r.push(o)}};return s(a),r}function Q(t){if(t===window)return`self (${location.origin})`;if(t===window.parent)return"parent";if(t===window.top)return"top";try{return`window (${t.location.href.slice(0,60)})`}catch{return"window (cross-origin)"}}function Ft(t){try{const n=t.$bimSandbox;return n&&typeof n=="object"?n:null}catch{return null}}function Ot(t,n,a){if(n.type!==jt)return{handled:!1};const r=It[n.action];if(!r)return{handled:!1};const s=Ft(t);if(!s||typeof s[n.action]!="function")return{handled:!1};const o=r(n.payload);let i;try{i=s[n.action](...o)}catch(l){return console.error("[szjy-ui] $bimSandbox 方法调用异常,回退 postMessage:",l),{handled:!1}}return a&&console.log("[szjy-ui] $bimSandbox 直调",{method:n.action,args:o,result:i,target:Q(t)}),{handled:!0,result:i}}function De(t,n,a,r,s,o,i){return(()=>{const{handled:c,result:u}=Ot(t,n,i);return c?(u&&u.success?o&&F(a,"success",u.message||"执行成功"):u&&Oe.test(String(u.message||""))&&r>0?(i&&console.warn(`[szjy-ui] $bimSandbox 直调失败(${u.message}),${s}ms 后自动重试,剩余 ${r-1} 次`),o&&F(a,"retrying",`${u.message},${Math.round(s/1e3)}s 后自动重试`),setTimeout(()=>{De(t,n,a,r-1,s,o,i)},s)):o&&F(a,"error",u&&u.message||"执行失败"),!0):!1})()}function Dt(t){const n=Ht(t.config),a=!t.config||t.config.debug!==!1,r=n.feedback!==!1,s=n.retry===!1?{retries:0,delay:2e3}:{retries:2,delay:2e3,...n.retry||{}};if(!t.params||typeof t.params!="object"||Array.isArray(t.params)){console.warn("[szjy-ui] postMessage 动作的 actionParams 必须是对象:",t.params),F(t.triggerEl,"error","参数无效");return}const o={...t.params},i=$t(n.target,o);if(!i.length){console.warn("[szjy-ui] postMessage 无可用目标窗口,target 配置:",n.target),F(t.triggerEl,"error","无目标窗口");return}const l=n.targetOrigin||"*",c=n.transport||"auto";if(c!=="postMessage"){let u=!1;for(const S of i)if(De(S,o,t.triggerEl,s.retries,s.delay,r,a)){u=!0;break}if(u)return;if(c==="global"){console.warn("[szjy-ui] transport=global 但 $bimSandbox 全局方法不可用:",{targets:i.map(Q),message:o}),F(t.triggerEl,"error","全局方法不可用");return}a&&console.log("[szjy-ui] $bimSandbox 不可用,回退 postMessage 通道")}o.requestId===void 0&&(o.requestId=`szjy-ui-${Date.now()}-${++Lt}`),He(i,o,l),a&&console.log("[szjy-ui] postMessage 已发送",{message:o,targets:i.map(Q),targetOrigin:l,feedback:r}),r&&(F(t.triggerEl,"loading","已发送"),qt(o,i,t.triggerEl,l,s,a))}function Ht(t){return t&&t.postMessage||{}}function He(t,n,a){t.forEach(r=>{try{r.postMessage(n,a)}catch(s){console.error("[szjy-ui] postMessage 发送失败:",s)}})}function qt(t,n,a,r,s,o){let i=s.retries;const l=s.delay;let c=null;const u=()=>{window.removeEventListener("message",R),c&&(clearTimeout(c),c=null)},S=()=>{c&&clearTimeout(c),c=setTimeout(()=>{u(),o&&console.warn("[szjy-ui] postMessage 超时未收到回执",{message:t,targets:n.map(Q),targetOrigin:r}),F(a,"none","未收到回执")},Mt)},R=v=>{const h=v.data;!h||typeof h!="object"||t.type!==void 0&&h.type!==t.type||h.success!==void 0&&(t.requestId!==void 0&&h.requestId!==void 0&&String(h.requestId)!==String(t.requestId)||v.source&&!n.includes(v.source)||(o&&console.log("[szjy-ui] postMessage 收到回执",{requestId:h.requestId,success:h.success,message:h.message,data:h.data,from:Q(v.source)}),h.success?(u(),F(a,"success",h.message||"执行成功")):Oe.test(String(h.message||""))&&i>0?(i-=1,o&&console.warn(`[szjy-ui] postMessage 回执失败(${h.message}),${l}ms 后自动重试,剩余 ${i} 次`),F(a,"retrying",`${h.message},${Math.round(l/1e3)}s 后自动重试`),c&&clearTimeout(c),setTimeout(()=>{He(n,t,r),o&&console.log("[szjy-ui] postMessage 重试已发送",{message:t,targets:n.map(Q),targetOrigin:r}),F(a,"loading","已发送"),S()},l)):(u(),F(a,"error",h.message||"执行失败"))))};window.addEventListener("message",R),S()}function F(t,n,a){if(!t||!t.isConnected)return;const r=t.querySelector(":scope > .szjy-ui-btn__status");t.classList.remove("is-loading","is-success","is-error","is-retrying"),n&&n!=="none"&&t.classList.add(`is-${n}`),r&&(r.textContent=a||"")}Pe("postMessage",Dt);const qe="szjy-ui";function We(t){if(!t||typeof t!="string")return null;const n=t.trim();if(!n.startsWith("{"))return null;let a;try{a=JSON.parse(n)}catch{return null}return Wt(a)}function Wt(t){return!t||typeof t!="object"||Array.isArray(t)||typeof t.type!="string"||!je(t.type)||t.items!==void 0&&!Array.isArray(t.items)?null:t}function Ge(t,n={}){if(!t)return()=>{};const a=r=>{var v;const s=r.target,o=s&&typeof s.closest=="function"?s.closest("[data-szjy-ui-action]"):null;if(!o||!t.contains(o))return;const i=o.getAttribute("data-szjy-ui-action")||"",l=Ie(i);if(!l){console.warn(`[szjy-ui] 未注册的动作: ${i}`);return}const c=o.getAttribute("data-szjy-ui-params");let u=null;if(c)try{u=JSON.parse(decodeURIComponent(c))}catch(h){console.error("[szjy-ui] actionParams 解析失败:",h);return}const S=n.getConfig?n.getConfig():null;if(!S||S.debug!==!1){const h=(v=o.querySelector(":scope > .szjy-ui-btn__text"))==null?void 0:v.textContent;console.log("[szjy-ui] 动作触发",{action:i,params:u,text:(h||o.textContent||"").trim().slice(0,40),trigger:o})}const R=n.getInterceptor?n.getInterceptor():null;if(!(R&&R(i,u,o)===!1)){if(n.onAction)try{n.onAction({action:i,params:u,triggerEl:o})}catch(h){console.error("[szjy-ui] onAction 回调执行失败:",h)}l({params:u,config:S,triggerEl:o})}};return t.addEventListener("click",a),()=>{t.removeEventListener("click",a)}}let D=null;function Gt(){return D||(window.markdownit?(D=new window.markdownit({html:!0,linkify:!0,typographer:!0}),D.renderer.rules.fence=(t,n)=>{const a=t[n],r=(a.info||"").trim().split(/\s+/)[0];if(r===qe){const o=We(a.content),i=o?$e(o):"";if(i)return i}let s="";if(r&&window.hljs&&window.hljs.getLanguage(r))try{s=window.hljs.highlight(a.content,{language:r}).value}catch{s=""}return s||(s=D.utils.escapeHtml(a.content)),`<pre class="md-code-block"><code class="hljs${r?" language-"+r:""}">${s}</code></pre>`}):console.log("markdownit is not loaded"),D)}const Jt=(t,n)=>{const a=t.__vccOpts||t;for(const[r,s]of n)a[r]=s;return a},Kt=["src","alt"],ue=Jt({__name:"SvgIcon",props:{name:{type:String,required:!0},size:{type:[Number,String],default:16},color:{type:String,default:""},className:{type:String,default:""},basePath:{type:String,default:"/icons/"}},setup(t){const n=t,a=e.computed(()=>{if(n.name.startsWith("http://")||n.name.startsWith("https://")||n.name.startsWith("/"))return n.name;const o=n.name.endsWith(".svg")?n.name:`${n.name}.svg`;return`${n.basePath}${o}`}),r=e.computed(()=>{const o=typeof n.size=="number"?`${n.size}px`:n.size;return{width:o,height:o,display:"inline-flex",justifyContent:"center",alignItems:"center"}}),s=e.computed(()=>{const o={width:"100%",height:"100%"};return n.color&&(o.filter=`drop-shadow(0 0 0 ${n.color})`),o});return(o,i)=>(e.openBlock(),e.createElementBlock("div",{class:"svg-icon-wrapper",style:e.normalizeStyle(r.value)},[e.createElementVNode("img",{src:a.value,alt:t.name,class:e.normalizeClass(["svg-icon",t.className]),style:e.normalizeStyle(s.value)},null,14,Kt)],4))}},[["__scopeId","data-v-490b11c1"]]),Yt=async t=>{if(navigator.clipboard&&navigator.permissions)await navigator.clipboard.writeText(t);else{const n=document.createElement("textArea");n.value=t,n.style.width=0,n.style.position="fixed",n.style.left="-999px",n.style.top="10px",n.setAttribute("readonly","readonly"),document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n)}},Zt={class:"thinking-title"},Xt={class:"thinking-toggle-hint"},Qt=["innerHTML"],en=["innerHTML"],tn=10,nn={__name:"Previewer",props:{reader:null,model:"szjy",scrollToBottomFn:null,displayText:"",messagePostRender:{type:Function,default:null},customUi:{type:Object,default:null},uiActionHandler:{type:Function,default:null}},emits:["failed","completed","updating","ui-action"],setup(t,{expose:n,emit:a}){const{appContext:r}=e.getCurrentInstance(),{$message:s}=r.config.globalProperties,o=t,i=e.ref(o.displayText||""),l=e.ref(!0),c=e.ref(!1),u=e.ref(!!o.displayText),S=a,R=e.ref(null);let v=null;e.watch(R,B=>{v&&(v(),v=null),B&&(v=Ge(B,{getConfig:()=>o.customUi,getInterceptor:()=>o.uiActionHandler,onAction:T=>S("ui-action",T)}))});let h=null;const M=e.computed(()=>Tt(i.value)),A=e.computed(()=>M.value.thinking.length>0),_=e.ref(o.displayText?M.value.content.length:0),k=e.computed(()=>M.value.isThinkingStreaming&&!u.value),p=e.ref(!1),w=()=>{p.value=!p.value};let f=null,d=null;const C=e.ref(0);e.watch(()=>M.value.thinking,B=>{!B||C.value>0||(d===null&&(d=f??Date.now()),M.value.content&&E())});const E=()=>{if(C.value>0||!A.value)return;const B=d??f;B&&(C.value=Math.max(1,Math.round((Date.now()-B)/1e3)))},z=e.computed(()=>k.value?"正在思考...":C.value>0?`已深度思考(用时 ${C.value} 秒)`:"思考过程"),N=e.computed(()=>A.value?D?D.render(M.value.thinking):M.value.thinking:""),x=e.computed(()=>M.value.content.slice(0,_.value)),b=e.computed(()=>D?D.render(x.value):x.value),P=()=>{o.reader&&o.reader.cancel(),c.value=!0,$.value=!1,K(),u.value=!0,E(),S("completed",i.value),l.value=!1,h&&(cancelAnimationFrame(h),h=null)},H=e.computed(()=>`${b.value}`),q=e.ref(!1),W=()=>{q.value=!0},K=()=>{q.value=!1},$=e.ref(!1),te=async()=>{if(!o.reader)return;const B=new TextDecoder("utf-8");for(l.value=!0;!c.value;)try{if(!o.reader){$.value=!0;break}const{value:T,done:I}=await o.reader.read();if(!o.reader){$.value=!0;break}if(I){$.value=!0;break}const oe=_e[o.model];if(!oe)break;const O=oe.call(_e,T,B);if(O.done){$.value=!0;break}!f&&O.content&&(f=Date.now()),i.value+=O.content,h===null&&ne()}catch(T){$.value=!0,console.log(3333,T),S("failed",T),P();break}finally{K()}},ie=async()=>{o.scrollToBottomFn&&o.scrollToBottomFn()},me=(B=()=>{},T=()=>{})=>{const I=M.value.content.length;_.value>I&&(_.value=I),_.value<I?(_.value=Math.min(I,_.value+tn),B()):T()},ne=()=>{if(c.value&&h){cancelAnimationFrame(h),h=null,l.value=!1;return}$.value?me(()=>{h=requestAnimationFrame(ne),S("updating",null)},()=>{E(),S("completed",i.value),l.value=!1,u.value=!0,e.nextTick(()=>{if($.value=!1,o.messagePostRender&&R.value)try{o.messagePostRender(R.value,M.value.content)}catch(B){console.error("messagePostRender 执行失败:",B)}}),h=null}):(me(),h=requestAnimationFrame(ne)),ie()};e.watch(()=>o.reader,()=>{o.reader&&te()},{immediate:!0,deep:!0}),e.onUnmounted(()=>{v&&(v(),v=null),P()}),n({abortReader:P,initializeStart:W,initializeEnd:K}),e.computed(()=>q.value?!0:(!o.reader||!l||i.value,!1));const ve=async()=>{try{const B=M.value.content||i.value;await Yt(B),s.success("复制成功")}catch(B){console.error("复制失败:",B),s.error("复制失败")}};return(B,T)=>(e.openBlock(),e.createBlock(e.Transition,{name:"fade"},{default:e.withCtx(()=>[H.value||A.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"refWrapperContent",ref:R,"text-16":"",class:"w-full h-full overflow-y-auto relative","p-24px":""},[A.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["ai-thinking-block",{"is-expanded":p.value||k.value,"is-streaming":k.value}])},[e.createElementVNode("div",{class:"thinking-header",onClick:w},[T[0]||(T[0]=e.createElementVNode("svg",{class:"thinking-arrow",viewBox:"0 0 1024 1024",width:"10",height:"10"},[e.createElementVNode("path",{d:"M704 512 320 256v512z",fill:"currentColor"})],-1)),e.createElementVNode("span",Zt,e.toDisplayString(z.value),1),e.createElementVNode("span",Xt,e.toDisplayString(p.value||k.value?"收起":"展开"),1)]),e.withDirectives(e.createElementVNode("div",{class:"thinking-body",innerHTML:N.value},null,8,Qt),[[e.vShow,p.value||k.value]])],2)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"markdown-wrapper",innerHTML:H.value},null,8,en),u.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"ai-copy-btn-wrapper",onClick:ve},[e.createVNode(ue,{name:"/images/svg/copy.svg",color:"#666666"}),T[1]||(T[1]=e.createElementVNode("span",{class:"copy-text"},"复制",-1))])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0)]),_:1}))}};class Je{constructor(n,a){V(this,"ratio");V(this,"leftover",new Float32Array(0));V(this,"fracOffset",0);this.ratio=n/a}reset(){this.leftover=new Float32Array(0),this.fracOffset=0}process(n){if(this.ratio===1)return new Float32Array(n);const a=new Float32Array(this.leftover.length+n.length);if(a.set(this.leftover),a.set(n,this.leftover.length),a.length<2)return this.leftover=a,new Float32Array(0);const r=[];let s=this.fracOffset;for(;s<a.length-1;){const i=Math.floor(s),l=s-i,c=a[i],u=a[i+1];r.push(c+l*(u-c)),s+=this.ratio}const o=Math.min(a.length,Math.floor(s));return this.leftover=a.slice(o),this.fracOffset=s-o,Float32Array.from(r)}}class Ke{constructor(n={}){V(this,"targetSampleRate");V(this,"audioContext",null);V(this,"mediaStream",null);V(this,"sourceNode",null);V(this,"processorNode",null);V(this,"muteGain",null);V(this,"resampler",null);V(this,"audioChunks",[]);V(this,"onVolumeChange");V(this,"onAudioChunk");V(this,"_isRecording",!1);this.targetSampleRate=n.sampleRate||16e3,this.onVolumeChange=n.onVolumeChange,this.onAudioChunk=n.onAudioChunk}get isRecording(){return this._isRecording}async start(){if(this._isRecording)return;if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("当前浏览器环境不支持获取麦克风音频,请使用现代浏览器并确保在 HTTPS/localhost 环境下运行。");try{this.mediaStream=await navigator.mediaDevices.getUserMedia({audio:{channelCount:{ideal:1},sampleRate:{ideal:this.targetSampleRate},echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}})}catch(r){throw r.name==="NotAllowedError"||r.name==="PermissionDeniedError"?new Error("麦克风权限被拒绝,请在浏览器地址栏允许麦克风访问权限。"):r.name==="NotFoundError"||r.name==="DevicesNotFoundError"?new Error("未检测到可用的麦克风输入设备。"):new Error(`无法启动麦克风: ${r.message||r}`)}const n=window.AudioContext||window.webkitAudioContext;try{this.audioContext=new n({sampleRate:this.targetSampleRate})}catch{this.audioContext=new n}this.audioContext.state==="suspended"&&await this.audioContext.resume(),this.audioChunks=[],this.resampler=this.audioContext.sampleRate===this.targetSampleRate?null:new Je(this.audioContext.sampleRate,this.targetSampleRate),this.sourceNode=this.audioContext.createMediaStreamSource(this.mediaStream);const a=4096;this.processorNode=this.audioContext.createScriptProcessor(a,1,1),this.processorNode.onaudioprocess=r=>{var i;if(!this._isRecording)return;const s=new Float32Array(r.inputBuffer.getChannelData(0));if(this.onVolumeChange){let l=0;for(let S=0;S<s.length;S++)l+=s[S]*s[S];const c=Math.sqrt(l/s.length),u=Math.min(100,Math.round(c*100*5));this.onVolumeChange(u)}const o=this.resampler?this.resampler.process(s):s;o.length&&(this.audioChunks.push(o),(i=this.onAudioChunk)==null||i.call(this,o))},this.muteGain=this.audioContext.createGain(),this.muteGain.gain.value=0,this.sourceNode.connect(this.processorNode),this.processorNode.connect(this.muteGain),this.muteGain.connect(this.audioContext.destination),this._isRecording=!0}async stop(){if(!this._isRecording)return new Float32Array(0);this._isRecording=!1,this.cleanup();const n=this.audioChunks.reduce((s,o)=>s+o.length,0),a=new Float32Array(n);let r=0;for(const s of this.audioChunks)a.set(s,r),r+=s.length;return this.audioChunks=[],a}cancel(){this._isRecording=!1,this.audioChunks=[],this.cleanup()}cleanup(){this.processorNode&&(this.processorNode.disconnect(),this.processorNode.onaudioprocess=null,this.processorNode=null),this.muteGain&&(this.muteGain.disconnect(),this.muteGain=null),this.sourceNode&&(this.sourceNode.disconnect(),this.sourceNode=null),this.resampler=null,this.mediaStream&&(this.mediaStream.getTracks().forEach(n=>n.stop()),this.mediaStream=null),this.audioContext&&this.audioContext.state!=="closed"&&(this.audioContext.close().catch(()=>{}),this.audioContext=null)}}function Ye(t,n,a){if(n===a)return new Float32Array(t);const r=n/a,s=Math.round(t.length/r),o=new Float32Array(s);for(let i=0;i<s;i++){const l=i*r,c=Math.floor(l),u=l-c,S=t[c]??0,R=t[c+1]??S;o[i]=S+u*(R-S)}return o}async function Ze(t,n=16e3){const a=await t.arrayBuffer(),r=window.AudioContext||window.webkitAudioContext,s=new r;try{const o=await s.decodeAudioData(a);let i;if(o.numberOfChannels>1){i=new Float32Array(o.length);for(let l=0;l<o.numberOfChannels;l++){const c=o.getChannelData(l);for(let u=0;u<o.length;u++)i[u]+=c[u]/o.numberOfChannels}}else i=o.getChannelData(0);return Ye(i,o.sampleRate,n)}finally{s.state!=="closed"&&await s.close().catch(()=>{})}}function be(t,n=16e3){const a=new ArrayBuffer(44+t.length*2),r=new DataView(a),s=(i,l)=>{for(let c=0;c<l.length;c++)r.setUint8(i+c,l.charCodeAt(c))};s(0,"RIFF"),r.setUint32(4,36+t.length*2,!0),s(8,"WAVE"),s(12,"fmt "),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,1,!0),r.setUint32(24,n,!0),r.setUint32(28,n*2,!0),r.setUint16(32,2,!0),r.setUint16(34,16,!0),s(36,"data"),r.setUint32(40,t.length*2,!0);let o=44;for(let i=0;i<t.length;i++,o+=2){const l=Math.max(-1,Math.min(1,t[i]));r.setInt16(o,l<0?l*32768:l*32767,!0)}return new Blob([r],{type:"audio/wav"})}const Xe=16e3,on=Math.round(Xe*.35),Se="/scripts/ai/whisper.worker.js";function rn(){return new Worker(Ce(Se),{type:"module"})}function Ce(t){return/^https?:\/\//i.test(t)?t:typeof location<"u"?new URL(t,location.origin).href:t}function Qe(t){if(!t.ok)return!1;const n=(t.headers.get("content-type")||"").toLowerCase();return!(n.includes("text/html")||n.includes("application/xhtml+xml"))}async function an(t){try{const n=await fetch(t,{method:"HEAD"});if(Qe(n))return!0}catch{}try{const n=await fetch(t,{headers:{Range:"bytes=0-64"}});if(Qe(n))return!0}catch{}return!1}async function sn(t){const n=[];t&&n.push(Ce(t)),n.push(Ce(Se));const a=[...new Set(n.filter(Boolean))];for(const r of a)if(await an(r))return console.log("[VoiceInputManager] 使用语音 Worker:",r),r;return console.warn("[VoiceInputManager] 未探测到可访问的 Worker 脚本,将回退到 Vite 打包注入地址。已尝试:",a.join(" , ")),null}class et{constructor(n={}){V(this,"recorder",null);V(this,"worker",null);V(this,"status","idle");V(this,"options");V(this,"isReady",!1);V(this,"initPromise",null);V(this,"currentTaskId",0);V(this,"pcmParts",[]);V(this,"pcmLength",0);V(this,"streamChunkIndex",0);V(this,"committedText","");this.options={soundBaseUrl:"/sounds/",remoteHost:"https://hf-mirror.com",modelId:"onnx-community/whisper-base",language:"chinese",...n}}get currentStatus(){return this.status}get ready(){return this.isReady}async init(n){if(!this.isReady)return this.initPromise?this.initPromise:(n&&(this.options.soundBaseUrl=n),this.initPromise=new Promise((a,r)=>{this.setStatus("loading","正在准备语音识别引擎..."),(async()=>{var o,i;try{const l=await sn(this.options.workerUrl);this.worker=l?new Worker(l,{type:"module"}):rn(),this.worker.onmessage=c=>{this.handleWorkerMessage(c,a,r)},this.worker.onerror=c=>{var R,v;const S=`语音后台线程异常: ${c.message||c.filename||l||"未知错误"}`;this.initPromise=null,this.setStatus("error",S),(v=(R=this.options).onError)==null||v.call(R,S),r(c)},this.worker.postMessage({type:"INIT",data:{modelId:this.options.modelId,soundBaseUrl:this.options.soundBaseUrl,remoteHost:this.options.remoteHost}})}catch(l){const c=`创建语音 Worker 失败: ${l.message||l}`;this.initPromise=null,this.setStatus("error",c),(i=(o=this.options).onError)==null||i.call(o,c),r(l)}})()}),this.initPromise)}async startRecording(){var n,a,r,s;if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){const o=window.isSecureContext?"当前浏览器环境不支持获取麦克风音频,请使用现代浏览器。":"当前页面不是安全上下文,浏览器禁止调用麦克风。请使用 https:// 或 http://localhost / http://127.0.0.1 访问(通过局域网 IP 的 http 地址无法录音)。";throw this.setStatus("error",o),(a=(n=this.options).onError)==null||a.call(n,o),new Error(o)}this.isReady||await this.init(),this.recorder||(this.recorder=new Ke({onVolumeChange:o=>{var i,l;(l=(i=this.options).onVolumeChange)==null||l.call(i,o)},onAudioChunk:o=>{this.appendPcm(o)}}));try{this.currentTaskId++,this.resetStreamState(),await this.recorder.start(),this.setStatus("recording","正在录音...")}catch(o){throw this.setStatus("error",o.message||"启动录音失败"),(s=(r=this.options).onError)==null||s.call(r,o.message||"启动录音失败"),o}}async stopAndTranscribe(){var n,a,r,s;if(!(!this.recorder||!this.recorder.isRecording))try{await this.recorder.stop();const o=this.mergePcm();if(o.length===0){this.resetStreamState(),this.setStatus("idle");return}this.setStatus("transcribing","正在识别语音...");try{const i=be(o),l=URL.createObjectURL(i);(a=(n=this.options).onAudioRecorded)==null||a.call(n,l,i)}catch(i){console.warn("生成录音回放音频失败:",i)}await this.transcribeAudioData(o)}catch(o){this.setStatus("error",o.message||"音频处理失败"),(s=(r=this.options).onError)==null||s.call(r,o.message||"音频处理失败")}}async transcribeAudioData(n,a){var r,s,o,i;this.isReady||await this.init(),this.setStatus("transcribing","正在流式识别音频...");try{a&&((s=(r=this.options).onAudioRecorded)==null||s.call(r,a,be(n))),this.currentTaskId++,this.resetStreamState(),this.appendPcm(n),this.dispatchFullAudio()}catch(l){this.setStatus("error",l.message||"音频处理失败"),(i=(o=this.options).onError)==null||i.call(o,l.message||"音频处理失败")}}async transcribeFile(n){var a,r;this.isReady||await this.init(),this.setStatus("loading","正在解析音频文件...");try{const s=await Ze(n);if(s.length===0)throw new Error("未能从该文件中提取出有效音频");const o=URL.createObjectURL(n);await this.transcribeAudioData(s,o)}catch(s){this.setStatus("error",s.message||"音频文件解析失败"),(r=(a=this.options).onError)==null||r.call(a,s.message||"音频文件解析失败")}}cancelRecording(){var a;const n=this.currentTaskId;this.currentTaskId++,(a=this.worker)==null||a.postMessage({type:"CANCEL",taskId:n}),this.resetStreamState(),this.recorder&&this.recorder.cancel(),this.setStatus("idle")}cancelTranscribe(){var a;const n=this.currentTaskId;this.currentTaskId++,(a=this.worker)==null||a.postMessage({type:"CANCEL",taskId:n}),this.resetStreamState(),(this.status==="transcribing"||this.status==="recording")&&this.setStatus("idle")}async clearCache(){this.worker&&(this.worker.postMessage({type:"CLEAR_CACHE"}),this.isReady=!1,this.initPromise=null)}destroy(){var a;const n=this.currentTaskId;this.currentTaskId++,(a=this.worker)==null||a.postMessage({type:"CANCEL",taskId:n}),this.resetStreamState(),this.recorder&&(this.recorder.cancel(),this.recorder=null),this.worker&&(this.worker.terminate(),this.worker=null),this.isReady=!1,this.initPromise=null,this.setStatus("idle")}resetStreamState(){this.pcmParts=[],this.pcmLength=0,this.streamChunkIndex=0,this.committedText=""}appendPcm(n){!n||n.length===0||(this.pcmParts.push(new Float32Array(n)),this.pcmLength+=n.length)}mergePcm(){const n=new Float32Array(this.pcmLength);let a=0;for(const r of this.pcmParts)n.set(r,a),a+=r.length;return n}emitPartial(n){var a,r;(r=(a=this.options).onPartial)==null||r.call(a,(n||"").trim())}finishStream(n){var r,s;const a=(n??this.committedText).trim();this.setStatus("idle"),(s=(r=this.options).onResult)==null||s.call(r,a)}dispatchFullAudio(){if(!this.worker){this.finishStream();return}if(this.pcmLength<on){this.finishStream();return}const n=this.mergePcm(),a=n.length>Xe*30;this.committedText="",this.worker.postMessage({type:"TRANSCRIBE",data:{taskId:this.currentTaskId,audio:n,language:this.options.language,stream:!0,chunkIndex:this.streamChunkIndex++,isFinal:!0,mode:"append",nativeChunking:a}},[n.buffer])}handleWorkerMessage(n,a,r){var u,S,R,v;const{type:s,data:o,taskId:i,text:l,error:c}=n.data;switch(s){case"READY":this.isReady=!0,this.setStatus("ready","语音引擎就绪"),a==null||a();break;case"PROGRESS":if(o){const h=typeof o.progress=="number"?Math.round(o.progress):0;this.setStatus("downloading",`正在下载语音模型... ${h}%`),(S=(u=this.options).onProgress)==null||S.call(u,{status:o.status||"progress",progress:h,file:o.file,loaded:o.loaded,total:o.total})}break;case"TRANSCRIBING":if(i&&i!==this.currentTaskId)return;this.status!=="recording"&&this.setStatus("transcribing","正在流式转写文字...");break;case"PARTIAL":if(i&&i!==this.currentTaskId)return;this.committedText=l||"",this.emitPartial(this.committedText);break;case"RESULT":if(i&&i!==this.currentTaskId)return;this.committedText=(l||"").trim()||this.committedText,this.emitPartial(this.committedText),this.finishStream(this.committedText);break;case"CACHE_CLEARED":this.setStatus("idle","语音模型缓存已清空");break;case"ERROR":if(i&&i!==this.currentTaskId)return;this.setStatus("error",c||"语音服务异常"),(v=(R=this.options).onError)==null||v.call(R,c||"语音服务异常"),r==null||r(new Error(c));break}}setStatus(n,a){var r,s;this.status=n,(s=(r=this.options).onStatusChange)==null||s.call(r,n,a)}}const ln={class:"panel-header"},cn={class:"header-actions"},un={class:"header-title"},dn={class:"action-icons"},fn={class:"body-content"},mn={key:0,class:"welcome-content"},hn={class:"subtitle"},pn={class:"highlight"},gn={class:"quick-questions"},yn=["onClick"],kn={key:1,class:"message-content user-content"},wn={class:"panel-footer"},bn={key:0,src:ht,alt:"加载中",class:"loading-icon"},Sn={key:0,class:"voice-progress-banner"},Cn={class:"progress-info"},En={class:"progress-text"},vn={key:0,class:"progress-percent"},Nn={key:0,class:"progress-track"},An={class:"recording-main"},Tn={class:"recording-status"},Rn={key:0,class:"recording-time"},Vn={class:"recording-hint"},xn={key:1,class:"volume-waves"},Un={class:"recording-actions"},Bn=["title"],_n={key:0,class:"voice-playback-bar"},zn=["title"],Pn={class:"playback-play-icon"},Mn={key:0,viewBox:"0 0 24 24",width:"14",height:"14",fill:"currentColor"},jn={key:1,viewBox:"0 0 24 24",width:"14",height:"14",fill:"currentColor"},In={class:"playback-title"},Ln={key:0,class:"playback-time"},$n={key:1,class:"playback-waves"},Fn={class:"input-box"},On={class:"input-actions-box"},Dn=["src"],tt={__name:"ChatPanel",props:{modelValue:{type:Boolean,default:!1},token:{type:String,default:""},identifier:{type:String,default:""},baseUrl:{type:String,default:""},title:{type:String,default:"数智AI助理"},llmName:{type:String,default:"szjy"},messagePostRender:{type:Function,default:null},extraConfig:{type:Object,default:()=>({})},soundBaseUrl:{type:String,default:"/sounds/"},workerUrl:{type:String,default:""},enableVoiceInput:{type:Boolean,default:!1},enableVoiceUpload:{type:Boolean,default:!1},embedded:{type:Boolean,default:!1},customUi:{type:Object,default:null},uiActionHandler:{type:Function,default:null},mockResponse:{type:String,default:""}},emits:["update:modelValue","submit","ui-action"],setup(t,{emit:n}){const{appContext:a}=e.getCurrentInstance(),{$message:r}=a.config.globalProperties,s=t;let o=null;const i=e.ref("idle"),l=e.ref(""),c=e.ref(0),u=e.ref(0),S=e.ref(0);let R=null;const v=e.ref(""),h=e.ref(!1),M=e.ref(0);let A=null;const _=e.ref(""),k=e.ref(""),p=e.computed(()=>i.value==="downloading"),w=e.computed(()=>i.value==="loading"),f=e.computed(()=>i.value==="recording"),d=e.computed(()=>i.value==="transcribing"),C=e.computed(()=>f.value?"正在录音,点击完成后开始识别":_.value?"正在流式转写...":"正在识别语音中..."),E=e.computed(()=>s.enableVoiceInput?"请输入您的问题或点击麦克风语音输入":s.enableVoiceUpload?"请输入您的问题或上传音频识别":"请输入您的问题"),z=(g,m)=>{const U=(g||"").trim(),j=(m||"").trim();return j?U?/[A-Za-z0-9]$/.test(U)&&/[A-Za-z0-9]/.test(j.charAt(0))?`${U} ${j}`:`${U}${j}`:j:U},N=g=>{const m=Math.floor(g/60),U=g%60;return`${m.toString().padStart(2,"0")}:${U.toString().padStart(2,"0")}`},x=()=>(o||(o=new et({soundBaseUrl:s.soundBaseUrl||"/sounds/",workerUrl:s.workerUrl||void 0,onStatusChange:(g,m)=>{i.value=g,m&&(l.value=m)},onProgress:g=>{typeof g.progress=="number"&&(c.value=g.progress)},onVolumeChange:g=>{u.value=g},onAudioRecorded:g=>{v.value&&URL.revokeObjectURL(v.value),v.value=g,M.value=S.value},onPartial:g=>{_.value=g||"",T.value=z(k.value,g)},onResult:g=>{_.value=g||"",T.value=z(k.value,g),g?r.success("语音识别完成"):r.warning("未能识别出有效语音,请重试"),setTimeout(()=>{_.value="",I.value&&I.value.focus()},100)},onError:g=>{r.error(g||"语音输入服务出错"),P()}})),o),b=()=>{P(),S.value=0,R=setInterval(()=>{S.value+=1},1e3)},P=()=>{R&&(clearInterval(R),R=null)},H=async()=>{if(!s.enableVoiceInput)return;if(f.value){await q();return}h.value&&A&&(A.pause(),h.value=!1);const g=x();try{k.value=T.value,_.value="",b(),await g.startRecording()}catch(m){P(),console.error("启动录音失败:",m)}},q=async()=>{P(),o&&await o.stopAndTranscribe()},W=e.ref(null),K=()=>{s.enableVoiceUpload&&W.value&&(W.value.value="",W.value.click())},$=async g=>{var J;if(!s.enableVoiceUpload)return;const m=g.target,U=(J=m==null?void 0:m.files)==null?void 0:J[0];if(!U)return;h.value&&A&&(A.pause(),h.value=!1);const j=x();try{k.value=T.value,_.value="",r.info(`正在流式识别文件: ${U.name}`),await j.transcribeFile(U)}catch(L){r.error(`文件识别失败: ${L.message||L}`)}},te=()=>{P(),_.value="",T.value=k.value,o&&o.cancelRecording()},ie=()=>{_.value="",T.value=k.value,o&&o.cancelTranscribe(),r.info("已取消本次语音识别")},me=()=>{if(v.value){if(h.value&&A){A.pause(),h.value=!1;return}A&&(A.pause(),A=null),A=new Audio(v.value),A.onloadedmetadata=()=>{A&&!isNaN(A.duration)&&(M.value=Math.round(A.duration))},A.onended=()=>{h.value=!1},A.onerror=()=>{h.value=!1,r.error("音频试听播放失败")},A.play().then(()=>{h.value=!0}).catch(g=>{console.error("音频播放出错:",g),h.value=!1})}},ne=()=>{A&&(A.pause(),A=null),h.value=!1,v.value&&(URL.revokeObjectURL(v.value),v.value="")};e.onBeforeUnmount(()=>{P(),ne(),o&&(o.destroy(),o=null)});const ve=e.computed(()=>Be.find(g=>g.modelName===s.llmName)??Be.find(g=>g.modelName==="szjy")),B=n,T=e.ref(""),I=e.ref(null),oe=e.ref(!1),O=e.ref([]),so=e.ref(["什么是AI助理,能做什么?","当前项目的基本情况?","当前项目的进度情况?","当前项目的参建方有哪些?","数智建管平台有哪些功能?能做什么?"]),re=e.ref([]),le=e.ref(!1),Ne=e.ref(null),Ae=()=>{e.nextTick(()=>{if(Ne.value){const g=Ne.value,m=g.scrollHeight,U=g.scrollTop,j=g.clientHeight;m-U-j<100?g.scrollTop=m:g.scrollTo({top:m})}})},Y=e.ref(!1),io=e.computed(()=>Y.value?"/images/ai-stop.png":"/images/ai-send.png"),dt=(g,m)=>{console.log("onFailedReader",g,m),le.value=!1;const U=ft();U&&U.initializeEnd(),r.error("转换失败,请重试"),Y.value=!1,setTimeout(()=>{I.value&&I.value.focus()})},lo=(g,m)=>{le.value=!1,Y.value=!1,Ae(),m&&O.value[g]&&(O.value[g].displayText=m),setTimeout(()=>{I.value&&I.value.focus()})},co=g=>{Y.value=!0},uo=()=>{Y.value=!1,B("update:modelValue",!1),oe.value=!1,O.value=[]},Te=e.ref(!1),fo=()=>{Te.value=!Te.value},mo=g=>{T.value=g,Re()},ft=()=>{for(let g=re.value.length-1;g>=0;g--)if(re.value[g])return re.value[g];return null},Re=async()=>{if(console.log("stylizingLoading:",le.value),le.value){const J=ft();console.log("lastPreviewer:",J),J&&(console.log("abortReader"),J.abortReader());return}if(!T.value.trim()){console.log("no input, return"),I.value.focus();return}O.value.push({type:"user",content:T.value}),Y.value=!0,oe.value=!0,B("submit",T.value),Ae();const g=T.value;T.value="";const m=O.value.length;re.value[m]&&re.value[m].initializeStart(),le.value=!0,O.value.push({type:"ai"});const{error:U,reader:j}=await Vt(ve.value,{text:g,token:s.token,identifier:s.identifier,baseUrl:s.baseUrl,extraConfig:s.mockResponse?Object.assign({},s.extraConfig,{mockResponse:s.mockResponse}):s.extraConfig});if(U){console.log(45455,U),dt(m,U);return}j&&(O.value[m].reader=j)};return(g,m)=>{const U=e.resolveComponent("el-icon"),j=e.resolveComponent("el-button"),J=e.resolveComponent("el-input");return e.openBlock(),e.createBlock(e.Transition,{name:"slide"},{default:e.withCtx(()=>[t.modelValue?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["ai-panel",{"drawer-mode":Te.value,"embedded-mode":t.embedded}])},[e.createElementVNode("div",ln,[e.createElementVNode("div",cn,[e.createElementVNode("div",un,e.toDisplayString(t.title),1),e.createElementVNode("div",dn,[t.embedded?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(U,{key:0,class:"action-icon",onClick:fo},{default:e.withCtx(()=>[e.createVNode(ue,{name:"/images/svg/drawer-layout.svg",color:"#999999"})]),_:1})),e.createVNode(U,{class:"action-icon",onClick:uo},{default:e.withCtx(()=>[e.createVNode(ue,{name:"/images/svg/close.svg",color:"#999999"})]),_:1})])])]),e.createElementVNode("div",fn,[oe.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"chat-messages",ref_key:"messageContainerRef",ref:Ne},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(O.value,(L,ae)=>(e.openBlock(),e.createElementBlock("div",{key:ae,class:e.normalizeClass(["message-item",L.type==="user"?"user-message":"ai-message"])},[L.type==="ai"?(e.openBlock(),e.createBlock(nn,{key:0,ref_for:!0,ref:G=>re.value[ae]=G,reader:L.reader,"onUpdate:reader":G=>L.reader=G,model:s.llmName,displayText:L.displayText,scrollToBottomFn:Ae,messagePostRender:t.messagePostRender,customUi:t.customUi,uiActionHandler:t.uiActionHandler,onFailed:G=>dt(ae,G),onCompleted:G=>lo(ae,G),onUpdating:()=>co(),onUiAction:m[0]||(m[0]=G=>B("ui-action",G))},null,8,["reader","onUpdate:reader","model","displayText","messagePostRender","customUi","uiActionHandler","onFailed","onCompleted","onUpdating"])):(e.openBlock(),e.createElementBlock("div",kn,e.toDisplayString(L.content),1))],2))),128))],512)):(e.openBlock(),e.createElementBlock("div",mn,[m[3]||(m[3]=e.createElementVNode("div",{class:"title"},[e.createElementVNode("img",{src:mt,alt:"AI助手",class:"panel-icon"}),e.createElementVNode("h3",{class:"title-text"},"Hi, 您好")],-1)),e.createElementVNode("div",hn,[m[2]||(m[2]=e.createTextVNode(" 我是",-1)),e.createElementVNode("span",pn,e.toDisplayString(t.title),1)]),e.createElementVNode("div",gn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(so.value,(L,ae)=>(e.openBlock(),e.createElementBlock("div",{key:ae,class:"question-item",onClick:G=>mo(L)},[e.createElementVNode("span",null,e.toDisplayString(L),1),e.createVNode(U,null,{default:e.withCtx(()=>[e.createVNode(ue,{name:"/images/svg/arrow-right.svg",color:"#999999"})]),_:1})],8,yn))),128))])]))]),e.createElementVNode("div",wn,[Y.value?(e.openBlock(),e.createElementBlock("img",bn)):e.createCommentVNode("",!0),e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[p.value||w.value?(e.openBlock(),e.createElementBlock("div",Sn,[e.createElementVNode("div",Cn,[m[4]||(m[4]=e.createElementVNode("span",{class:"progress-icon"},"⏳",-1)),e.createElementVNode("span",En,e.toDisplayString(l.value),1),c.value>0?(e.openBlock(),e.createElementBlock("span",vn,e.toDisplayString(c.value)+"%",1)):e.createCommentVNode("",!0)]),c.value>0?(e.openBlock(),e.createElementBlock("div",Nn,[e.createElementVNode("div",{class:"progress-bar",style:e.normalizeStyle({width:c.value+"%"})},null,4)])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[f.value||d.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["voice-recording-panel",{"has-transcript":d.value}])},[e.createElementVNode("div",An,[e.createElementVNode("div",Tn,[e.createElementVNode("span",{class:e.normalizeClass(["recording-pulse",{transcribing:d.value}])},null,2),f.value?(e.openBlock(),e.createElementBlock("span",Rn,e.toDisplayString(N(S.value)),1)):e.createCommentVNode("",!0),e.createElementVNode("span",Vn,e.toDisplayString(C.value),1),f.value?(e.openBlock(),e.createElementBlock("div",xn,[e.createElementVNode("span",{class:"wave",style:e.normalizeStyle({height:Math.max(4,Math.min(22,u.value*.3))+"px"})},null,4),e.createElementVNode("span",{class:"wave",style:e.normalizeStyle({height:Math.max(4,Math.min(30,u.value*.5))+"px"})},null,4),e.createElementVNode("span",{class:"wave",style:e.normalizeStyle({height:Math.max(4,Math.min(18,u.value*.25))+"px"})},null,4)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",Un,[f.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(j,{size:"small",circle:"",onClick:te,title:"取消录音",class:"voice-cancel-btn"},{default:e.withCtx(()=>[...m[5]||(m[5]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"12",height:"12"},[e.createElementVNode("path",{d:"M512 456.310154L94.247385 38.557538a39.384615 39.384615 0 0 0-55.689847 55.689847L456.310154 512 38.557538 929.752615a39.384615 39.384615 0 0 0 55.689847 55.689847L512 567.689846l417.752615 417.752616c15.163077 15.163077 40.526769 15.163077 55.689847 0s15.163077-40.526769 0-55.689847L567.689846 512l417.752616-417.752615a39.384615 39.384615 0 0 0-55.689847-55.689847L512 456.310154z",fill:"currentColor"})],-1)])]),_:1}),e.createVNode(j,{type:"primary",size:"small",round:"",onClick:q,class:"voice-finish-btn"},{default:e.withCtx(()=>[...m[6]||(m[6]=[e.createTextVNode(" 完成 ",-1)])]),_:1})],64)):d.value?(e.openBlock(),e.createBlock(j,{key:1,size:"small",round:"",onClick:ie,class:"voice-cancel-transcribe-btn"},{default:e.withCtx(()=>[...m[7]||(m[7]=[e.createTextVNode(" 取消识别 ",-1)])]),_:1})):e.createCommentVNode("",!0)])]),d.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["live-transcript",{empty:!_.value}]),title:_.value},[_.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(_.value),1),m[8]||(m[8]=e.createElementVNode("span",{class:"caret"},"|",-1))],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode("正在识别,文字将实时显示...")],64))],10,Bn)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[v.value&&!f.value&&!d.value?(e.openBlock(),e.createElementBlock("div",_n,[e.createElementVNode("div",{class:"playback-main",onClick:me,title:h.value?"点击暂停":"点击播放录音"},[e.createElementVNode("div",Pn,[h.value?(e.openBlock(),e.createElementBlock("svg",jn,[...m[10]||(m[10]=[e.createElementVNode("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",Mn,[...m[9]||(m[9]=[e.createElementVNode("path",{d:"M8 5v14l11-7z"},null,-1)])]))]),e.createElementVNode("span",In,e.toDisplayString(h.value?"正在播放录音...":"点击试听本次录音"),1),M.value>0?(e.openBlock(),e.createElementBlock("span",Ln,e.toDisplayString(N(M.value)),1)):e.createCommentVNode("",!0),h.value?(e.openBlock(),e.createElementBlock("div",$n,[...m[11]||(m[11]=[e.createElementVNode("span",{class:"wave-bar"},null,-1),e.createElementVNode("span",{class:"wave-bar"},null,-1),e.createElementVNode("span",{class:"wave-bar"},null,-1),e.createElementVNode("span",{class:"wave-bar"},null,-1)])])):e.createCommentVNode("",!0)],8,zn),e.createElementVNode("div",{class:"playback-close",onClick:ne,title:"清除试听"},[...m[12]||(m[12]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"12",height:"12"},[e.createElementVNode("path",{d:"M512 456.310154L94.247385 38.557538a39.384615 39.384615 0 0 0-55.689847 55.689847L456.310154 512 38.557538 929.752615a39.384615 39.384615 0 0 0 55.689847 55.689847L512 567.689846l417.752615 417.752616c15.163077 15.163077 40.526769 15.163077 55.689847 0s15.163077-40.526769 0-55.689847L567.689846 512l417.752616-417.752615a39.384615 39.384615 0 0 0-55.689847-55.689847L512 456.310154z",fill:"currentColor"})],-1)])])])):e.createCommentVNode("",!0)]),_:1}),e.withDirectives(e.createElementVNode("div",Fn,[e.createVNode(J,{modelValue:T.value,"onUpdate:modelValue":m[1]||(m[1]=L=>T.value=L),ref_key:"refInputTextString",ref:I,placeholder:E.value,autofocus:"",onKeyup:e.withKeys(Re,["enter"])},{append:e.withCtx(()=>[e.createElementVNode("div",On,[t.enableVoiceUpload?(e.openBlock(),e.createElementBlock("div",{key:0,class:"voice-upload-btn",onClick:K,title:"上传音频/视频文件识别 (支持 .wav, .mp4, .mp3, .m4a)"},[...m[13]||(m[13]=[e.createElementVNode("svg",{viewBox:"0 0 24 24",width:"17",height:"17",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.createElementVNode("polyline",{points:"17 8 12 3 7 8"}),e.createElementVNode("line",{x1:"12",y1:"3",x2:"12",y2:"15"})],-1)])])):e.createCommentVNode("",!0),t.enableVoiceUpload?(e.openBlock(),e.createElementBlock("input",{key:1,type:"file",ref_key:"refAudioFileInput",ref:W,accept:"audio/*,video/mp4,.wav,.mp4,.mp3,.m4a",style:{display:"none"},onChange:$},null,544)):e.createCommentVNode("",!0),t.enableVoiceInput?(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(["voice-mic-btn",{"loading-anim":p.value||w.value}]),onClick:H,title:"语音输入"},[...m[14]||(m[14]=[e.createElementVNode("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",fill:"currentColor",opacity:"0.2"}),e.createElementVNode("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"}),e.createElementVNode("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),e.createElementVNode("line",{x1:"12",y1:"19",x2:"12",y2:"22"})],-1)])],2)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"send-icon-box",onClick:Re},[e.createElementVNode("img",{src:io.value,alt:"发送",class:"send-icon"},null,8,Dn)])])]),_:1},8,["modelValue","placeholder"])],512),[[e.vShow,!f.value&&!d.value]])])],2)):e.createCommentVNode("",!0)]),_:1})}}};var nt={exports:{}};(function(t,n){(function(a,r){t.exports=r()})(window,function(){return function(a){var r={};function s(o){if(r[o])return r[o].exports;var i=r[o]={i:o,l:!1,exports:{}};return a[o].call(i.exports,i,i.exports,s),i.l=!0,i.exports}return s.m=a,s.c=r,s.d=function(o,i,l){s.o(o,i)||Object.defineProperty(o,i,{enumerable:!0,get:l})},s.r=function(o){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})},s.t=function(o,i){if(1&i&&(o=s(o)),8&i||4&i&&typeof o=="object"&&o&&o.__esModule)return o;var l=Object.create(null);if(s.r(l),Object.defineProperty(l,"default",{enumerable:!0,value:o}),2&i&&typeof o!="string")for(var c in o)s.d(l,c,(function(u){return o[u]}).bind(null,c));return l},s.n=function(o){var i=o&&o.__esModule?function(){return o.default}:function(){return o};return s.d(i,"a",i),i},s.o=function(o,i){return Object.prototype.hasOwnProperty.call(o,i)},s.p="",s(s.s=0)}([function(a,r,s){function o(k,p,w,f){w.push(k),f.push([].concat(p[k]||[]))}function i(k,p){if(!k)throw new Error("[getMaxDepsChain] dep 参数不能为空");var w=[],f=[],d=[];for(o(k,p,f,d);f.length;){var C=d.pop();if(C&&C.length){var E=C.shift();if(d.push(C),~f.indexOf(E))throw new Error("[getMaxDepsChain][loop] 存在循环依赖,请检查依赖关系; nextName: "+E+", mainStack: "+f);o(E,p,f,d)}else w.push([].concat(f)),f.pop()}return w.reduce(function(z,N){return N.length>z.length?N:z},[])}function l(k){if(!k)throw new Error("[depsParser] 入参不能为空");var p={};k.forEach(function(f){p[f.name]=f.deps||[]});var w=[];return k.forEach(function(f){var d=i(f.name,p).length-1;f.priority=d,w[d]=(w[d]||[]).concat(f)}),w}s.r(r),s.d(r,"loadScript",function(){return v}),s.d(r,"loadScripts",function(){return h}),s.d(r,"dynamicLoadScripts",function(){return M}),s.d(r,"createScriptsLoadIterator",function(){return A}),s.d(r,"loadScriptsQueue",function(){return _}),s.d(r,"getMaxDepsChain",function(){return i}),s.d(r,"depsParser",function(){return l});var c=function(){return(c=Object.assign||function(k){for(var p,w=1,f=arguments.length;w<f;w++)for(var d in p=arguments[w])Object.prototype.hasOwnProperty.call(p,d)&&(k[d]=p[d]);return k}).apply(this,arguments)},u=function(k,p,w,f){return new(w||(w=Promise))(function(d,C){function E(x){try{N(f.next(x))}catch(b){C(b)}}function z(x){try{N(f.throw(x))}catch(b){C(b)}}function N(x){var b;x.done?d(x.value):(b=x.value,b instanceof w?b:new w(function(P){P(b)})).then(E,z)}N((f=f.apply(k,[])).next())})},S=function(k,p){var w,f,d,C,E={label:0,sent:function(){if(1&d[0])throw d[1];return d[1]},trys:[],ops:[]};return C={next:z(0),throw:z(1),return:z(2)},typeof Symbol=="function"&&(C[Symbol.iterator]=function(){return this}),C;function z(N){return function(x){return function(b){if(w)throw new TypeError("Generator is already executing.");for(;E;)try{if(w=1,f&&(d=2&b[0]?f.return:b[0]?f.throw||((d=f.return)&&d.call(f),0):f.next)&&!(d=d.call(f,b[1])).done)return d;switch(f=0,d&&(b=[2&b[0],d.value]),b[0]){case 0:case 1:d=b;break;case 4:return E.label++,{value:b[1],done:!1};case 5:E.label++,f=b[1],b=[0];continue;case 7:b=E.ops.pop(),E.trys.pop();continue;default:if(d=E.trys,!((d=d.length>0&&d[d.length-1])||b[0]!==6&&b[0]!==2)){E=0;continue}if(b[0]===3&&(!d||b[1]>d[0]&&b[1]<d[3])){E.label=b[1];break}if(b[0]===6&&E.label<d[1]){E.label=d[1],d=b;break}if(d&&E.label<d[2]){E.label=d[2],E.ops.push(b);break}d[2]&&E.ops.pop(),E.trys.pop();continue}b=p.call(k,E)}catch(P){b=[6,P],f=0}finally{w=d=0}if(5&b[0])throw b[1];return{value:b[0]?b[1]:void 0,done:!0}}([N,x])}}},R=function(k){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var p,w=k[Symbol.asyncIterator];return w?w.call(k):(k=typeof __values=="function"?__values(k):k[Symbol.iterator](),p={},f("next"),f("throw"),f("return"),p[Symbol.asyncIterator]=function(){return this},p);function f(d){p[d]=k[d]&&function(C){return new Promise(function(E,z){(function(N,x,b,P){Promise.resolve(P).then(function(H){N({value:H,done:b})},x)})(E,z,(C=k[d](C)).done,C.value)})}}};function v(k,p){return p===void 0&&(p=!1),new Promise(function(w,f){var d=p?document.head:document.body,C=document.createElement("script");C.type="text/javascript",C.src=k,C.crossOrigin="anonymous",C.onreadystatechange=w,C.onload=w,C.onerror=f,d.appendChild(C)})}var h=function(k,p){return p===void 0&&(p={}),u(void 0,void 0,void 0,function(){var w,f,d,C,E;return S(this,function(z){switch(z.label){case 0:return w=p.baseUrl,f=w===void 0?"":w,d=p.lastLoadResult,C=p.inHead,E=C!==void 0&&C,[4,Promise.all(k.map(function(N){return u(void 0,void 0,void 0,function(){var x,b,P,H,q,W,K,$;return S(this,function(te){switch(te.label){case 0:return x=N.name,b=N.path,P=N.deps,(K={})[x]=!0,H=K,($={})[x]=!1,q=$,window[x]?[2,H]:[3,1];case 1:return W=!0,P&&d&&[].concat(P).forEach(function(ie){d[ie]!==!1&&(W=!0)}),W?[4,v(b.indexOf("http")===0||b.indexOf("//:")===0?b:f+b,E).then(function(){return H}).catch(function(){return q})]:[3,3];case 2:return[2,te.sent()];case 3:return[2,q]}})})}))];case 1:return[2,z.sent()]}})})},M=function(k,p){return p===void 0&&(p={}),function(){var w=[].concat(l(k));return{next:function(){if(w.length){var f=w.shift();return h(f,p).then(function(d){return{value:d,done:!1}})}return Promise.resolve({done:!0})}}}},A=function(k,p){var w;return p===void 0&&(p={}),(w={})[Symbol.asyncIterator]=M(k,p),w},_=function(k,p){return p===void 0&&(p={}),u(void 0,void 0,void 0,function(){var w,f,d,C,E,z;return S(this,function(N){switch(N.label){case 0:N.trys.push([0,5,6,11]),w=R(A(k,p)),N.label=1;case 1:return[4,w.next()];case 2:if((f=N.sent()).done)return[3,4];d=f.value,p.lastLoadResult=p.lastLoadResult||{},console.log("current load: ",d),d.forEach(function(x){p.lastLoadResult=c(c({},p.lastLoadResult),x)}),N.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return C=N.sent(),E={error:C},[3,11];case 6:return N.trys.push([6,,9,10]),f&&!f.done&&(z=w.return)?[4,z.call(w)]:[3,8];case 7:N.sent(),N.label=8;case 8:return[3,10];case 9:if(E)throw E.error;return[7];case 10:return[7];case 11:return[2,p.lastLoadResult]}})})}}])})})(nt);var Hn=nt.exports;function ot(){const t=[{name:"markdownit",path:"markdown-it.min.js"},{name:"hljs",path:"highlight.11.11.1.min.js"}];let n={};Hn.loadScriptsQueue(t,{baseUrl:"/scripts/ai/",lastLoadResult:n,inHead:!1}).then(a=>{if(console.log("load ai deps: ",a),window.markdownit){const r=window.markdownit();console.log("markdownit: ",r),Gt()}})}const qn={key:0,class:"ai-assistant"},Wn={name:"AiChat"},rt=e.defineComponent({...Wn,props:{token:{type:String,default:""},identifier:{type:String,default:""},baseUrl:{type:String,default:""},title:{type:String,default:"数智AI助理"},llmName:{type:String,default:"szjy"},messagePostRender:{type:Function,default:null},extraConfig:{type:Object,default:()=>({})},soundBaseUrl:{type:String,default:"/sounds/"},workerUrl:{type:String,default:""},enableVoiceInput:{type:Boolean,default:!1},enableVoiceUpload:{type:Boolean,default:!1},customUi:{type:Object,default:null},uiActionHandler:{type:Function,default:null},mockResponse:{type:String,default:""}},emits:["ui-action"],setup(t,{emit:n}){const a=e.ref(!1),r=e.ref(!1),s=n,o=()=>{a.value=!a.value},i=()=>{r.value=!0,a.value=!1},l=c=>{console.log("用户输入:",c)};return ot(),(c,u)=>r.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",qn,[e.createVNode(tt,{modelValue:a.value,"onUpdate:modelValue":u[0]||(u[0]=S=>a.value=S),onSubmit:l,onUiAction:u[1]||(u[1]=S=>s("ui-action",S)),token:t.token,identifier:t.identifier,baseUrl:t.baseUrl,title:t.title,llmName:t.llmName,messagePostRender:t.messagePostRender,extraConfig:t.extraConfig,customUi:t.customUi,uiActionHandler:t.uiActionHandler,mockResponse:t.mockResponse,soundBaseUrl:t.soundBaseUrl,workerUrl:t.workerUrl,enableVoiceInput:t.enableVoiceInput,enableVoiceUpload:t.enableVoiceUpload},null,8,["modelValue","token","identifier","baseUrl","title","llmName","messagePostRender","extraConfig","customUi","uiActionHandler","mockResponse","soundBaseUrl","workerUrl","enableVoiceInput","enableVoiceUpload"]),e.createElementVNode("div",{class:"ai-icon",onClick:o},[e.createElementVNode("div",{class:"close-icon",onClick:e.withModifiers(i,["stop"])},[...u[2]||(u[2]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"8",height:"8"},[e.createElementVNode("path",{d:"M512 456.310154L94.247385 38.557538a39.384615 39.384615 0 0 0-55.689847 55.689847L456.310154 512 38.557538 929.752615a39.384615 39.384615 0 0 0 55.689847 55.689847L512 567.689846l417.752615 417.752616c15.163077 15.163077 40.526769 15.163077 55.689847 0s15.163077-40.526769 0-55.689847L567.689846 512l417.752616-417.752615a39.384615 39.384615 0 0 0-55.689847-55.689847L512 456.310154z",fill:"currentColor"})],-1)])]),u[3]||(u[3]=e.createElementVNode("img",{src:Z,alt:"AI助手"},null,-1)),u[4]||(u[4]=e.createElementVNode("span",{class:"ai-icon-text"},"AI助手",-1))])]))}}),Gn={class:"ai-chat-plain"},Jn={name:"AiChatPlain"},at=e.defineComponent({...Jn,props:{token:{type:String,default:""},identifier:{type:String,default:""},baseUrl:{type:String,default:""},title:{type:String,default:"数智AI助理"},llmName:{type:String,default:"szjy"},messagePostRender:{type:Function,default:null},extraConfig:{type:Object,default:()=>({})},soundBaseUrl:{type:String,default:"/sounds/"},workerUrl:{type:String,default:""},enableVoiceInput:{type:Boolean,default:!1},enableVoiceUpload:{type:Boolean,default:!1},customUi:{type:Object,default:null},uiActionHandler:{type:Function,default:null},mockResponse:{type:String,default:""}},emits:["submit","ui-action"],setup(t,{emit:n}){const a=n;return ot(),(r,s)=>(e.openBlock(),e.createElementBlock("div",Gn,[e.createVNode(tt,{"model-value":!0,token:t.token,identifier:t.identifier,baseUrl:t.baseUrl,title:t.title,llmName:t.llmName,messagePostRender:t.messagePostRender,extraConfig:t.extraConfig,customUi:t.customUi,uiActionHandler:t.uiActionHandler,mockResponse:t.mockResponse,soundBaseUrl:t.soundBaseUrl,workerUrl:t.workerUrl,enableVoiceInput:t.enableVoiceInput,enableVoiceUpload:t.enableVoiceUpload,embedded:!0,onSubmit:s[0]||(s[0]=o=>a("submit",o)),onUiAction:s[1]||(s[1]=o=>a("ui-action",o))},null,8,["token","identifier","baseUrl","title","llmName","messagePostRender","extraConfig","customUi","uiActionHandler","mockResponse","soundBaseUrl","workerUrl","enableVoiceInput","enableVoiceUpload"])]))}}),st=Object.freeze(Object.defineProperty({__proto__:null,SzAiChat:rt,SzAiChatPlain:at},Symbol.toStringTag,{value:"Module"})),Ee=function(t){if(!Ee.installed){Ee.installed=!0;for(let n in st){const a=Reflect.get(st,n);t.component(a.name,a)}}},Kn=(t,n)=>{const a=n?`?${new URLSearchParams(n).toString()}`:"";console.log(`点击了路由链接: ${t}${a}`)},it=t=>{const n=t.indexOf("?");if(n===-1)return{routeName:t};const a=t.substring(0,n),r=t.substring(n+1),s={};return new URLSearchParams(r).forEach((i,l)=>{s[l]=i}),{routeName:a,queryParams:Object.keys(s).length>0?s:void 0}},Yn={color:"#536fec",fontWeight:"bold",textDecoration:"underline",cursor:"pointer",padding:"0 3px"},lt=t=>{const n=/#router:([^#]+)#/g,a=[];let r=0,s;for(;(s=n.exec(t))!==null;){s.index>r&&a.push({text:t.substring(r,s.index)});const o=s[1],{routeName:i,queryParams:l}=it(o);a.push({text:i,routeName:i,queryParams:l}),r=n.lastIndex}return r<t.length&&a.push({text:t.substring(r)}),a},ct=(t,n,a={},r)=>{const{onRouteClick:s=Kn,linkStyle:o={}}=a,i=document.createElement("a");i.href="#",i.textContent=t;const l={...Yn,...o};return Object.assign(i.style,l),i.addEventListener("click",c=>{c.preventDefault(),s(n,r)}),i},ut=t=>{const n=/#router:([^#]+)#/g,a=[],r=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null);let s=r.nextNode();for(;s;){const o=s,i=o.textContent||"";if(n.test(i)){n.lastIndex=0;const l=lt(i);l.length>0&&a.push({node:o,replacements:l})}s=r.nextNode()}return a},Zn=(t,n,a={})=>{const r=ut(t);r.forEach(({node:s,replacements:o})=>{var l;const i=document.createDocumentFragment();o.forEach(({text:c,routeName:u,queryParams:S})=>{if(u){const R=ct(c,u,a,S);i.appendChild(R)}else i.appendChild(document.createTextNode(c))}),(l=s.parentNode)==null||l.replaceChild(i,s)}),a!=null&&a.nodeCallback&&r.forEach(({node:s,replacements:o})=>{var i;(i=a.nodeCallback)==null||i.call(a,s,o)})},se="szjy-voice-models",de="szjy-voice-cache-v1";function ee(){return typeof navigator<"u"&&!!navigator.storage&&typeof navigator.storage.getDirectory=="function"}async function fe(t=se){if(!ee())return null;try{return await(await navigator.storage.getDirectory()).getDirectoryHandle(t,{create:!0})}catch(n){return console.warn("[OPFS] 获取目录失败,将使用降级缓存:",n),null}}async function Xn(t,n,a=se){if(ee())try{const r=await fe(a);if(r){const o=await(await r.getFileHandle(t,{create:!0})).createWritable();return await o.write(n),await o.close(),!0}}catch(r){console.warn(`[OPFS] 写入文件 ${t} 失败:`,r)}if(typeof caches<"u")try{const r=await caches.open(de),s=new Response(n,{headers:{"Content-Type":"application/octet-stream"}});return await r.put(`/${a}/${t}`,s),!0}catch(r){console.warn(`[CacheStorage] 缓存写入 ${t} 失败:`,r)}return!1}async function Qn(t,n=se){if(ee())try{const a=await fe(n);if(a)return await(await(await a.getFileHandle(t,{create:!1})).getFile()).arrayBuffer()}catch{}if(typeof caches<"u")try{const r=await(await caches.open(de)).match(`/${n}/${t}`);if(r)return await r.arrayBuffer()}catch{}return null}async function eo(t,n=se){if(ee())try{const a=await fe(n);if(a)return(await(await a.getFileHandle(t,{create:!1})).getFile()).size>0}catch{}if(typeof caches<"u")try{return!!await(await caches.open(de)).match(`/${n}/${t}`)}catch{}return!1}async function to(t=se){let n=!1;if(ee())try{await(await navigator.storage.getDirectory()).removeEntry(t,{recursive:!0}),n=!0,console.log(`[OPFS] 成功清空语音模型缓存目录: ${t}`)}catch(a){a.name==="NotFoundError"?n=!0:console.warn(`[OPFS] 清理目录 ${t} 异常:`,a)}if(typeof caches<"u")try{const a=await caches.keys();for(const r of a)(r.includes("transformers")||r.includes("szjy-voice")||r===de)&&(await caches.delete(r),n=!0)}catch(a){console.warn("[CacheStorage] 清除缓存异常:",a)}return n}const no="0.1.13",oo="Sz";function ro({componentPrefix:t=oo,components:n=[]}={}){const a=[];function r(o,i,l){o.component(t+i)||o.component(t+i,l)}function s(o){a.includes(o)||(a.push(o),n.forEach(i=>{const{name:l,alias:c}=i;r(o,l,i),c&&c.forEach(u=>{r(o,u,i)})}))}return{version:no,componentPrefix:t,install:s}}const ao={install(t){Ee(t)}};y.AudioRecorder=Ke,y.DEFAULT_MOCK_RESPONSE=xe,y.DEFAULT_WHISPER_WORKER_URL=Se,y.SZJY_UI_FENCE_LANG=qe,y.StreamResampler=Je,y.SzAiChat=rt,y.SzAiChatPlain=at,y.VoiceInputManager=et,y.bindSzjyUiEvents=Ge,y.clearVoiceModelCache=to,y.create=ro,y.createMockStylized=Ue,y.createRouteLink=ct,y.decodeAudioFile=Ze,y.default=ao,y.escapeHtml=X,y.findRouteTextNodes=ut,y.float32ToWav=be,y.getFileFromCache=Qn,y.getOPFSDirectory=fe,y.getSzjyUiAction=Ie,y.getSzjyUiComponent=Me,y.hasFileInCache=eo,y.hasSzjyUiAction=Le,y.hasSzjyUiComponent=je,y.isOPFSSupported=ee,y.parseRouteMarkerContent=it,y.parseRouteMarkers=lt,y.parseSzjyUiFence=We,y.registerSzjyUiAction=Pe,y.registerSzjyUiComponent=ke,y.renderActionAttrs=Fe,y.renderSzjyUiBlock=$e,y.renderSzjyUiNode=we,y.resampleAudioData=Ye,y.routeLinkRender=Zn,y.saveFileToCache=Xn,Object.defineProperties(y,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
export type AiExtraConfig = {
|
|
2
|
+
projectId?: string | number;
|
|
3
|
+
authToken?: string;
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
};
|
|
1
6
|
/**
|
|
2
7
|
* Event Stream 调用大模型接口 Dify(兼容 OpenAI 格式)(Fetch 调用)
|
|
3
8
|
* 请求格式:
|
|
@@ -7,28 +12,28 @@
|
|
|
7
12
|
* "messages": [ { role, content }, ... ]
|
|
8
13
|
* }
|
|
9
14
|
*/
|
|
10
|
-
export declare function createDifyOpenAIStylized(text: any, token: any, identifier: any, baseUrl?: string, extraConfig?:
|
|
15
|
+
export declare function createDifyOpenAIStylized(text: any, token: any, identifier: any, baseUrl?: string, extraConfig?: AiExtraConfig): Promise<Response>;
|
|
11
16
|
/**
|
|
12
17
|
* Event Stream 调用大模型接口 Ollama3 (Fetch 调用)
|
|
13
18
|
*/
|
|
14
|
-
export declare function createOllama3Stylized(text: any,
|
|
19
|
+
export declare function createOllama3Stylized(text: any, _token: any, _identifier: any, _baseUrl?: string, _extraConfig?: AiExtraConfig): Promise<Response>;
|
|
15
20
|
/**
|
|
16
21
|
* Event Stream 调用大模型接口 Spark 星火认知大模型 (Fetch 调用)
|
|
17
22
|
*/
|
|
18
|
-
export declare function createSparkStylized(text: any, token: any,
|
|
23
|
+
export declare function createSparkStylized(text: any, token: any, _identifier: any, _baseUrl?: string, _extraConfig?: AiExtraConfig): Promise<Response>;
|
|
19
24
|
/**
|
|
20
25
|
* Event Stream 调用大模型接口 SiliconFlow 硅基流动大模型 (Fetch 调用)
|
|
21
26
|
*/
|
|
22
|
-
export declare function createSiliconFlowStylized(text: any, token: any,
|
|
27
|
+
export declare function createSiliconFlowStylized(text: any, token: any, _identifier: any, _baseUrl?: string, _extraConfig?: AiExtraConfig): Promise<Response>;
|
|
23
28
|
/**
|
|
24
29
|
* Event Stream 调用大模型接口 Kimi Moonshot 月之暗面大模型 (Fetch 调用)
|
|
25
30
|
*/
|
|
26
|
-
export declare function createKimiMoonshotStylized(text: any, token: any,
|
|
31
|
+
export declare function createKimiMoonshotStylized(text: any, token: any, _identifier: any, _baseUrl?: string, _extraConfig?: AiExtraConfig): Promise<Response>;
|
|
27
32
|
/**
|
|
28
33
|
* Event Stream 调用大模型接口 Kimi Moonshot 月之暗面大模型 (Fetch 调用)
|
|
29
34
|
*/
|
|
30
|
-
export declare function createDashScopeStylized(text: any, token: any,
|
|
35
|
+
export declare function createDashScopeStylized(text: any, token: any, _identifier: any, _baseUrl?: string, _extraConfig?: AiExtraConfig): Promise<Response>;
|
|
31
36
|
/**
|
|
32
37
|
* Event Stream 调用大模型接口 数智交院 月之暗面大模型 (Fetch 调用)
|
|
33
38
|
*/
|
|
34
|
-
export declare function createSZJYStylized(text: any, token: any, identifier: any, baseUrl?: string,
|
|
39
|
+
export declare function createSZJYStylized(text: any, token: any, identifier: any, baseUrl?: string, _extraConfig?: AiExtraConfig): Promise<Response>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 模拟后端(llmName: 'standard',LLMTypes 中标注「模拟数据模型」)。
|
|
3
|
+
*
|
|
4
|
+
* 不请求真实后端:将 extraConfig.mockResponse(或内置样例)按小块流式返回,
|
|
5
|
+
* 走与真实供应商完全一致的 reader / 打字机渲染管线,
|
|
6
|
+
* 用于联调 szjy-ui fence 渲染与 postMessage 动作。
|
|
7
|
+
*/
|
|
8
|
+
/** 内置 mock 样例:包含 szjy-ui fence 块,演示驱动 BIM 沙盘定位构件
|
|
9
|
+
* wbsCode 为演示项目 BIM2024CHKSLDY(125.122.34.243:8867)结构目录中的真实编码 */
|
|
10
|
+
export declare const DEFAULT_MOCK_RESPONSE: string;
|
|
11
|
+
/**
|
|
12
|
+
* mock 供应商 API,签名与其他供应商一致。
|
|
13
|
+
* 优先使用 extraConfig.mockResponse(由 sz-ai-chat 的 mockResponse prop 注入),
|
|
14
|
+
* 未提供时使用内置样例。
|
|
15
|
+
*/
|
|
16
|
+
export declare function createMockStylized(_text: string, _token: string, _identifier: string, _baseUrl?: string, extraConfig?: any): Promise<Response>;
|