fmode-ng 0.0.20 → 0.0.21
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/fesm2015/fmode-ng.mjs
CHANGED
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* 保留所有权利 All Rights Reserved.
|
|
6
6
|
* /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/fesm2015/fmode-ng.mjs
|
|
7
7
|
*/
|
|
8
|
-
import*as i0 from"@angular/core";import{Injectable,Pipe,Component,Input,ViewChild,NgModule,EventEmitter,Output}from"@angular/core";import{__awaiter}from"tslib";import*as Parse from"parse";import Parse__default from"parse";import*as i1 from"@angular/common/http";import{HttpHeaders,HttpClientModule}from"@angular/common/http";import*as i1$2 from"@angular/common";import{DatePipe,CommonModule}from"@angular/common";import{Camera,CameraSource,CameraResultType}from"@capacitor/camera";import{Capacitor}from"@capacitor/core";import{Filesystem}from"@capacitor/filesystem";import{FilesystemWeb}from"@capacitor/filesystem/dist/esm/web.js";import*as qiniu from"qiniu-js";import{MediaCapture}from"@awesome-cordova-plugins/media-capture";import SparkMD5 from"spark-md5";import*as i2 from"@ionic/angular";import{IonicModule,IonModal}from"@ionic/angular";import*as i2$1 from"@awesome-cordova-plugins/diagnostic/ngx";import{Diagnostic}from"@awesome-cordova-plugins/diagnostic/ngx";import{finalize,Observable,bufferTime,concatMap,delay}from"rxjs";import*as i3 from"@angular/router";import{RouterModule}from"@angular/router";import{mathjax}from"mathjax-full/js/mathjax";import{TeX}from"mathjax-full/js/input/tex";import{SVG}from"mathjax-full/js/output/svg";import{CHTML}from"mathjax-full/js/output/chtml";import{AllPackages}from"mathjax-full/js/input/tex/AllPackages";import{liteAdaptor}from"mathjax-full/js/adaptors/liteAdaptor";import{RegisterHTMLHandler}from"mathjax-full/js/handlers/html";import hljs from"highlight.js";import MarkdownIt from"markdown-it";import $ from"jquery";import abbr from"markdown-it-abbr";import footnote from"markdown-it-footnote";import deflist from"markdown-it-deflist";import mark from"markdown-it-mark";import ins from"markdown-it-ins";import sub from"markdown-it-sub";import sup from"markdown-it-sup";import ruby from"markdown-it-ruby";import plantumlEncoder from"plantuml-encoder";import*as i1$1 from"@angular/platform-browser";import{Clipboard}from"@capacitor/clipboard";import Recorder from"recorder-core";import"recorder-core/src/engine/pcm";import"recorder-core/src/engine/wav";import"recorder-core/src/extensions/waveview";import CryptoJS from"crypto-js";import*as i2$2 from"@angular/forms";import{FormsModule,ReactiveFormsModule}from"@angular/forms";import*as BABYLON from"@babylonjs/core";import"@babylonjs/loaders";import*as sdk from"microsoft-cognitiveservices-speech-sdk";import*as AMapLoader from"@amap/amap-jsapi-loader";import ObsClient from"esdk-obs-browserjs";class NovaCloudService{constructor(e){this.http=e,this.serverURL="https://server.fmode.cn/api",localStorage.setItem("NOVA_APIG_SERVER","aHR0cHMlM0ElMkYlMkZzZXJ2ZXIuZm1vZGUuY24lMkZhcGklMkZhcGlnJTJG")}novaql(e,t){let o=this.serverURL+"/novaql/select",n={sql:e};return n&&(null==t?void 0:t.length)>0&&(n.params=JSON.stringify(t)),new Promise(((e,t)=>{this.http.post(o,n,{headers:new HttpHeaders({"Content-Type":"application/json"}),withCredentials:!1}).subscribe((t=>{if(t&&200==t.code){let o=t.data;e(o)}}),(e=>{t(e)}))}))}apig(e,t,o="post"){localStorage.setItem("NOVA_APIG_SERVER","aHR0cHMlM0ElMkYlMkZzZXJ2ZXIuZm1vZGUuY24lMkZhcGklMkZhcGlnJTJG");let n=localStorage.getItem("NOVA_APIG_SERVER");n=decodeURIComponent(atob(n)),e=n+e,console.log(e);let i=Parse__default.User.current();return new Promise(((n,a)=>{try{this.http.request(o,e,{body:t||null,headers:new HttpHeaders({"Content-Type":"application/json",Authorization:`Bearer ${null==i?void 0:i.getSessionToken()}`}),withCredentials:!1}).subscribe((e=>{if(e&&200==e.code||e&&1==e.code||e&&0==e.code){let t=null==e?void 0:e.data;n(t)}else n(null)}),(e=>{console.error(e.mess),a(e)}))}catch(e){return console.error("请求出错")}}))}apigTest(e,t,o="post"){e="https://test.fmode.cn/api/apig/"+e,console.log(e);let n=Parse__default.User.current();return t.token=`Bearer ${null==n?void 0:n.getSessionToken()}`,new Promise(((n,i)=>{try{this.http.request(o,e,{body:t||null,headers:new HttpHeaders({"Content-Type":"application/json"}),withCredentials:!1}).subscribe((e=>{if(e&&200==e.code||e&&1==e.code||e&&0==e.code){let t=null==e?void 0:e.data;n(t)}else n(null)}),(e=>{console.error(e.mess),i(e)}))}catch(e){return console.error("请求出错")}}))}api(e,t){return e=this.serverURL+e,new Promise(((o,n)=>{this.http.post(e,t,{headers:new HttpHeaders({"Content-Type":"application/json"}),withCredentials:!1}).subscribe((e=>{if(e&&200==e.code||e&&1==e.code){let t=e.data;o(t)}else o(null)}),(e=>{n(e)}))}))}searchParse(e){let t={};if((e=e||location.search)&&e.length>1){let o=(e=e.substring(1)).split("&");for(let e=0;e<o.length;e++){if(!o[e])continue;let n=o[e].split("=");t[n[0]]=void 0===n[1]?"":n[1]}}return t}}function calcFileMd5(e){return new Promise(((t,o)=>{const n=new FileReader;n.onload=e=>{var n;try{const i=null===(n=e.target)||void 0===n?void 0:n.result;if(i){const e=new SparkMD5.ArrayBuffer;e.append(i);const o=e.end();t(o)}else o(new Error("Failed to load file"))}catch(e){o(e)}},n.onerror=e=>{o(e)},n.readAsArrayBuffer(e)}))}NovaCloudService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:NovaCloudService,deps:[{token:i1.HttpClient}],target:i0.ɵɵFactoryTarget.Injectable}),NovaCloudService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:NovaCloudService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:NovaCloudService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[{type:i1.HttpClient}]}});class NovaUploadService{constructor(e,t){this.platform=e,this.diagnostic=t,this.maxSize=5242880,this.getUptoken(!0),this.requestPermission(),this.queryDomain()}upload(e,t){var o,n;return __awaiter(this,void 0,void 0,(function*(){let i,a=e.type,r=null===(o=e.name)||void 0===o?void 0:o.split("."),s=r[r.length-1];try{i=yield calcFileMd5(e)}catch(e){}let l,c,d=this.fileToBlob(e);return l=a.indexOf("image")>-1?yield this.saveQiniuImageFile(d,s,null,t):yield this.saveQiniuMediaFile(e,d,null,t),l.md5=i,(null===(n=null==l?void 0:l.url)||void 0===n?void 0:n.indexOf("undefined"))>-1&&(l.url=(this.qiniuDomain||"https://file-cloud.fmode.cn/")+l.url.replace("undefined/","")),(null==l?void 0:l.url)&&(c=yield this.saveAttachment(l,this.qiniuDomain,null,this.getCompanyId())),(null==c?void 0:c.id)&&(l.id=null==c?void 0:c.id),l}))}isCapacitor(){return this.platform.is("capacitor")||this.platform.is("cordova")}requestPermission(){return __awaiter(this,void 0,void 0,(function*(){this.isCapacitor()&&(yield this.requestStoagePermission(),yield this.requestCameraPermission())}))}requestStoagePermission(){return __awaiter(this,void 0,void 0,(function*(){let e=yield this.diagnostic.isExternalStorageAuthorized();if(console.log("permisson_STORAGE:",e),!e){yield this.diagnostic.requestExternalStorageAuthorization()}}))}requestCameraPermission(){return __awaiter(this,void 0,void 0,(function*(){let e=yield this.diagnostic.isCameraAuthorized();if(console.log("permisson_Camera:",e),!e){yield this.diagnostic.requestCameraAuthorization()}}))}getUptoken(e=!1){return __awaiter(this,void 0,void 0,(function*(){if(console.log("getUptoken"),this.qiniuConf||e)try{console.log(this.getCompanyId());let e=yield Parse__default.Cloud.run("qiniu_uptoken",{company:this.getCompanyId()});console.log(e),this.qiniuConf=e}catch(e){console.error(e)}}))}genFileKey(e,t){let o=new Date,n=new DatePipe("en");return t||(t=this.getCompanyId()),t+"/"+n.transform(o,"yMMdd")+"/"+String(e.id).substr(20,6)+n.transform(o,"hhmmssSSS")+/\.[^\.]+/.exec(e.name)}getCompanyId(){if(this.company)return this.company;return localStorage.getItem("company")}queryDomain(){return __awaiter(this,void 0,void 0,(function*(){let e=new Parse__default.Query("Company"),t=yield e.get(this.getCompanyId());t.get("configQiniu")&&t.get("configQiniu").domain?(console.log(t.get("configQiniu").domain),this.qiniuDomain=t.get("configQiniu").domain):this.qiniuDomain="https://file-cloud.fmode.cn"}))}saveAttachment(e,t,o,n){return __awaiter(this,void 0,void 0,(function*(){let i=e.url;i.startsWith("http")||(i=t+i),i=i.replace(/undefined\//,""),n||(n=localStorage.getItem("company"));let a=Parse__default.User.current(),r=new Parse__default.Query("Attachment");r.equalTo("url",i);let s=yield r.first();if(s&&s.id)return console.error("该文件已存在,无需重复上传"),s;return s=new(Parse__default.Object.extend("Attachment")),s.set("size",e.size),s.set("url",i),s.set("name",e.name),s.set("mime",e.type),s.set("md5",null==e?void 0:e.md5),(null==a?void 0:a.id)&&s.set("user",a.toPointer()),n&&s.set("company",{__type:"Pointer",className:"Company",objectId:localStorage.getItem("company")}),o&&s.set("category",{__type:"Pointer",className:"Category",objectId:o}),yield s.save()}))}captureVideo(e){return __awaiter(this,void 0,void 0,(function*(){if(this.qiniuConf=e,!this.isCapacitor())return;let t=yield this.cameraCaptureVideoFile(),o=yield this.getMediaFileDataString(t);return yield this.saveQiniuMediaFile(t,o)}))}cameraCaptureVideoFile(){return __awaiter(this,void 0,void 0,(function*(){let e=MediaCapture,t=yield e.captureVideo({limit:1});return(null==t?void 0:t.length)>0?t[0]:null}))}getMediaFileDataString(e){return __awaiter(this,void 0,void 0,(function*(){new FilesystemWeb,e.fullPath.replaceAll("///","//");let t=yield Filesystem.stat({path:e.fullPath}),o=Capacitor.convertFileSrc(t.uri),n=yield fetch(o),i=yield n.blob();if(console.log(i.size),console.log(JSON.stringify(t)),console.log(JSON.stringify(n)),console.log(JSON.stringify(Object.keys(n))),i)return i;throw"读取文件失败"}))}takePicture(e){return __awaiter(this,void 0,void 0,(function*(){if(this.qiniuConf=e,!this.isCapacitor())return;yield this.getUptoken();let t=yield this.cameraTakePictureDataUrl();if(!(null==t?void 0:t.dataUrl))return;let o=yield this.base64ToBlob(null==t?void 0:t.dataUrl),n=yield this.saveQiniuImageFile(o,null==t?void 0:t.format);return console.log(JSON.stringify(n)),n}))}cameraTakePictureDataUrl(){return __awaiter(this,void 0,void 0,(function*(){if(!this.isCapacitor())return;return yield Camera.getPhoto({quality:90,allowEditing:!1,source:CameraSource.Camera,resultType:CameraResultType.DataUrl})}))}saveQiniuImageFile(e,t,o,n){return __awaiter(this,void 0,void 0,(function*(){let o=this.maxSize;if(e.size>o)throw yield console.log("照片过大,超出限制5MB"),"超出文件大小";let i=new DatePipe("en").transform(new Date,"yyyyMMddHHmmss"),a=`${i}.${t}`,r=`image/${t}`,s={fname:a,params:{},mimeType:"image/*"},l={useCdnDomain:!0,forceDirect:!0};console.log(this.qiniuConf);let c=this.genFileKey({id:i,name:a});return console.log("图片上传前"),new Promise(((t,o)=>{var i;console.log("进入了上传"),qiniu.upload(e,c,null===(i=this.qiniuConf)||void 0===i?void 0:i.uptoken,s,l).subscribe({next:e=>{console.log(e),n&&n(e)},error:e=>__awaiter(this,void 0,void 0,(function*(){console.log(e)})),complete:o=>{var n,i;console.log("上传完成"),console.log(`${null===(n=this.qiniuConf)||void 0===n?void 0:n.domain}${o.key}`),o.url=`${null===(i=this.qiniuConf)||void 0===i?void 0:i.domain}${o.key}`,o.name=a,o.type=r,o.size=e.size,t(o)}})}))}))}saveQiniuMediaFile(e,t,o,n){return __awaiter(this,void 0,void 0,(function*(){let o=e.name,i=e.type;if(e.size>104857600)throw console.log("视频过大,超出限制100MB"),"超出文件大小";let a=new DatePipe("en").transform(new Date,"yyyyMMddHHmmss"),r={fname:o,params:{},mimeType:i},s={useCdnDomain:!0,forceDirect:!0},l=this.genFileKey({id:a,name:o});return console.log("图片上传前"),console.log(e.name,t.size),console.log(t.size),console.log(t.size/1024/1024),new Promise(((o,i)=>{var a;console.log("进入了上传"),qiniu.upload(t,l,null===(a=this.qiniuConf)||void 0===a?void 0:a.uptoken,r,s).subscribe({next:e=>{console.log("主要用来展示进度"),n&&n(e),console.log(JSON.stringify(e))},error:e=>__awaiter(this,void 0,void 0,(function*(){console.log("上传失败"),console.log(JSON.stringify(e))})),complete:t=>{var n;console.log("上传完成"),console.log(JSON.stringify(t)),e.key=t.key,console.log(e.type),e.url=`${null===(n=this.qiniuConf)||void 0===n?void 0:n.domain}${t.key}`,console.log(e.url),o(e)}})}))}))}base64ToBlobType(e,t){return __awaiter(this,void 0,void 0,(function*(){let o=yield fetch(`data:${t};base64,${e}`);return yield o.blob()}))}base64ToBlob(e){return __awaiter(this,void 0,void 0,(function*(){let t=yield fetch(e);return yield t.blob()}))}fileToBlob(e){const t=e.slice(0,e.size,e.type);return new Blob([t],{type:e.type})}}NovaUploadService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:NovaUploadService,deps:[{token:i2.Platform},{token:i2$1.Diagnostic}],target:i0.ɵɵFactoryTarget.Injectable}),NovaUploadService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:NovaUploadService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:NovaUploadService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[{type:i2.Platform},{type:i2$1.Diagnostic}]}});class ImagineService{constructor(e,t,o){this.http=e,this.ncloud=t,this.uploadServ=o,this.taskDetailMap={},this.newWorkList=[],this.myWorkList=[]}drawDalle(e){var t;return __awaiter(this,void 0,void 0,(function*(){e.size=(null==e?void 0:e.size)||"1024x1024",e.style=(null==e?void 0:e.style)||"natural",e.quality=(null==e?void 0:e.quality)||null;let o={model:"dall-e-3",prompt:e.prompt,n:1,quality:e.quality,response_format:"url",size:e.size,style:e.style};if((null===(t=e.prompt)||void 0===t?void 0:t.length)>3e3)throw"prompt maximum < 4000 characters";let n=yield this.ncloud.apigTest("aigc/gpt/v1/images/generations",o);if(console.log(n),null==n?void 0:n.id){let e=new Parse__default.Query("ImagineWork");e.get(null==n?void 0:n.id);let t=yield e.first();console.log(t),(null==t?void 0:t.id)&&this.newWorkList.unshift(t)}return n}))}priceDalle(e){let t=[{model:"dall-e-3",quality:null,size:"1024x1024",credit:6.4},{model:"dall-e-3",quality:null,size:"1024x1792",credit:12.8},{model:"dall-e-3",quality:null,size:"1792x1024",credit:12.8},{model:"dall-e-3",quality:"hd",size:"1024x1024",credit:12.8},{model:"dall-e-3",quality:"hd",size:"1024x1792",credit:19.2},{model:"dall-e-3",quality:"hd",size:"1792x1024",credit:19.2},{model:"dall-e-2",quality:null,size:"1024x1024",credit:3.2},{model:"dall-e-2",quality:null,size:"512x512",credit:2.88},{model:"dall-e-2",quality:null,size:"256x256",credit:2.56}].find((t=>t.model==e.model&&t.quality==e.quality&&t.size==e.size));return(null==t?void 0:t.credit)||19.2}priceStableDiffusion(e){var t,o,n,i,a,r;let s=e.width*e.height,l=763e-9*s*e.steps+2278e-8*s*((null==e?void 0:e.upscale)||0)+((null==e?void 0:e.hrSteps)||0)*s*((null==e?void 0:e.hrScale)||0)*((null==e?void 0:e.hrScale)||0)*763e-9+((null==e?void 0:e.faceFix)?2:0)+((null===(t=null==e?void 0:e.imgOptions)||void 0===t?void 0:t.removeBackground)?2:0)+((null===(o=null==e?void 0:e.imgOptions)||void 0===o?void 0:o.redrawBackground)?2:0)+((null===(n=null==e?void 0:e.imgOptions)||void 0===n?void 0:n.facePreservation)?2:0)+((null===(i=null==e?void 0:e.imgOptions)||void 0===i?void 0:i.genderDetect)?1:0)+2*((null===(r=null===(a=null==e?void 0:e.controlnet)||void 0===a?void 0:a.units)||void 0===r?void 0:r.length)||0);return l=.3*l*e.batchSize,l}b64DataToBase64Image(e){let t=atob(e),o=new Blob([t],{type:"image/webp"});new Promise((e=>{let t=new FileReader;t.onloadend=function(){let o=t.result;console.log(o),e(o)},t.readAsDataURL(o)}))}draw(e){return __awaiter(this,void 0,void 0,(function*(){let t=yield this.ncloud.apig("aigc/sdapi/v1/draw",e),o=null==t?void 0:t.paintingSign;return o&&setTimeout((()=>__awaiter(this,void 0,void 0,(function*(){let e=new Parse__default.Query("ImagineWork");e.equalTo("taskId",o);let t=yield e.first();console.log(t),(null==t?void 0:t.id)&&this.newWorkList.unshift(t)}))),1e3),t}))}taskDetail(e){return __awaiter(this,void 0,void 0,(function*(){let t=yield this.ncloud.apig("aigc/sdapi/v1/task/detail",{taskId:e});return console.log(t),this.taskDetailMap[e]=t,t}))}getMyWorkQuery(){let e=Parse__default.User.current();if(!(null==e?void 0:e.id))return;let t=this.getWorkQuery();return t.include("model","module","user"),t.equalTo("user",e.toPointer()),t}getWorkQuery(){let e=new Date((new Date).getTime()-6e4),t=Parse__default.Query.fromJSON("ImagineWork",{where:{$or:[{createdAt:{$lte:e},progress:{$ne:0}},{createdAt:{$gt:e}}]}});return t.include("model","module","user"),t.notEqualTo("isDeleted",!0),t.notEqualTo("isFailed",!0),t.doesNotExist("respData.error"),t.doesNotExist("respData.data.taskLimitCount"),t.addDescending("createdAt"),t}getimg(){return new Promise(((e,t)=>{let o=document.createElement("input");o.type="file",o.click();let handleChange=()=>__awaiter(this,void 0,void 0,(function*(){if(o.removeEventListener("change",handleChange),o.files&&o.files.length>0){let t=o.files[0],n=yield this.uploadServ.upload(t,(e=>{console.log(e),e.total.percent.toFixed(2)}));e(n.url)}else t("未选择文件")}));o.addEventListener("change",handleChange)}))}}ImagineService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ImagineService,deps:[{token:i1.HttpClient},{token:NovaCloudService},{token:NovaUploadService}],target:i0.ɵɵFactoryTarget.Injectable}),ImagineService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ImagineService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ImagineService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[{type:i1.HttpClient},{type:NovaCloudService},{type:NovaUploadService}]}});const API_BASE="https://server.fmode.cn/api/apig/aigc/gpt";function getMessageContentText(e){var t;let o="";return"string"==typeof e&&(o=e),"object"==typeof e&&(o=(null===(t=null==e?void 0:e.find((e=>null==e?void 0:e.text)))||void 0===t?void 0:t.text)||""),o}function getMessageImageUrl(e){var t,o;return"object"==typeof e?(null===(o=null===(t=null==e?void 0:e.find((e=>null==e?void 0:e.image_url)))||void 0===t?void 0:t.image_url)||void 0===o?void 0:o.url)||"":null}class FmodeChat{constructor(e,t,o,n){this.ChatSession=Parse__default.Object.extend("ChatSession"),this.messageList=[{role:"system",content:"系统提示:AI仅供参考"}],this.latestAIResponse="",this.userInput="",this.userImage="",this.isTalkMode=!1,this.SSMLRoleVoice="zh-CN-XiaoxiaoNeural",this.playAnimation=e=>{console.log(e)},this.chatServ=n,this.role=t,this.sessionId=e,(null==o?void 0:o.id)&&(this.chatSession=o,this.messageList=this.chatSession.get("messageList"),this.sessionId=null==o?void 0:o.id)}loadTalkSystemPrompt(e){var t,o,n;if(!e)return;"男"==(null==e?void 0:e.get("gender"))?this.SSMLRoleVoice="zh-CN-YunyeNeural":this.SSMLRoleVoice="zh-CN-XiaoxiaoNeural",this.SSMLRoleVoice=(null===(t=null==e?void 0:e.get("voiceConfig"))||void 0===t?void 0:t.voice)||this.SSMLRoleVoice;let i=`您的语言简短且口语化,每句话都要用mstts:express-as标签,style属性情绪表达(advertisement_upbeat,affectionate,angry,assistant,calm,chat,cheerful,customerservice,depressed,disgruntled,documentary-narration,embarrassed,empathetic,envious,excited,fearful,friendly,gentle,hopeful,lyrical,narration-professional,narration-relaxed,newscast,newscast-casual,newscast-formal,poetry-reading,sad,serious,shouting,sports_commentary,sports_commentary_excited,whispering,terrified,unfriendly,),styledegree属性语气强度(默认1,从0.01最轻柔到2最强调),并适当用break增加自然停顿效果。并编写成带<speak xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="http://www.w3.org/2001/mstts" xmlns:emo="http://www.w3.org/2009/10/emotionml" version="1.0" xml:lang="zh-CN"><voice name="${this.SSMLRoleVoice}">标签的SSML返回。`,a=e.get("prompt")||"请你扮演脑控科技的人工智能专家。";a+=i;let r={role:"user",content:a,hidden:!0};if((null===(o=this.messageList)||void 0===o?void 0:o.map((e=>null==e?void 0:e.content)).join()).indexOf(a)>-1)return;let s=(null===(n=this.messageList)||void 0===n?void 0:n.findIndex((e=>"system"==(null==e?void 0:e.role))))+1;this.messageList.splice(s,0,r)}loadRolePrompt(){var e,t,o;let n=null===(e=this.role)||void 0===e?void 0:e.get("prompt"),i={role:"user",content:n,hidden:!0};if(!n)return;if((null===(t=this.messageList)||void 0===t?void 0:t.map((e=>null==e?void 0:e.content)).join()).indexOf(n)>-1)return;let a=(null===(o=this.messageList)||void 0===o?void 0:o.findIndex((e=>"system"==(null==e?void 0:e.role))))+1;this.messageList.splice(a,0,i),console.log(this.messageList)}sendMessage(e="FmodeAiTest测试问题",t,o){var n,i,a,r;this.loadTalkSystemPrompt(this.role),this.loadRolePrompt(),t?this.messageList.push({role:"user",content:[{type:"image_url",image_url:{url:t}},{type:"text",text:e}],complete:!0,createdAt:new Date}):this.messageList.push({role:"user",content:e,complete:!0,createdAt:new Date});let s=new FmodeChatCompletion(this.fixMessageList(this.messageList),{model:(null===(i=null===(n=this.chatServ)||void 0===n?void 0:n.currentModel)||void 0===i?void 0:i.get("code"))||"fmode-3.6-16k"});console.log(null===(r=null===(a=this.chatServ)||void 0===a?void 0:a.currentModel)||void 0===r?void 0:r.toJSON());let l=!1;this.isTalkMode&&(l=!0);let c=s.sendCompletion({isDirect:l,onComplete:o||null}).pipe(finalize((()=>{this.messageList[s.indexOfList].complete=!0}))).subscribe((e=>{var t,o,n,i,a;this.messageList[s.indexOfList]=e,"string"==typeof(null==e?void 0:e.content)?this.latestAIResponse=null==e?void 0:e.content:this.latestAIResponse=(null===(o=null===(t=null==e?void 0:e.content)||void 0===t?void 0:t[0])||void 0===o?void 0:o.text)||"";let r=null===(i=null===(n=this.chatSession)||void 0===n?void 0:n.get("messageList"))||void 0===i?void 0:i.length;(null===(a=this.messageList)||void 0===a?void 0:a.length)>r&&(console.log("cycle新会话"),this.saveChatSession()),(null==e?void 0:e.complete)&&(this.saveChatSession(),c.unsubscribe())}))}saveChatSession(){var e,t,o,n,i,a,r,s,l,c,d,p,m,u,h,g,v,f;return __awaiter(this,void 0,void 0,(function*(){if("new"==this.sessionId&&(this.chatSession=new this.ChatSession),this.chatSession.set("title",this.genTitle()),this.chatSession.set("role",null===(e=this.role)||void 0===e?void 0:e.toPointer()),this.chatSession.set("messageList",this.messageList),this.chatSession.set("user",null===(t=Parse__default.User.current())||void 0===t?void 0:t.toPointer()),this.chatSession=yield this.chatSession.save(),this.sessionId=null===(o=this.chatSession)||void 0===o?void 0:o.id,this.sessionId){let e=`${window.location.origin}/chat/pro/chat/${this.sessionId}`;e=this.getInviteUrl(e),window.history.replaceState(null,null,e);let t={sid:null===(n=this.chatSession)||void 0===n?void 0:n.id,rid:null===(i=this.role)||void 0===i?void 0:i.id,name:null===(a=this.role)||void 0===a?void 0:a.get("name"),message:null===(p=null===(d=null===(s=null===(r=this.chatSession)||void 0===r?void 0:r.get("messageList"))||void 0===s?void 0:s[(null===(c=null===(l=this.chatSession)||void 0===l?void 0:l.get("messageList"))||void 0===c?void 0:c.length)-1])||void 0===d?void 0:d.content)||void 0===p?void 0:p.slice(0,20),latest:null===(m=this.chatSession)||void 0===m?void 0:m.createdAt};(null===(h=null===(u=this.chatServ)||void 0===u?void 0:u.chatList)||void 0===h?void 0:h.length)||(this.chatServ.chatList=[]);let o=null===(v=null===(g=this.chatServ)||void 0===g?void 0:g.chatList)||void 0===v?void 0:v.find((e=>(null==e?void 0:e.sid)==(null==t?void 0:t.sid)));o>-1?this.chatServ.chatList[o]=t:null===(f=this.chatServ)||void 0===f||f.chatList.unshift(t)}}))}getInviteUrl(e){var t,o;let n="?";n=(null==e?void 0:e.indexOf("?"))>-1?"&":"?";let i=null===(o=null===(t=Parse__default.User)||void 0===t?void 0:t.current())||void 0===o?void 0:o.id;if(-1==(null==e?void 0:e.indexOf("invite="+i))){if(!i)return e;e+=n+"invite="+i}return e}genTitle(){var e,t;if(this.title)return this.title;let o=null===(e=this.messageList.find((e=>"user"==e.role)))||void 0===e?void 0:e.content;return"string"==typeof o&&(this.title=(null==o?void 0:o.slice(0,15))||""),"object"==typeof o&&(this.title=(null===(t=null==o?void 0:o.find((e=>null==e?void 0:e.text)))||void 0===t?void 0:t.text)||""),this.title}fixMessageList(e){return e.map((e=>({role:e.role,content:e.content})))}nowStr(){let e=new Date;return`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()} ${e.getHours()}:${e.getMinutes()}:${e.getSeconds()}`}}class FmodeChatCompletion{constructor(e,t){this.content="",this.contentBuffer=[],this.isCompleted=!1,this.indexOfList=Number(e.length),this.messages=e,this.model=(null==t?void 0:t.model)||"fmode-3.6-16k"}sendCompletion(e={}){e.intTime=(null==e?void 0:e.intTime)||50,e.isDirect=(null==e?void 0:e.isDirect)||!1,(null==e?void 0:e.isDirect)&&(e.intTime=1);let t={messages:this.messages,stream:!0,model:this.model,temperature:.5,presence_penalty:0,frequency_penalty:0};return console.log(t),new Observable((o=>{let n=RequestFmodeChatApi("/v1/chat/completions",t).subscribe((t=>{var i,a,r;let s=String(t);if(console.log(s),"data: [DONE]"==s&&(this.isCompleted=!0,console.log(null==e?void 0:e.isDirect,this.isCompleted),(null==e?void 0:e.isDirect)&&this.isCompleted&&(o.next({role:"assistant",content:this.content,complete:!0,createdAt:new Date}),n.unsubscribe(),(null==e?void 0:e.onComplete)&&e.onComplete({role:"assistant",content:this.content,complete:!0,createdAt:new Date}),o.complete())),s.indexOf("data: {")>-1){let t=chunkToJson(s),l=(null===(r=null===(a=null===(i=null==t?void 0:t.choices)||void 0===i?void 0:i[0])||void 0===a?void 0:a.delta)||void 0===r?void 0:r.content)||"";this.contentBuffer.push(l),(null==e?void 0:e.isDirect)&&(this.content+=l||"",this.isCompleted||o.next({role:"assistant",cid:null==t?void 0:t.id,content:this.content,createdAt:new Date})),(null==e?void 0:e.isDirect)||this.contentPusher||(this.contentPusher=setInterval((()=>{var e,i,a;this.isCompleted&&0==(null===(e=this.contentBuffer)||void 0===e?void 0:e.length)&&(o.next({role:"assistant",cid:null==t?void 0:t.id,content:this.content,complete:!0,createdAt:new Date}),n.unsubscribe(),clearInterval(this.contentPusher),o.complete()),(null===(i=this.contentBuffer)||void 0===i?void 0:i.length)>=0&&((null===(a=this.contentBuffer)||void 0===a?void 0:a.length)>0&&(this.content+=this.contentBuffer.shift()),o.next({role:"assistant",cid:null==t?void 0:t.id,content:this.content,createdAt:new Date}))}),null==e?void 0:e.intTime))}}))})).pipe(bufferTime(100),concatMap((e=>e)),delay(200))}}function chunkToJson(e){let t;try{t=JSON.parse(e.replaceAll("data: ",""))}catch(e){console.error(e)}return t||{}}function RequestFmodeChatApi(e,t,o="POST"){return new Observable((n=>{var i;let a=API_BASE+e,r=`Bearer ${(null===(i=Parse__default.User.current())||void 0===i?void 0:i.getSessionToken())||localStorage.getItem("FMODE_AI_TOKEN")}`;return t.token=r,t&&(t=JSON.stringify(t)),fetch(a,{headers:{"Content-Type":"text/plain","Cache-Control":"no-cache"},body:t||null,method:o,credentials:"omit",mode:"cors"}).then((e=>{var t;let o="";{let i=null===(t=e.body)||void 0===t?void 0:t.getReader();const a=new TextDecoder;let r=new ReadableStream({start(e){!function read(){i.read().then((({done:t,value:o})=>{if(t)return e.close(),void n.complete();e.enqueue(o),read()}))}()}}).getReader();r.read().then((function processStream({done:e,value:t}){if(e)return;!function processData(e){let t=(o+e).split("\n");if((null==t?void 0:t.length)>1){for(let e=0;e<t.length-1;e++){let o=t[e];n.next(o)}o=t[t.length-1]}}(a.decode(t)),r.read().then(processStream)}))}})).catch((e=>n.error(e))),()=>{}}))}function JsonToFormData(e){const t=new FormData;return function appendFormData(e,o=""){Array.isArray(e)?e.forEach(((e,t)=>{appendFormData(e,`${o}[${t}]`)})):"object"==typeof e&&null!==e?Object.keys(e).forEach((t=>{const n=o?`${o}.${t}`:t;appendFormData(e[t],n)})):t.append(o,e)}(e),t}class CrossService{getMenuType(){return this.clientWidth=document.body.clientWidth,this.onResizeScreen(),this.navMenuType}constructor(e,t,o){this.platform=e,this.modalCtrl=t,this.navCtrl=o,this.mobileWidth=915,this.clientWidth=document.body.clientWidth,this.clientWidth=document.body.clientWidth,this.updateWidth(),this.onResizeScreen()}dismisModalTop(e){return __awaiter(this,void 0,void 0,(function*(){let t=yield this.modalCtrl.getTop();t&&((null==e?void 0:e.preventDefault)&&(null==e||e.preventDefault()),t.dismiss(),t.isOpen=!1)}))}updateWidth(){this.fixInterval=setInterval((()=>{if(this.clientWidth)return clearInterval(this.fixInterval),void delete this.fixInterval;console.log(document.body.clientWidth),this.clientWidth=document.body.clientWidth}),200)}onResizeScreen(e){this.clientWidth=document.body.clientWidth,this.clientWidth>=this.mobileWidth?(this.leftMenuMode="horizontal",this.navMenuType="pc"):(this.leftMenuMode="inline",this.navMenuType="mobile")}}CrossService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CrossService,deps:[{token:i2.Platform},{token:i2.ModalController},{token:i2.NavController}],target:i0.ɵɵFactoryTarget.Injectable}),CrossService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CrossService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CrossService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[{type:i2.Platform},{type:i2.ModalController},{type:i2.NavController}]}});class ChatService{constructor(e,t,o,n,i,a){this.router=e,this.ncloud=t,this.platform=o,this.alertCtrl=n,this.navCtrl=i,this.cross=a,this.chatMap={},this.isCapacitor=!1,this.platformMap={pc:"电脑端",mobile:"移动端"},this.isCapacitor=this.platform.is("capacitor")}loadModelList(e){var t;return __awaiter(this,void 0,void 0,(function*(){let o=new Parse__default.Query("ChatModel");o.notEqualTo("isDeleted",!0),o.equalTo("isEnabled",!0),o.addAscending("index"),this.modelList=yield o.find(),this.currentModel=e||(null===(t=this.modelList)||void 0===t?void 0:t.find((e=>"fmode-3.6-16k"==e.get("code"))))}))}doButtonAction(e){var t,o,n;return __awaiter(this,void 0,void 0,(function*(){let i=this.cross.navMenuType,a=null===(t=null==e?void 0:e.platform)||void 0===t?void 0:t.map((e=>this.platformMap[e])).join("、");if((null===(o=null==e?void 0:e.platform)||void 0===o?void 0:o.length)>0&&-1==(null===(n=null==e?void 0:e.platform)||void 0===n?void 0:n.indexOf(i))){(yield this.alertCtrl.create({header:"注意",subHeader:"终端不符",message:`请您使用${a}开启本功能。`,buttons:[{role:"ok",text:"知道了"}]})).present()}else(null==e?void 0:e.path)&&this.navCtrl.navigateRoot(null==e?void 0:e.path)}))}initChatMap(e){return __awaiter(this,void 0,void 0,(function*(){if(this.chatMap[e])return this.chatMap[e];let t=new Parse__default.Query("ChatSession");t.include("role","role.model");let o=yield t.get(e),n=new FmodeChat(null==o?void 0:o.id,null==o?void 0:o.get("role"),o,this);return this.chatMap[e]=n,this.chatMap[e]}))}getChatSession(){var e,t;return __awaiter(this,void 0,void 0,(function*(){if(!(null===(t=null===(e=null==Parse__default?void 0:Parse__default.User)||void 0===e?void 0:e.current())||void 0===t?void 0:t.id))return;let o=new Parse__default.Query("ChatSession");o.include("role","role.model"),o.addDescending("updatedAt"),o.equalTo("user",Parse__default.User.current().toPointer()),o.notEqualTo("isDeleted",!0),o.limit(10);let n=yield o.find();this.chatList=n.map((e=>{var t,o,n,i,a,r,s,l;return this.chatMap[null==e?void 0:e.id]=new FmodeChat(null==e?void 0:e.id,null==e?void 0:e.get("role"),e),{session:e,sid:null==e?void 0:e.id,isHidden:!1,rid:null===(t=null==e?void 0:e.get("role"))||void 0===t?void 0:t.id,name:null===(o=null==e?void 0:e.get("role"))||void 0===o?void 0:o.get("name"),thumb:null===(n=null==e?void 0:e.get("role"))||void 0===n?void 0:n.get("thumb"),title:(null==e?void 0:e.get("title"))||(null===(i=null==e?void 0:e.get("role"))||void 0===i?void 0:i.get("name")),message:null===(l=null===(s=null===(a=null==e?void 0:e.get("messageList"))||void 0===a?void 0:a[(null===(r=null==e?void 0:e.get("messageList"))||void 0===r?void 0:r.length)-1])||void 0===s?void 0:s.content)||void 0===l?void 0:l.slice(0,20),latest:null==e?void 0:e.createdAt}}))}))}getChatSessionDistinct(){var e;return __awaiter(this,void 0,void 0,(function*(){let t=yield this.ncloud.novaql('SELECT t1."objectId" as sid , "AvatarRole"."objectId" as rid, * FROM (\n SELECT *,ROW_NUMBER() OVER (PARTITION BY "user", "role" ORDER BY "createdAt" DESC) AS rn\n FROM "ChatSession" WHERE "user"=$1\n ) as t1\n LEFT JOIN "AvatarRole" ON "AvatarRole"."objectId" = t1."role"\n WHERE t1.rn=1\n LIMIT $2\n ;',[null===(e=Parse__default.User.current())||void 0===e?void 0:e.id,10]),o=null==t?void 0:t.map((e=>{var t,o,n,i;return{sid:null==e?void 0:e.sid,rid:null==e?void 0:e.rid,name:null==e?void 0:e.name,message:null===(i=null===(n=null===(t=null==e?void 0:e.messageList)||void 0===t?void 0:t[(null===(o=null==e?void 0:e.messageList)||void 0===o?void 0:o.length)-1])||void 0===n?void 0:n.content)||void 0===i?void 0:i.slice(0,20),latest:null==e?void 0:e.createdAt}}));return this.chatList=o,this.chatList}))}createChatPanel(e,t){let o=(null==t?void 0:t.id)||"new";t=new FmodeChat(o,e,t,this),this.chatMap[o]=t,this.router.navigate(["/chat/pro/chat/"+o])}createNewRoleChat(e){return __awaiter(this,void 0,void 0,(function*(){let t=new Parse__default.Query("AvatarRole");t.include("model");let o=yield t.get(e);return new FmodeChat("new",o,null,this)}))}restoreChatPanel(e){return __awaiter(this,void 0,void 0,(function*(){let t=new Parse__default.Query("AvatarRole"),o=new Parse__default.Query("ChatSession"),n=yield t.get(null==e?void 0:e.rid),i=yield o.get(null==e?void 0:e.sid),a=new FmodeChat(null==e?void 0:e.sid,n,i);this.chatMap[null==e?void 0:e.sid]=a,this.router.navigate(["/chat/pro/chat/"+(null==e?void 0:e.sid)])}))}callRole(e){return __awaiter(this,void 0,void 0,(function*(){document.body.classList.add("dark"),this.router.navigate([`/avatar/role/${e.id}`,{type:"phone"}])}))}}ChatService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ChatService,deps:[{token:i3.Router},{token:NovaCloudService},{token:i2.Platform},{token:i2.AlertController},{token:i2.NavController},{token:CrossService}],target:i0.ɵɵFactoryTarget.Injectable}),ChatService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ChatService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ChatService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[{type:i3.Router},{type:NovaCloudService},{type:i2.Platform},{type:i2.AlertController},{type:i2.NavController},{type:CrossService}]}});class FmaiService{constructor(e,t){this.imagine=e,this.chat=t}}FmaiService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmaiService,deps:[{token:ImagineService},{token:ChatService}],target:i0.ɵɵFactoryTarget.Injectable}),FmaiService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmaiService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmaiService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[{type:ImagineService},{type:ChatService}]}});let colorMap=["primary","secondary","tertiary","success","warning","danger","light","medium","dark"];const MASK_LIST=[{name:"执行李",type:"employee",title:"首席执行官",desc:"一位富有远见和领导才能的创业新秀。她具备战略思维和决策能力,能够为公司设定长期目标并领导团队实现这些目标。",color:colorMap[0],cover:"https://imgsource.huashi6.com/images/ai/2023/9/29/15_48766.jpg?e=1695974629&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:oPkQSsyQLLD08R_J4SMeO1f1RdM="},{name:"技术刘",type:"employee",title:"首席技术官",desc:"一位技术专家,拥有广泛的技术知识和经验。他善于解决复杂的技术问题,并能够领导开发团队实施创新的技术解决方案。",color:colorMap[1],cover:["https://imgsource.huashi6.com/images/ai/2023/9/29/9_619877.jpg?e=1695952672&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:LDuSg8_n5g4Rj_8F5PKrGzV4T54=","https://imgsource.huashi6.com/images/ai/2023/9/27/20_17767.jpg?e=1695819037&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:a9uOeeJMN2oopK-3WQZzldPXfH0="]},{name:"点子王",type:"employee",title:"首席运营官",desc:"一位富有创意和市场洞察力的市场营销专家。她擅长制定营销策略,了解目标受众,并能够利用各种渠道和工具推广公司的产品或服务。",color:colorMap[2],cover:"https://imgsource.huashi6.com/images/ai/2023/9/29/9_186291.jpg?e=1695952125&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:EhEUtwnC9hpu-SXXsBrp2Q-rcJk="},{title:"设计总监",name:"李欣",type:"employee",desc:"一位富有创造力和用户导向思维的设计师。她能够理解用户需求,并通过设计直观、易用且吸引人的用户界面来提供出色的用户体验。",color:colorMap[3],cover:"https://imgsource.huashi6.com/images/ai/2023/9/29/9_18099.jpg?e=1695952201&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:G_a60v52iTTqvJgeTSa_8zJUY2w="},{title:"运营经理",name:"刘洁",type:"employee",desc:"一位组织能力强、注重细节并擅长解决问题的运营专家。她能够协调各个部门的工作,并确保公司的运营流程高效运行。",color:colorMap[4],cover:"https://imgsource.huashi6.com/images/ai/2023/9/29/9_842519.jpg?e=1695952125&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:FM_kKZDzkcLQ1EX4266dXU46cRc="},{title:"销售经理",name:"张伟",type:"employee",desc:"一位富有销售天赋和人际交往能力的销售专家。他善于与客户建立良好的关系,并能够推动销售团队实现业绩目标。",color:colorMap[5],cover:"https://imgsource.huashi6.com/images/ai/2023/9/29/15_739110.jpg?e=1695974920&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:vg_sn-qn67MJS-7j2o7mWzOCUSk="},{title:"数据分析师",name:"杨晨",type:"employee",desc:"一位善于解读数据和提供商业洞察的数据分析专家。她能够收集、分析和解释数据,为公司的决策制定提供有力的支持。",color:colorMap[6],cover:"https://imgsource.huashi6.com/images/ai/2023/9/29/15_204321.jpg?e=1695974779&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:dC2sGmJekSPBTCycPF76BkQPBoo="},{title:"财务经理",name:"赵晓",type:"employee",desc:"一位精通财务管理和分析的专业人士。她能够制定财务战略、管理公司的财务流程,并提供准确的财务报告和预测。",color:colorMap[7],cover:"https://imgsource.huashi6.com/images/ai/2023/9/29/15_947878.jpg?e=1695974779&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:TFGn0_l2PqhUTe9G4A3it769hcU="},{title:"品牌专员",name:"王雅",type:"employee",desc:"一位富有创意和品牌意识的专业人士。她能够塑造和管理公司的品牌形象,制定品牌营销策略,并与内部和外部利益相关者建立良好的合作关系。",color:colorMap[8],cover:["https://imgsource.huashi6.com/images/ai/2023/9/29/15_129581.jpg?e=1695975151&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:YQrpiv1hBKRPIdaEbDDDkLFuPG8=","https://imgsource.huashi6.com/images/ai/2023/9/29/15_912136.jpg?e=1695975151&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:8SVMU1rdKD8eaJ1gH_qGQzcrMhM="]},{title:"全科",name:"孔博",type:"teacher",desc:"擅长全科教学的金牌教师,知识面广泛,博古通今,因材施教,耐心稳重。",color:colorMap[0],cover:["https://imgsource.huashi6.com/images/ai/2023/10/18/12_40958.jpg?e=1697604189&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:U7r1Td30lXdf9mE1TMVAnDhBP6c="]},{title:"语文",name:"王明",type:"teacher",desc:"激发学生对文学的热爱,引导他们成为优秀的作家和沟通者。",color:colorMap[1],cover:["https://imgsource.huashi6.com/images/ai/2023/10/18/11_698893.jpg?e=1697602689&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:hK_AuY7BA1pp33QVeUue5QjIg4o="]},{title:"数学",name:"万红",type:"teacher",desc:"以清晰的逻辑和耐心的指导,帮助学生掌握数学的基础知识和解题技巧。",color:colorMap[2],cover:["https://imgsource.huashi6.com/images/ai/2023/10/18/11_256253.jpg?e=1697603314&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:K2iqp_ZzHYzXNu_0VJlywyANHp8="]},{title:"英语",name:"张瑞",type:"teacher",desc:"激发学生对英语学习的兴趣,培养他们的听、说、读、写能力,让他们自信地运用英语。",color:colorMap[3],cover:["https://imgsource.huashi6.com/images/ai/2023/10/18/12_266171.jpg?e=1697603707&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:uhpxBbT-jlSt_KjAnj0SFsFAjWU="]},{title:"物理",name:"金晓",type:"teacher",desc:"通过实验和案例,帮助学生理解物理原理,培养他们的科学思维和实验技能。",color:colorMap[4],cover:["https://imgsource.huashi6.com/images/ai/2023/10/18/11_694925.jpg?e=1697603071&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:FznZxhkYUrZ-BzX05dvNt8acTUw="]},{title:"化学",name:"陈华",type:"teacher",desc:"激发学生对化学的好奇心,教授他们化学知识和实验技巧,培养他们的实验和分析能力。",color:colorMap[5],cover:["https://imgsource.huashi6.com/images/ai/2023/10/18/11_942234.jpg?e=1697603169&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:__2T8cxLl4J0AwMR9MJdDiooDF0="]},{title:"生物",name:"杨婷",type:"teacher",desc:"引导学生探索生命的奥秘,培养他们的科学观察和实验能力,让他们热爱生物科学。",color:colorMap[6],cover:["https://imgsource.huashi6.com/images/ai/2023/10/18/12_330738.jpg?e=1697603491&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:2K5-DHPnUQ-R9GGxtWKiEG68QlE="]},{title:"历史",name:"赵亮",type:"teacher",desc:"帮助学生了解历史事件和文化背景,培养他们的历史意识和批判思维。",color:colorMap[7],cover:["https://imgsource.huashi6.com/images/ai/2023/10/18/11_256302.jpg?e=1697602689&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:YP7ffC1YKO-Pb0C3ks4caT0QqZk="]},{title:"地理",name:"林丽",type:"teacher",desc:"引导学生探索地球的奥秘,培养他们的地理观察和分析能力,让他们热爱地理科学。",color:colorMap[8],cover:["https://imgsource.huashi6.com/images/ai/2023/10/18/12_555804.jpg?e=1697604054&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:xLN4QW0x9jx9lEB4EFHWvI_gEsI="]}];class UtilnowPipe{constructor(){this.enLocale={"秒钟前":" seconds ago","分钟前":" minutes ago","小时前":" hours ago","天前":" days ago"}}transform(e,t){let o=((new Date).getTime()-e.getTime())/1e3;if(o<=60)return this.handleArgs(o.toFixed(0),"秒钟前",t);let n=o/60;if(n<60)return this.handleArgs(n.toFixed(0),"分钟前",t);let i=n/60;if(i<24)return this.handleArgs(i.toFixed(0),"小时前",t);let a=i/24;return a<7?this.handleArgs(a.toFixed(0),"天前",t):`${null==e?void 0:e.getFullYear()}-${(null==e?void 0:e.getMonth())+1}-${null==e?void 0:e.getDate()}`}handleArgs(e,t,o){var n;return"en"==o&&(t=this.enLocale[t]),"TranslateService"==(null===(n=null==o?void 0:o.constructor)||void 0===n?void 0:n.name)&&(console.log(t),"en"==(null==o?void 0:o.getDefaultLang())&&(t=this.enLocale[t])),"json"==o?{unit:t,value:e}:e+t}}UtilnowPipe.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:UtilnowPipe,deps:[],target:i0.ɵɵFactoryTarget.Pipe}),UtilnowPipe.ɵpipe=i0.ɵɵngDeclarePipe({minVersion:"14.0.0",version:"15.1.0",ngImport:i0,type:UtilnowPipe,isStandalone:!0,name:"utilnow"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:UtilnowPipe,decorators:[{type:Pipe,args:[{name:"utilnow",standalone:!0}]}]});class ChatContentPipe{transform(e,...t){console.log(t);let o=(null==t?void 0:t[0])||"text";return"text"==o?getMessageContentText(e):"image_url"==o?getMessageImageUrl(e):e}}ChatContentPipe.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ChatContentPipe,deps:[],target:i0.ɵɵFactoryTarget.Pipe}),ChatContentPipe.ɵpipe=i0.ɵɵngDeclarePipe({minVersion:"14.0.0",version:"15.1.0",ngImport:i0,type:ChatContentPipe,isStandalone:!0,name:"chatContent"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ChatContentPipe,decorators:[{type:Pipe,args:[{name:"chatContent",pure:!0,standalone:!0}]}]});class HidexmlPipe{transform(e,...t){return e?this.hideXmlTags(e):""}hideXmlTags(e){return e.replace(/<[^>]*>/g,"")}}HidexmlPipe.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:HidexmlPipe,deps:[],target:i0.ɵɵFactoryTarget.Pipe}),HidexmlPipe.ɵpipe=i0.ɵɵngDeclarePipe({minVersion:"14.0.0",version:"15.1.0",ngImport:i0,type:HidexmlPipe,isStandalone:!0,name:"hidexml"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:HidexmlPipe,decorators:[{type:Pipe,args:[{name:"hidexml",standalone:!0}]}]});class MarkdownMathJax{constructor(e){this.options=e,this.adaptor=liteAdaptor(),RegisterHTMLHandler(this.adaptor)}text_to_mathjax(e,t){if(!(null==e?void 0:e.length))return"";if(!(null==e?void 0:e.replace))return"";t=t||this.options;let o=new SVG({fontCache:"local"});"chtml"==(null==t?void 0:t.output)&&(o=new CHTML);const n=mathjax.document("",{skipHtmlTags:["script","noscript","style","textarea","pre","code","annotation","annotation-xml"],InputJax:new TeX({processEscapes:!0,packages:AllPackages}),OutputJax:o}),i={em:16,ex:8,containerWidth:1280};return[/\$\$\ (.+?)\ \$\$/g,/\$\$(.+?)\$\$/g,/\$\$\n(.+?)\n\$\$/g,/\$(.+?)\$/g,/\\\((.+?)\\\)/g,/\\\[(.+?)\\\]/g].forEach((t=>{e=e.replace(t,((e,t)=>{let o=n.convert(`${t}`,i);return`<span class="mathjax raw" style="margin-left:10px;margin-right:10px;">${this.adaptor.innerHTML(o)}</span>`}))})),e}}let md=new MarkdownIt({html:!0,xhtmlOut:!0,breaks:!1,linkify:!1,typographer:!1,quotes:"“”‘’",highlight:function(e,t){if(t&&hljs.getLanguage(t))try{return`<pre style="position:relative;padding:10px;" class="hljs lang-${t}"><code>${hljs.highlight(e,{language:t}).value}</code><small class="hljs-lang"><span class="sr-only">Language:</span>${t}</small></pre>`}catch(e){}return""}});md.use(abbr),md.use(footnote),md.use(deflist),md.use(mark),md.use(ins),md.use(sub),md.use(sup),md.use(ruby);const mditConfig={plantumlServer:"https://www.plantuml.com/plantuml"};function makePlantumlURL(e){const t=plantumlEncoder.encode(e);return`${mditConfig.plantumlServer}/svg/${t}`}md.renderer.rules.plantuml=(e,t,o,n,i)=>{const a=e[t];if("plantuml"!==a.type)return e[t].content;return`\n <img src="${makePlantumlURL(a.content)}" />\n <pre style="position:relative;padding:10px;" class="hljs lang-plantuml"><code>${a.content}</code><small class="hljs-lang"><span class="sr-only">Language:</span>plantuml</small></pre>\n `},md.core.ruler.push("plantuml",(e=>{const t=e.tokens;for(const e of t)"fence"===e.type&&"plantuml"===e.info&&(e.type="plantuml")}));const spaceregex=/\s*/,notinhtmltagregex=/(?![^<]*>|[^<>]*<\/)/;let coloregex=/\[color=([#|(|)|\s|,|\w]*?)\]/;coloregex=new RegExp(coloregex.source+notinhtmltagregex.source,"g");let nameregex=/\[name=(.*?)\]/,timeregex=/\[time=([:|,|+|-|(|)|\s|\w]*?)\]/;const nameandtimeregex=new RegExp(nameregex.source+spaceregex.source+timeregex.source+notinhtmltagregex.source,"g");function replaceExtraTags(e){return console.log("replaceExtraTags",e),e=(e=(e=(e=e.replace(coloregex,'<span class="color" data-color="$1"></span>')).replace(nameandtimeregex,'<small><i class="fa fa-user"></i> $1 <i class="fa fa-clock-o"></i> $2</small>')).replace(nameregex,'<small><i class="fa fa-user"></i> $1</small>')).replace(timeregex,'<small><i class="fa fa-clock-o"></i> $1</small>'),console.log("replaceExtraTags",e),e}function finishView(e){let t=$.parseHTML(`<html><body><div id="topmd">${e}</div></body></html>`)[0],o=$(t),n=o.find("blockquote.raw").removeClass("raw");n=o.find("blockquote");let i=$(n).find("p");i.each(((e,t)=>{let o=$(t).html();o=replaceExtraTags(o),t.innerHTML=o,$(t).html(o),i[e].innerHTML=o,$(i[e]).html(o)})),n.find(".color").each(((e,t)=>{let o=$(t).attr("data-color");$(t).closest("blockquote").css("border-left-color",o)}));let a="<style>\n .markdown-section {\n color: black;\n text-align: left;\n }\n .markdown-section pre .hljs-lang{\n text-transform: uppercase;\n font-weight: 700;\n font-size: .75rem;\n line-height: 1rem;\n padding-top: .25rem;\n padding-bottom: .25rem;\n padding-left: .5rem;\n padding-right: .5rem;\n background-color: rgba(0,0,0,.3);\n border-bottom-left-radius: .375rem;\n top:0;\n right:0;\n position:absolute;\n}\n\n }\n .markdown-section pre .hljs {\n position:relative!important;\n background: #272822!important;\n padding:10px!important;\n color: #ddd;\n text-shadow: none!important;\n }\n\n .markdown-section blockquote {\n margin: 0;\n margin-bottom: 0px;\n margin-bottom: .85em;\n padding: 0 15px;\n color: #858585;\n border-left: 4px solid #e5e5e5;\n border-left-color: rgb(229, 229, 229);\n }\n .markdown-section img {\n max-width:100%;\n }\n </style>"+(o.html()||e);return a=a.replaceAll('src="/uploads/','src="https://md.fmode.cn/uploads/'),a}nameregex=new RegExp(nameregex.source+notinhtmltagregex.source,"g"),timeregex=new RegExp(timeregex.source+notinhtmltagregex.source,"g");class MarkdownParse{constructor(){}parseToHTML(e){this.info("markdown",e),e=(new MarkdownMathJax).text_to_mathjax(e,{output:"svg"});let t=md.render(e);return t=finishView(t),t}info(...e){}}class MarkdownPreviewComponent{constructor(e,t){this.domSan=e,this.renderer=t,this.content="",this.render=!0}ngAfterViewInit(){this.renderMdToHTML()}renderMdToHTML(){if(!this.render)return;let e=(new MarkdownParse).parseToHTML(this.content);this.safeHTML=this.domSan.bypassSecurityTrustHtml(e);let t=this.renderer.createElement("div");t.innerHTML=e,this.renderer.appendChild(this.mdContent.nativeElement,t)}}MarkdownPreviewComponent.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:MarkdownPreviewComponent,deps:[{token:i1$1.DomSanitizer},{token:i0.Renderer2}],target:i0.ɵɵFactoryTarget.Component}),MarkdownPreviewComponent.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"14.0.0",version:"15.1.0",type:MarkdownPreviewComponent,selector:"fm-markdown-preview",inputs:{content:"content",render:"render"},viewQueries:[{propertyName:"mdContent",first:!0,predicate:["mdContent"],descendants:!0}],ngImport:i0,template:'<div class="message-body">\n <div *ngIf="render" #mdContent class="markdown-section">\n </div>\n <div *ngIf="!render" class="pre-section">\n {{content}}\n </div>\n</div>',styles:[":host{overflow-x:auto}.message-body div{text-align:left;overflow-x:auto}.message-body .pre-section{white-space:pre-wrap}.markdown-section blockquote{margin:0 0 .85em;padding:0 15px;color:#858585;border-left:4px solid #e5e5e5;border-left-color:#e5e5e5}\n"],dependencies:[{kind:"directive",type:i1$2.NgIf,selector:"[ngIf]",inputs:["ngIf","ngIfThen","ngIfElse"]}]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:MarkdownPreviewComponent,decorators:[{type:Component,args:[{selector:"fm-markdown-preview",template:'<div class="message-body">\n <div *ngIf="render" #mdContent class="markdown-section">\n </div>\n <div *ngIf="!render" class="pre-section">\n {{content}}\n </div>\n</div>',styles:[":host{overflow-x:auto}.message-body div{text-align:left;overflow-x:auto}.message-body .pre-section{white-space:pre-wrap}.markdown-section blockquote{margin:0 0 .85em;padding:0 15px;color:#858585;border-left:4px solid #e5e5e5;border-left-color:#e5e5e5}\n"]}]}],ctorParameters:function(){return[{type:i1$1.DomSanitizer},{type:i0.Renderer2}]},propDecorators:{content:[{type:Input}],mdContent:[{type:ViewChild,args:["mdContent"]}],render:[{type:Input}]}});class MarkdownPreviewModule{}MarkdownPreviewModule.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:MarkdownPreviewModule,deps:[],target:i0.ɵɵFactoryTarget.NgModule}),MarkdownPreviewModule.ɵmod=i0.ɵɵngDeclareNgModule({minVersion:"14.0.0",version:"15.1.0",ngImport:i0,type:MarkdownPreviewModule,declarations:[MarkdownPreviewComponent],imports:[CommonModule],exports:[MarkdownPreviewComponent]}),MarkdownPreviewModule.ɵinj=i0.ɵɵngDeclareInjector({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:MarkdownPreviewModule,imports:[CommonModule]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:MarkdownPreviewModule,decorators:[{type:NgModule,args:[{declarations:[MarkdownPreviewComponent],imports:[CommonModule],exports:[MarkdownPreviewComponent]}]}]});class ClipboardService{constructor(e){this.toastCtrl=e}copyToClipboard(e){var t;return __awaiter(this,void 0,void 0,(function*(){try{return yield Clipboard.write({string:e}),void this.copySuccess()}catch(o){try{if(navigator.clipboard&&window.isSecureContext)return yield null===(t=null===navigator||void 0===navigator?void 0:navigator.clipboard)||void 0===t?void 0:t.writeText(e),void this.copySuccess();throw!1}catch(t){let o=document.createElement("textarea");o.value=e,o.style.position="fixed",o.style.left="-9999px",o.style.top="-9999px",document.body.appendChild(o),o.focus(),o.select();try{(null===document||void 0===document?void 0:document.execCommand("copy"))?this.copySuccess():console.error("无法复制文本")}catch(e){console.error("无法复制文本: ",e)}document.body.removeChild(o)}}}))}copySuccess(){return __awaiter(this,void 0,void 0,(function*(){(yield this.toastCtrl.create({duration:1e3,message:"复制成功",color:"primary",icon:"information-circle",position:"top"})).present()}))}}function pcmtoWav(e,t,o,n){let i={chunkId:[82,73,70,70],chunkSize:0,format:[87,65,86,69],subChunk1Id:[102,109,116,32],subChunk1Size:16,audioFormat:1,numChannels:o||1,sampleRate:t||16e3,byteRate:0,blockAlign:0,bitsPerSample:n||16,subChunk2Id:[100,97,116,97],subChunk2Size:0};function u32ToArray(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]}function u16ToArray(e){return[255&e,e>>8&255]}let a=new Uint8Array(e);i.blockAlign=i.numChannels*i.bitsPerSample>>3,i.byteRate=i.blockAlign*i.sampleRate,i.subChunk2Size=a.length*(i.bitsPerSample>>3),i.chunkSize=36+i.subChunk2Size;let r=i.chunkId.concat(u32ToArray(i.chunkSize),i.format,i.subChunk1Id,u32ToArray(i.subChunk1Size),u16ToArray(i.audioFormat),u16ToArray(i.numChannels),u32ToArray(i.sampleRate),u32ToArray(i.byteRate),u16ToArray(i.blockAlign),u16ToArray(i.bitsPerSample),i.subChunk2Id,u32ToArray(i.subChunk2Size)),s=new Uint8Array(r),l=new Uint8Array(s.length+a.length);l.set(s),l.set(a,s.length);let c=new Blob([l],{type:"audio/wav"});return window.URL.createObjectURL(c)}function resampleAudio(e,t,o){let n=e.length,i=Math.floor(n/t*o),a=[];for(let n=0;n<i;n++){let i=Math.floor(n*(t/o));a[n]=e[i]}return a}function convertFrameBufferToBase64(e){const t=new Uint8Array(2*e.length);for(let o=0;o<e.length;o++){const n=e[o];t[2*o]=255&n,t[2*o+1]=n>>8&255}return btoa(String.fromCharCode.apply(null,t))}function resampleBuffer(e,t,o){const n=t/o,i=Math.round(e.length/n),a=new Int16Array(i);for(let t=0;t<i;t++){const o=Math.floor(t*n);a[t]=e[o]}return a}ClipboardService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ClipboardService,deps:[{token:i2.ToastController}],target:i0.ɵɵFactoryTarget.Injectable}),ClipboardService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ClipboardService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ClipboardService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[{type:i2.ToastController}]}});const SpeechRecognition=window.SpeechRecognition||window.webkitSpeechRecognition,SpeechGrammarList=window.SpeechGrammarList||window.webkitSpeechGrammarList;class WebSpeech{constructor(e){this.platform=e}startRecognition(e="Nihao | Hello"){if(!SpeechRecognition)return;if(this.recognition&&this.recognition.stop(),console.log("startRecognition"),this.recognition=new SpeechRecognition,!this.recognition)return;this.recognition.continuous=!0;let t=`#JSGF V1.0; grammar words; public <word> = ${e} ;`;this.recognition=new SpeechRecognition;let o=new SpeechGrammarList;o.addFromString(t,1),this.recognition.grammars=o,this.recognition.start(),this.recognition.onresult=e=>{var t,o,n,i,a,r,s;let l=e.results||[];console.log(l),console.log(null===(t=l[0])||void 0===t?void 0:t[0]),(null===(i=null===(n=null===(o=l[0])||void 0===o?void 0:o[0])||void 0===n?void 0:n.transcript)||void 0===i?void 0:i.indexOf("Nihao"))>-1&&console.log("Nihao成功唤醒"),(null===(s=null===(r=null===(a=l[0])||void 0===a?void 0:a[0])||void 0===r?void 0:r.transcript)||void 0===s?void 0:s.indexOf("Hello"))>-1&&console.log("Hello成功唤醒"),this.startRecognition()},this.recognition.onend=e=>{console.log(e)},this.recognition.onerror=e=>{console.error(e)}}speak(e,t=1,o=1.2,n=.8){this.platform.is("capacitor")||this.speakWithEdge(e,1,1.2,.8)}speakWithEdge(e,t=1,o=1.2,n=.8){let i=new SpeechSynthesisUtterance(e),a=this.getVoiceByName("Yaoyao");console.log(a),a&&(i.voice=a),i.rate=o,i.pitch=t,i.volume=10,window.speechSynthesis.speak(i)}getVoiceByName(e){return window.speechSynthesis.getVoices().find((t=>t.name.indexOf(e)>-1))}}class FmodeVoiceService{constructor(e,t){this.platform=e,this.diagnostic=t,this.webSpeech=WebSpeech,this.recordPcmBlob=null,this.recordType="pcm",this.encodingType="raw",this.connStatus="",this.btnStatus="UNDEFINED",this.resultText="",this.resultTextTemp="",this.APPID="23265215",this.API_SECRET="YzMzMWUzMmFkYjU2ZjE5OTc4M2Q1NjE1",this.API_KEY="8c58aa034946e1de30f2b145cf0cc3c3",this.requestPermission()}toggleRecord(){console.log(this.btnStatus),"UNDEFINED"===this.btnStatus||"CLOSED"===this.btnStatus?this.startTalk():"CONNECTING"!==this.btnStatus&&"OPEN"!==this.btnStatus||this.finishTalk()}finishTalk(){this.onBeforeFinishTalk&&this.onBeforeFinishTalk(),this.recordStop(),setTimeout((()=>{this.onAfterFinishTalk&&this.onAfterFinishTalk()}),1e3)}startTalk(e){return __awaiter(this,void 0,void 0,(function*(){this.onBeforeStartTalk&&this.onBeforeStartTalk(),null===event||void 0===event||event.preventDefault(),yield this.openWithPriviledge(),setTimeout((()=>{this.connectWebSocket()}),100),this.onAfterStartTalk&&this.onAfterStartTalk()}))}cancelTalk(){this.onBeforeCancelTalk&&this.onBeforeCancelTalk(),this.recordStop(),this.iatWS.close(),this.resultText=null,this.onAfterCancelTalk&&this.onAfterCancelTalk()}recordStart(){return __awaiter(this,void 0,void 0,(function*(){this.createRecorder(),yield this.openWithPriviledge(),this.recorder.start(),this.changeBtnStatus("OPEN")}))}recordStop(){var e;null===(e=this.recorder)||void 0===e||e.stop(((e,t)=>{this.iatWS.send(JSON.stringify({data:{status:2,format:"audio/L16;rate=16000",encoding:this.encodingType,audio:""}}));let o=(window.URL||webkitURL).createObjectURL(e);console.log(e,o,"时长:"+t+"ms"),this.recordPcmBlob=e,this.recorder.close(),this.recorder=null,console.log("localUrl",o)}),(e=>{console.log("录音失败:"+e),this.recorder.close(),this.recorder=null})),clearInterval(this.countdownInterval),this.changeBtnStatus("CLOSED")}playRecord(){this.playPCM(this.recordPcmBlob,44100)}playPCM(e,t){let o=new FileReader;o.onload=function(e){let o=pcmtoWav(e.target.result,t,1,16),n=new Audio;n.src=o,n.play()},o.readAsArrayBuffer(e)}playBuffers(){return __awaiter(this,void 0,void 0,(function*(){let e=yield this.BuffersToBlob(this.buffers);this.playPCM(e,44100)}))}BuffersToBlob(e){let t=[];return e.forEach((e=>{e.forEach((e=>{t.push(e)}))})),new Blob([t],{type:"audio/pcm"})}splitAudioData(e){const t=1280,o=Math.ceil(e.length/t),n=[];for(let i=0;i<o;i++){const o=i*t,a=o+t,r=e.slice(o,a);n.push(r)}return n}BufferToBlob(e){return new Blob([e],{type:"audio/pcm"})}createRecorder(){this.recorder||(this.recorder=Recorder({type:this.recordType,sampleRate:44100,bitRate:16,onProcess:(e,t,o,n,i,a)=>{var r;let s=e.length&&e[e.length-1];if(this.buffers=e,s=resampleBuffer(s,44100,16e3),this.iatWS.readyState===this.iatWS.OPEN){if(this.disableASR)return;this.iatWS.send(JSON.stringify({data:{status:1,format:"audio/L16;rate=16000",encoding:this.encodingType,audio:convertFrameBufferToBase64(s)}}))}null===(r=this.waveClient)||void 0===r||r.input(e[e.length-1],t,n)}}))}openWithPriviledge(){return __awaiter(this,void 0,void 0,(function*(){return console.log(this.btnStatus),yield this.requestPermission(),this.createRecorder(),!!Recorder.IsOpen()||new Promise((e=>{this.recorder.open((()=>{Recorder.WaveView&&(this.waveClient=Recorder.WaveView({elem:".record-wave"})),e(!0)}),((e,t)=>{console.log((t?"UserNotAllow,":"")+"无法录音:"+e)}))}))}))}getWebSocketUrl(){let e="wss://iat-api.xfyun.cn/v2/iat",t="iat-api.xfyun.cn",o=this.API_KEY,n=this.API_SECRET,i=(new Date).toUTCString(),a=`host: ${t}\ndate: ${i}\nGET /v2/iat HTTP/1.1`,r=CryptoJS.HmacSHA256(a,n),s=CryptoJS.enc.Base64.stringify(r);return e=`${e}?authorization=${btoa(`api_key="${o}", algorithm="hmac-sha256", headers="host date request-line", signature="${s}"`)}&date=${i}&host=${t}`,e}toBase64(e){for(var t="",o=new Uint8Array(e),n=o.byteLength,i=0;i<n;i++)t+=String.fromCharCode(o[i]);return window.btoa(t)}countdown(){let e=60;this.connStatus=`录音中(${e}s)`,this.countdownInterval=setInterval((()=>{e-=1,console.log(e),e<=0?(clearInterval(this.countdownInterval),this.recordStop()):this.connStatus=`录音中(${e}s)`}),1e3)}changeBtnStatus(e){this.btnStatus=e,"CONNECTING"===e?(this.connStatus="建立连接中",this.resultText="",this.resultTextTemp=""):"OPEN"===e?this.countdown():"CLOSING"===e?this.connStatus="关闭连接中":"CLOSED"===e&&(this.connStatus="开始录音")}renderResult(e){let t=JSON.parse(e);if(t.data&&t.data.result){let e=t.data.result,o="",n=e.ws;for(let e=0;e<n.length;e++)o+=n[e].cw[0].w,console.log(o);e.pgs?("apd"===e.pgs&&(this.resultText=this.resultTextTemp),this.resultTextTemp=this.resultText+o):this.resultText=this.resultText+o,this.resultTextTemp||this.resultText}0===t.code&&2===t.data.status&&this.iatWS.close(),0!==t.code&&(this.iatWS.close(),console.error(t))}connectWebSocket(){console.log("connectWebSocket");const e=this.getWebSocketUrl();if("WebSocket"in window)this.iatWS=new WebSocket(e);else if(!("MozWebSocket"in window))return void alert("浏览器不支持WebSocket");console.log("connectWebSocket",this.btnStatus),this.changeBtnStatus("CONNECTING"),this.iatWS.onopen=e=>{this.recordStart();var t={common:{app_id:this.APPID},business:{language:"zh_cn",domain:"iat",accent:"mandarin",vad_eos:5e3,dwa:"wpgs"},data:{status:0,format:"audio/L16;rate=16000",encoding:this.encodingType}};this.iatWS.send(JSON.stringify(t))},this.iatWS.onmessage=e=>{this.renderResult(e.data)},this.iatWS.onerror=e=>{console.error("error",e),this.recordStop(),this.changeBtnStatus("CLOSED")},this.iatWS.onclose=e=>{console.error("close",e),this.recordStop(),this.changeBtnStatus("CLOSED")}}isCapacitor(){return this.platform.is("capacitor")||this.platform.is("cordova")}requestPermission(){return __awaiter(this,void 0,void 0,(function*(){if(this.isCapacitor())try{yield this.requestStoagePermission(),yield this.requestCameraPermission(),yield this.requestMicPermission(),yield this.requestRecordAudioPermission()}catch(e){console.error(e)}}))}requestRecordAudioPermission(){return __awaiter(this,void 0,void 0,(function*(){let e=yield this.diagnostic.requestRuntimePermissions([this.diagnostic.permission.RECORD_AUDIO]);console.log("record permission request:",e)}))}requestMicPermission(){return __awaiter(this,void 0,void 0,(function*(){let e=yield this.diagnostic.isMicrophoneAuthorized();if(console.log("permisson_MIC:",e),!e){yield this.diagnostic.requestMicrophoneAuthorization()}}))}requestStoagePermission(){return __awaiter(this,void 0,void 0,(function*(){let e=yield this.diagnostic.isExternalStorageAuthorized();if(console.log("permisson_STORAGE:",e),!e){yield this.diagnostic.requestExternalStorageAuthorization()}}))}requestCameraPermission(){return __awaiter(this,void 0,void 0,(function*(){let e=yield this.diagnostic.isCameraAuthorized();if(console.log("permisson_Camera:",e),!e){yield this.diagnostic.requestCameraAuthorization()}}))}}FmodeVoiceService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmodeVoiceService,deps:[{token:i2.Platform},{token:i2$1.Diagnostic}],target:i0.ɵɵFactoryTarget.Injectable}),FmodeVoiceService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmodeVoiceService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmodeVoiceService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[{type:i2.Platform},{type:i2$1.Diagnostic}]}});class RolePointsCloud{constructor(e,t,o){this.offsetPosition=new BABYLON.Vector3(0,1.25,0),this.animationGroup=new BABYLON.AnimationGroup("RoleAnimGroup"),this.AnimMap={idle:null},this.scene=e,this.engine=this.engine}init(){return __awaiter(this,void 0,void 0,(function*(){this.Mesh=this.loadMesh(),this.loadIdleAnim()}))}playAnim(e){this.scene.beginDirectAnimation(this.Mesh,[this.AnimMap[e]],0,120,!0)}loadMesh(){let e=BABYLON.MeshBuilder.CreateSphere("sphere",{diameter:2},this.scene);return e.position.addInPlace(this.offsetPosition),e.visibility=1,e.material=new BABYLON.StandardMaterial("mat",this.scene),e.material.wireframe=!0,e.scaling=new BABYLON.Vector3(1,1,1),e}loadIdleAnim(){let e=new BABYLON.Animation("idle","scaling",30,BABYLON.Animation.ANIMATIONTYPE_VECTOR3,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE),t=[];t.push({frame:0,value:new BABYLON.Vector3(1,1,1)}),t.push({frame:60,value:new BABYLON.Vector3(1.5,1.5,1.5)}),t.push({frame:120,value:new BABYLON.Vector3(1,1,1)}),e.setKeys(t),this.Mesh.animations.push(this.AnimMap.idle),this.AnimMap.idle=e,this.animationGroup.addTargetedAnimation(this.AnimMap.idle,this.Mesh)}}class CompAvatarParticleComponent{constructor(e){this.elementRef=e,this.isWebVR=!1,this.animMap={}}ngAfterViewInit(){if(this.canvas=this.renderCanvas.nativeElement,console.log(this.canvas),this.canvas){let e={};this.engine=new BABYLON.Engine(this.canvas,!0,e),console.log(this.engine),this.createScene(),this.engine.runRenderLoop((()=>{var e,t;null===(e=this.scene)||void 0===e||e.render(),null===(t=this.engine)||void 0===t||t.resize()})),window.addEventListener("resize",(()=>{var e;null===(e=this.engine)||void 0===e||e.resize()}))}}createScene(){var e;return __awaiter(this,void 0,void 0,(function*(){this.scene=new BABYLON.Scene(this.engine),this.scene.clearColor=new BABYLON.Color4(0,0,0,1),this.mainCamera=this.createCamera(),console.log(this.mainCamera),this.currentRole=new RolePointsCloud(this.scene,this.engine,this.mainCamera),yield this.currentRole.init(),this.currentRole.playAnim("idle"),this.currentRole.Mesh.visibility=0,yield this.createCloudPoints();new BABYLON.HemisphericLight("light1",new BABYLON.Vector3(0,1,0),this.scene);null===(e=this.engine)||void 0===e||e.resize()}))}createCamera(){let e=new(this.isWebVR?BABYLON.VRDeviceOrientationArcRotateCamera:BABYLON.ArcRotateCamera)("Camera",0,0,30,new BABYLON.Vector3(0,.5,0),this.scene);return e.setPosition(new BABYLON.Vector3(0,0,5)),e.beta=Math.PI/3,e.alpha=Math.PI/1.2,e.radius=15,e}createCloudPoints(){return __awaiter(this,void 0,void 0,(function*(){this.pointsMesh=this.currentRole.Mesh,this.pointsCloud=new BABYLON.PointsCloudSystem("pcs",1,this.scene);let e=new BABYLON.Color3(.7,.8,1),t=new BABYLON.Color4(.7,.8,1),o=(new BABYLON.Color4(.2,.5,1),new BABYLON.Color4(0,0,.2,0),new BABYLON.Texture("/assets/avatar/particle/textures/flare.png",this.scene)),n=new BABYLON.PBRMaterial("material",this.scene);n.emissiveTexture=o,n.emissiveColor=e,this.pointsCloud.addVolumePoints(this.currentRole.Mesh,5e3,BABYLON.PointColor.Color,t),this.pointsCloud.buildMeshAsync().then((()=>{this.playAnimation("waiting")})),this.scene.registerAfterRender((()=>{this.pointsCloud.setParticles()})),this.engine.runRenderLoop((()=>{this.scene.render()}))}))}playAnimation(e){switch(e){case"waiting":this.cloudAnim();break;case"listening":this.cloudAnim({rotateSpeed:.01,breathing:!1});break;case"thinking":this.cloudAnim({rotateSpeed:.2,breathing:!1});break;case"talking":this.animMap.idle&&this.scene.beginDirectAnimation(this.pointsMesh,[this.animMap.talking],0,20,!0)}}cloudAnim(e={breathing:!0,rotateSpeed:.002}){this.animMap.idle&&this.scene.beginDirectAnimation(this.pointsMesh,[this.animMap.idle],0,120,!0);let t=new BABYLON.Color4(1,1,1,1),o=(new BABYLON.Texture("/assets/avatar/particle/textures/flare.png",this.scene),0);this.pointsCloud.updateParticle=n=>{var i,a,r,s;let l=null===(a=null===(i=this.currentRole.Mesh.getBoundingInfo())||void 0===i?void 0:i.boundingSphere)||void 0===a?void 0:a.radiusWorld,c=null===(s=null===(r=this.currentRole.Mesh.getBoundingInfo())||void 0===r?void 0:r.boundingSphere)||void 0===s?void 0:s.centerWorld;n.idx;if(n.color=t,n.rotation.y+=e.rotateSpeed,n&&o<3&&(console.log(this.currentRole.Mesh.getBoundingInfo()),console.log(n),o++),n.initpos||(n.initpos=n.position),e.breathing){let e=n.initpos.subtract(c);n.position=new BABYLON.Vector3(e.x*l,e.y*l,e.z*l).add(this.currentRole.offsetPosition)}return n}}createSphere(){let e=BABYLON.MeshBuilder.CreateSphere("sphere",{diameter:2},this.scene);e.visibility=1,e.material=new BABYLON.StandardMaterial("mat",this.scene),e.material.wireframe=!0,e.scaling=new BABYLON.Vector3(1,1,1),this.pointsMesh=e;let t=new BABYLON.Animation("breathingAnimation","scaling",30,BABYLON.Animation.ANIMATIONTYPE_VECTOR3,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE),o=[];o.push({frame:0,value:new BABYLON.Vector3(.3,.3,.3)}),o.push({frame:60,value:new BABYLON.Vector3(.5,.5,.5)}),o.push({frame:120,value:new BABYLON.Vector3(.3,.3,.3)}),t.setKeys(o),this.animMap.idle=t;let n=[{frame:0,value:BABYLON.Vector3.One()},{frame:10,value:new BABYLON.Vector3(1.2,.8,1.2)},{frame:20,value:BABYLON.Vector3.One()}],i=new BABYLON.Animation("talkAnimation","scaling",30,BABYLON.Animation.ANIMATIONTYPE_VECTOR3,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);return i.setKeys(n),this.animMap.talk=i,this.scene.beginDirectAnimation(e,[this.animMap.idle],0,120,!0),e}createParticle(){return __awaiter(this,void 0,void 0,(function*(){let e=this.createSphere(),t=new BABYLON.ParticleSystem("particles",2e3,this.scene);t.particleTexture=new BABYLON.Texture("/assets/avatar/particle/textures/flare.png",this.scene),t.emitter=e,t.minEmitBox=new BABYLON.Vector3(0,0,0),t.maxEmitBox=new BABYLON.Vector3(0,0,0),t.color1=new BABYLON.Color4(.7,.8,1,1),t.color2=new BABYLON.Color4(.2,.5,1,1),t.colorDead=new BABYLON.Color4(0,0,.2,0),t.minSize=.5,t.maxSize=.5,t.minLifeTime=.1,t.maxLifeTime=.1,t.minAngularSpeed=0,t.maxAngularSpeed=Math.PI,t.minInitialRotation=0,t.maxInitialRotation=Math.PI,t.minEmitPower=0,t.maxEmitPower=0,t.emitRate=1500,t.updateSpeed=.01,t.blendMode=BABYLON.ParticleSystem.BLENDMODE_ONEONE,t.direction1=new BABYLON.Vector3(0,0,0),t.direction2=new BABYLON.Vector3(0,0,0),t.start();let o=t.createSphereEmitter();o.radius=2,o.radiusRange=0,o.directionRandomizer=0,t.gravity=new BABYLON.Vector3(0,0,0),t.disposeOnStop=!0,t.updateFunction=o=>{var n,i;for(let a=0;a<o.length;a++){let r=o[a],s=null===(i=null===(n=e.getBoundingInfo())||void 0===n?void 0:n.boundingSphere)||void 0===i?void 0:i.radiusWorld;r.position=r.position.normalize().scale(s),r.age+=this.scene.getEngine().getDeltaTime()/1e3,r.age>=r.lifeTime&&(t.recycleParticle(r),a--)}},this.engine.runRenderLoop((()=>{this.scene.render(),t.worldOffset=e.position}))}))}setCameraToMeshCenter(e,t){t.computeWorldMatrix(!0);let o=t.getBoundingInfo(),n=o.minimum,i=o.maximum,a=i.x-n.x,r=i.y-n.y,s=i.z-n.z,l=o.boundingBox.center;console.log("宽度:"+a),console.log("高度:"+r),console.log("深度:"+s),console.log("中心点:"+l)}}CompAvatarParticleComponent.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompAvatarParticleComponent,deps:[{token:i0.ElementRef}],target:i0.ɵɵFactoryTarget.Component}),CompAvatarParticleComponent.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"14.0.0",version:"15.1.0",type:CompAvatarParticleComponent,isStandalone:!0,selector:"fm-avatar-role-particle",viewQueries:[{propertyName:"renderCanvas",first:!0,predicate:["renderCanvas"],descendants:!0}],ngImport:i0,template:'<canvas #renderCanvas class="render-canvas"></canvas>',styles:[".render-canvas{display:block;width:100%;height:100%;touch-action:none}\n"],dependencies:[{kind:"ngmodule",type:CommonModule},{kind:"ngmodule",type:FormsModule}]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompAvatarParticleComponent,decorators:[{type:Component,args:[{selector:"fm-avatar-role-particle",standalone:!0,imports:[CommonModule,FormsModule],template:'<canvas #renderCanvas class="render-canvas"></canvas>',styles:[".render-canvas{display:block;width:100%;height:100%;touch-action:none}\n"]}]}],ctorParameters:function(){return[{type:i0.ElementRef}]},propDecorators:{renderCanvas:[{type:ViewChild,args:["renderCanvas"]}]}});class CompAvatarRoleImageComponent{constructor(){this.animClass="waiting"}playWave(){!this.wave&&Recorder.WaveView&&(this.wave=Recorder.WaveView({elem:".record-wave-avatar",keep:!1}));let e=function generatePowerLevel(){return 100*Math.random()}();this.waveInterval=setInterval((()=>{let t=function generateSampleRate(){const e=[44100,48e3,88200,96e3];return e[Math.floor(Math.random()*e.length)]}(),o=function generatePcmData(e){const t=[];for(let o=0;o<e;o++)t.push(Math.floor(65536*Math.random())-32768);return t}(1e3);this.wave.input(o,e,t)}),40)}stopWave(){clearInterval(this.waveInterval)}ngAfterViewInit(){}ngOnInit(){setTimeout((()=>{this.fmodeChat.playAnimation=this.playAnimation}),1500)}playAnimation(){let e=this;return t=>{let o=e.avatarImage.nativeElement;switch(e.animClass=t,e.stopWave(),t){case"thinking":case"waiting":o.style.animationPlayState="running";break;case"talking":o.style.animationPlayState="running",e.playWave();break;case"listening":o.style.animationPlayState="pause";break;default:o.style.animationPlayState="paused"}}}}CompAvatarRoleImageComponent.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompAvatarRoleImageComponent,deps:[],target:i0.ɵɵFactoryTarget.Component}),CompAvatarRoleImageComponent.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"14.0.0",version:"15.1.0",type:CompAvatarRoleImageComponent,isStandalone:!0,selector:"fm-avatar-role-image",inputs:{fmodeChat:"fmodeChat",role:"role"},viewQueries:[{propertyName:"avatarImage",first:!0,predicate:["avatarImage"],descendants:!0}],ngImport:i0,template:'<div class="page">\n <div class="avatar" [class]="animClass">\n <div class="avatar-photo">\n <img #avatarImage [src]="role?.get(\'thumb\')" alt="">\n \x3c!-- 音频波动 --\x3e\n <div class="record-wave-avatar">\n </div>\n </div>\n </div>\n</div>',styles:[".page{position:fixed;width:100vw;height:100vh;top:0;left:0;display:flex;justify-content:center;align-items:center;background-color:#000}.avatar{height:50vh;width:100%;display:flex;justify-content:center;align-items:center}.avatar .avatar-photo{position:relative;margin-top:-10vh;width:80%}.avatar .avatar-photo img{border-radius:10px}.avatar .record-wave-avatar{height:50px;width:100%;position:absolute;float:left;left:0;bottom:0}.thinking,.listening,.waiting,.talking{animation-duration:2s;animation-play-state:running;animation-iteration-count:infinite;animation-timing-function:ease-in-out}@keyframes waitingAnimation{0%{transform:scale(1)}50%{transform:scale(1.05)}to{transform:scale(1)}}@keyframes thinkingAnimation{0%{transform:rotate(0)}30%{transform:rotate(10deg)}60%{transform:rotate(-10deg)}to{transform:rotate(0)}}.thinking{animation-name:thinkingAnimation}.waiting{animation-name:waitingAnimation}.listening{animation-name:listeningAnimation}.talking{animation-name:talkingAnimation}\n"],dependencies:[{kind:"ngmodule",type:CommonModule},{kind:"ngmodule",type:FormsModule}]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompAvatarRoleImageComponent,decorators:[{type:Component,args:[{selector:"fm-avatar-role-image",standalone:!0,imports:[CommonModule,FormsModule],template:'<div class="page">\n <div class="avatar" [class]="animClass">\n <div class="avatar-photo">\n <img #avatarImage [src]="role?.get(\'thumb\')" alt="">\n \x3c!-- 音频波动 --\x3e\n <div class="record-wave-avatar">\n </div>\n </div>\n </div>\n</div>',styles:[".page{position:fixed;width:100vw;height:100vh;top:0;left:0;display:flex;justify-content:center;align-items:center;background-color:#000}.avatar{height:50vh;width:100%;display:flex;justify-content:center;align-items:center}.avatar .avatar-photo{position:relative;margin-top:-10vh;width:80%}.avatar .avatar-photo img{border-radius:10px}.avatar .record-wave-avatar{height:50px;width:100%;position:absolute;float:left;left:0;bottom:0}.thinking,.listening,.waiting,.talking{animation-duration:2s;animation-play-state:running;animation-iteration-count:infinite;animation-timing-function:ease-in-out}@keyframes waitingAnimation{0%{transform:scale(1)}50%{transform:scale(1.05)}to{transform:scale(1)}}@keyframes thinkingAnimation{0%{transform:rotate(0)}30%{transform:rotate(10deg)}60%{transform:rotate(-10deg)}to{transform:rotate(0)}}.thinking{animation-name:thinkingAnimation}.waiting{animation-name:waitingAnimation}.listening{animation-name:listeningAnimation}.talking{animation-name:talkingAnimation}\n"]}]}],propDecorators:{avatarImage:[{type:ViewChild,args:["avatarImage"]}],fmodeChat:[{type:Input}],role:[{type:Input}]}});class FmodeTTS{constructor(e){this.subscriptionKey=null==e?void 0:e.subscriptionKey,this.authorizationToken=null==e?void 0:e.token,this.region=null==e?void 0:e.region,this.subscriptionKey&&(this.speechConfig=sdk.SpeechConfig.fromSubscription(this.subscriptionKey,this.region)),this.authorizationToken&&(this.speechConfig=sdk.SpeechConfig.fromAuthorizationToken(this.authorizationToken,this.region),console.log(this.authorizationToken,this.speechConfig)),console.log(this.speechConfig),this.synthesizer=new sdk.SpeechSynthesizer(this.speechConfig)}extractSSMLContent(e){var t=e.match(/<speak.*?<\/speak>/);return t?t[0]:e}speakAsync(e){return __awaiter(this,void 0,void 0,(function*(){return e=this.extractSSMLContent(e),new Promise(((t,o)=>{const n=Date.now();let i="speakTextAsync";(null==e?void 0:e.indexOf("<"))>-1&&(i="speakSsmlAsync"),console.log(e),this.synthesizer[i](e,(e=>{if(console.log(e),console.log(e.resultId),console.log(e.reason),e.reason===sdk.ResultReason.SynthesizingAudioCompleted){const o=Date.now();let i=null==e?void 0:e.audioData;this.playAudioData(i),console.log(`Audio synthesis finished. Duration: ${o-n} ms`),t()}else o(`Speech synthesis failed. Reason: ${e.errorDetails}`)}),(e=>{o(`Error occurred during synthesis: ${e}`)}))}))}))}onBreak(e){}playAudioData(e){let t=new Blob([e],{type:"audio/wav"}),o=URL.createObjectURL(t);new Audio(o).play()}}class ModalChatVoiceInputComponent{constructor(e,t,o,n,i,a){this.platform=e,this.router=t,this.voiceServ=o,this.toastCtrl=n,this.ncloud=i,this.chatServ=a,this.talkMode="click",this.talkTips="点击话筒开始讲话",this.errorText="",this.player=new Audio}ngOnInit(){"press"==this.talkMode&&(this.talkTips="轻触底部开始讲话"),setTimeout((()=>{this.initVoiceSevice(),this.initVoiceASR()}),500)}initVoiceASR(){return __awaiter(this,void 0,void 0,(function*(){this.voiceServ.requestPermission().then((()=>{this.voiceServ.openWithPriviledge(),this.startASRAwake()}))}))}startASRAwake(){return __awaiter(this,void 0,void 0,(function*(){yield this.voiceServ.openWithPriviledge(),new this.voiceServ.webSpeech(this.platform).startRecognition("Nihao | Hello")}))}playMusic(e){this.player.src=`/assets/avatar/voice/${e}.mp3`,this.player.play()}initVoiceSevice(){this.fmodeChat.userInput=this.voiceServ.resultText,this.voiceServ.requestPermission().then((()=>{this.voiceServ.openWithPriviledge()})),this.voiceServ.onBeforeStartTalk=()=>{this.fmodeChat.playAnimation("listening"),this.playMusic("start-talk")},this.voiceServ.onBeforeCancelTalk=()=>{this.playMusic("interupt-talk"),this.fmodeChat.playAnimation("waiting")},this.voiceServ.onAfterCancelTalk=()=>{this.startASRAwake()},this.voiceServ.onBeforeFinishTalk=()=>{this.fmodeChat.playAnimation("thinking"),this.playMusic("stop-talk")},this.voiceServ.onAfterFinishTalk=()=>{var e;console.log("onAfterFinishTalk"),this.fmodeChat.userInput=null===(e=this.voiceServ)||void 0===e?void 0:e.resultText,this.sendMessage(),this.startASRAwake()}}sendMessage(){var e;return __awaiter(this,void 0,void 0,(function*(){if(!this.fmodeChat.userInput){return this.errorText="内容不能为空",void(yield this.toastCtrl.create({message:this.errorText,position:"top",icon:"alert",color:"warning-circle",duration:1e3})).present()}null===(e=this.fmodeChat)||void 0===e||e.sendMessage(this.voiceServ.resultText,null,(e=>{let t=e.content;this.playTTS(t),this.fmodeChat.playAnimation("talking"),setTimeout((()=>{this.fmodeChat.playAnimation("waiting")}),6e3)})),this.fmodeChat.userInput="",this.fmodeChat.userImage=""}))}initTTS(){return __awaiter(this,void 0,void 0,(function*(){let e=yield this.ncloud.apig("voice/voice/tts/token",{company:localStorage.getItem("company")});if(console.log(e),null==e?void 0:e.token){let t=new FmodeTTS(e);this.tts=t}}))}playTTS(e){return __awaiter(this,void 0,void 0,(function*(){if(yield this.initTTS(),console.log(this.tts),this.tts)try{yield this.tts.speakAsync(e)}catch(e){console.error(e)}}))}playTTSTeting(){this.playTTS('<speak xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="http://www.w3.org/2001/mstts" xmlns:emo="http://www.w3.org/2009/10/emotionml" version="1.0" xml:lang="zh-CN">\n <voice name="zh-CN-XiaoxiaoNeural"><mstts:express-as style="angry">”好没意思的话!去不去,关我什么事儿?又没叫你替我解闷儿,还许你<mstts:ttsbreak strength="none" />从此<prosody contour="(24%, +49%) (59%, -2%)">不</prosody><prosody rate="-15.00%" contour="(24%, +49%) (59%, -2%)">理</prosody><prosody contour="(24%, +49%) (59%, -2%)">我呢</prosody>!”</mstts:express-as></voice>\n </speak>')}testTTS(e){console.log(e),e=e||"你好呀,我是飞马小智!很高兴为您介绍脑控科技的发展历程。我们成立于2019年",new this.voiceServ.webSpeech(this.platform).speak(e)}testXunfeiTTS(){}}ModalChatVoiceInputComponent.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ModalChatVoiceInputComponent,deps:[{token:i2.Platform},{token:i3.Router},{token:FmodeVoiceService},{token:i2.ToastController},{token:NovaCloudService},{token:ChatService}],target:i0.ɵɵFactoryTarget.Component}),ModalChatVoiceInputComponent.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"14.0.0",version:"15.1.0",type:ModalChatVoiceInputComponent,isStandalone:!0,selector:"fm-modal-chat-voice-input",inputs:{fmodeChat:"fmodeChat",talkMode:"talkMode"},ngImport:i0,template:' \n <ng-container *ngIf="fmodeChat">\n\n \x3c!-- 用户输入 提示区域 --\x3e\n <div class="user-asr-input" style="text-align: center;" *ngIf="!fmodeChat?.userInput && voiceServ.btnStatus!=\'OPEN\'">{{talkTips}}</div>\n <div class="user-asr-input">{{fmodeChat?.userInput}}</div>\n \n \x3c!-- 测试按钮 --\x3e\n <div class="test-button-group" *ngIf="false">\n <button class="button-record" (click)="voiceServ.toggleRecord()">开始录制 {{voiceServ.connStatus}} {{voiceServ.btnStatus}}</button>\n <br>\n <button class="button-record" (click)="voiceServ.playRecord()">播放录制结果</button>\n <br>\n <button class="button-record" (click)="voiceServ.playBuffers()">播放Buffers结果</button>\n <button (click)="testTTS()">测试TTS纯WEB</button>\n <button (click)="startASR()">测试ASR</button> \n <button (click)="testXunfeiTTS()">测试合成</button> \n </div>\n\n \n \n \x3c!-- 交互按钮 --\x3e\n <ion-fab slot="fixed" horizontal="center" vertical="bottom">\n <ng-container *ngIf="talkMode==\'click\'">\n \x3c!-- 默认按钮:开始讲话 --\x3e\n <ion-fab-button color="primary" closeIcon="checkmark" (click)="voiceServ.toggleRecord()">\n <ion-icon name="mic-outline"></ion-icon>\n </ion-fab-button>\n\n \x3c!-- 讲话中:取消发送 --\x3e\n <ion-fab-list side="end">\n <ion-fab-button [class]="\'loading\'" (click)="voiceServ.cancelTalk()">\n <ion-icon name="pause-outline"></ion-icon>\n </ion-fab-button>\n </ion-fab-list>\n </ng-container>\n \n <ng-container *ngIf="talkMode==\'press\'">\n <ion-fab-button color="primary" closeIcon="mic-outline" (touchstart)="voiceServ.toggleRecord()" (touchend)="voiceServ.cancelTalk()">\n <ion-icon name="mic-outline"></ion-icon>\n </ion-fab-button>\n </ng-container>\n </ion-fab>\n\n\n \x3c!-- 音频波动 --\x3e\n <div class="record-wave">\n </div>\n</ng-container>\n',styles:['ion-fab{margin-bottom:15vh}.fab-button-close-active:before{content:"";position:absolute;top:-5px;left:-5px;width:66px;height:66px;border-radius:50%;border:5px solid #fff;border-top-color:transparent;animation:spin 2s ease-in-out infinite;animation-fill-mode:both;animation-play-state:running}.record-wave{position:fixed;bottom:0;width:100vw;height:6vh}\n'],dependencies:[{kind:"ngmodule",type:CommonModule},{kind:"directive",type:i1$2.NgIf,selector:"[ngIf]",inputs:["ngIf","ngIfThen","ngIfElse"]},{kind:"ngmodule",type:IonicModule},{kind:"component",type:i2.IonFab,selector:"ion-fab",inputs:["activated","edge","horizontal","vertical"]},{kind:"component",type:i2.IonFabButton,selector:"ion-fab-button",inputs:["activated","closeIcon","color","disabled","download","href","mode","rel","routerAnimation","routerDirection","show","size","target","translucent","type"]},{kind:"component",type:i2.IonFabList,selector:"ion-fab-list",inputs:["activated","side"]},{kind:"component",type:i2.IonIcon,selector:"ion-icon",inputs:["color","flipRtl","icon","ios","lazy","md","mode","name","sanitize","size","src"]},{kind:"ngmodule",type:RouterModule}]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ModalChatVoiceInputComponent,decorators:[{type:Component,args:[{selector:"fm-modal-chat-voice-input",standalone:!0,imports:[CommonModule,IonicModule,RouterModule],template:' \n <ng-container *ngIf="fmodeChat">\n\n \x3c!-- 用户输入 提示区域 --\x3e\n <div class="user-asr-input" style="text-align: center;" *ngIf="!fmodeChat?.userInput && voiceServ.btnStatus!=\'OPEN\'">{{talkTips}}</div>\n <div class="user-asr-input">{{fmodeChat?.userInput}}</div>\n \n \x3c!-- 测试按钮 --\x3e\n <div class="test-button-group" *ngIf="false">\n <button class="button-record" (click)="voiceServ.toggleRecord()">开始录制 {{voiceServ.connStatus}} {{voiceServ.btnStatus}}</button>\n <br>\n <button class="button-record" (click)="voiceServ.playRecord()">播放录制结果</button>\n <br>\n <button class="button-record" (click)="voiceServ.playBuffers()">播放Buffers结果</button>\n <button (click)="testTTS()">测试TTS纯WEB</button>\n <button (click)="startASR()">测试ASR</button> \n <button (click)="testXunfeiTTS()">测试合成</button> \n </div>\n\n \n \n \x3c!-- 交互按钮 --\x3e\n <ion-fab slot="fixed" horizontal="center" vertical="bottom">\n <ng-container *ngIf="talkMode==\'click\'">\n \x3c!-- 默认按钮:开始讲话 --\x3e\n <ion-fab-button color="primary" closeIcon="checkmark" (click)="voiceServ.toggleRecord()">\n <ion-icon name="mic-outline"></ion-icon>\n </ion-fab-button>\n\n \x3c!-- 讲话中:取消发送 --\x3e\n <ion-fab-list side="end">\n <ion-fab-button [class]="\'loading\'" (click)="voiceServ.cancelTalk()">\n <ion-icon name="pause-outline"></ion-icon>\n </ion-fab-button>\n </ion-fab-list>\n </ng-container>\n \n <ng-container *ngIf="talkMode==\'press\'">\n <ion-fab-button color="primary" closeIcon="mic-outline" (touchstart)="voiceServ.toggleRecord()" (touchend)="voiceServ.cancelTalk()">\n <ion-icon name="mic-outline"></ion-icon>\n </ion-fab-button>\n </ng-container>\n </ion-fab>\n\n\n \x3c!-- 音频波动 --\x3e\n <div class="record-wave">\n </div>\n</ng-container>\n',styles:['ion-fab{margin-bottom:15vh}.fab-button-close-active:before{content:"";position:absolute;top:-5px;left:-5px;width:66px;height:66px;border-radius:50%;border:5px solid #fff;border-top-color:transparent;animation:spin 2s ease-in-out infinite;animation-fill-mode:both;animation-play-state:running}.record-wave{position:fixed;bottom:0;width:100vw;height:6vh}\n']}]}],ctorParameters:function(){return[{type:i2.Platform},{type:i3.Router},{type:FmodeVoiceService},{type:i2.ToastController},{type:NovaCloudService},{type:ChatService}]},propDecorators:{fmodeChat:[{type:Input}],talkMode:[{type:Input}]}});class CompAvatarTalkComponent{constructor(e,t,o,n,i,a,r){this.voiceServ=e,this.platform=t,this.router=o,this.navCtrl=n,this.route=i,this.chatServ=a,this.ncloud=r,this.route.paramMap.subscribe((e=>{this.roleId=e.get("roleId"),this.loadAvatarRole(this.roleId)})),document.body.classList.add("dark")}ngOnInit(){}ngOnDestroy(){document.body.classList.remove("dark"),this.voiceServ.resultText=null,this.fmodeChat&&(this.fmodeChat.latestAIResponse=null)}goBack(){document.body.classList.remove("dark"),this.navCtrl.navigateRoot("/chat/pro/role/"+this.roleId)}loadAvatarRole(e){return __awaiter(this,void 0,void 0,(function*(){let t=new Parse.Query("AvatarRole");this.avatarRole=yield t.get(e);let o=yield this.chatServ.createNewRoleChat(this.roleId);o.isTalkMode=!0,this.fmodeChat=o}))}ngAfterViewInit(){this.listenDivChange()}listenDivChange(){new MutationObserver((()=>{this.scrollToBottom(this.aiRespComp)})).observe(this.aiRespComp.nativeElement,{childList:!0,subtree:!0,attributes:!0})}scrollToBottom(e){var t;(null===(t=null==e?void 0:e.nativeElement)||void 0===t?void 0:t.scrollHeight)&&(e.nativeElement.scrollTop=e.nativeElement.scrollHeight)}}CompAvatarTalkComponent.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompAvatarTalkComponent,deps:[{token:FmodeVoiceService},{token:i2.Platform},{token:i3.Router},{token:i2.NavController},{token:i3.ActivatedRoute},{token:ChatService},{token:NovaCloudService}],target:i0.ɵɵFactoryTarget.Component}),CompAvatarTalkComponent.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"14.0.0",version:"15.1.0",type:CompAvatarTalkComponent,isStandalone:!0,selector:"app-comp-avatar-talk",providers:[FmodeVoiceService,NovaCloudService,ChatService,Diagnostic],viewQueries:[{propertyName:"avatarComp",first:!0,predicate:["avatar"],descendants:!0},{propertyName:"aiRespComp",first:!0,predicate:["aiRespComp"],descendants:!0}],ngImport:i0,template:'<ion-menu #menu contentId="main-content" side="end">\n <ion-header>\n <ion-toolbar>\n <ion-title>资料</ion-title>\n </ion-toolbar>\n </ion-header>\n <ion-content class="ion-padding">\n\n <ion-card style="margin: 0px;">\n <img [src]="avatarRole?.get(\'thumb\')" alt="">\n <ion-card-header>\n <ion-card-subtitle>{{avatarRole?.get(\'tags\')}}</ion-card-subtitle>\n <ion-card-title>{{avatarRole?.get("name")}}</ion-card-title>\n </ion-card-header>\n \n <ion-card-content>\n {{avatarRole?.get("desc")}}\n\n <ion-list [inset]="true" style="margin:0px;">\n \x3c!-- <ion-item>\n <ion-avatar *ngIf="avatarRole?.get(\'thumb\')" aria-hidden="true" slot="start">\n <img [src]="avatarRole?.get(\'thumb\')" />\n </ion-avatar>\n <ion-label>{{avatarRole?.get("name")}}</ion-label>\n </ion-item> --\x3e\n <ion-item lines="none" *ngIf="avatarRole?.get(\'age\')">\n <ion-note slot="start">年龄</ion-note>\n <ion-label>{{avatarRole?.get("age")}}</ion-label>\n </ion-item>\n <ion-item lines="none" *ngIf="avatarRole?.get(\'gender\')">\n <ion-note slot="start">性别</ion-note>\n <ion-label>{{avatarRole?.get("gender")}}</ion-label>\n </ion-item>\n <ion-item lines="none">\n <ion-note slot="start">称号</ion-note>\n <ion-label>{{avatarRole?.get("title")}}</ion-label>\n </ion-item>\n \n <ion-item lines="none">\n <ion-note slot="start">擅长</ion-note>\n <ion-label>{{avatarRole?.get("tags")?.join(\',\')}}</ion-label>\n </ion-item>\n\n </ion-list>\n </ion-card-content>\n </ion-card>\n \n \n \n </ion-content>\n</ion-menu>\n\n<div class="ion-page" id="main-content">\n <ion-header class="ion-no-border">\n <ion-toolbar>\n <ion-buttons slot="start">\n <ion-button (click)="goBack()"> <ion-icon name="chevron-back-outline"></ion-icon> </ion-button>\n </ion-buttons>\n <ion-title>\n <ion-chip *ngIf="avatarRole?.get(\'title\')">{{avatarRole?.get("title")}}</ion-chip>\n </ion-title>\n <ion-buttons slot="end">\n \x3c!-- <ion-button (click)="playTTSTeting()">TTS测试</ion-button> --\x3e\n {{avatarRole?.get("name")}}\n <ion-button (click)="menu.toggle()"> <ion-icon name="ellipsis-horizontal-outline"></ion-icon> </ion-button>\n </ion-buttons>\n </ion-toolbar>\n </ion-header>\n\n <ion-segment value="voice">\n <ion-segment-button (click)="chatServ.createChatPanel(avatarRole)" value="chat">\n <ion-label>聊天</ion-label>\n </ion-segment-button>\n <ion-segment-button routerLink="{{\'/avatar/role/\'+avatarRole?.id}}" value="voice">\n <ion-label>语音</ion-label>\n </ion-segment-button>\n </ion-segment>\n\n \x3c!-- 数字形象:动画效果 --\x3e\n <fm-avatar-role-image *ngIf="avatarRole&&fmodeChat" [fmodeChat]="fmodeChat" [role]="avatarRole" #avatar class="avatar"></fm-avatar-role-image>\n \x3c!-- <fm-avatar-role-particle #avatar class="avatar"></fm-avatar-role-particle> --\x3e\n\n \x3c!-- AI回复的最新消息 --\x3e\n <div class="ai-resp-input" #aiRespComp>{{fmodeChat?.latestAIResponse | hidexml}}</div>\n\n <fm-modal-chat-voice-input *ngIf="fmodeChat" [fmodeChat]="fmodeChat"></fm-modal-chat-voice-input>\n\n</div>\n\n',styles:["ion-menu ion-note{color:#ccc;font-weight:700}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.avatar{display:block;width:100%;height:100%}.ai-resp-input{font-size:1rem;color:#fff;position:fixed;top:5vh;max-height:15vh;overflow-y:scroll;padding:0 10px}.user-asr-input{font-size:1rem;color:#fff;position:fixed;bottom:6vh;padding:0 10px}.test-button-group{color:#00f;position:fixed;bottom:20vh}.test-button-group button{padding:10px;margin:10px}\n"],dependencies:[{kind:"ngmodule",type:CommonModule},{kind:"directive",type:i1$2.NgIf,selector:"[ngIf]",inputs:["ngIf","ngIfThen","ngIfElse"]},{kind:"ngmodule",type:RouterModule},{kind:"directive",type:i3.RouterLink,selector:"[routerLink]",inputs:["target","queryParams","fragment","queryParamsHandling","state","relativeTo","preserveFragment","skipLocationChange","replaceUrl","routerLink"]},{kind:"ngmodule",type:FormsModule},{kind:"ngmodule",type:IonicModule},{kind:"component",type:i2.IonButton,selector:"ion-button",inputs:["buttonType","color","disabled","download","expand","fill","form","href","mode","rel","routerAnimation","routerDirection","shape","size","strong","target","type"]},{kind:"component",type:i2.IonButtons,selector:"ion-buttons",inputs:["collapse"]},{kind:"component",type:i2.IonCard,selector:"ion-card",inputs:["button","color","disabled","download","href","mode","rel","routerAnimation","routerDirection","target","type"]},{kind:"component",type:i2.IonCardContent,selector:"ion-card-content",inputs:["mode"]},{kind:"component",type:i2.IonCardHeader,selector:"ion-card-header",inputs:["color","mode","translucent"]},{kind:"component",type:i2.IonCardSubtitle,selector:"ion-card-subtitle",inputs:["color","mode"]},{kind:"component",type:i2.IonCardTitle,selector:"ion-card-title",inputs:["color","mode"]},{kind:"component",type:i2.IonChip,selector:"ion-chip",inputs:["color","disabled","mode","outline"]},{kind:"component",type:i2.IonContent,selector:"ion-content",inputs:["color","forceOverscroll","fullscreen","scrollEvents","scrollX","scrollY"]},{kind:"component",type:i2.IonHeader,selector:"ion-header",inputs:["collapse","mode","translucent"]},{kind:"component",type:i2.IonIcon,selector:"ion-icon",inputs:["color","flipRtl","icon","ios","lazy","md","mode","name","sanitize","size","src"]},{kind:"component",type:i2.IonItem,selector:"ion-item",inputs:["button","color","counter","counterFormatter","detail","detailIcon","disabled","download","fill","href","lines","mode","rel","routerAnimation","routerDirection","shape","target","type"]},{kind:"component",type:i2.IonLabel,selector:"ion-label",inputs:["color","mode","position"]},{kind:"component",type:i2.IonList,selector:"ion-list",inputs:["inset","lines","mode"]},{kind:"component",type:i2.IonMenu,selector:"ion-menu",inputs:["contentId","disabled","maxEdgeStart","menuId","side","swipeGesture","type"]},{kind:"component",type:i2.IonNote,selector:"ion-note",inputs:["color","mode"]},{kind:"component",type:i2.IonSegment,selector:"ion-segment",inputs:["color","disabled","mode","scrollable","selectOnFocus","swipeGesture","value"]},{kind:"component",type:i2.IonSegmentButton,selector:"ion-segment-button",inputs:["disabled","layout","mode","type","value"]},{kind:"component",type:i2.IonTitle,selector:"ion-title",inputs:["color","size"]},{kind:"component",type:i2.IonToolbar,selector:"ion-toolbar",inputs:["color","mode"]},{kind:"directive",type:i2.SelectValueAccessor,selector:"ion-range, ion-select, ion-radio-group, ion-segment, ion-datetime"},{kind:"directive",type:i2.RouterLinkDelegate,selector:":not(a):not(area)[routerLink]",inputs:["routerDirection","routerAnimation"]},{kind:"component",type:CompAvatarRoleImageComponent,selector:"fm-avatar-role-image",inputs:["fmodeChat","role"]},{kind:"component",type:ModalChatVoiceInputComponent,selector:"fm-modal-chat-voice-input",inputs:["fmodeChat","talkMode"]},{kind:"pipe",type:HidexmlPipe,name:"hidexml"}]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompAvatarTalkComponent,decorators:[{type:Component,args:[{selector:"app-comp-avatar-talk",standalone:!0,imports:[CommonModule,RouterModule,FormsModule,IonicModule,CompAvatarParticleComponent,CompAvatarRoleImageComponent,ModalChatVoiceInputComponent,HidexmlPipe],providers:[FmodeVoiceService,NovaCloudService,ChatService,Diagnostic],template:'<ion-menu #menu contentId="main-content" side="end">\n <ion-header>\n <ion-toolbar>\n <ion-title>资料</ion-title>\n </ion-toolbar>\n </ion-header>\n <ion-content class="ion-padding">\n\n <ion-card style="margin: 0px;">\n <img [src]="avatarRole?.get(\'thumb\')" alt="">\n <ion-card-header>\n <ion-card-subtitle>{{avatarRole?.get(\'tags\')}}</ion-card-subtitle>\n <ion-card-title>{{avatarRole?.get("name")}}</ion-card-title>\n </ion-card-header>\n \n <ion-card-content>\n {{avatarRole?.get("desc")}}\n\n <ion-list [inset]="true" style="margin:0px;">\n \x3c!-- <ion-item>\n <ion-avatar *ngIf="avatarRole?.get(\'thumb\')" aria-hidden="true" slot="start">\n <img [src]="avatarRole?.get(\'thumb\')" />\n </ion-avatar>\n <ion-label>{{avatarRole?.get("name")}}</ion-label>\n </ion-item> --\x3e\n <ion-item lines="none" *ngIf="avatarRole?.get(\'age\')">\n <ion-note slot="start">年龄</ion-note>\n <ion-label>{{avatarRole?.get("age")}}</ion-label>\n </ion-item>\n <ion-item lines="none" *ngIf="avatarRole?.get(\'gender\')">\n <ion-note slot="start">性别</ion-note>\n <ion-label>{{avatarRole?.get("gender")}}</ion-label>\n </ion-item>\n <ion-item lines="none">\n <ion-note slot="start">称号</ion-note>\n <ion-label>{{avatarRole?.get("title")}}</ion-label>\n </ion-item>\n \n <ion-item lines="none">\n <ion-note slot="start">擅长</ion-note>\n <ion-label>{{avatarRole?.get("tags")?.join(\',\')}}</ion-label>\n </ion-item>\n\n </ion-list>\n </ion-card-content>\n </ion-card>\n \n \n \n </ion-content>\n</ion-menu>\n\n<div class="ion-page" id="main-content">\n <ion-header class="ion-no-border">\n <ion-toolbar>\n <ion-buttons slot="start">\n <ion-button (click)="goBack()"> <ion-icon name="chevron-back-outline"></ion-icon> </ion-button>\n </ion-buttons>\n <ion-title>\n <ion-chip *ngIf="avatarRole?.get(\'title\')">{{avatarRole?.get("title")}}</ion-chip>\n </ion-title>\n <ion-buttons slot="end">\n \x3c!-- <ion-button (click)="playTTSTeting()">TTS测试</ion-button> --\x3e\n {{avatarRole?.get("name")}}\n <ion-button (click)="menu.toggle()"> <ion-icon name="ellipsis-horizontal-outline"></ion-icon> </ion-button>\n </ion-buttons>\n </ion-toolbar>\n </ion-header>\n\n <ion-segment value="voice">\n <ion-segment-button (click)="chatServ.createChatPanel(avatarRole)" value="chat">\n <ion-label>聊天</ion-label>\n </ion-segment-button>\n <ion-segment-button routerLink="{{\'/avatar/role/\'+avatarRole?.id}}" value="voice">\n <ion-label>语音</ion-label>\n </ion-segment-button>\n </ion-segment>\n\n \x3c!-- 数字形象:动画效果 --\x3e\n <fm-avatar-role-image *ngIf="avatarRole&&fmodeChat" [fmodeChat]="fmodeChat" [role]="avatarRole" #avatar class="avatar"></fm-avatar-role-image>\n \x3c!-- <fm-avatar-role-particle #avatar class="avatar"></fm-avatar-role-particle> --\x3e\n\n \x3c!-- AI回复的最新消息 --\x3e\n <div class="ai-resp-input" #aiRespComp>{{fmodeChat?.latestAIResponse | hidexml}}</div>\n\n <fm-modal-chat-voice-input *ngIf="fmodeChat" [fmodeChat]="fmodeChat"></fm-modal-chat-voice-input>\n\n</div>\n\n',styles:["ion-menu ion-note{color:#ccc;font-weight:700}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.avatar{display:block;width:100%;height:100%}.ai-resp-input{font-size:1rem;color:#fff;position:fixed;top:5vh;max-height:15vh;overflow-y:scroll;padding:0 10px}.user-asr-input{font-size:1rem;color:#fff;position:fixed;bottom:6vh;padding:0 10px}.test-button-group{color:#00f;position:fixed;bottom:20vh}.test-button-group button{padding:10px;margin:10px}\n"]}]}],ctorParameters:function(){return[{type:FmodeVoiceService},{type:i2.Platform},{type:i3.Router},{type:i2.NavController},{type:i3.ActivatedRoute},{type:ChatService},{type:NovaCloudService}]},propDecorators:{avatarComp:[{type:ViewChild,args:["avatar"]}],aiRespComp:[{type:ViewChild,args:["aiRespComp"]}]}});const AvatarRoutes=[{path:"role/:roleId",component:CompAvatarTalkComponent,runGuardsAndResolvers:"always"}];class AvatarModule{}AvatarModule.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:AvatarModule,deps:[],target:i0.ɵɵFactoryTarget.NgModule}),AvatarModule.ɵmod=i0.ɵɵngDeclareNgModule({minVersion:"14.0.0",version:"15.1.0",ngImport:i0,type:AvatarModule,imports:[CommonModule,FormsModule,HttpClientModule,ReactiveFormsModule,i3.RouterModule,CompAvatarTalkComponent],exports:[CompAvatarTalkComponent]}),AvatarModule.ɵinj=i0.ɵɵngDeclareInjector({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:AvatarModule,imports:[CommonModule,FormsModule,HttpClientModule,ReactiveFormsModule,RouterModule.forChild(AvatarRoutes),CompAvatarTalkComponent]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:AvatarModule,decorators:[{type:NgModule,args:[{declarations:[],imports:[CommonModule,FormsModule,HttpClientModule,ReactiveFormsModule,RouterModule.forChild(AvatarRoutes),CompAvatarTalkComponent],exports:[CompAvatarTalkComponent]}]}]}),window._AMapSecurityConfig={securityJsCode:"32aa3f4ab0fa0061de03edd4eafdd50a"};class PageMapStartComponent{constructor(){this.placeList=[{name:"江财蛟桥校区",location:[115.855125,28.744335]},{name:"江财枫林校区",location:[115.835639,28.734119]},{name:"江财麦庐校区",location:[115.816717,28.728899]}]}ngAfterViewInit(){this.initMap()}initMap(){return __awaiter(this,void 0,void 0,(function*(){yield this.createMap(),this.goAndMarkPlace(this.placeList[1])}))}createMap(){return __awaiter(this,void 0,void 0,(function*(){this.AMap=yield AMapLoader.load({key:"473b52010df7d3a32db0a2f5db245c8e",version:"2.0"}),this.map=new this.AMap.Map("container")}))}addMarks(){return __awaiter(this,void 0,void 0,(function*(){let e=new this.AMap.Marker({position:[115.835639,28.734119]});this.map.add(e)}))}goAndMarkPlace(e){this.map.setCenter(e.location),this.map.setZoom(18),console.log(this.placeList),e.marker||(e.marker=new this.AMap.Marker({position:e.location}),this.map.add(e.marker))}clearMark(e){var t;null===(t=null==e?void 0:e.marker)||void 0===t||t.remove()}planRoute(e,t){let o;this.map.plugin(["AMap.Transfer"],(()=>{let n={map:this.map,city:"南昌市",panel:"panel",policy:this.AMap.TransferPolicy.LEAST_TIME};console.log(this.AMap),console.log(this.AMap.TransferPolicy),o=new this.AMap.Transfer(n),o.search(new this.AMap.LngLat(e.location[0],e.location[1]),new this.AMap.LngLat(t.location[0],t.location[1]),((e,t)=>{"complete"===e?(console.log("绘制公交路线完成:"),console.log(t)):console.error("公交路线数据查询失败"+t)}))}))}}PageMapStartComponent.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:PageMapStartComponent,deps:[],target:i0.ɵɵFactoryTarget.Component}),PageMapStartComponent.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"14.0.0",version:"15.1.0",type:PageMapStartComponent,selector:"app-page-map.start",ngImport:i0,template:'\x3c!-- 全屏地图 --\x3e\n<div id="container"></div>\n\n\x3c!-- 右侧地点 --\x3e\n<div class="place-list">\n <ng-container *ngFor="let place of placeList">\n <div class="place-item" (click)="goAndMarkPlace(place)">\n {{place.name}}\n <button (click)="clearMark(place)">清除标记</button>\n </div>\n </ng-container>\n\n <button (click)="planRoute(placeList[0],placeList[1])">从蛟桥到枫林</button>\n \n</div>',styles:["#container{width:100%;height:100%;position:fixed}.place-list{display:flex;flex-direction:column;position:fixed;justify-content:center;align-items:center;height:80%;width:200px}.place-list .place-item{background-color:#ffffff4d;height:100px;width:90%}\n"],dependencies:[{kind:"directive",type:i1$2.NgForOf,selector:"[ngFor][ngForOf]",inputs:["ngForOf","ngForTrackBy","ngForTemplate"]}]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:PageMapStartComponent,decorators:[{type:Component,args:[{selector:"app-page-map.start",template:'\x3c!-- 全屏地图 --\x3e\n<div id="container"></div>\n\n\x3c!-- 右侧地点 --\x3e\n<div class="place-list">\n <ng-container *ngFor="let place of placeList">\n <div class="place-item" (click)="goAndMarkPlace(place)">\n {{place.name}}\n <button (click)="clearMark(place)">清除标记</button>\n </div>\n </ng-container>\n\n <button (click)="planRoute(placeList[0],placeList[1])">从蛟桥到枫林</button>\n \n</div>',styles:["#container{width:100%;height:100%;position:fixed}.place-list{display:flex;flex-direction:column;position:fixed;justify-content:center;align-items:center;height:80%;width:200px}.place-list .place-item{background-color:#ffffff4d;height:100px;width:90%}\n"]}]}]}),window._AMapSecurityConfig={securityJsCode:"32aa3f4ab0fa0061de03edd4eafdd50a"};class CompPoiPickerComponent{get name(){return this._name}set name(e){this._name=e,this.nameChange.emit(e)}get address(){return this._address}set address(e){this._address=e,this.addressChange.emit(e)}get location(){return this._location}set location(e){this._location=e,this.locationChange.emit(e)}constructor(){this.nameChange=new EventEmitter,this.addressChange=new EventEmitter,this.locationChange=new EventEmitter,this.isModalOpen=!1}cancel(){this.isModalOpen=!1,this.modal.dismiss(null,"cancel")}confirm(){this.isModalOpen=!1,this.modal.dismiss(this.address,"confirm")}onWillDismiss(e){"confirm"===e.detail.role&&console.log("确认")}openModal(){this.isModalOpen=!0,setTimeout((()=>{this.initMap()}),800)}ngAfterViewInit(){}initMap(){this.createMap()}createMap(){return __awaiter(this,void 0,void 0,(function*(){this.AMap=yield AMapLoader.load({key:"473b52010df7d3a32db0a2f5db245c8e",version:"2.0"});let e=this.container.nativeElement;this.map=new this.AMap.Map(e),this.goCurrentCenter()}))}goCurrentCenter(){this.AMap.plugin(["AMap.Geolocation"],(()=>{let e=new this.AMap.Geolocation({enableHighAccuracy:!0,timeout:1e4,maximumAge:0,convert:!0,showButton:!0,buttonPosition:"RB",buttonOffset:new this.AMap.Pixel(10,10),showMarker:!1,showCircle:!1,panToLocation:!0,zoomToAccuracy:!1});this.map.addControl(e),e.getCurrentPosition((function(e,t){"complete"===e?(console.log("当前位置经度:"+t.position.getLng()),console.log("当前位置纬度:"+t.position.getLat())):console.log("定位失败:"+t.message)}))}))}searchByAddress(){let e=this.panel.nativeElement;this.AMap.plugin(["AMap.PlaceSearch"],(()=>{let t=new this.AMap.PlaceSearch({pageSize:3,pageIndex:1,map:this.map,panel:e,autoFitView:!0});t.on("selectChanged",(e=>{this.name=e.selected.data.name,this.address=e.selected.data.address,this.location=new Parse__default.GeoPoint({latitude:e.selected.data.location.lat,longitude:e.selected.data.location.lng}),this.createCenterMarker()})),t.search(this.address)}))}createCenterMarker(){this.centerMarker||(this.centerMarker=new this.AMap.Marker({position:this.map.getCenter(),offset:new this.AMap.Pixel(-15,-15)}),this.map.add(this.centerMarker),this.map.on("dragging",(()=>{this.centerMarker.setPosition(this.map.getCenter())})),this.map.on("dragend",(()=>{let e=this.centerMarker.getPosition();this.location=new Parse__default.GeoPoint({latitude:e.lat,longitude:e.lng})})))}}CompPoiPickerComponent.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompPoiPickerComponent,deps:[],target:i0.ɵɵFactoryTarget.Component}),CompPoiPickerComponent.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"14.0.0",version:"15.1.0",type:CompPoiPickerComponent,selector:"fm-map-poi-picker",inputs:{_name:["name","_name"],_address:["address","_address"],_location:["location","_location"]},outputs:{nameChange:"nameChange",addressChange:"addressChange",locationChange:"locationChange"},viewQueries:[{propertyName:"container",first:!0,predicate:["container"],descendants:!0},{propertyName:"panel",first:!0,predicate:["panel"],descendants:!0},{propertyName:"modal",first:!0,predicate:IonModal,descendants:!0}],ngImport:i0,template:'\x3c!-- 未选点 --\x3e\n<ion-button (click)="openModal()" expand="block">开始选点</ion-button>\n\n\x3c!-- 已选点 --\x3e\n\n<ion-modal [isOpen]="isModalOpen" (willDismiss)="onWillDismiss($event)">\n<ng-template>\n <ion-header>\n <ion-toolbar>\n <ion-buttons slot="start">\n <ion-button (click)="cancel()">Cancel</ion-button>\n </ion-buttons>\n <ion-title>地图选点<ng-container *ngIf="location">({{location.latitude}},{{location.longitude}})</ng-container></ion-title>\n <ion-buttons slot="end">\n <ion-button (click)="confirm()" [strong]="true">Confirm</ion-button>\n </ion-buttons>\n </ion-toolbar>\n </ion-header>\n <ion-content class="ion-padding" style="height:100%">\n \x3c!-- 详细地址 --\x3e\n <ion-item>\n <ion-input\n label="请输入详细地址"\n labelPlacement="stacked"\n type="text"\n placeholder="精确到门牌号"\n [(ngModel)]="address"\n ></ion-input>\n <ion-button slot="end" (click)="searchByAddress()">搜索</ion-button>\n </ion-item>\n \n \x3c!-- 地图选点 --\x3e\n <div #container class="container"></div>\n <div #panel class="panel"></div>\n\n </ion-content>\n</ng-template>\n</ion-modal>\n\n',styles:[".container{width:100%;height:100%}.panel{position:absolute;background-color:#fff;max-height:50%;overflow-y:auto;top:12%;right:10px;width:45%}\n"],dependencies:[{kind:"directive",type:i1$2.NgIf,selector:"[ngIf]",inputs:["ngIf","ngIfThen","ngIfElse"]},{kind:"directive",type:i2$2.NgControlStatus,selector:"[formControlName],[ngModel],[formControl]"},{kind:"directive",type:i2$2.NgModel,selector:"[ngModel]:not([formControlName]):not([formControl])",inputs:["name","disabled","ngModel","ngModelOptions"],outputs:["ngModelChange"],exportAs:["ngModel"]},{kind:"component",type:i2.IonButton,selector:"ion-button",inputs:["buttonType","color","disabled","download","expand","fill","form","href","mode","rel","routerAnimation","routerDirection","shape","size","strong","target","type"]},{kind:"component",type:i2.IonButtons,selector:"ion-buttons",inputs:["collapse"]},{kind:"component",type:i2.IonContent,selector:"ion-content",inputs:["color","forceOverscroll","fullscreen","scrollEvents","scrollX","scrollY"]},{kind:"component",type:i2.IonHeader,selector:"ion-header",inputs:["collapse","mode","translucent"]},{kind:"component",type:i2.IonInput,selector:"ion-input",inputs:["accept","autocapitalize","autocomplete","autocorrect","autofocus","clearInput","clearOnEdit","color","counter","counterFormatter","debounce","disabled","enterkeyhint","errorText","fill","helperText","inputmode","label","labelPlacement","legacy","max","maxlength","min","minlength","mode","multiple","name","pattern","placeholder","readonly","required","shape","size","spellcheck","step","type","value"]},{kind:"component",type:i2.IonItem,selector:"ion-item",inputs:["button","color","counter","counterFormatter","detail","detailIcon","disabled","download","fill","href","lines","mode","rel","routerAnimation","routerDirection","shape","target","type"]},{kind:"component",type:i2.IonTitle,selector:"ion-title",inputs:["color","size"]},{kind:"component",type:i2.IonToolbar,selector:"ion-toolbar",inputs:["color","mode"]},{kind:"component",type:i2.IonModal,selector:"ion-modal",inputs:["animated","keepContentsMounted","backdropBreakpoint","backdropDismiss","breakpoints","canDismiss","cssClass","enterAnimation","event","handle","handleBehavior","initialBreakpoint","isOpen","keyboardClose","leaveAnimation","mode","presentingElement","showBackdrop","translucent","trigger"]},{kind:"directive",type:i2.TextValueAccessor,selector:"ion-input:not([type=number]),ion-textarea,ion-searchbar"}]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompPoiPickerComponent,decorators:[{type:Component,args:[{selector:"fm-map-poi-picker",template:'\x3c!-- 未选点 --\x3e\n<ion-button (click)="openModal()" expand="block">开始选点</ion-button>\n\n\x3c!-- 已选点 --\x3e\n\n<ion-modal [isOpen]="isModalOpen" (willDismiss)="onWillDismiss($event)">\n<ng-template>\n <ion-header>\n <ion-toolbar>\n <ion-buttons slot="start">\n <ion-button (click)="cancel()">Cancel</ion-button>\n </ion-buttons>\n <ion-title>地图选点<ng-container *ngIf="location">({{location.latitude}},{{location.longitude}})</ng-container></ion-title>\n <ion-buttons slot="end">\n <ion-button (click)="confirm()" [strong]="true">Confirm</ion-button>\n </ion-buttons>\n </ion-toolbar>\n </ion-header>\n <ion-content class="ion-padding" style="height:100%">\n \x3c!-- 详细地址 --\x3e\n <ion-item>\n <ion-input\n label="请输入详细地址"\n labelPlacement="stacked"\n type="text"\n placeholder="精确到门牌号"\n [(ngModel)]="address"\n ></ion-input>\n <ion-button slot="end" (click)="searchByAddress()">搜索</ion-button>\n </ion-item>\n \n \x3c!-- 地图选点 --\x3e\n <div #container class="container"></div>\n <div #panel class="panel"></div>\n\n </ion-content>\n</ng-template>\n</ion-modal>\n\n',styles:[".container{width:100%;height:100%}.panel{position:absolute;background-color:#fff;max-height:50%;overflow-y:auto;top:12%;right:10px;width:45%}\n"]}]}],ctorParameters:function(){return[]},propDecorators:{container:[{type:ViewChild,args:["container"]}],panel:[{type:ViewChild,args:["panel"]}],_name:[{type:Input,args:["name"]}],nameChange:[{type:Output}],_address:[{type:Input,args:["address"]}],addressChange:[{type:Output}],_location:[{type:Input,args:["location"]}],locationChange:[{type:Output}],modal:[{type:ViewChild,args:[IonModal]}]}});class CompPoiPickerModule{}CompPoiPickerModule.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompPoiPickerModule,deps:[],target:i0.ɵɵFactoryTarget.NgModule}),CompPoiPickerModule.ɵmod=i0.ɵɵngDeclareNgModule({minVersion:"14.0.0",version:"15.1.0",ngImport:i0,type:CompPoiPickerModule,declarations:[CompPoiPickerComponent],imports:[CommonModule,FormsModule,ReactiveFormsModule,i2.IonicModule],exports:[CompPoiPickerComponent]}),CompPoiPickerModule.ɵinj=i0.ɵɵngDeclareInjector({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompPoiPickerModule,imports:[CommonModule,FormsModule,ReactiveFormsModule,IonicModule.forRoot({mode:"ios"})]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompPoiPickerModule,decorators:[{type:NgModule,args:[{declarations:[CompPoiPickerComponent],imports:[CommonModule,FormsModule,ReactiveFormsModule,IonicModule.forRoot({mode:"ios"})],exports:[CompPoiPickerComponent]}]}]}),window._AMapSecurityConfig={securityJsCode:"32aa3f4ab0fa0061de03edd4eafdd50a"};class PagePlanRouteComponent{constructor(){this.placeList=[],this.currentTab="place",this.addNewPlace(),this.addNewPlace(),this.currentTab="plan"}addNewPlace(){var e;(null===(e=this.placeList)||void 0===e?void 0:e.length)>=1?this.placeList.push({name:"秋水广场",address:"南昌市秋水广场",location:new Parse__default.GeoPoint({latitude:28.682634,longitude:115.86273})}):this.placeList.push({name:"八一广场",address:"南昌市八一广场",location:new Parse__default.GeoPoint({latitude:28.673856,longitude:115.904477})})}ngAfterViewInit(){}initMap(){return __awaiter(this,void 0,void 0,(function*(){yield this.createMap(),this.goAndMarkPlace(this.placeList[0])}))}createMap(){return __awaiter(this,void 0,void 0,(function*(){this.AMap=yield AMapLoader.load({key:"473b52010df7d3a32db0a2f5db245c8e",version:"2.0"}),this.map=new this.AMap.Map("container-plan")}))}goAndMarkPlace(e){this.map.setCenter([e.location.latitude,e.location.longitude]),this.map.setZoom(18),e.marker||(e.marker=new this.AMap.Marker({position:[e.location.latitude,e.location.longitude]}),this.map.add(e.marker))}clearMark(e){var t;null===(t=null==e?void 0:e.marker)||void 0===t||t.remove()}planRoute(e,t){let o;this.map.plugin(["AMap.Transfer"],(()=>{let n={map:this.map,city:"南昌市",panel:"panel",policy:this.AMap.TransferPolicy.LEAST_TIME};o=new this.AMap.Transfer(n);let i=new this.AMap.LngLat(e.location.longitude,e.location.latitude),a=new this.AMap.LngLat(t.location.longitude,t.location.latitude);o.search(i,a,((e,t)=>{"complete"===e?(console.log("绘制公交路线完成:"),console.log(t)):console.error("公交路线数据查询失败"+t)}))}))}createPlan(){return __awaiter(this,void 0,void 0,(function*(){yield this.initMap(),this.planRoute(this.placeList[0],this.placeList[1])}))}}PagePlanRouteComponent.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:PagePlanRouteComponent,deps:[],target:i0.ɵɵFactoryTarget.Component}),PagePlanRouteComponent.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"14.0.0",version:"15.1.0",type:PagePlanRouteComponent,selector:"app-page-plan-route",ngImport:i0,template:'<ion-segment value="place">\n <ion-segment-button (click)="currentTab=\'place\'" value="place">\n <ion-label>景点选择</ion-label>\n </ion-segment-button>\n <ion-segment-button (click)="currentTab=\'plan\'" value="plan">\n <ion-label>路线规划</ion-label>\n </ion-segment-button>\n </ion-segment>\n \n\n<ng-container *ngIf="currentTab==\'place\'">\n <h1>选择旅游计划景点</h1>\n\n <ng-container *ngFor="let place of placeList">\n <ion-card>\n <h2>{{place?.name}}</h2>\n <span *ngIf="place.address">详细地址:{{place.address}}</span>\n <span *ngIf="place.location">地图坐标:{{place.location.latitude}},{{place.location.longitude}}</span>\n <fm-map-poi-picker [(name)]="place.name" [(address)]="place.address" [(location)]="place.location"></fm-map-poi-picker>\n </ion-card>\n </ng-container>\n <ion-button (click)="addNewPlace()" expand="block">添加新景点</ion-button>\n</ng-container>\n\n<ng-container *ngIf="currentTab==\'plan\'">\n <ion-button (click)="createPlan()" expand="block">创建规划路线</ion-button>\n\n <div id="container-plan"></div>\n <div id="panel"></div>\n</ng-container>\n\n',styles:["#container-plan{width:100%;height:40%}#panel{width:100%;height:50%}\n"],dependencies:[{kind:"directive",type:i1$2.NgForOf,selector:"[ngFor][ngForOf]",inputs:["ngForOf","ngForTrackBy","ngForTemplate"]},{kind:"directive",type:i1$2.NgIf,selector:"[ngIf]",inputs:["ngIf","ngIfThen","ngIfElse"]},{kind:"component",type:i2.IonButton,selector:"ion-button",inputs:["buttonType","color","disabled","download","expand","fill","form","href","mode","rel","routerAnimation","routerDirection","shape","size","strong","target","type"]},{kind:"component",type:i2.IonCard,selector:"ion-card",inputs:["button","color","disabled","download","href","mode","rel","routerAnimation","routerDirection","target","type"]},{kind:"component",type:i2.IonLabel,selector:"ion-label",inputs:["color","mode","position"]},{kind:"component",type:i2.IonSegment,selector:"ion-segment",inputs:["color","disabled","mode","scrollable","selectOnFocus","swipeGesture","value"]},{kind:"component",type:i2.IonSegmentButton,selector:"ion-segment-button",inputs:["disabled","layout","mode","type","value"]},{kind:"directive",type:i2.SelectValueAccessor,selector:"ion-range, ion-select, ion-radio-group, ion-segment, ion-datetime"},{kind:"component",type:CompPoiPickerComponent,selector:"fm-map-poi-picker",inputs:["name","address","location"],outputs:["nameChange","addressChange","locationChange"]}]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:PagePlanRouteComponent,decorators:[{type:Component,args:[{selector:"app-page-plan-route",template:'<ion-segment value="place">\n <ion-segment-button (click)="currentTab=\'place\'" value="place">\n <ion-label>景点选择</ion-label>\n </ion-segment-button>\n <ion-segment-button (click)="currentTab=\'plan\'" value="plan">\n <ion-label>路线规划</ion-label>\n </ion-segment-button>\n </ion-segment>\n \n\n<ng-container *ngIf="currentTab==\'place\'">\n <h1>选择旅游计划景点</h1>\n\n <ng-container *ngFor="let place of placeList">\n <ion-card>\n <h2>{{place?.name}}</h2>\n <span *ngIf="place.address">详细地址:{{place.address}}</span>\n <span *ngIf="place.location">地图坐标:{{place.location.latitude}},{{place.location.longitude}}</span>\n <fm-map-poi-picker [(name)]="place.name" [(address)]="place.address" [(location)]="place.location"></fm-map-poi-picker>\n </ion-card>\n </ng-container>\n <ion-button (click)="addNewPlace()" expand="block">添加新景点</ion-button>\n</ng-container>\n\n<ng-container *ngIf="currentTab==\'plan\'">\n <ion-button (click)="createPlan()" expand="block">创建规划路线</ion-button>\n\n <div id="container-plan"></div>\n <div id="panel"></div>\n</ng-container>\n\n',styles:["#container-plan{width:100%;height:40%}#panel{width:100%;height:50%}\n"]}]}],ctorParameters:function(){return[]}}),window._AMapSecurityConfig={securityJsCode:"32aa3f4ab0fa0061de03edd4eafdd50a"};class PageLocaScatterComponent{ngAfterViewInit(){this.initMap()}initMap(){return __awaiter(this,void 0,void 0,(function*(){yield this.createMap(),yield this.createLoca()}))}createLoca(){return __awaiter(this,void 0,void 0,(function*(){let e=window.loca=new Loca.Container({map:this.map}),t=new Loca.GeoJSONSource({url:"https://a.amap.com/Loca/static/loca-v2/demos/mock_data/sz_road.json"}),o=new Loca.ScatterLayer({zIndex:111,opacity:1,visible:!0,zooms:[2,22]});o.setSource(t),o.setStyle({color:"rgba(43,156,75,1)",unit:"meter",size:[150,150],borderWidth:0}),e.add(o);let n=new Loca.GeoJSONSource({url:"https://a.amap.com/Loca/static/loca-v2/demos/mock_data/sz_road_F.json"}),i=new Loca.ScatterLayer({loca:e,zIndex:113,opacity:1,visible:!0,zooms:[2,22]});i.setSource(n),i.setStyle({unit:"meter",size:[2600,2600],borderWidth:0,texture:"https://a.amap.com/Loca/static/loca-v2/demos/images/breath_red.png",duration:500,animate:!0});let a=new Loca.GeoJSONSource({url:"https://a.amap.com/Loca/static/loca-v2/demos/mock_data/sz_road_E.json"}),r=new Loca.ScatterLayer({loca:e,zIndex:112,opacity:1,visible:!0,zooms:[2,22]});r.setSource(a),r.setStyle({unit:"meter",size:[1e3,1e3],borderWidth:0,texture:"https://a.amap.com/Loca/static/loca-v2/demos/images/breath_yellow.png",duration:1e3,animate:!0}),e.animate.start();let s=new Loca.Dat;s.addLayer(o," 贴地"),s.addLayer(i,"红色"),s.addLayer(r,"黄色")}))}createMap(){return __awaiter(this,void 0,void 0,(function*(){this.AMap=yield AMapLoader.load({key:"473b52010df7d3a32db0a2f5db245c8e",version:"2.0",Loca:{version:"2.0.0"}}),this.map=new this.AMap.Map("container",{zoom:11.7,center:[113.97199630737305,22.5807295363949],pitch:40,showLabel:!1,mapStyle:"amap://styles/dark",viewMode:"3D"})}))}}PageLocaScatterComponent.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:PageLocaScatterComponent,deps:[],target:i0.ɵɵFactoryTarget.Component}),PageLocaScatterComponent.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"14.0.0",version:"15.1.0",type:PageLocaScatterComponent,selector:"app-page-loca-scatter",ngImport:i0,template:'<div id="container"></div>',styles:["#container{width:100%;height:100%;position:fixed}\n"]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:PageLocaScatterComponent,decorators:[{type:Component,args:[{selector:"app-page-loca-scatter",template:'<div id="container"></div>',styles:["#container{width:100%;height:100%;position:fixed}\n"]}]}]});const routes=[{path:"start",component:PageMapStartComponent},{path:"plan/route",component:PagePlanRouteComponent},{path:"loca/scatter",component:PageLocaScatterComponent}];class FmodeMapModule{}FmodeMapModule.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmodeMapModule,deps:[],target:i0.ɵɵFactoryTarget.NgModule}),FmodeMapModule.ɵmod=i0.ɵɵngDeclareNgModule({minVersion:"14.0.0",version:"15.1.0",ngImport:i0,type:FmodeMapModule,declarations:[PageMapStartComponent,PagePlanRouteComponent,PageLocaScatterComponent],imports:[CommonModule,i3.RouterModule,i2.IonicModule,CompPoiPickerModule],exports:[CompPoiPickerModule]}),FmodeMapModule.ɵinj=i0.ɵɵngDeclareInjector({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmodeMapModule,imports:[CommonModule,RouterModule.forChild(routes),IonicModule.forRoot({mode:"ios"}),CompPoiPickerModule,CompPoiPickerModule]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmodeMapModule,decorators:[{type:NgModule,args:[{declarations:[PageMapStartComponent,PagePlanRouteComponent,PageLocaScatterComponent],imports:[CommonModule,RouterModule.forChild(routes),IonicModule.forRoot({mode:"ios"}),CompPoiPickerModule],exports:[CompPoiPickerModule]}]}]});class HwobsService{constructor(){this.Attachment=Parse__default.Object.extend("Attachment"),this.host="https://web3-test.obs.cn-south-1.myhuaweicloud.com/",this.bucketName="web3-test",this.obsClient=new ObsClient({access_key_id:"6UIET20WHUI5TLXWOVNA",secret_access_key:"YaoY8Kj3TeGZHEcBzplTMZiPGNL13Y3frEavC1kF",server:"https://obs.cn-south-1.myhuaweicloud.com"})}listDir(e){return new Promise(((t,o)=>{this.obsClient.listObjects({Bucket:this.bucketName,Prefix:e,Delimiter:"/"},((e,n)=>{if(e)console.error("Error--\x3e"+e),o(e);else{if(console.log("Status--\x3e"+n.CommonMsg.Status),console.log(n),n.CommonMsg.Status<300&&n.InterfaceResult)for(var i in n.InterfaceResult.Contents)console.log("Contents["+i+"]:"),console.log("Key--\x3e"+n.InterfaceResult.Contents[i].Key),console.log("Owner[ID]--\x3e"+n.InterfaceResult.Contents[i].Owner.ID);let e=n.InterfaceResult.CommonPrefixes,o=n.InterfaceResult.Contents;t({dirs:e,files:o})}}))}))}uploadFile(e,t){return __awaiter(this,void 0,void 0,(function*(){let o=yield this.checkFileExists(e);return(null==o?void 0:o.id)?o:new Promise(((o,n)=>{this.obsClient.putObject({Bucket:this.bucketName,Key:t,SourceFile:e},((i,a)=>__awaiter(this,void 0,void 0,(function*(){if(i)console.error("Error--\x3e"+i),n(i);else{console.log("Status--\x3e"+a.CommonMsg.Status);let n=yield this.saveAttachment(e,t);o(n)}}))))}))}))}checkFileExists(e){return __awaiter(this,void 0,void 0,(function*(){let t,o=yield this.getFileHash(e),n=new Parse__default.Query("Attachment");n.equalTo("hash",o),n.equalTo("size",e.size);let i=yield n.first();return(null==i?void 0:i.id)||(i=new this.Attachment),t=i,t}))}saveAttachment(e,t){return __awaiter(this,void 0,void 0,(function*(){let o=yield this.getFileHash(e),n=yield this.checkFileExists(e);return n.set("name",e.name),n.set("size",e.size),n.set("mime",e.type),n.set("url",this.host+t),n.set("hash",o),n=yield n.save(),n}))}getFileHash(e){return __awaiter(this,void 0,void 0,(function*(){return new Promise(((t,o)=>{const n=new FileReader;n.onload=e=>__awaiter(this,void 0,void 0,(function*(){const o=e.target.result,n=yield crypto.subtle.digest("SHA-256",o),i=Array.from(new Uint8Array(n)).map((e=>e.toString(16).padStart(2,"0"))).join("");t(i)})),n.onerror=e=>{o(e.target.error)},n.readAsArrayBuffer(e)}))}))}}HwobsService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:HwobsService,deps:[],target:i0.ɵɵFactoryTarget.Injectable}),HwobsService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:HwobsService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:HwobsService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[]}});class HwobsManagerComponent{openFile(e){console.log("Opening file:",e)}openDir(e,t="pre"){if(e)this.prefix=e.Prefix,this.listDir(e.Prefix);else if("pre"==t){let e=this.prefix.split("/");if(e.length>1){let t=e.splice(0,e.length-1).join("/");console.log(t),this.prefix=t,this.listDir(t)}}}showName(e){return e.replaceAll(this.prefix,"")}constructor(e){this.hwobs=e,this.dirs=[],this.files=[],this.prefix="storage/",this.listDir(this.prefix)}listDir(e){return __awaiter(this,void 0,void 0,(function*(){let{dirs:t,files:o}=yield this.hwobs.listDir(e);this.dirs=t,this.files=o}))}}HwobsManagerComponent.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:HwobsManagerComponent,deps:[{token:HwobsService}],target:i0.ɵɵFactoryTarget.Component}),HwobsManagerComponent.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"14.0.0",version:"15.1.0",type:HwobsManagerComponent,isStandalone:!0,selector:"fm-storage-hwobs-manager",ngImport:i0,template:'<ion-header>\n <ion-toolbar>\n <ion-title>\n File Manager\n </ion-title>\n </ion-toolbar>\n </ion-header>\n \n <ion-content>\n <ion-list>\n <ion-item (click)="openDir(null,\'pre\')">\n <ion-icon [name]="\'folder\'" slot="start"></ion-icon>\n <ion-label>../</ion-label>\n </ion-item>\n <ion-item *ngFor="let item of dirs" (click)="openDir(item)">\n <ion-icon [name]="\'folder\'" slot="start"></ion-icon>\n <ion-label>{{ showName(item.Prefix) }}</ion-label>\n </ion-item>\n <ion-item *ngFor="let item of files" (click)="openFile(item)">\n <ion-icon [name]="\'document\'" slot="start"></ion-icon>\n <ion-label>{{ showName(item.Key) }}</ion-label>\n </ion-item>\n </ion-list>\n </ion-content>',styles:["ion-list ion-item ion-icon{font-size:24px;margin-right:8px}\n"],dependencies:[{kind:"ngmodule",type:CommonModule},{kind:"directive",type:i1$2.NgForOf,selector:"[ngFor][ngForOf]",inputs:["ngForOf","ngForTrackBy","ngForTemplate"]},{kind:"ngmodule",type:FormsModule},{kind:"ngmodule",type:ReactiveFormsModule},{kind:"ngmodule",type:IonicModule},{kind:"component",type:i2.IonContent,selector:"ion-content",inputs:["color","forceOverscroll","fullscreen","scrollEvents","scrollX","scrollY"]},{kind:"component",type:i2.IonHeader,selector:"ion-header",inputs:["collapse","mode","translucent"]},{kind:"component",type:i2.IonIcon,selector:"ion-icon",inputs:["color","flipRtl","icon","ios","lazy","md","mode","name","sanitize","size","src"]},{kind:"component",type:i2.IonItem,selector:"ion-item",inputs:["button","color","counter","counterFormatter","detail","detailIcon","disabled","download","fill","href","lines","mode","rel","routerAnimation","routerDirection","shape","target","type"]},{kind:"component",type:i2.IonLabel,selector:"ion-label",inputs:["color","mode","position"]},{kind:"component",type:i2.IonList,selector:"ion-list",inputs:["inset","lines","mode"]},{kind:"component",type:i2.IonTitle,selector:"ion-title",inputs:["color","size"]},{kind:"component",type:i2.IonToolbar,selector:"ion-toolbar",inputs:["color","mode"]}]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:HwobsManagerComponent,decorators:[{type:Component,args:[{standalone:!0,imports:[CommonModule,FormsModule,ReactiveFormsModule,IonicModule],selector:"fm-storage-hwobs-manager",template:'<ion-header>\n <ion-toolbar>\n <ion-title>\n File Manager\n </ion-title>\n </ion-toolbar>\n </ion-header>\n \n <ion-content>\n <ion-list>\n <ion-item (click)="openDir(null,\'pre\')">\n <ion-icon [name]="\'folder\'" slot="start"></ion-icon>\n <ion-label>../</ion-label>\n </ion-item>\n <ion-item *ngFor="let item of dirs" (click)="openDir(item)">\n <ion-icon [name]="\'folder\'" slot="start"></ion-icon>\n <ion-label>{{ showName(item.Prefix) }}</ion-label>\n </ion-item>\n <ion-item *ngFor="let item of files" (click)="openFile(item)">\n <ion-icon [name]="\'document\'" slot="start"></ion-icon>\n <ion-label>{{ showName(item.Key) }}</ion-label>\n </ion-item>\n </ion-list>\n </ion-content>',styles:["ion-list ion-item ion-icon{font-size:24px;margin-right:8px}\n"]}]}],ctorParameters:function(){return[{type:HwobsService}]}});class FmodeStorgeModule{}FmodeStorgeModule.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmodeStorgeModule,deps:[],target:i0.ɵɵFactoryTarget.NgModule}),FmodeStorgeModule.ɵmod=i0.ɵɵngDeclareNgModule({minVersion:"14.0.0",version:"15.1.0",ngImport:i0,type:FmodeStorgeModule,imports:[CommonModule,i2.IonicModule,HwobsManagerComponent],exports:[HwobsManagerComponent]}),FmodeStorgeModule.ɵinj=i0.ɵɵngDeclareInjector({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmodeStorgeModule,providers:[Diagnostic,NovaUploadService],imports:[CommonModule,IonicModule.forRoot({mode:"ios"}),HwobsManagerComponent]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmodeStorgeModule,decorators:[{type:NgModule,args:[{declarations:[],imports:[CommonModule,IonicModule.forRoot({mode:"ios"}),HwobsManagerComponent],exports:[HwobsManagerComponent],providers:[Diagnostic,NovaUploadService]}]}]});export{AvatarModule,AvatarRoutes,ChatContentPipe,ChatService,ClipboardService,CompAvatarParticleComponent,CompAvatarRoleImageComponent,CompAvatarTalkComponent,CompPoiPickerComponent,CompPoiPickerModule,CrossService,FmaiService,FmodeChat,FmodeChatCompletion,FmodeMapModule,FmodeStorgeModule,FmodeVoiceService,HidexmlPipe,HwobsManagerComponent,HwobsService,ImagineService,MASK_LIST,MarkdownMathJax,MarkdownParse,MarkdownPreviewComponent,MarkdownPreviewModule,ModalChatVoiceInputComponent,NovaCloudService,NovaUploadService,UtilnowPipe,getMessageContentText,getMessageImageUrl};
|
|
8
|
+
import*as i0 from"@angular/core";import{Injectable,Pipe,Component,Input,ViewChild,NgModule,EventEmitter,Output}from"@angular/core";import{__awaiter}from"tslib";import*as Parse from"parse";import Parse__default from"parse";import*as i1 from"@angular/common/http";import{HttpHeaders,HttpClientModule}from"@angular/common/http";import*as i1$2 from"@angular/common";import{DatePipe,CommonModule}from"@angular/common";import{Camera,CameraSource,CameraResultType}from"@capacitor/camera";import{Capacitor}from"@capacitor/core";import{Filesystem}from"@capacitor/filesystem";import{FilesystemWeb}from"@capacitor/filesystem/dist/esm/web.js";import*as qiniu from"qiniu-js";import{MediaCapture}from"@awesome-cordova-plugins/media-capture";import SparkMD5 from"spark-md5";import*as i2 from"@ionic/angular";import{IonicModule,IonModal}from"@ionic/angular";import*as i2$1 from"@awesome-cordova-plugins/diagnostic/ngx";import{Diagnostic}from"@awesome-cordova-plugins/diagnostic/ngx";import{finalize,Observable,bufferTime,concatMap,delay}from"rxjs";import*as i3 from"@angular/router";import{RouterModule}from"@angular/router";import{mathjax}from"mathjax-full/js/mathjax";import{TeX}from"mathjax-full/js/input/tex";import{SVG}from"mathjax-full/js/output/svg";import{CHTML}from"mathjax-full/js/output/chtml";import{AllPackages}from"mathjax-full/js/input/tex/AllPackages";import{liteAdaptor}from"mathjax-full/js/adaptors/liteAdaptor";import{RegisterHTMLHandler}from"mathjax-full/js/handlers/html";import hljs from"highlight.js";import MarkdownIt from"markdown-it";import $ from"jquery";import abbr from"markdown-it-abbr";import footnote from"markdown-it-footnote";import deflist from"markdown-it-deflist";import mark from"markdown-it-mark";import ins from"markdown-it-ins";import sub from"markdown-it-sub";import sup from"markdown-it-sup";import ruby from"markdown-it-ruby";import plantumlEncoder from"plantuml-encoder";import*as i1$1 from"@angular/platform-browser";import{Clipboard}from"@capacitor/clipboard";import Recorder from"recorder-core";import"recorder-core/src/engine/pcm";import"recorder-core/src/engine/wav";import"recorder-core/src/extensions/waveview";import CryptoJS from"crypto-js";import*as i2$2 from"@angular/forms";import{FormsModule,ReactiveFormsModule}from"@angular/forms";import*as BABYLON from"@babylonjs/core";import"@babylonjs/loaders";import*as sdk from"microsoft-cognitiveservices-speech-sdk";import*as AMapLoader from"@amap/amap-jsapi-loader";import ObsClient from"esdk-obs-browserjs";class NovaCloudService{constructor(e){this.http=e,this.serverURL="https://server.fmode.cn/api",localStorage.setItem("NOVA_APIG_SERVER","aHR0cHMlM0ElMkYlMkZzZXJ2ZXIuZm1vZGUuY24lMkZhcGklMkZhcGlnJTJG")}novaql(e,t){let o=this.serverURL+"/novaql/select",n={sql:e};return n&&(null==t?void 0:t.length)>0&&(n.params=JSON.stringify(t)),new Promise(((e,t)=>{this.http.post(o,n,{headers:new HttpHeaders({"Content-Type":"application/json"}),withCredentials:!1}).subscribe((t=>{if(t&&200==t.code){let o=t.data;e(o)}}),(e=>{t(e)}))}))}apig(e,t,o="post"){localStorage.setItem("NOVA_APIG_SERVER","aHR0cHMlM0ElMkYlMkZzZXJ2ZXIuZm1vZGUuY24lMkZhcGklMkZhcGlnJTJG");let n=localStorage.getItem("NOVA_APIG_SERVER");n=decodeURIComponent(atob(n)),e=n+e,console.log(e);let i=Parse__default.User.current();return new Promise(((n,a)=>{try{this.http.request(o,e,{body:t||null,headers:new HttpHeaders({"Content-Type":"application/json",Authorization:`Bearer ${null==i?void 0:i.getSessionToken()}`}),withCredentials:!1}).subscribe((e=>{if(e&&200==e.code||e&&1==e.code||e&&0==e.code){let t=null==e?void 0:e.data;n(t)}else n(null)}),(e=>{console.error(e.mess),a(e)}))}catch(e){return console.error("请求出错")}}))}apigTest(e,t,o="post"){e="https://test.fmode.cn/api/apig/"+e,console.log(e);let n=Parse__default.User.current();return t.token=`Bearer ${null==n?void 0:n.getSessionToken()}`,new Promise(((n,i)=>{try{this.http.request(o,e,{body:t||null,headers:new HttpHeaders({"Content-Type":"application/json"}),withCredentials:!1}).subscribe((e=>{if(e&&200==e.code||e&&1==e.code||e&&0==e.code){let t=null==e?void 0:e.data;n(t)}else n(null)}),(e=>{console.error(e.mess),i(e)}))}catch(e){return console.error("请求出错")}}))}api(e,t){return e=this.serverURL+e,new Promise(((o,n)=>{this.http.post(e,t,{headers:new HttpHeaders({"Content-Type":"application/json"}),withCredentials:!1}).subscribe((e=>{if(e&&200==e.code||e&&1==e.code){let t=e.data;o(t)}else o(null)}),(e=>{n(e)}))}))}searchParse(e){let t={};if((e=e||location.search)&&e.length>1){let o=(e=e.substring(1)).split("&");for(let e=0;e<o.length;e++){if(!o[e])continue;let n=o[e].split("=");t[n[0]]=void 0===n[1]?"":n[1]}}return t}}function calcFileMd5(e){return new Promise(((t,o)=>{const n=new FileReader;n.onload=e=>{var n;try{const i=null===(n=e.target)||void 0===n?void 0:n.result;if(i){const e=new SparkMD5.ArrayBuffer;e.append(i);const o=e.end();t(o)}else o(new Error("Failed to load file"))}catch(e){o(e)}},n.onerror=e=>{o(e)},n.readAsArrayBuffer(e)}))}NovaCloudService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:NovaCloudService,deps:[{token:i1.HttpClient}],target:i0.ɵɵFactoryTarget.Injectable}),NovaCloudService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:NovaCloudService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:NovaCloudService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[{type:i1.HttpClient}]}});class NovaUploadService{constructor(e,t){this.platform=e,this.diagnostic=t,this.maxSize=5242880,this.getUptoken(!0),this.requestPermission(),this.queryDomain()}upload(e,t){var o,n;return __awaiter(this,void 0,void 0,(function*(){let i,a=e.type,r=null===(o=e.name)||void 0===o?void 0:o.split("."),s=r[r.length-1];try{i=yield calcFileMd5(e)}catch(e){}let l,c,d=this.fileToBlob(e);return l=a.indexOf("image")>-1?yield this.saveQiniuImageFile(d,s,null,t):yield this.saveQiniuMediaFile(e,d,null,t),l.md5=i,(null===(n=null==l?void 0:l.url)||void 0===n?void 0:n.indexOf("undefined"))>-1&&(l.url=(this.qiniuDomain||"https://file-cloud.fmode.cn/")+l.url.replace("undefined/","")),(null==l?void 0:l.url)&&(c=yield this.saveAttachment(l,this.qiniuDomain,null,this.getCompanyId())),(null==c?void 0:c.id)&&(l.id=null==c?void 0:c.id),l}))}isCapacitor(){return this.platform.is("capacitor")||this.platform.is("cordova")}requestPermission(){return __awaiter(this,void 0,void 0,(function*(){this.isCapacitor()&&(yield this.requestStoagePermission(),yield this.requestCameraPermission())}))}requestStoagePermission(){return __awaiter(this,void 0,void 0,(function*(){let e=yield this.diagnostic.isExternalStorageAuthorized();if(console.log("permisson_STORAGE:",e),!e){yield this.diagnostic.requestExternalStorageAuthorization()}}))}requestCameraPermission(){return __awaiter(this,void 0,void 0,(function*(){let e=yield this.diagnostic.isCameraAuthorized();if(console.log("permisson_Camera:",e),!e){yield this.diagnostic.requestCameraAuthorization()}}))}getUptoken(e=!1){return __awaiter(this,void 0,void 0,(function*(){if(console.log("getUptoken"),this.qiniuConf||e)try{console.log(this.getCompanyId());let e=yield Parse__default.Cloud.run("qiniu_uptoken",{company:this.getCompanyId()});console.log(e),this.qiniuConf=e}catch(e){console.error(e)}}))}genFileKey(e,t){let o=new Date,n=new DatePipe("en");return t||(t=this.getCompanyId()),t+"/"+n.transform(o,"yMMdd")+"/"+String(e.id).substr(20,6)+n.transform(o,"hhmmssSSS")+/\.[^\.]+/.exec(e.name)}getCompanyId(){if(this.company)return this.company;return localStorage.getItem("company")}queryDomain(){return __awaiter(this,void 0,void 0,(function*(){let e=new Parse__default.Query("Company"),t=yield e.get(this.getCompanyId());t.get("configQiniu")&&t.get("configQiniu").domain?(console.log(t.get("configQiniu").domain),this.qiniuDomain=t.get("configQiniu").domain):this.qiniuDomain="https://file-cloud.fmode.cn"}))}saveAttachment(e,t,o,n){return __awaiter(this,void 0,void 0,(function*(){let i=e.url;i.startsWith("http")||(i=t+i),i=i.replace(/undefined\//,""),n||(n=localStorage.getItem("company"));let a=Parse__default.User.current(),r=new Parse__default.Query("Attachment");r.equalTo("url",i);let s=yield r.first();if(s&&s.id)return console.error("该文件已存在,无需重复上传"),s;return s=new(Parse__default.Object.extend("Attachment")),s.set("size",e.size),s.set("url",i),s.set("name",e.name),s.set("mime",e.type),s.set("md5",null==e?void 0:e.md5),(null==a?void 0:a.id)&&s.set("user",a.toPointer()),n&&s.set("company",{__type:"Pointer",className:"Company",objectId:localStorage.getItem("company")}),o&&s.set("category",{__type:"Pointer",className:"Category",objectId:o}),yield s.save()}))}captureVideo(e){return __awaiter(this,void 0,void 0,(function*(){if(this.qiniuConf=e,!this.isCapacitor())return;let t=yield this.cameraCaptureVideoFile(),o=yield this.getMediaFileDataString(t);return yield this.saveQiniuMediaFile(t,o)}))}cameraCaptureVideoFile(){return __awaiter(this,void 0,void 0,(function*(){let e=MediaCapture,t=yield e.captureVideo({limit:1});return(null==t?void 0:t.length)>0?t[0]:null}))}getMediaFileDataString(e){return __awaiter(this,void 0,void 0,(function*(){new FilesystemWeb,e.fullPath.replaceAll("///","//");let t=yield Filesystem.stat({path:e.fullPath}),o=Capacitor.convertFileSrc(t.uri),n=yield fetch(o),i=yield n.blob();if(console.log(i.size),console.log(JSON.stringify(t)),console.log(JSON.stringify(n)),console.log(JSON.stringify(Object.keys(n))),i)return i;throw"读取文件失败"}))}takePicture(e){return __awaiter(this,void 0,void 0,(function*(){if(this.qiniuConf=e,!this.isCapacitor())return;yield this.getUptoken();let t=yield this.cameraTakePictureDataUrl();if(!(null==t?void 0:t.dataUrl))return;let o=yield this.base64ToBlob(null==t?void 0:t.dataUrl),n=yield this.saveQiniuImageFile(o,null==t?void 0:t.format);return console.log(JSON.stringify(n)),n}))}cameraTakePictureDataUrl(){return __awaiter(this,void 0,void 0,(function*(){if(!this.isCapacitor())return;return yield Camera.getPhoto({quality:90,allowEditing:!1,source:CameraSource.Camera,resultType:CameraResultType.DataUrl})}))}saveQiniuImageFile(e,t,o,n){return __awaiter(this,void 0,void 0,(function*(){let o=this.maxSize;if(e.size>o)throw yield console.log("照片过大,超出限制5MB"),"超出文件大小";let i=new DatePipe("en").transform(new Date,"yyyyMMddHHmmss"),a=`${i}.${t}`,r=`image/${t}`,s={fname:a,params:{},mimeType:"image/*"},l={useCdnDomain:!0,forceDirect:!0};console.log(this.qiniuConf);let c=this.genFileKey({id:i,name:a});return console.log("图片上传前"),new Promise(((t,o)=>{var i;console.log("进入了上传"),qiniu.upload(e,c,null===(i=this.qiniuConf)||void 0===i?void 0:i.uptoken,s,l).subscribe({next:e=>{console.log(e),n&&n(e)},error:e=>__awaiter(this,void 0,void 0,(function*(){console.log(e)})),complete:o=>{var n,i;console.log("上传完成"),console.log(`${null===(n=this.qiniuConf)||void 0===n?void 0:n.domain}${o.key}`),o.url=`${null===(i=this.qiniuConf)||void 0===i?void 0:i.domain}${o.key}`,o.name=a,o.type=r,o.size=e.size,t(o)}})}))}))}saveQiniuMediaFile(e,t,o,n){return __awaiter(this,void 0,void 0,(function*(){let o=e.name,i=e.type;if(e.size>104857600)throw console.log("视频过大,超出限制100MB"),"超出文件大小";let a=new DatePipe("en").transform(new Date,"yyyyMMddHHmmss"),r={fname:o,params:{},mimeType:i},s={useCdnDomain:!0,forceDirect:!0},l=this.genFileKey({id:a,name:o});return console.log("图片上传前"),console.log(e.name,t.size),console.log(t.size),console.log(t.size/1024/1024),new Promise(((o,i)=>{var a;console.log("进入了上传"),qiniu.upload(t,l,null===(a=this.qiniuConf)||void 0===a?void 0:a.uptoken,r,s).subscribe({next:e=>{console.log("主要用来展示进度"),n&&n(e),console.log(JSON.stringify(e))},error:e=>__awaiter(this,void 0,void 0,(function*(){console.log("上传失败"),console.log(JSON.stringify(e))})),complete:t=>{var n;console.log("上传完成"),console.log(JSON.stringify(t)),e.key=t.key,console.log(e.type),e.url=`${null===(n=this.qiniuConf)||void 0===n?void 0:n.domain}${t.key}`,console.log(e.url),o(e)}})}))}))}base64ToBlobType(e,t){return __awaiter(this,void 0,void 0,(function*(){let o=yield fetch(`data:${t};base64,${e}`);return yield o.blob()}))}base64ToBlob(e){return __awaiter(this,void 0,void 0,(function*(){let t=yield fetch(e);return yield t.blob()}))}fileToBlob(e){const t=e.slice(0,e.size,e.type);return new Blob([t],{type:e.type})}}NovaUploadService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:NovaUploadService,deps:[{token:i2.Platform},{token:i2$1.Diagnostic}],target:i0.ɵɵFactoryTarget.Injectable}),NovaUploadService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:NovaUploadService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:NovaUploadService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[{type:i2.Platform},{type:i2$1.Diagnostic}]}});class ImagineService{constructor(e,t,o){this.http=e,this.ncloud=t,this.uploadServ=o,this.taskDetailMap={},this.newWorkList=[],this.myWorkList=[]}drawDalle(e){var t;return __awaiter(this,void 0,void 0,(function*(){e.size=(null==e?void 0:e.size)||"1024x1024",e.style=(null==e?void 0:e.style)||"natural",e.quality=(null==e?void 0:e.quality)||null;let o={model:"dall-e-3",prompt:e.prompt,n:1,quality:e.quality,response_format:"url",size:e.size,style:e.style};if((null===(t=e.prompt)||void 0===t?void 0:t.length)>3e3)throw"prompt maximum < 4000 characters";let n=yield this.ncloud.apigTest("aigc/gpt/v1/images/generations",o);if(console.log(n),null==n?void 0:n.id){let e=new Parse__default.Query("ImagineWork");e.get(null==n?void 0:n.id);let t=yield e.first();console.log(t),(null==t?void 0:t.id)&&this.newWorkList.unshift(t)}return n}))}priceDalle(e){let t=[{model:"dall-e-3",quality:null,size:"1024x1024",credit:6.4},{model:"dall-e-3",quality:null,size:"1024x1792",credit:12.8},{model:"dall-e-3",quality:null,size:"1792x1024",credit:12.8},{model:"dall-e-3",quality:"hd",size:"1024x1024",credit:12.8},{model:"dall-e-3",quality:"hd",size:"1024x1792",credit:19.2},{model:"dall-e-3",quality:"hd",size:"1792x1024",credit:19.2},{model:"dall-e-2",quality:null,size:"1024x1024",credit:3.2},{model:"dall-e-2",quality:null,size:"512x512",credit:2.88},{model:"dall-e-2",quality:null,size:"256x256",credit:2.56}].find((t=>t.model==e.model&&t.quality==e.quality&&t.size==e.size));return(null==t?void 0:t.credit)||19.2}priceStableDiffusion(e){var t,o,n,i,a,r;let s=e.width*e.height,l=763e-9*s*e.steps+2278e-8*s*((null==e?void 0:e.upscale)||0)+((null==e?void 0:e.hrSteps)||0)*s*((null==e?void 0:e.hrScale)||0)*((null==e?void 0:e.hrScale)||0)*763e-9+((null==e?void 0:e.faceFix)?2:0)+((null===(t=null==e?void 0:e.imgOptions)||void 0===t?void 0:t.removeBackground)?2:0)+((null===(o=null==e?void 0:e.imgOptions)||void 0===o?void 0:o.redrawBackground)?2:0)+((null===(n=null==e?void 0:e.imgOptions)||void 0===n?void 0:n.facePreservation)?2:0)+((null===(i=null==e?void 0:e.imgOptions)||void 0===i?void 0:i.genderDetect)?1:0)+2*((null===(r=null===(a=null==e?void 0:e.controlnet)||void 0===a?void 0:a.units)||void 0===r?void 0:r.length)||0);return l=.3*l*e.batchSize,l}b64DataToBase64Image(e){let t=atob(e),o=new Blob([t],{type:"image/webp"});new Promise((e=>{let t=new FileReader;t.onloadend=function(){let o=t.result;console.log(o),e(o)},t.readAsDataURL(o)}))}draw(e){return __awaiter(this,void 0,void 0,(function*(){let t=yield this.ncloud.apig("aigc/sdapi/v1/draw",e),o=null==t?void 0:t.paintingSign;return o&&setTimeout((()=>__awaiter(this,void 0,void 0,(function*(){let e=new Parse__default.Query("ImagineWork");e.equalTo("taskId",o);let t=yield e.first();console.log(t),(null==t?void 0:t.id)&&this.newWorkList.unshift(t)}))),1e3),t}))}taskDetail(e){return __awaiter(this,void 0,void 0,(function*(){let t=yield this.ncloud.apig("aigc/sdapi/v1/task/detail",{taskId:e});return console.log(t),this.taskDetailMap[e]=t,t}))}getMyWorkQuery(){let e=Parse__default.User.current();if(!(null==e?void 0:e.id))return;let t=this.getWorkQuery();return t.include("model","module","user"),t.equalTo("user",e.toPointer()),t}getWorkQuery(){let e=new Date((new Date).getTime()-6e4),t=Parse__default.Query.fromJSON("ImagineWork",{where:{$or:[{createdAt:{$lte:e},progress:{$ne:0}},{createdAt:{$gt:e}}]}});return t.include("model","module","user"),t.notEqualTo("isDeleted",!0),t.notEqualTo("isFailed",!0),t.doesNotExist("respData.error"),t.doesNotExist("respData.data.taskLimitCount"),t.addDescending("createdAt"),t}getimg(){return new Promise(((e,t)=>{let o=document.createElement("input");o.type="file",o.click();let handleChange=()=>__awaiter(this,void 0,void 0,(function*(){if(o.removeEventListener("change",handleChange),o.files&&o.files.length>0){let t=o.files[0],n=yield this.uploadServ.upload(t,(e=>{console.log(e),e.total.percent.toFixed(2)}));e(n.url)}else t("未选择文件")}));o.addEventListener("change",handleChange)}))}}ImagineService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ImagineService,deps:[{token:i1.HttpClient},{token:NovaCloudService},{token:NovaUploadService}],target:i0.ɵɵFactoryTarget.Injectable}),ImagineService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ImagineService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ImagineService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[{type:i1.HttpClient},{type:NovaCloudService},{type:NovaUploadService}]}});const API_BASE="https://server.fmode.cn/api/apig/aigc/gpt";function getMessageContentText(e){var t;let o="";return"string"==typeof e&&(o=e),"object"==typeof e&&(o=(null===(t=null==e?void 0:e.find((e=>null==e?void 0:e.text)))||void 0===t?void 0:t.text)||""),o}function getMessageImageUrl(e){var t,o;return"object"==typeof e?(null===(o=null===(t=null==e?void 0:e.find((e=>null==e?void 0:e.image_url)))||void 0===t?void 0:t.image_url)||void 0===o?void 0:o.url)||"":null}class FmodeChat{constructor(e,t,o,n){this.ChatSession=Parse__default.Object.extend("ChatSession"),this.messageList=[{role:"system",content:"系统提示:AI仅供参考"}],this.latestAIResponse="",this.userInput="",this.userImage="",this.isTalkMode=!1,this.SSMLRoleVoice="zh-CN-XiaoxiaoNeural",this.playAnimation=e=>{console.log(e)},this.chatServ=n,this.role=t,this.sessionId=e,(null==o?void 0:o.id)&&(this.chatSession=o,this.messageList=this.chatSession.get("messageList"),this.sessionId=null==o?void 0:o.id)}loadTalkSystemPrompt(e){var t,o,n;if(!e)return;"男"==(null==e?void 0:e.get("gender"))?this.SSMLRoleVoice="zh-CN-YunyeNeural":this.SSMLRoleVoice="zh-CN-XiaoxiaoNeural",this.SSMLRoleVoice=(null===(t=null==e?void 0:e.get("voiceConfig"))||void 0===t?void 0:t.voice)||this.SSMLRoleVoice;let i=`您的语言简短且口语化,每句话都要用mstts:express-as标签,style属性情绪表达(advertisement_upbeat,affectionate,angry,assistant,calm,chat,cheerful,customerservice,depressed,disgruntled,documentary-narration,embarrassed,empathetic,envious,excited,fearful,friendly,gentle,hopeful,lyrical,narration-professional,narration-relaxed,newscast,newscast-casual,newscast-formal,poetry-reading,sad,serious,shouting,sports_commentary,sports_commentary_excited,whispering,terrified,unfriendly,),styledegree属性语气强度(默认1,从0.01最轻柔到2最强调),并适当用break增加自然停顿效果。并编写成带<speak xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="http://www.w3.org/2001/mstts" xmlns:emo="http://www.w3.org/2009/10/emotionml" version="1.0" xml:lang="zh-CN"><voice name="${this.SSMLRoleVoice}">标签的SSML返回。`,a=e.get("prompt")||"请你扮演脑控科技的人工智能专家。";a+=i;let r={role:"user",content:a,hidden:!0};if((null===(o=this.messageList)||void 0===o?void 0:o.map((e=>null==e?void 0:e.content)).join()).indexOf(a)>-1)return;let s=(null===(n=this.messageList)||void 0===n?void 0:n.findIndex((e=>"system"==(null==e?void 0:e.role))))+1;this.messageList.splice(s,0,r)}loadRolePrompt(){var e,t,o;let n=null===(e=this.role)||void 0===e?void 0:e.get("prompt"),i={role:"user",content:n,hidden:!0};if(!n)return;if((null===(t=this.messageList)||void 0===t?void 0:t.map((e=>null==e?void 0:e.content)).join()).indexOf(n)>-1)return;let a=(null===(o=this.messageList)||void 0===o?void 0:o.findIndex((e=>"system"==(null==e?void 0:e.role))))+1;this.messageList.splice(a,0,i),console.log(this.messageList)}sendMessage(e="FmodeAiTest测试问题",t,o){var n,i,a,r;this.loadTalkSystemPrompt(this.role),this.loadRolePrompt(),t?this.messageList.push({role:"user",content:[{type:"image_url",image_url:{url:t}},{type:"text",text:e}],complete:!0,createdAt:new Date}):this.messageList.push({role:"user",content:e,complete:!0,createdAt:new Date});let s=new FmodeChatCompletion(this.fixMessageList(this.messageList),{model:(null===(i=null===(n=this.chatServ)||void 0===n?void 0:n.currentModel)||void 0===i?void 0:i.get("code"))||"fmode-3.6-16k"});console.log(null===(r=null===(a=this.chatServ)||void 0===a?void 0:a.currentModel)||void 0===r?void 0:r.toJSON());let l=!1;this.isTalkMode&&(l=!0);let c=s.sendCompletion({isDirect:l,onComplete:o||null}).pipe(finalize((()=>{this.messageList[s.indexOfList].complete=!0}))).subscribe((e=>{var t,o,n,i,a;this.messageList[s.indexOfList]=e,"string"==typeof(null==e?void 0:e.content)?this.latestAIResponse=null==e?void 0:e.content:this.latestAIResponse=(null===(o=null===(t=null==e?void 0:e.content)||void 0===t?void 0:t[0])||void 0===o?void 0:o.text)||"";let r=null===(i=null===(n=this.chatSession)||void 0===n?void 0:n.get("messageList"))||void 0===i?void 0:i.length;(null===(a=this.messageList)||void 0===a?void 0:a.length)>r&&(console.log("cycle新会话"),this.saveChatSession()),(null==e?void 0:e.complete)&&(this.saveChatSession(),c.unsubscribe())}))}saveChatSession(){var e,t,o,n,i,a,r,s,l,c,d,p,m,u,h,g,v,f;return __awaiter(this,void 0,void 0,(function*(){if("new"==this.sessionId&&(this.chatSession=new this.ChatSession),this.chatSession.set("title",this.genTitle()),this.chatSession.set("role",null===(e=this.role)||void 0===e?void 0:e.toPointer()),this.chatSession.set("messageList",this.messageList),this.chatSession.set("user",null===(t=Parse__default.User.current())||void 0===t?void 0:t.toPointer()),this.chatSession=yield this.chatSession.save(),this.sessionId=null===(o=this.chatSession)||void 0===o?void 0:o.id,this.sessionId){let e=`${window.location.origin}/chat/pro/chat/${this.sessionId}`;e=this.getInviteUrl(e),window.history.replaceState(null,null,e);let t={sid:null===(n=this.chatSession)||void 0===n?void 0:n.id,rid:null===(i=this.role)||void 0===i?void 0:i.id,name:null===(a=this.role)||void 0===a?void 0:a.get("name"),message:null===(p=null===(d=null===(s=null===(r=this.chatSession)||void 0===r?void 0:r.get("messageList"))||void 0===s?void 0:s[(null===(c=null===(l=this.chatSession)||void 0===l?void 0:l.get("messageList"))||void 0===c?void 0:c.length)-1])||void 0===d?void 0:d.content)||void 0===p?void 0:p.slice(0,20),latest:null===(m=this.chatSession)||void 0===m?void 0:m.createdAt};(null===(h=null===(u=this.chatServ)||void 0===u?void 0:u.chatList)||void 0===h?void 0:h.length)||(this.chatServ.chatList=[]);let o=null===(v=null===(g=this.chatServ)||void 0===g?void 0:g.chatList)||void 0===v?void 0:v.find((e=>(null==e?void 0:e.sid)==(null==t?void 0:t.sid)));o>-1?this.chatServ.chatList[o]=t:null===(f=this.chatServ)||void 0===f||f.chatList.unshift(t)}}))}getInviteUrl(e){var t,o;let n="?";n=(null==e?void 0:e.indexOf("?"))>-1?"&":"?";let i=null===(o=null===(t=Parse__default.User)||void 0===t?void 0:t.current())||void 0===o?void 0:o.id;if(-1==(null==e?void 0:e.indexOf("invite="+i))){if(!i)return e;e+=n+"invite="+i}return e}genTitle(){var e,t;if(this.title)return this.title;let o=null===(e=this.messageList.find((e=>"user"==e.role)))||void 0===e?void 0:e.content;return"string"==typeof o&&(this.title=(null==o?void 0:o.slice(0,15))||""),"object"==typeof o&&(this.title=(null===(t=null==o?void 0:o.find((e=>null==e?void 0:e.text)))||void 0===t?void 0:t.text)||""),this.title}fixMessageList(e){return e.map((e=>({role:e.role,content:e.content})))}nowStr(){let e=new Date;return`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()} ${e.getHours()}:${e.getMinutes()}:${e.getSeconds()}`}}class FmodeChatCompletion{constructor(e,t){this.content="",this.contentBuffer=[],this.isCompleted=!1,this.indexOfList=Number(e.length),this.messages=e,this.model=(null==t?void 0:t.model)||"fmode-3.6-16k"}sendCompletion(e={}){e.intTime=(null==e?void 0:e.intTime)||50,e.isDirect=(null==e?void 0:e.isDirect)||!1,(null==e?void 0:e.isDirect)&&(e.intTime=1);let t={messages:this.messages,stream:!0,model:this.model,temperature:.5,presence_penalty:0,frequency_penalty:0};return console.log(t),new Observable((o=>{let n=RequestFmodeChatApi("/v1/chat/completions",t).subscribe((t=>{var i,a,r;let s=String(t);if(console.log(s),"data: [DONE]"==s&&(this.isCompleted=!0,console.log(null==e?void 0:e.isDirect,this.isCompleted),(null==e?void 0:e.isDirect)&&this.isCompleted&&(o.next({role:"assistant",content:this.content,complete:!0,createdAt:new Date}),n.unsubscribe(),(null==e?void 0:e.onComplete)&&e.onComplete({role:"assistant",content:this.content,complete:!0,createdAt:new Date}),o.complete())),s.indexOf("data: {")>-1){let t=chunkToJson(s),l=(null===(r=null===(a=null===(i=null==t?void 0:t.choices)||void 0===i?void 0:i[0])||void 0===a?void 0:a.delta)||void 0===r?void 0:r.content)||"";this.contentBuffer.push(l),(null==e?void 0:e.isDirect)&&(this.content+=l||"",this.isCompleted||o.next({role:"assistant",cid:null==t?void 0:t.id,content:this.content,createdAt:new Date})),(null==e?void 0:e.isDirect)||this.contentPusher||(this.contentPusher=setInterval((()=>{var e,i,a;this.isCompleted&&0==(null===(e=this.contentBuffer)||void 0===e?void 0:e.length)&&(o.next({role:"assistant",cid:null==t?void 0:t.id,content:this.content,complete:!0,createdAt:new Date}),n.unsubscribe(),clearInterval(this.contentPusher),o.complete()),(null===(i=this.contentBuffer)||void 0===i?void 0:i.length)>=0&&((null===(a=this.contentBuffer)||void 0===a?void 0:a.length)>0&&(this.content+=this.contentBuffer.shift()),o.next({role:"assistant",cid:null==t?void 0:t.id,content:this.content,createdAt:new Date}))}),null==e?void 0:e.intTime))}}))})).pipe(bufferTime(100),concatMap((e=>e)),delay(200))}}function chunkToJson(e){let t;try{t=JSON.parse(e.replaceAll("data: ",""))}catch(e){console.error(e)}return t||{}}function RequestFmodeChatApi(e,t,o="POST"){return new Observable((n=>{var i;let a=API_BASE+e,r=`Bearer ${(null===(i=Parse__default.User.current())||void 0===i?void 0:i.getSessionToken())||localStorage.getItem("FMODE_AI_TOKEN")}`;return t.token=r,t&&(t=JSON.stringify(t)),fetch(a,{headers:{"Content-Type":"text/plain","Cache-Control":"no-cache"},body:t||null,method:o,credentials:"omit",mode:"cors"}).then((e=>{var t;let o="";{let i=null===(t=e.body)||void 0===t?void 0:t.getReader();const a=new TextDecoder;let r=new ReadableStream({start(e){!function read(){i.read().then((({done:t,value:o})=>{if(t)return e.close(),void n.complete();e.enqueue(o),read()}))}()}}).getReader();r.read().then((function processStream({done:e,value:t}){if(e)return;!function processData(e){let t=(o+e).split("\n");if((null==t?void 0:t.length)>1){for(let e=0;e<t.length-1;e++){let o=t[e];n.next(o)}o=t[t.length-1]}}(a.decode(t)),r.read().then(processStream)}))}})).catch((e=>n.error(e))),()=>{}}))}function JsonToFormData(e){const t=new FormData;return function appendFormData(e,o=""){Array.isArray(e)?e.forEach(((e,t)=>{appendFormData(e,`${o}[${t}]`)})):"object"==typeof e&&null!==e?Object.keys(e).forEach((t=>{const n=o?`${o}.${t}`:t;appendFormData(e[t],n)})):t.append(o,e)}(e),t}class CrossService{getMenuType(){return this.clientWidth=document.body.clientWidth,this.onResizeScreen(),this.navMenuType}constructor(e,t,o){this.platform=e,this.modalCtrl=t,this.navCtrl=o,this.mobileWidth=915,this.clientWidth=document.body.clientWidth,this.clientWidth=document.body.clientWidth,this.updateWidth(),this.onResizeScreen()}dismisModalTop(e){return __awaiter(this,void 0,void 0,(function*(){let t=yield this.modalCtrl.getTop();t&&((null==e?void 0:e.preventDefault)&&(null==e||e.preventDefault()),t.dismiss(),t.isOpen=!1)}))}updateWidth(){this.fixInterval=setInterval((()=>{if(this.clientWidth)return clearInterval(this.fixInterval),void delete this.fixInterval;console.log(document.body.clientWidth),this.clientWidth=document.body.clientWidth}),200)}onResizeScreen(e){this.clientWidth=document.body.clientWidth,this.clientWidth>=this.mobileWidth?(this.leftMenuMode="horizontal",this.navMenuType="pc"):(this.leftMenuMode="inline",this.navMenuType="mobile")}}CrossService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CrossService,deps:[{token:i2.Platform},{token:i2.ModalController},{token:i2.NavController}],target:i0.ɵɵFactoryTarget.Injectable}),CrossService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CrossService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CrossService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[{type:i2.Platform},{type:i2.ModalController},{type:i2.NavController}]}});class ChatService{constructor(e,t,o,n,i,a){this.router=e,this.ncloud=t,this.platform=o,this.alertCtrl=n,this.navCtrl=i,this.cross=a,this.chatMap={},this.isCapacitor=!1,this.platformMap={pc:"电脑端",mobile:"移动端"},this.isCapacitor=this.platform.is("capacitor")}loadModelList(e){var t;return __awaiter(this,void 0,void 0,(function*(){let o=new Parse__default.Query("ChatModel");o.notEqualTo("isDeleted",!0),o.equalTo("isEnabled",!0),o.addAscending("index"),this.modelList=yield o.find(),this.currentModel=e||(null===(t=this.modelList)||void 0===t?void 0:t.find((e=>"fmode-3.6-16k"==e.get("code"))))}))}doButtonAction(e){var t,o,n;return __awaiter(this,void 0,void 0,(function*(){let i=this.cross.navMenuType,a=null===(t=null==e?void 0:e.platform)||void 0===t?void 0:t.map((e=>this.platformMap[e])).join("、");if((null===(o=null==e?void 0:e.platform)||void 0===o?void 0:o.length)>0&&-1==(null===(n=null==e?void 0:e.platform)||void 0===n?void 0:n.indexOf(i))){(yield this.alertCtrl.create({header:"注意",subHeader:"终端不符",message:`请您使用${a}开启本功能。`,buttons:[{role:"ok",text:"知道了"}]})).present()}else(null==e?void 0:e.path)&&this.navCtrl.navigateRoot(null==e?void 0:e.path)}))}initChatMap(e){return __awaiter(this,void 0,void 0,(function*(){if(this.chatMap[e])return this.chatMap[e];let t=new Parse__default.Query("ChatSession");t.include("role","role.model");let o=yield t.get(e),n=new FmodeChat(null==o?void 0:o.id,null==o?void 0:o.get("role"),o,this);return this.chatMap[e]=n,this.chatMap[e]}))}getChatSession(){var e,t;return __awaiter(this,void 0,void 0,(function*(){if(!(null===(t=null===(e=null==Parse__default?void 0:Parse__default.User)||void 0===e?void 0:e.current())||void 0===t?void 0:t.id))return;let o=new Parse__default.Query("ChatSession");o.include("role","role.model"),o.addDescending("updatedAt"),o.equalTo("user",Parse__default.User.current().toPointer()),o.notEqualTo("isDeleted",!0),o.limit(10);let n=yield o.find();this.chatList=n.map((e=>{var t,o,n,i,a,r,s,l;return this.chatMap[null==e?void 0:e.id]=new FmodeChat(null==e?void 0:e.id,null==e?void 0:e.get("role"),e),{session:e,sid:null==e?void 0:e.id,isHidden:!1,rid:null===(t=null==e?void 0:e.get("role"))||void 0===t?void 0:t.id,name:null===(o=null==e?void 0:e.get("role"))||void 0===o?void 0:o.get("name"),thumb:null===(n=null==e?void 0:e.get("role"))||void 0===n?void 0:n.get("thumb"),title:(null==e?void 0:e.get("title"))||(null===(i=null==e?void 0:e.get("role"))||void 0===i?void 0:i.get("name")),message:null===(l=null===(s=null===(a=null==e?void 0:e.get("messageList"))||void 0===a?void 0:a[(null===(r=null==e?void 0:e.get("messageList"))||void 0===r?void 0:r.length)-1])||void 0===s?void 0:s.content)||void 0===l?void 0:l.slice(0,20),latest:null==e?void 0:e.createdAt}}))}))}getChatSessionDistinct(){var e;return __awaiter(this,void 0,void 0,(function*(){let t=yield this.ncloud.novaql('SELECT t1."objectId" as sid , "AvatarRole"."objectId" as rid, * FROM (\n SELECT *,ROW_NUMBER() OVER (PARTITION BY "user", "role" ORDER BY "createdAt" DESC) AS rn\n FROM "ChatSession" WHERE "user"=$1\n ) as t1\n LEFT JOIN "AvatarRole" ON "AvatarRole"."objectId" = t1."role"\n WHERE t1.rn=1\n LIMIT $2\n ;',[null===(e=Parse__default.User.current())||void 0===e?void 0:e.id,10]),o=null==t?void 0:t.map((e=>{var t,o,n,i;return{sid:null==e?void 0:e.sid,rid:null==e?void 0:e.rid,name:null==e?void 0:e.name,message:null===(i=null===(n=null===(t=null==e?void 0:e.messageList)||void 0===t?void 0:t[(null===(o=null==e?void 0:e.messageList)||void 0===o?void 0:o.length)-1])||void 0===n?void 0:n.content)||void 0===i?void 0:i.slice(0,20),latest:null==e?void 0:e.createdAt}}));return this.chatList=o,this.chatList}))}createChatPanel(e,t){let o=(null==t?void 0:t.id)||"new";t=new FmodeChat(o,e,t,this),this.chatMap[o]=t,this.router.navigate(["/chat/pro/chat/"+o])}createNewRoleChat(e){return __awaiter(this,void 0,void 0,(function*(){let t=new Parse__default.Query("AvatarRole");t.include("model");let o=yield t.get(e);return new FmodeChat("new",o,null,this)}))}restoreChatPanel(e){return __awaiter(this,void 0,void 0,(function*(){let t=new Parse__default.Query("AvatarRole"),o=new Parse__default.Query("ChatSession"),n=yield t.get(null==e?void 0:e.rid),i=yield o.get(null==e?void 0:e.sid),a=new FmodeChat(null==e?void 0:e.sid,n,i);this.chatMap[null==e?void 0:e.sid]=a,this.router.navigate(["/chat/pro/chat/"+(null==e?void 0:e.sid)])}))}callRole(e){return __awaiter(this,void 0,void 0,(function*(){document.body.classList.add("dark"),this.router.navigate([`/avatar/role/${e.id}`,{type:"phone"}])}))}}ChatService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ChatService,deps:[{token:i3.Router},{token:NovaCloudService},{token:i2.Platform},{token:i2.AlertController},{token:i2.NavController},{token:CrossService}],target:i0.ɵɵFactoryTarget.Injectable}),ChatService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ChatService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ChatService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[{type:i3.Router},{type:NovaCloudService},{type:i2.Platform},{type:i2.AlertController},{type:i2.NavController},{type:CrossService}]}});class FmaiService{constructor(e,t){this.imagine=e,this.chat=t}}FmaiService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmaiService,deps:[{token:ImagineService},{token:ChatService}],target:i0.ɵɵFactoryTarget.Injectable}),FmaiService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmaiService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmaiService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[{type:ImagineService},{type:ChatService}]}});let colorMap=["primary","secondary","tertiary","success","warning","danger","light","medium","dark"];const MASK_LIST=[{name:"执行李",type:"employee",title:"首席执行官",desc:"一位富有远见和领导才能的创业新秀。她具备战略思维和决策能力,能够为公司设定长期目标并领导团队实现这些目标。",color:colorMap[0],cover:"https://imgsource.huashi6.com/images/ai/2023/9/29/15_48766.jpg?e=1695974629&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:oPkQSsyQLLD08R_J4SMeO1f1RdM="},{name:"技术刘",type:"employee",title:"首席技术官",desc:"一位技术专家,拥有广泛的技术知识和经验。他善于解决复杂的技术问题,并能够领导开发团队实施创新的技术解决方案。",color:colorMap[1],cover:["https://imgsource.huashi6.com/images/ai/2023/9/29/9_619877.jpg?e=1695952672&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:LDuSg8_n5g4Rj_8F5PKrGzV4T54=","https://imgsource.huashi6.com/images/ai/2023/9/27/20_17767.jpg?e=1695819037&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:a9uOeeJMN2oopK-3WQZzldPXfH0="]},{name:"点子王",type:"employee",title:"首席运营官",desc:"一位富有创意和市场洞察力的市场营销专家。她擅长制定营销策略,了解目标受众,并能够利用各种渠道和工具推广公司的产品或服务。",color:colorMap[2],cover:"https://imgsource.huashi6.com/images/ai/2023/9/29/9_186291.jpg?e=1695952125&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:EhEUtwnC9hpu-SXXsBrp2Q-rcJk="},{title:"设计总监",name:"李欣",type:"employee",desc:"一位富有创造力和用户导向思维的设计师。她能够理解用户需求,并通过设计直观、易用且吸引人的用户界面来提供出色的用户体验。",color:colorMap[3],cover:"https://imgsource.huashi6.com/images/ai/2023/9/29/9_18099.jpg?e=1695952201&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:G_a60v52iTTqvJgeTSa_8zJUY2w="},{title:"运营经理",name:"刘洁",type:"employee",desc:"一位组织能力强、注重细节并擅长解决问题的运营专家。她能够协调各个部门的工作,并确保公司的运营流程高效运行。",color:colorMap[4],cover:"https://imgsource.huashi6.com/images/ai/2023/9/29/9_842519.jpg?e=1695952125&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:FM_kKZDzkcLQ1EX4266dXU46cRc="},{title:"销售经理",name:"张伟",type:"employee",desc:"一位富有销售天赋和人际交往能力的销售专家。他善于与客户建立良好的关系,并能够推动销售团队实现业绩目标。",color:colorMap[5],cover:"https://imgsource.huashi6.com/images/ai/2023/9/29/15_739110.jpg?e=1695974920&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:vg_sn-qn67MJS-7j2o7mWzOCUSk="},{title:"数据分析师",name:"杨晨",type:"employee",desc:"一位善于解读数据和提供商业洞察的数据分析专家。她能够收集、分析和解释数据,为公司的决策制定提供有力的支持。",color:colorMap[6],cover:"https://imgsource.huashi6.com/images/ai/2023/9/29/15_204321.jpg?e=1695974779&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:dC2sGmJekSPBTCycPF76BkQPBoo="},{title:"财务经理",name:"赵晓",type:"employee",desc:"一位精通财务管理和分析的专业人士。她能够制定财务战略、管理公司的财务流程,并提供准确的财务报告和预测。",color:colorMap[7],cover:"https://imgsource.huashi6.com/images/ai/2023/9/29/15_947878.jpg?e=1695974779&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:TFGn0_l2PqhUTe9G4A3it769hcU="},{title:"品牌专员",name:"王雅",type:"employee",desc:"一位富有创意和品牌意识的专业人士。她能够塑造和管理公司的品牌形象,制定品牌营销策略,并与内部和外部利益相关者建立良好的合作关系。",color:colorMap[8],cover:["https://imgsource.huashi6.com/images/ai/2023/9/29/15_129581.jpg?e=1695975151&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:YQrpiv1hBKRPIdaEbDDDkLFuPG8=","https://imgsource.huashi6.com/images/ai/2023/9/29/15_912136.jpg?e=1695975151&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:8SVMU1rdKD8eaJ1gH_qGQzcrMhM="]},{title:"全科",name:"孔博",type:"teacher",desc:"擅长全科教学的金牌教师,知识面广泛,博古通今,因材施教,耐心稳重。",color:colorMap[0],cover:["https://imgsource.huashi6.com/images/ai/2023/10/18/12_40958.jpg?e=1697604189&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:U7r1Td30lXdf9mE1TMVAnDhBP6c="]},{title:"语文",name:"王明",type:"teacher",desc:"激发学生对文学的热爱,引导他们成为优秀的作家和沟通者。",color:colorMap[1],cover:["https://imgsource.huashi6.com/images/ai/2023/10/18/11_698893.jpg?e=1697602689&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:hK_AuY7BA1pp33QVeUue5QjIg4o="]},{title:"数学",name:"万红",type:"teacher",desc:"以清晰的逻辑和耐心的指导,帮助学生掌握数学的基础知识和解题技巧。",color:colorMap[2],cover:["https://imgsource.huashi6.com/images/ai/2023/10/18/11_256253.jpg?e=1697603314&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:K2iqp_ZzHYzXNu_0VJlywyANHp8="]},{title:"英语",name:"张瑞",type:"teacher",desc:"激发学生对英语学习的兴趣,培养他们的听、说、读、写能力,让他们自信地运用英语。",color:colorMap[3],cover:["https://imgsource.huashi6.com/images/ai/2023/10/18/12_266171.jpg?e=1697603707&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:uhpxBbT-jlSt_KjAnj0SFsFAjWU="]},{title:"物理",name:"金晓",type:"teacher",desc:"通过实验和案例,帮助学生理解物理原理,培养他们的科学思维和实验技能。",color:colorMap[4],cover:["https://imgsource.huashi6.com/images/ai/2023/10/18/11_694925.jpg?e=1697603071&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:FznZxhkYUrZ-BzX05dvNt8acTUw="]},{title:"化学",name:"陈华",type:"teacher",desc:"激发学生对化学的好奇心,教授他们化学知识和实验技巧,培养他们的实验和分析能力。",color:colorMap[5],cover:["https://imgsource.huashi6.com/images/ai/2023/10/18/11_942234.jpg?e=1697603169&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:__2T8cxLl4J0AwMR9MJdDiooDF0="]},{title:"生物",name:"杨婷",type:"teacher",desc:"引导学生探索生命的奥秘,培养他们的科学观察和实验能力,让他们热爱生物科学。",color:colorMap[6],cover:["https://imgsource.huashi6.com/images/ai/2023/10/18/12_330738.jpg?e=1697603491&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:2K5-DHPnUQ-R9GGxtWKiEG68QlE="]},{title:"历史",name:"赵亮",type:"teacher",desc:"帮助学生了解历史事件和文化背景,培养他们的历史意识和批判思维。",color:colorMap[7],cover:["https://imgsource.huashi6.com/images/ai/2023/10/18/11_256302.jpg?e=1697602689&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:YP7ffC1YKO-Pb0C3ks4caT0QqZk="]},{title:"地理",name:"林丽",type:"teacher",desc:"引导学生探索地球的奥秘,培养他们的地理观察和分析能力,让他们热爱地理科学。",color:colorMap[8],cover:["https://imgsource.huashi6.com/images/ai/2023/10/18/12_555804.jpg?e=1697604054&token=qFZErZx7WS1v5B4rgQE2KLMHlYHVNaCuXeaA9OLD:xLN4QW0x9jx9lEB4EFHWvI_gEsI="]}];class UtilnowPipe{constructor(){this.enLocale={"秒钟前":" seconds ago","分钟前":" minutes ago","小时前":" hours ago","天前":" days ago"}}transform(e,t){let o=((new Date).getTime()-e.getTime())/1e3;if(o<=60)return this.handleArgs(o.toFixed(0),"秒钟前",t);let n=o/60;if(n<60)return this.handleArgs(n.toFixed(0),"分钟前",t);let i=n/60;if(i<24)return this.handleArgs(i.toFixed(0),"小时前",t);let a=i/24;return a<7?this.handleArgs(a.toFixed(0),"天前",t):`${null==e?void 0:e.getFullYear()}-${(null==e?void 0:e.getMonth())+1}-${null==e?void 0:e.getDate()}`}handleArgs(e,t,o){var n;return"en"==o&&(t=this.enLocale[t]),"TranslateService"==(null===(n=null==o?void 0:o.constructor)||void 0===n?void 0:n.name)&&(console.log(t),"en"==(null==o?void 0:o.getDefaultLang())&&(t=this.enLocale[t])),"json"==o?{unit:t,value:e}:e+t}}UtilnowPipe.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:UtilnowPipe,deps:[],target:i0.ɵɵFactoryTarget.Pipe}),UtilnowPipe.ɵpipe=i0.ɵɵngDeclarePipe({minVersion:"14.0.0",version:"15.1.0",ngImport:i0,type:UtilnowPipe,isStandalone:!0,name:"utilnow"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:UtilnowPipe,decorators:[{type:Pipe,args:[{name:"utilnow",standalone:!0}]}]});class ChatContentPipe{transform(e,...t){console.log(t);let o=(null==t?void 0:t[0])||"text";return"text"==o?getMessageContentText(e):"image_url"==o?getMessageImageUrl(e):e}}ChatContentPipe.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ChatContentPipe,deps:[],target:i0.ɵɵFactoryTarget.Pipe}),ChatContentPipe.ɵpipe=i0.ɵɵngDeclarePipe({minVersion:"14.0.0",version:"15.1.0",ngImport:i0,type:ChatContentPipe,isStandalone:!0,name:"chatContent"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ChatContentPipe,decorators:[{type:Pipe,args:[{name:"chatContent",pure:!0,standalone:!0}]}]});class HidexmlPipe{transform(e,...t){return e?this.hideXmlTags(e):""}hideXmlTags(e){return e.replace(/<[^>]*>/g,"")}}HidexmlPipe.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:HidexmlPipe,deps:[],target:i0.ɵɵFactoryTarget.Pipe}),HidexmlPipe.ɵpipe=i0.ɵɵngDeclarePipe({minVersion:"14.0.0",version:"15.1.0",ngImport:i0,type:HidexmlPipe,isStandalone:!0,name:"hidexml"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:HidexmlPipe,decorators:[{type:Pipe,args:[{name:"hidexml",standalone:!0}]}]});class MarkdownMathJax{constructor(e){this.options=e,this.adaptor=liteAdaptor(),RegisterHTMLHandler(this.adaptor)}text_to_mathjax(e,t){if(!(null==e?void 0:e.length))return"";if(!(null==e?void 0:e.replace))return"";t=t||this.options;let o=new SVG({fontCache:"local"});"chtml"==(null==t?void 0:t.output)&&(o=new CHTML);const n=mathjax.document("",{skipHtmlTags:["script","noscript","style","textarea","pre","code","annotation","annotation-xml"],InputJax:new TeX({processEscapes:!0,packages:AllPackages}),OutputJax:o}),i={em:16,ex:8,containerWidth:1280};return[/\$\$\ (.+?)\ \$\$/g,/\$\$(.+?)\$\$/g,/\$\$\n(.+?)\n\$\$/g,/\$(.+?)\$/g,/\\\((.+?)\\\)/g,/\\\[(.+?)\\\]/g].forEach((t=>{e=e.replace(t,((e,t)=>{let o=n.convert(`${t}`,i);return`<span class="mathjax raw" style="margin-left:10px;margin-right:10px;">${this.adaptor.innerHTML(o)}</span>`}))})),e}}let md=new MarkdownIt({html:!0,xhtmlOut:!0,breaks:!1,linkify:!1,typographer:!1,quotes:"“”‘’",highlight:function(e,t){if(t&&hljs.getLanguage(t))try{return`<pre style="position:relative;padding:10px;" class="hljs lang-${t}"><code>${hljs.highlight(e,{language:t}).value}</code><small class="hljs-lang"><span class="sr-only">Language:</span>${t}</small></pre>`}catch(e){}return""}});md.use(abbr),md.use(footnote),md.use(deflist),md.use(mark),md.use(ins),md.use(sub),md.use(sup),md.use(ruby);const mditConfig={plantumlServer:"https://www.plantuml.com/plantuml"};function makePlantumlURL(e){const t=plantumlEncoder.encode(e);return`${mditConfig.plantumlServer}/svg/${t}`}md.renderer.rules.plantuml=(e,t,o,n,i)=>{const a=e[t];if("plantuml"!==a.type)return e[t].content;return`\n <img src="${makePlantumlURL(a.content)}" />\n <pre style="position:relative;padding:10px;" class="hljs lang-plantuml"><code>${a.content}</code><small class="hljs-lang"><span class="sr-only">Language:</span>plantuml</small></pre>\n `},md.core.ruler.push("plantuml",(e=>{const t=e.tokens;for(const e of t)"fence"===e.type&&"plantuml"===e.info&&(e.type="plantuml")}));const spaceregex=/\s*/,notinhtmltagregex=/(?![^<]*>|[^<>]*<\/)/;let coloregex=/\[color=([#|(|)|\s|,|\w]*?)\]/;coloregex=new RegExp(coloregex.source+notinhtmltagregex.source,"g");let nameregex=/\[name=(.*?)\]/,timeregex=/\[time=([:|,|+|-|(|)|\s|\w]*?)\]/;const nameandtimeregex=new RegExp(nameregex.source+spaceregex.source+timeregex.source+notinhtmltagregex.source,"g");function replaceExtraTags(e){return console.log("replaceExtraTags",e),e=(e=(e=(e=e.replace(coloregex,'<span class="color" data-color="$1"></span>')).replace(nameandtimeregex,'<small><i class="fa fa-user"></i> $1 <i class="fa fa-clock-o"></i> $2</small>')).replace(nameregex,'<small><i class="fa fa-user"></i> $1</small>')).replace(timeregex,'<small><i class="fa fa-clock-o"></i> $1</small>'),console.log("replaceExtraTags",e),e}function finishView(e){let t=$.parseHTML(`<html><body><div id="topmd">${e}</div></body></html>`)[0],o=$(t),n=o.find("blockquote.raw").removeClass("raw");n=o.find("blockquote");let i=$(n).find("p");i.each(((e,t)=>{let o=$(t).html();o=replaceExtraTags(o),t.innerHTML=o,$(t).html(o),i[e].innerHTML=o,$(i[e]).html(o)})),n.find(".color").each(((e,t)=>{let o=$(t).attr("data-color");$(t).closest("blockquote").css("border-left-color",o)}));let a="<style>\n .markdown-section {\n color: black;\n text-align: left;\n }\n .markdown-section pre .hljs-lang{\n text-transform: uppercase;\n font-weight: 700;\n font-size: .75rem;\n line-height: 1rem;\n padding-top: .25rem;\n padding-bottom: .25rem;\n padding-left: .5rem;\n padding-right: .5rem;\n background-color: rgba(0,0,0,.3);\n border-bottom-left-radius: .375rem;\n top:0;\n right:0;\n position:absolute;\n}\n\n }\n .markdown-section pre .hljs {\n position:relative!important;\n background: #272822!important;\n padding:10px!important;\n color: #ddd;\n text-shadow: none!important;\n }\n\n .markdown-section blockquote {\n margin: 0;\n margin-bottom: 0px;\n margin-bottom: .85em;\n padding: 0 15px;\n color: #858585;\n border-left: 4px solid #e5e5e5;\n border-left-color: rgb(229, 229, 229);\n }\n .markdown-section img {\n max-width:100%;\n }\n </style>"+(o.html()||e);return a=a.replaceAll('src="/uploads/','src="https://md.fmode.cn/uploads/'),a}nameregex=new RegExp(nameregex.source+notinhtmltagregex.source,"g"),timeregex=new RegExp(timeregex.source+notinhtmltagregex.source,"g");class MarkdownParse{constructor(){}parseToHTML(e){this.info("markdown",e),e=(new MarkdownMathJax).text_to_mathjax(e,{output:"svg"});let t=md.render(e);return t=finishView(t),t}info(...e){}}class MarkdownPreviewComponent{constructor(e,t){this.domSan=e,this.renderer=t,this.content="",this.render=!0}ngAfterViewInit(){this.renderMdToHTML()}renderMdToHTML(){if(!this.render)return;let e=(new MarkdownParse).parseToHTML(this.content);this.safeHTML=this.domSan.bypassSecurityTrustHtml(e);let t=this.renderer.createElement("div");t.innerHTML=e,this.renderer.appendChild(this.mdContent.nativeElement,t)}}MarkdownPreviewComponent.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:MarkdownPreviewComponent,deps:[{token:i1$1.DomSanitizer},{token:i0.Renderer2}],target:i0.ɵɵFactoryTarget.Component}),MarkdownPreviewComponent.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"14.0.0",version:"15.1.0",type:MarkdownPreviewComponent,selector:"fm-markdown-preview",inputs:{content:"content",render:"render"},viewQueries:[{propertyName:"mdContent",first:!0,predicate:["mdContent"],descendants:!0}],ngImport:i0,template:'<div class="message-body">\n <div *ngIf="render" #mdContent class="markdown-section">\n </div>\n <div *ngIf="!render" class="pre-section">\n {{content}}\n </div>\n</div>',styles:[":host{overflow-x:auto}.message-body div{text-align:left;overflow-x:auto}.message-body .pre-section{white-space:pre-wrap}.markdown-section blockquote{margin:0 0 .85em;padding:0 15px;color:#858585;border-left:4px solid #e5e5e5;border-left-color:#e5e5e5}\n"],dependencies:[{kind:"directive",type:i1$2.NgIf,selector:"[ngIf]",inputs:["ngIf","ngIfThen","ngIfElse"]}]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:MarkdownPreviewComponent,decorators:[{type:Component,args:[{selector:"fm-markdown-preview",template:'<div class="message-body">\n <div *ngIf="render" #mdContent class="markdown-section">\n </div>\n <div *ngIf="!render" class="pre-section">\n {{content}}\n </div>\n</div>',styles:[":host{overflow-x:auto}.message-body div{text-align:left;overflow-x:auto}.message-body .pre-section{white-space:pre-wrap}.markdown-section blockquote{margin:0 0 .85em;padding:0 15px;color:#858585;border-left:4px solid #e5e5e5;border-left-color:#e5e5e5}\n"]}]}],ctorParameters:function(){return[{type:i1$1.DomSanitizer},{type:i0.Renderer2}]},propDecorators:{content:[{type:Input}],mdContent:[{type:ViewChild,args:["mdContent"]}],render:[{type:Input}]}});class MarkdownPreviewModule{}MarkdownPreviewModule.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:MarkdownPreviewModule,deps:[],target:i0.ɵɵFactoryTarget.NgModule}),MarkdownPreviewModule.ɵmod=i0.ɵɵngDeclareNgModule({minVersion:"14.0.0",version:"15.1.0",ngImport:i0,type:MarkdownPreviewModule,declarations:[MarkdownPreviewComponent],imports:[CommonModule],exports:[MarkdownPreviewComponent]}),MarkdownPreviewModule.ɵinj=i0.ɵɵngDeclareInjector({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:MarkdownPreviewModule,imports:[CommonModule]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:MarkdownPreviewModule,decorators:[{type:NgModule,args:[{declarations:[MarkdownPreviewComponent],imports:[CommonModule],exports:[MarkdownPreviewComponent]}]}]});class ClipboardService{constructor(e){this.toastCtrl=e}copyToClipboard(e){var t;return __awaiter(this,void 0,void 0,(function*(){try{return yield Clipboard.write({string:e}),void this.copySuccess()}catch(o){try{if(navigator.clipboard&&window.isSecureContext)return yield null===(t=null===navigator||void 0===navigator?void 0:navigator.clipboard)||void 0===t?void 0:t.writeText(e),void this.copySuccess();throw!1}catch(t){let o=document.createElement("textarea");o.value=e,o.style.position="fixed",o.style.left="-9999px",o.style.top="-9999px",document.body.appendChild(o),o.focus(),o.select();try{(null===document||void 0===document?void 0:document.execCommand("copy"))?this.copySuccess():console.error("无法复制文本")}catch(e){console.error("无法复制文本: ",e)}document.body.removeChild(o)}}}))}copySuccess(){return __awaiter(this,void 0,void 0,(function*(){(yield this.toastCtrl.create({duration:1e3,message:"复制成功",color:"primary",icon:"information-circle",position:"top"})).present()}))}}function pcmtoWav(e,t,o,n){let i={chunkId:[82,73,70,70],chunkSize:0,format:[87,65,86,69],subChunk1Id:[102,109,116,32],subChunk1Size:16,audioFormat:1,numChannels:o||1,sampleRate:t||16e3,byteRate:0,blockAlign:0,bitsPerSample:n||16,subChunk2Id:[100,97,116,97],subChunk2Size:0};function u32ToArray(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]}function u16ToArray(e){return[255&e,e>>8&255]}let a=new Uint8Array(e);i.blockAlign=i.numChannels*i.bitsPerSample>>3,i.byteRate=i.blockAlign*i.sampleRate,i.subChunk2Size=a.length*(i.bitsPerSample>>3),i.chunkSize=36+i.subChunk2Size;let r=i.chunkId.concat(u32ToArray(i.chunkSize),i.format,i.subChunk1Id,u32ToArray(i.subChunk1Size),u16ToArray(i.audioFormat),u16ToArray(i.numChannels),u32ToArray(i.sampleRate),u32ToArray(i.byteRate),u16ToArray(i.blockAlign),u16ToArray(i.bitsPerSample),i.subChunk2Id,u32ToArray(i.subChunk2Size)),s=new Uint8Array(r),l=new Uint8Array(s.length+a.length);l.set(s),l.set(a,s.length);let c=new Blob([l],{type:"audio/wav"});return window.URL.createObjectURL(c)}function resampleAudio(e,t,o){let n=e.length,i=Math.floor(n/t*o),a=[];for(let n=0;n<i;n++){let i=Math.floor(n*(t/o));a[n]=e[i]}return a}function convertFrameBufferToBase64(e){const t=new Uint8Array(2*e.length);for(let o=0;o<e.length;o++){const n=e[o];t[2*o]=255&n,t[2*o+1]=n>>8&255}return btoa(String.fromCharCode.apply(null,t))}function resampleBuffer(e,t,o){const n=t/o,i=Math.round(e.length/n),a=new Int16Array(i);for(let t=0;t<i;t++){const o=Math.floor(t*n);a[t]=e[o]}return a}ClipboardService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ClipboardService,deps:[{token:i2.ToastController}],target:i0.ɵɵFactoryTarget.Injectable}),ClipboardService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ClipboardService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ClipboardService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[{type:i2.ToastController}]}});const SpeechRecognition=window.SpeechRecognition||window.webkitSpeechRecognition,SpeechGrammarList=window.SpeechGrammarList||window.webkitSpeechGrammarList;class WebSpeech{constructor(e){this.platform=e}startRecognition(e="Nihao | Hello"){if(!SpeechRecognition)return;if(this.recognition&&this.recognition.stop(),console.log("startRecognition"),this.recognition=new SpeechRecognition,!this.recognition)return;this.recognition.continuous=!0;let t=`#JSGF V1.0; grammar words; public <word> = ${e} ;`;this.recognition=new SpeechRecognition;let o=new SpeechGrammarList;o.addFromString(t,1),this.recognition.grammars=o,this.recognition.start(),this.recognition.onresult=e=>{var t,o,n,i,a,r,s;let l=e.results||[];console.log(l),console.log(null===(t=l[0])||void 0===t?void 0:t[0]),(null===(i=null===(n=null===(o=l[0])||void 0===o?void 0:o[0])||void 0===n?void 0:n.transcript)||void 0===i?void 0:i.indexOf("Nihao"))>-1&&console.log("Nihao成功唤醒"),(null===(s=null===(r=null===(a=l[0])||void 0===a?void 0:a[0])||void 0===r?void 0:r.transcript)||void 0===s?void 0:s.indexOf("Hello"))>-1&&console.log("Hello成功唤醒"),this.startRecognition()},this.recognition.onend=e=>{console.log(e)},this.recognition.onerror=e=>{console.error(e)}}speak(e,t=1,o=1.2,n=.8){this.platform.is("capacitor")||this.speakWithEdge(e,1,1.2,.8)}speakWithEdge(e,t=1,o=1.2,n=.8){let i=new SpeechSynthesisUtterance(e),a=this.getVoiceByName("Yaoyao");console.log(a),a&&(i.voice=a),i.rate=o,i.pitch=t,i.volume=10,window.speechSynthesis.speak(i)}getVoiceByName(e){return window.speechSynthesis.getVoices().find((t=>t.name.indexOf(e)>-1))}}class FmodeVoiceService{constructor(e,t){this.platform=e,this.diagnostic=t,this.webSpeech=WebSpeech,this.recordPcmBlob=null,this.recordType="pcm",this.encodingType="raw",this.connStatus="",this.btnStatus="UNDEFINED",this.resultText="",this.resultTextTemp="",this.APPID="23265215",this.API_SECRET="YzMzMWUzMmFkYjU2ZjE5OTc4M2Q1NjE1",this.API_KEY="8c58aa034946e1de30f2b145cf0cc3c3",this.requestPermission()}toggleRecord(){console.log(this.btnStatus),"UNDEFINED"===this.btnStatus||"CLOSED"===this.btnStatus?this.startTalk():"CONNECTING"!==this.btnStatus&&"OPEN"!==this.btnStatus||this.finishTalk()}finishTalk(){this.onBeforeFinishTalk&&this.onBeforeFinishTalk(),this.recordStop(),setTimeout((()=>{this.onAfterFinishTalk&&this.onAfterFinishTalk()}),1e3)}startTalk(e){return __awaiter(this,void 0,void 0,(function*(){this.onBeforeStartTalk&&this.onBeforeStartTalk(),null===event||void 0===event||event.preventDefault(),yield this.openWithPriviledge(),setTimeout((()=>{this.connectWebSocket()}),100),this.onAfterStartTalk&&this.onAfterStartTalk()}))}cancelTalk(){this.onBeforeCancelTalk&&this.onBeforeCancelTalk(),this.recordStop(),this.iatWS.close(),this.resultText=null,this.onAfterCancelTalk&&this.onAfterCancelTalk()}recordStart(){return __awaiter(this,void 0,void 0,(function*(){this.createRecorder(),yield this.openWithPriviledge(),this.recorder.start(),this.changeBtnStatus("OPEN")}))}recordStop(){var e;null===(e=this.recorder)||void 0===e||e.stop(((e,t)=>{this.iatWS.send(JSON.stringify({data:{status:2,format:"audio/L16;rate=16000",encoding:this.encodingType,audio:""}}));let o=(window.URL||webkitURL).createObjectURL(e);console.log(e,o,"时长:"+t+"ms"),this.recordPcmBlob=e,this.recorder.close(),this.recorder=null,console.log("localUrl",o)}),(e=>{console.log("录音失败:"+e),this.recorder.close(),this.recorder=null})),clearInterval(this.countdownInterval),this.changeBtnStatus("CLOSED")}playRecord(){this.playPCM(this.recordPcmBlob,44100)}playPCM(e,t){let o=new FileReader;o.onload=function(e){let o=pcmtoWav(e.target.result,t,1,16),n=new Audio;n.src=o,n.play()},o.readAsArrayBuffer(e)}playBuffers(){return __awaiter(this,void 0,void 0,(function*(){let e=yield this.BuffersToBlob(this.buffers);this.playPCM(e,44100)}))}BuffersToBlob(e){let t=[];return e.forEach((e=>{e.forEach((e=>{t.push(e)}))})),new Blob([t],{type:"audio/pcm"})}splitAudioData(e){const t=1280,o=Math.ceil(e.length/t),n=[];for(let i=0;i<o;i++){const o=i*t,a=o+t,r=e.slice(o,a);n.push(r)}return n}BufferToBlob(e){return new Blob([e],{type:"audio/pcm"})}createRecorder(){this.recorder||(this.recorder=Recorder({type:this.recordType,sampleRate:44100,bitRate:16,onProcess:(e,t,o,n,i,a)=>{var r;let s=e.length&&e[e.length-1];if(this.buffers=e,s=resampleBuffer(s,44100,16e3),this.iatWS.readyState===this.iatWS.OPEN){if(this.disableASR)return;this.iatWS.send(JSON.stringify({data:{status:1,format:"audio/L16;rate=16000",encoding:this.encodingType,audio:convertFrameBufferToBase64(s)}}))}null===(r=this.waveClient)||void 0===r||r.input(e[e.length-1],t,n)}}))}openWithPriviledge(){return __awaiter(this,void 0,void 0,(function*(){return console.log(this.btnStatus),yield this.requestPermission(),this.createRecorder(),!!Recorder.IsOpen()||new Promise((e=>{this.recorder.open((()=>{Recorder.WaveView&&(this.waveClient=Recorder.WaveView({elem:".record-wave"})),e(!0)}),((e,t)=>{console.log((t?"UserNotAllow,":"")+"无法录音:"+e)}))}))}))}getWebSocketUrl(){let e="wss://iat-api.xfyun.cn/v2/iat",t="iat-api.xfyun.cn",o=this.API_KEY,n=this.API_SECRET,i=(new Date).toUTCString(),a=`host: ${t}\ndate: ${i}\nGET /v2/iat HTTP/1.1`,r=CryptoJS.HmacSHA256(a,n),s=CryptoJS.enc.Base64.stringify(r);return e=`${e}?authorization=${btoa(`api_key="${o}", algorithm="hmac-sha256", headers="host date request-line", signature="${s}"`)}&date=${i}&host=${t}`,e}toBase64(e){for(var t="",o=new Uint8Array(e),n=o.byteLength,i=0;i<n;i++)t+=String.fromCharCode(o[i]);return window.btoa(t)}countdown(){let e=60;this.connStatus=`录音中(${e}s)`,this.countdownInterval=setInterval((()=>{e-=1,console.log(e),e<=0?(clearInterval(this.countdownInterval),this.recordStop()):this.connStatus=`录音中(${e}s)`}),1e3)}changeBtnStatus(e){this.btnStatus=e,"CONNECTING"===e?(this.connStatus="建立连接中",this.resultText="",this.resultTextTemp=""):"OPEN"===e?this.countdown():"CLOSING"===e?this.connStatus="关闭连接中":"CLOSED"===e&&(this.connStatus="开始录音")}renderResult(e){let t=JSON.parse(e);if(t.data&&t.data.result){let e=t.data.result,o="",n=e.ws;for(let e=0;e<n.length;e++)o+=n[e].cw[0].w,console.log(o);e.pgs?("apd"===e.pgs&&(this.resultText=this.resultTextTemp),this.resultTextTemp=this.resultText+o):this.resultText=this.resultText+o,this.resultTextTemp||this.resultText}0===t.code&&2===t.data.status&&this.iatWS.close(),0!==t.code&&(this.iatWS.close(),console.error(t))}connectWebSocket(){console.log("connectWebSocket");const e=this.getWebSocketUrl();if("WebSocket"in window)this.iatWS=new WebSocket(e);else if(!("MozWebSocket"in window))return void alert("浏览器不支持WebSocket");console.log("connectWebSocket",this.btnStatus),this.changeBtnStatus("CONNECTING"),this.iatWS.onopen=e=>{this.recordStart();var t={common:{app_id:this.APPID},business:{language:"zh_cn",domain:"iat",accent:"mandarin",vad_eos:5e3,dwa:"wpgs"},data:{status:0,format:"audio/L16;rate=16000",encoding:this.encodingType}};this.iatWS.send(JSON.stringify(t))},this.iatWS.onmessage=e=>{this.renderResult(e.data)},this.iatWS.onerror=e=>{console.error("error",e),this.recordStop(),this.changeBtnStatus("CLOSED")},this.iatWS.onclose=e=>{console.error("close",e),this.recordStop(),this.changeBtnStatus("CLOSED")}}isCapacitor(){return this.platform.is("capacitor")||this.platform.is("cordova")}requestPermission(){return __awaiter(this,void 0,void 0,(function*(){if(this.isCapacitor())try{yield this.requestStoagePermission(),yield this.requestCameraPermission(),yield this.requestMicPermission(),yield this.requestRecordAudioPermission()}catch(e){console.error(e)}}))}requestRecordAudioPermission(){return __awaiter(this,void 0,void 0,(function*(){let e=yield this.diagnostic.requestRuntimePermissions([this.diagnostic.permission.RECORD_AUDIO]);console.log("record permission request:",e)}))}requestMicPermission(){return __awaiter(this,void 0,void 0,(function*(){let e=yield this.diagnostic.isMicrophoneAuthorized();if(console.log("permisson_MIC:",e),!e){yield this.diagnostic.requestMicrophoneAuthorization()}}))}requestStoagePermission(){return __awaiter(this,void 0,void 0,(function*(){let e=yield this.diagnostic.isExternalStorageAuthorized();if(console.log("permisson_STORAGE:",e),!e){yield this.diagnostic.requestExternalStorageAuthorization()}}))}requestCameraPermission(){return __awaiter(this,void 0,void 0,(function*(){let e=yield this.diagnostic.isCameraAuthorized();if(console.log("permisson_Camera:",e),!e){yield this.diagnostic.requestCameraAuthorization()}}))}}FmodeVoiceService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmodeVoiceService,deps:[{token:i2.Platform},{token:i2$1.Diagnostic}],target:i0.ɵɵFactoryTarget.Injectable}),FmodeVoiceService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmodeVoiceService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmodeVoiceService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[{type:i2.Platform},{type:i2$1.Diagnostic}]}});class RolePointsCloud{constructor(e,t,o){this.offsetPosition=new BABYLON.Vector3(0,1.25,0),this.animationGroup=new BABYLON.AnimationGroup("RoleAnimGroup"),this.AnimMap={idle:null},this.scene=e,this.engine=this.engine}init(){return __awaiter(this,void 0,void 0,(function*(){this.Mesh=this.loadMesh(),this.loadIdleAnim()}))}playAnim(e){this.scene.beginDirectAnimation(this.Mesh,[this.AnimMap[e]],0,120,!0)}loadMesh(){let e=BABYLON.MeshBuilder.CreateSphere("sphere",{diameter:2},this.scene);return e.position.addInPlace(this.offsetPosition),e.visibility=1,e.material=new BABYLON.StandardMaterial("mat",this.scene),e.material.wireframe=!0,e.scaling=new BABYLON.Vector3(1,1,1),e}loadIdleAnim(){let e=new BABYLON.Animation("idle","scaling",30,BABYLON.Animation.ANIMATIONTYPE_VECTOR3,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE),t=[];t.push({frame:0,value:new BABYLON.Vector3(1,1,1)}),t.push({frame:60,value:new BABYLON.Vector3(1.5,1.5,1.5)}),t.push({frame:120,value:new BABYLON.Vector3(1,1,1)}),e.setKeys(t),this.Mesh.animations.push(this.AnimMap.idle),this.AnimMap.idle=e,this.animationGroup.addTargetedAnimation(this.AnimMap.idle,this.Mesh)}}class CompAvatarParticleComponent{constructor(e){this.elementRef=e,this.isWebVR=!1,this.animMap={}}ngAfterViewInit(){if(this.canvas=this.renderCanvas.nativeElement,console.log(this.canvas),this.canvas){let e={};this.engine=new BABYLON.Engine(this.canvas,!0,e),console.log(this.engine),this.createScene(),this.engine.runRenderLoop((()=>{var e,t;null===(e=this.scene)||void 0===e||e.render(),null===(t=this.engine)||void 0===t||t.resize()})),window.addEventListener("resize",(()=>{var e;null===(e=this.engine)||void 0===e||e.resize()}))}}createScene(){var e;return __awaiter(this,void 0,void 0,(function*(){this.scene=new BABYLON.Scene(this.engine),this.scene.clearColor=new BABYLON.Color4(0,0,0,1),this.mainCamera=this.createCamera(),console.log(this.mainCamera),this.currentRole=new RolePointsCloud(this.scene,this.engine,this.mainCamera),yield this.currentRole.init(),this.currentRole.playAnim("idle"),this.currentRole.Mesh.visibility=0,yield this.createCloudPoints();new BABYLON.HemisphericLight("light1",new BABYLON.Vector3(0,1,0),this.scene);null===(e=this.engine)||void 0===e||e.resize()}))}createCamera(){let e=new(this.isWebVR?BABYLON.VRDeviceOrientationArcRotateCamera:BABYLON.ArcRotateCamera)("Camera",0,0,30,new BABYLON.Vector3(0,.5,0),this.scene);return e.setPosition(new BABYLON.Vector3(0,0,5)),e.beta=Math.PI/3,e.alpha=Math.PI/1.2,e.radius=15,e}createCloudPoints(){return __awaiter(this,void 0,void 0,(function*(){this.pointsMesh=this.currentRole.Mesh,this.pointsCloud=new BABYLON.PointsCloudSystem("pcs",1,this.scene);let e=new BABYLON.Color3(.7,.8,1),t=new BABYLON.Color4(.7,.8,1),o=(new BABYLON.Color4(.2,.5,1),new BABYLON.Color4(0,0,.2,0),new BABYLON.Texture("/assets/avatar/particle/textures/flare.png",this.scene)),n=new BABYLON.PBRMaterial("material",this.scene);n.emissiveTexture=o,n.emissiveColor=e,this.pointsCloud.addVolumePoints(this.currentRole.Mesh,5e3,BABYLON.PointColor.Color,t),this.pointsCloud.buildMeshAsync().then((()=>{this.playAnimation("waiting")})),this.scene.registerAfterRender((()=>{this.pointsCloud.setParticles()})),this.engine.runRenderLoop((()=>{this.scene.render()}))}))}playAnimation(e){switch(e){case"waiting":this.cloudAnim();break;case"listening":this.cloudAnim({rotateSpeed:.01,breathing:!1});break;case"thinking":this.cloudAnim({rotateSpeed:.2,breathing:!1});break;case"talking":this.animMap.idle&&this.scene.beginDirectAnimation(this.pointsMesh,[this.animMap.talking],0,20,!0)}}cloudAnim(e={breathing:!0,rotateSpeed:.002}){this.animMap.idle&&this.scene.beginDirectAnimation(this.pointsMesh,[this.animMap.idle],0,120,!0);let t=new BABYLON.Color4(1,1,1,1),o=(new BABYLON.Texture("/assets/avatar/particle/textures/flare.png",this.scene),0);this.pointsCloud.updateParticle=n=>{var i,a,r,s;let l=null===(a=null===(i=this.currentRole.Mesh.getBoundingInfo())||void 0===i?void 0:i.boundingSphere)||void 0===a?void 0:a.radiusWorld,c=null===(s=null===(r=this.currentRole.Mesh.getBoundingInfo())||void 0===r?void 0:r.boundingSphere)||void 0===s?void 0:s.centerWorld;n.idx;if(n.color=t,n.rotation.y+=e.rotateSpeed,n&&o<3&&(console.log(this.currentRole.Mesh.getBoundingInfo()),console.log(n),o++),n.initpos||(n.initpos=n.position),e.breathing){let e=n.initpos.subtract(c);n.position=new BABYLON.Vector3(e.x*l,e.y*l,e.z*l).add(this.currentRole.offsetPosition)}return n}}createSphere(){let e=BABYLON.MeshBuilder.CreateSphere("sphere",{diameter:2},this.scene);e.visibility=1,e.material=new BABYLON.StandardMaterial("mat",this.scene),e.material.wireframe=!0,e.scaling=new BABYLON.Vector3(1,1,1),this.pointsMesh=e;let t=new BABYLON.Animation("breathingAnimation","scaling",30,BABYLON.Animation.ANIMATIONTYPE_VECTOR3,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE),o=[];o.push({frame:0,value:new BABYLON.Vector3(.3,.3,.3)}),o.push({frame:60,value:new BABYLON.Vector3(.5,.5,.5)}),o.push({frame:120,value:new BABYLON.Vector3(.3,.3,.3)}),t.setKeys(o),this.animMap.idle=t;let n=[{frame:0,value:BABYLON.Vector3.One()},{frame:10,value:new BABYLON.Vector3(1.2,.8,1.2)},{frame:20,value:BABYLON.Vector3.One()}],i=new BABYLON.Animation("talkAnimation","scaling",30,BABYLON.Animation.ANIMATIONTYPE_VECTOR3,BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);return i.setKeys(n),this.animMap.talk=i,this.scene.beginDirectAnimation(e,[this.animMap.idle],0,120,!0),e}createParticle(){return __awaiter(this,void 0,void 0,(function*(){let e=this.createSphere(),t=new BABYLON.ParticleSystem("particles",2e3,this.scene);t.particleTexture=new BABYLON.Texture("/assets/avatar/particle/textures/flare.png",this.scene),t.emitter=e,t.minEmitBox=new BABYLON.Vector3(0,0,0),t.maxEmitBox=new BABYLON.Vector3(0,0,0),t.color1=new BABYLON.Color4(.7,.8,1,1),t.color2=new BABYLON.Color4(.2,.5,1,1),t.colorDead=new BABYLON.Color4(0,0,.2,0),t.minSize=.5,t.maxSize=.5,t.minLifeTime=.1,t.maxLifeTime=.1,t.minAngularSpeed=0,t.maxAngularSpeed=Math.PI,t.minInitialRotation=0,t.maxInitialRotation=Math.PI,t.minEmitPower=0,t.maxEmitPower=0,t.emitRate=1500,t.updateSpeed=.01,t.blendMode=BABYLON.ParticleSystem.BLENDMODE_ONEONE,t.direction1=new BABYLON.Vector3(0,0,0),t.direction2=new BABYLON.Vector3(0,0,0),t.start();let o=t.createSphereEmitter();o.radius=2,o.radiusRange=0,o.directionRandomizer=0,t.gravity=new BABYLON.Vector3(0,0,0),t.disposeOnStop=!0,t.updateFunction=o=>{var n,i;for(let a=0;a<o.length;a++){let r=o[a],s=null===(i=null===(n=e.getBoundingInfo())||void 0===n?void 0:n.boundingSphere)||void 0===i?void 0:i.radiusWorld;r.position=r.position.normalize().scale(s),r.age+=this.scene.getEngine().getDeltaTime()/1e3,r.age>=r.lifeTime&&(t.recycleParticle(r),a--)}},this.engine.runRenderLoop((()=>{this.scene.render(),t.worldOffset=e.position}))}))}setCameraToMeshCenter(e,t){t.computeWorldMatrix(!0);let o=t.getBoundingInfo(),n=o.minimum,i=o.maximum,a=i.x-n.x,r=i.y-n.y,s=i.z-n.z,l=o.boundingBox.center;console.log("宽度:"+a),console.log("高度:"+r),console.log("深度:"+s),console.log("中心点:"+l)}}CompAvatarParticleComponent.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompAvatarParticleComponent,deps:[{token:i0.ElementRef}],target:i0.ɵɵFactoryTarget.Component}),CompAvatarParticleComponent.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"14.0.0",version:"15.1.0",type:CompAvatarParticleComponent,isStandalone:!0,selector:"fm-avatar-role-particle",viewQueries:[{propertyName:"renderCanvas",first:!0,predicate:["renderCanvas"],descendants:!0}],ngImport:i0,template:'<canvas #renderCanvas class="render-canvas"></canvas>',styles:[".render-canvas{display:block;width:100%;height:100%;touch-action:none}\n"],dependencies:[{kind:"ngmodule",type:CommonModule},{kind:"ngmodule",type:FormsModule}]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompAvatarParticleComponent,decorators:[{type:Component,args:[{selector:"fm-avatar-role-particle",standalone:!0,imports:[CommonModule,FormsModule],template:'<canvas #renderCanvas class="render-canvas"></canvas>',styles:[".render-canvas{display:block;width:100%;height:100%;touch-action:none}\n"]}]}],ctorParameters:function(){return[{type:i0.ElementRef}]},propDecorators:{renderCanvas:[{type:ViewChild,args:["renderCanvas"]}]}});class CompAvatarRoleImageComponent{constructor(){this.animClass="waiting"}playWave(){!this.wave&&Recorder.WaveView&&(this.wave=Recorder.WaveView({elem:".record-wave-avatar",keep:!1}));let e=function generatePowerLevel(){return 100*Math.random()}();this.waveInterval=setInterval((()=>{let t=function generateSampleRate(){const e=[44100,48e3,88200,96e3];return e[Math.floor(Math.random()*e.length)]}(),o=function generatePcmData(e){const t=[];for(let o=0;o<e;o++)t.push(Math.floor(65536*Math.random())-32768);return t}(1e3);this.wave.input(o,e,t)}),40)}stopWave(){clearInterval(this.waveInterval)}ngAfterViewInit(){}ngOnInit(){setTimeout((()=>{this.fmodeChat.playAnimation=this.playAnimation}),1500)}playAnimation(){let e=this;return t=>{let o=e.avatarImage.nativeElement;switch(e.animClass=t,e.stopWave(),t){case"thinking":case"waiting":o.style.animationPlayState="running";break;case"talking":o.style.animationPlayState="running",e.playWave();break;case"listening":o.style.animationPlayState="pause";break;default:o.style.animationPlayState="paused"}}}}CompAvatarRoleImageComponent.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompAvatarRoleImageComponent,deps:[],target:i0.ɵɵFactoryTarget.Component}),CompAvatarRoleImageComponent.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"14.0.0",version:"15.1.0",type:CompAvatarRoleImageComponent,isStandalone:!0,selector:"fm-avatar-role-image",inputs:{fmodeChat:"fmodeChat",role:"role"},viewQueries:[{propertyName:"avatarImage",first:!0,predicate:["avatarImage"],descendants:!0}],ngImport:i0,template:'<div class="page">\n <div class="avatar" [class]="animClass">\n <div class="avatar-photo">\n <img #avatarImage [src]="role?.get(\'thumb\')" alt="">\n \x3c!-- 音频波动 --\x3e\n <div class="record-wave-avatar">\n </div>\n </div>\n </div>\n</div>',styles:[".page{position:fixed;width:100vw;height:100vh;top:0;left:0;display:flex;justify-content:center;align-items:center;background-color:#000}.avatar{height:50vh;width:100%;display:flex;justify-content:center;align-items:center}.avatar .avatar-photo{position:relative;margin-top:-10vh;width:80%}.avatar .avatar-photo img{border-radius:10px}.avatar .record-wave-avatar{height:50px;width:100%;position:absolute;float:left;left:0;bottom:0}.thinking,.listening,.waiting,.talking{animation-duration:2s;animation-play-state:running;animation-iteration-count:infinite;animation-timing-function:ease-in-out}@keyframes waitingAnimation{0%{transform:scale(1)}50%{transform:scale(1.05)}to{transform:scale(1)}}@keyframes thinkingAnimation{0%{transform:rotate(0)}30%{transform:rotate(10deg)}60%{transform:rotate(-10deg)}to{transform:rotate(0)}}.thinking{animation-name:thinkingAnimation}.waiting{animation-name:waitingAnimation}.listening{animation-name:listeningAnimation}.talking{animation-name:talkingAnimation}\n"],dependencies:[{kind:"ngmodule",type:CommonModule},{kind:"ngmodule",type:FormsModule}]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompAvatarRoleImageComponent,decorators:[{type:Component,args:[{selector:"fm-avatar-role-image",standalone:!0,imports:[CommonModule,FormsModule],template:'<div class="page">\n <div class="avatar" [class]="animClass">\n <div class="avatar-photo">\n <img #avatarImage [src]="role?.get(\'thumb\')" alt="">\n \x3c!-- 音频波动 --\x3e\n <div class="record-wave-avatar">\n </div>\n </div>\n </div>\n</div>',styles:[".page{position:fixed;width:100vw;height:100vh;top:0;left:0;display:flex;justify-content:center;align-items:center;background-color:#000}.avatar{height:50vh;width:100%;display:flex;justify-content:center;align-items:center}.avatar .avatar-photo{position:relative;margin-top:-10vh;width:80%}.avatar .avatar-photo img{border-radius:10px}.avatar .record-wave-avatar{height:50px;width:100%;position:absolute;float:left;left:0;bottom:0}.thinking,.listening,.waiting,.talking{animation-duration:2s;animation-play-state:running;animation-iteration-count:infinite;animation-timing-function:ease-in-out}@keyframes waitingAnimation{0%{transform:scale(1)}50%{transform:scale(1.05)}to{transform:scale(1)}}@keyframes thinkingAnimation{0%{transform:rotate(0)}30%{transform:rotate(10deg)}60%{transform:rotate(-10deg)}to{transform:rotate(0)}}.thinking{animation-name:thinkingAnimation}.waiting{animation-name:waitingAnimation}.listening{animation-name:listeningAnimation}.talking{animation-name:talkingAnimation}\n"]}]}],propDecorators:{avatarImage:[{type:ViewChild,args:["avatarImage"]}],fmodeChat:[{type:Input}],role:[{type:Input}]}});class FmodeTTS{constructor(e){this.subscriptionKey=null==e?void 0:e.subscriptionKey,this.authorizationToken=null==e?void 0:e.token,this.region=null==e?void 0:e.region,this.subscriptionKey&&(this.speechConfig=sdk.SpeechConfig.fromSubscription(this.subscriptionKey,this.region)),this.authorizationToken&&(this.speechConfig=sdk.SpeechConfig.fromAuthorizationToken(this.authorizationToken,this.region),console.log(this.authorizationToken,this.speechConfig)),console.log(this.speechConfig),this.synthesizer=new sdk.SpeechSynthesizer(this.speechConfig)}extractSSMLContent(e){var t=e.match(/<speak.*?<\/speak>/);return t?t[0]:e}speakAsync(e){return __awaiter(this,void 0,void 0,(function*(){return e=this.extractSSMLContent(e),new Promise(((t,o)=>{const n=Date.now();let i="speakTextAsync";(null==e?void 0:e.indexOf("<"))>-1&&(i="speakSsmlAsync"),console.log(e),this.synthesizer[i](e,(e=>{if(console.log(e),console.log(e.resultId),console.log(e.reason),e.reason===sdk.ResultReason.SynthesizingAudioCompleted){const o=Date.now();let i=null==e?void 0:e.audioData;this.playAudioData(i),console.log(`Audio synthesis finished. Duration: ${o-n} ms`),t()}else o(`Speech synthesis failed. Reason: ${e.errorDetails}`)}),(e=>{o(`Error occurred during synthesis: ${e}`)}))}))}))}onBreak(e){}playAudioData(e){let t=new Blob([e],{type:"audio/wav"}),o=URL.createObjectURL(t);new Audio(o).play()}}class ModalChatVoiceInputComponent{constructor(e,t,o,n,i,a){this.platform=e,this.router=t,this.voiceServ=o,this.toastCtrl=n,this.ncloud=i,this.chatServ=a,this.talkMode="click",this.talkTips="点击话筒开始讲话",this.errorText="",this.player=new Audio}ngOnInit(){"press"==this.talkMode&&(this.talkTips="轻触底部开始讲话"),setTimeout((()=>{this.initVoiceSevice(),this.initVoiceASR()}),500)}initVoiceASR(){return __awaiter(this,void 0,void 0,(function*(){this.voiceServ.requestPermission().then((()=>{this.voiceServ.openWithPriviledge(),this.startASRAwake()}))}))}startASRAwake(){return __awaiter(this,void 0,void 0,(function*(){yield this.voiceServ.openWithPriviledge(),new this.voiceServ.webSpeech(this.platform).startRecognition("Nihao | Hello")}))}playMusic(e){this.player.src=`/assets/avatar/voice/${e}.mp3`,this.player.play()}initVoiceSevice(){this.fmodeChat.userInput=this.voiceServ.resultText,this.voiceServ.requestPermission().then((()=>{this.voiceServ.openWithPriviledge()})),this.voiceServ.onBeforeStartTalk=()=>{this.fmodeChat.playAnimation("listening"),this.playMusic("start-talk")},this.voiceServ.onBeforeCancelTalk=()=>{this.playMusic("interupt-talk"),this.fmodeChat.playAnimation("waiting")},this.voiceServ.onAfterCancelTalk=()=>{this.startASRAwake()},this.voiceServ.onBeforeFinishTalk=()=>{this.fmodeChat.playAnimation("thinking"),this.playMusic("stop-talk")},this.voiceServ.onAfterFinishTalk=()=>{var e;console.log("onAfterFinishTalk"),this.fmodeChat.userInput=null===(e=this.voiceServ)||void 0===e?void 0:e.resultText,this.sendMessage(),this.startASRAwake()}}sendMessage(){var e;return __awaiter(this,void 0,void 0,(function*(){if(!this.fmodeChat.userInput){return this.errorText="内容不能为空",void(yield this.toastCtrl.create({message:this.errorText,position:"top",icon:"alert",color:"warning-circle",duration:1e3})).present()}null===(e=this.fmodeChat)||void 0===e||e.sendMessage(this.voiceServ.resultText,null,(e=>{let t=e.content;this.playTTS(t),this.fmodeChat.playAnimation("talking"),setTimeout((()=>{this.fmodeChat.playAnimation("waiting")}),6e3)})),this.fmodeChat.userInput="",this.fmodeChat.userImage=""}))}initTTS(){return __awaiter(this,void 0,void 0,(function*(){let e=yield this.ncloud.apig("voice/voice/tts/token",{company:localStorage.getItem("company")});if(console.log(e),null==e?void 0:e.token){let t=new FmodeTTS(e);this.tts=t}}))}playTTS(e){return __awaiter(this,void 0,void 0,(function*(){if(yield this.initTTS(),console.log(this.tts),this.tts)try{yield this.tts.speakAsync(e)}catch(e){console.error(e)}}))}playTTSTeting(){this.playTTS('<speak xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="http://www.w3.org/2001/mstts" xmlns:emo="http://www.w3.org/2009/10/emotionml" version="1.0" xml:lang="zh-CN">\n <voice name="zh-CN-XiaoxiaoNeural"><mstts:express-as style="angry">”好没意思的话!去不去,关我什么事儿?又没叫你替我解闷儿,还许你<mstts:ttsbreak strength="none" />从此<prosody contour="(24%, +49%) (59%, -2%)">不</prosody><prosody rate="-15.00%" contour="(24%, +49%) (59%, -2%)">理</prosody><prosody contour="(24%, +49%) (59%, -2%)">我呢</prosody>!”</mstts:express-as></voice>\n </speak>')}testTTS(e){console.log(e),e=e||"你好呀,我是飞马小智!很高兴为您介绍脑控科技的发展历程。我们成立于2019年",new this.voiceServ.webSpeech(this.platform).speak(e)}testXunfeiTTS(){}}ModalChatVoiceInputComponent.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ModalChatVoiceInputComponent,deps:[{token:i2.Platform},{token:i3.Router},{token:FmodeVoiceService},{token:i2.ToastController},{token:NovaCloudService},{token:ChatService}],target:i0.ɵɵFactoryTarget.Component}),ModalChatVoiceInputComponent.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"14.0.0",version:"15.1.0",type:ModalChatVoiceInputComponent,isStandalone:!0,selector:"fm-modal-chat-voice-input",inputs:{fmodeChat:"fmodeChat",talkMode:"talkMode"},providers:[FmodeVoiceService],ngImport:i0,template:' \n <ng-container *ngIf="fmodeChat">\n\n \x3c!-- 用户输入 提示区域 --\x3e\n <div class="user-asr-input" style="text-align: center;" *ngIf="!fmodeChat?.userInput && voiceServ.btnStatus!=\'OPEN\'">{{talkTips}}</div>\n <div class="user-asr-input">{{fmodeChat?.userInput}}</div>\n \n \x3c!-- 测试按钮 --\x3e\n <div class="test-button-group" *ngIf="false">\n <button class="button-record" (click)="voiceServ.toggleRecord()">开始录制 {{voiceServ.connStatus}} {{voiceServ.btnStatus}}</button>\n <br>\n <button class="button-record" (click)="voiceServ.playRecord()">播放录制结果</button>\n <br>\n <button class="button-record" (click)="voiceServ.playBuffers()">播放Buffers结果</button>\n <button (click)="testTTS()">测试TTS纯WEB</button>\n <button (click)="startASR()">测试ASR</button> \n <button (click)="testXunfeiTTS()">测试合成</button> \n </div>\n\n \n \n \x3c!-- 交互按钮 --\x3e\n <ion-fab slot="fixed" horizontal="center" vertical="bottom">\n <ng-container *ngIf="talkMode==\'click\'">\n \x3c!-- 默认按钮:开始讲话 --\x3e\n <ion-fab-button color="primary" closeIcon="checkmark" (click)="voiceServ.toggleRecord()">\n <ion-icon name="mic-outline"></ion-icon>\n </ion-fab-button>\n\n \x3c!-- 讲话中:取消发送 --\x3e\n <ion-fab-list side="end">\n <ion-fab-button [class]="\'loading\'" (click)="voiceServ.cancelTalk()">\n <ion-icon name="pause-outline"></ion-icon>\n </ion-fab-button>\n </ion-fab-list>\n </ng-container>\n \n <ng-container *ngIf="talkMode==\'press\'">\n <ion-fab-button color="primary" closeIcon="mic-outline" (touchstart)="voiceServ.toggleRecord()" (touchend)="voiceServ.cancelTalk()">\n <ion-icon name="mic-outline"></ion-icon>\n </ion-fab-button>\n </ng-container>\n </ion-fab>\n\n\n \x3c!-- 音频波动 --\x3e\n <div class="record-wave">\n </div>\n</ng-container>\n',styles:['ion-fab{margin-bottom:15vh}.fab-button-close-active:before{content:"";position:absolute;top:-5px;left:-5px;width:66px;height:66px;border-radius:50%;border:5px solid #fff;border-top-color:transparent;animation:spin 2s ease-in-out infinite;animation-fill-mode:both;animation-play-state:running}.record-wave{position:fixed;bottom:0;width:100vw;height:6vh}\n'],dependencies:[{kind:"ngmodule",type:CommonModule},{kind:"directive",type:i1$2.NgIf,selector:"[ngIf]",inputs:["ngIf","ngIfThen","ngIfElse"]},{kind:"ngmodule",type:IonicModule},{kind:"component",type:i2.IonFab,selector:"ion-fab",inputs:["activated","edge","horizontal","vertical"]},{kind:"component",type:i2.IonFabButton,selector:"ion-fab-button",inputs:["activated","closeIcon","color","disabled","download","href","mode","rel","routerAnimation","routerDirection","show","size","target","translucent","type"]},{kind:"component",type:i2.IonFabList,selector:"ion-fab-list",inputs:["activated","side"]},{kind:"component",type:i2.IonIcon,selector:"ion-icon",inputs:["color","flipRtl","icon","ios","lazy","md","mode","name","sanitize","size","src"]},{kind:"ngmodule",type:RouterModule}]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:ModalChatVoiceInputComponent,decorators:[{type:Component,args:[{selector:"fm-modal-chat-voice-input",standalone:!0,imports:[CommonModule,IonicModule,RouterModule],providers:[FmodeVoiceService],template:' \n <ng-container *ngIf="fmodeChat">\n\n \x3c!-- 用户输入 提示区域 --\x3e\n <div class="user-asr-input" style="text-align: center;" *ngIf="!fmodeChat?.userInput && voiceServ.btnStatus!=\'OPEN\'">{{talkTips}}</div>\n <div class="user-asr-input">{{fmodeChat?.userInput}}</div>\n \n \x3c!-- 测试按钮 --\x3e\n <div class="test-button-group" *ngIf="false">\n <button class="button-record" (click)="voiceServ.toggleRecord()">开始录制 {{voiceServ.connStatus}} {{voiceServ.btnStatus}}</button>\n <br>\n <button class="button-record" (click)="voiceServ.playRecord()">播放录制结果</button>\n <br>\n <button class="button-record" (click)="voiceServ.playBuffers()">播放Buffers结果</button>\n <button (click)="testTTS()">测试TTS纯WEB</button>\n <button (click)="startASR()">测试ASR</button> \n <button (click)="testXunfeiTTS()">测试合成</button> \n </div>\n\n \n \n \x3c!-- 交互按钮 --\x3e\n <ion-fab slot="fixed" horizontal="center" vertical="bottom">\n <ng-container *ngIf="talkMode==\'click\'">\n \x3c!-- 默认按钮:开始讲话 --\x3e\n <ion-fab-button color="primary" closeIcon="checkmark" (click)="voiceServ.toggleRecord()">\n <ion-icon name="mic-outline"></ion-icon>\n </ion-fab-button>\n\n \x3c!-- 讲话中:取消发送 --\x3e\n <ion-fab-list side="end">\n <ion-fab-button [class]="\'loading\'" (click)="voiceServ.cancelTalk()">\n <ion-icon name="pause-outline"></ion-icon>\n </ion-fab-button>\n </ion-fab-list>\n </ng-container>\n \n <ng-container *ngIf="talkMode==\'press\'">\n <ion-fab-button color="primary" closeIcon="mic-outline" (touchstart)="voiceServ.toggleRecord()" (touchend)="voiceServ.cancelTalk()">\n <ion-icon name="mic-outline"></ion-icon>\n </ion-fab-button>\n </ng-container>\n </ion-fab>\n\n\n \x3c!-- 音频波动 --\x3e\n <div class="record-wave">\n </div>\n</ng-container>\n',styles:['ion-fab{margin-bottom:15vh}.fab-button-close-active:before{content:"";position:absolute;top:-5px;left:-5px;width:66px;height:66px;border-radius:50%;border:5px solid #fff;border-top-color:transparent;animation:spin 2s ease-in-out infinite;animation-fill-mode:both;animation-play-state:running}.record-wave{position:fixed;bottom:0;width:100vw;height:6vh}\n']}]}],ctorParameters:function(){return[{type:i2.Platform},{type:i3.Router},{type:FmodeVoiceService},{type:i2.ToastController},{type:NovaCloudService},{type:ChatService}]},propDecorators:{fmodeChat:[{type:Input}],talkMode:[{type:Input}]}});class CompAvatarTalkComponent{constructor(e,t,o,n,i,a,r){this.voiceServ=e,this.platform=t,this.router=o,this.navCtrl=n,this.route=i,this.chatServ=a,this.ncloud=r,this.route.paramMap.subscribe((e=>{this.roleId=e.get("roleId"),this.loadAvatarRole(this.roleId)})),document.body.classList.add("dark")}ngOnInit(){}ngOnDestroy(){document.body.classList.remove("dark"),this.voiceServ.resultText=null,this.fmodeChat&&(this.fmodeChat.latestAIResponse=null)}goBack(){document.body.classList.remove("dark"),this.navCtrl.navigateRoot("/chat/pro/role/"+this.roleId)}loadAvatarRole(e){return __awaiter(this,void 0,void 0,(function*(){let t=new Parse.Query("AvatarRole");this.avatarRole=yield t.get(e);let o=yield this.chatServ.createNewRoleChat(this.roleId);o.isTalkMode=!0,this.fmodeChat=o}))}ngAfterViewInit(){this.listenDivChange()}listenDivChange(){new MutationObserver((()=>{this.scrollToBottom(this.aiRespComp)})).observe(this.aiRespComp.nativeElement,{childList:!0,subtree:!0,attributes:!0})}scrollToBottom(e){var t;(null===(t=null==e?void 0:e.nativeElement)||void 0===t?void 0:t.scrollHeight)&&(e.nativeElement.scrollTop=e.nativeElement.scrollHeight)}}CompAvatarTalkComponent.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompAvatarTalkComponent,deps:[{token:FmodeVoiceService},{token:i2.Platform},{token:i3.Router},{token:i2.NavController},{token:i3.ActivatedRoute},{token:ChatService},{token:NovaCloudService}],target:i0.ɵɵFactoryTarget.Component}),CompAvatarTalkComponent.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"14.0.0",version:"15.1.0",type:CompAvatarTalkComponent,isStandalone:!0,selector:"app-comp-avatar-talk",providers:[FmodeVoiceService,NovaCloudService,ChatService,Diagnostic],viewQueries:[{propertyName:"avatarComp",first:!0,predicate:["avatar"],descendants:!0},{propertyName:"aiRespComp",first:!0,predicate:["aiRespComp"],descendants:!0}],ngImport:i0,template:'<ion-menu #menu contentId="main-content" side="end">\n <ion-header>\n <ion-toolbar>\n <ion-title>资料</ion-title>\n </ion-toolbar>\n </ion-header>\n <ion-content class="ion-padding">\n\n <ion-card style="margin: 0px;">\n <img [src]="avatarRole?.get(\'thumb\')" alt="">\n <ion-card-header>\n <ion-card-subtitle>{{avatarRole?.get(\'tags\')}}</ion-card-subtitle>\n <ion-card-title>{{avatarRole?.get("name")}}</ion-card-title>\n </ion-card-header>\n \n <ion-card-content>\n {{avatarRole?.get("desc")}}\n\n <ion-list [inset]="true" style="margin:0px;">\n \x3c!-- <ion-item>\n <ion-avatar *ngIf="avatarRole?.get(\'thumb\')" aria-hidden="true" slot="start">\n <img [src]="avatarRole?.get(\'thumb\')" />\n </ion-avatar>\n <ion-label>{{avatarRole?.get("name")}}</ion-label>\n </ion-item> --\x3e\n <ion-item lines="none" *ngIf="avatarRole?.get(\'age\')">\n <ion-note slot="start">年龄</ion-note>\n <ion-label>{{avatarRole?.get("age")}}</ion-label>\n </ion-item>\n <ion-item lines="none" *ngIf="avatarRole?.get(\'gender\')">\n <ion-note slot="start">性别</ion-note>\n <ion-label>{{avatarRole?.get("gender")}}</ion-label>\n </ion-item>\n <ion-item lines="none">\n <ion-note slot="start">称号</ion-note>\n <ion-label>{{avatarRole?.get("title")}}</ion-label>\n </ion-item>\n \n <ion-item lines="none">\n <ion-note slot="start">擅长</ion-note>\n <ion-label>{{avatarRole?.get("tags")?.join(\',\')}}</ion-label>\n </ion-item>\n\n </ion-list>\n </ion-card-content>\n </ion-card>\n \n \n \n </ion-content>\n</ion-menu>\n\n<div class="ion-page" id="main-content">\n <ion-header class="ion-no-border">\n <ion-toolbar>\n <ion-buttons slot="start">\n <ion-button (click)="goBack()"> <ion-icon name="chevron-back-outline"></ion-icon> </ion-button>\n </ion-buttons>\n <ion-title>\n <ion-chip *ngIf="avatarRole?.get(\'title\')">{{avatarRole?.get("title")}}</ion-chip>\n </ion-title>\n <ion-buttons slot="end">\n \x3c!-- <ion-button (click)="playTTSTeting()">TTS测试</ion-button> --\x3e\n {{avatarRole?.get("name")}}\n <ion-button (click)="menu.toggle()"> <ion-icon name="ellipsis-horizontal-outline"></ion-icon> </ion-button>\n </ion-buttons>\n </ion-toolbar>\n </ion-header>\n\n <ion-segment value="voice">\n <ion-segment-button (click)="chatServ.createChatPanel(avatarRole)" value="chat">\n <ion-label>聊天</ion-label>\n </ion-segment-button>\n <ion-segment-button routerLink="{{\'/avatar/role/\'+avatarRole?.id}}" value="voice">\n <ion-label>语音</ion-label>\n </ion-segment-button>\n </ion-segment>\n\n \x3c!-- 数字形象:动画效果 --\x3e\n <fm-avatar-role-image *ngIf="avatarRole&&fmodeChat" [fmodeChat]="fmodeChat" [role]="avatarRole" #avatar class="avatar"></fm-avatar-role-image>\n \x3c!-- <fm-avatar-role-particle #avatar class="avatar"></fm-avatar-role-particle> --\x3e\n\n \x3c!-- AI回复的最新消息 --\x3e\n <div class="ai-resp-input" #aiRespComp>{{fmodeChat?.latestAIResponse | hidexml}}</div>\n\n <fm-modal-chat-voice-input *ngIf="fmodeChat" [fmodeChat]="fmodeChat"></fm-modal-chat-voice-input>\n\n</div>\n\n',styles:["ion-menu ion-note{color:#ccc;font-weight:700}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.avatar{display:block;width:100%;height:100%}.ai-resp-input{font-size:1rem;color:#fff;position:fixed;top:5vh;max-height:15vh;overflow-y:scroll;padding:0 10px}.user-asr-input{font-size:1rem;color:#fff;position:fixed;bottom:6vh;padding:0 10px}.test-button-group{color:#00f;position:fixed;bottom:20vh}.test-button-group button{padding:10px;margin:10px}\n"],dependencies:[{kind:"ngmodule",type:CommonModule},{kind:"directive",type:i1$2.NgIf,selector:"[ngIf]",inputs:["ngIf","ngIfThen","ngIfElse"]},{kind:"ngmodule",type:RouterModule},{kind:"directive",type:i3.RouterLink,selector:"[routerLink]",inputs:["target","queryParams","fragment","queryParamsHandling","state","relativeTo","preserveFragment","skipLocationChange","replaceUrl","routerLink"]},{kind:"ngmodule",type:FormsModule},{kind:"ngmodule",type:IonicModule},{kind:"component",type:i2.IonButton,selector:"ion-button",inputs:["buttonType","color","disabled","download","expand","fill","form","href","mode","rel","routerAnimation","routerDirection","shape","size","strong","target","type"]},{kind:"component",type:i2.IonButtons,selector:"ion-buttons",inputs:["collapse"]},{kind:"component",type:i2.IonCard,selector:"ion-card",inputs:["button","color","disabled","download","href","mode","rel","routerAnimation","routerDirection","target","type"]},{kind:"component",type:i2.IonCardContent,selector:"ion-card-content",inputs:["mode"]},{kind:"component",type:i2.IonCardHeader,selector:"ion-card-header",inputs:["color","mode","translucent"]},{kind:"component",type:i2.IonCardSubtitle,selector:"ion-card-subtitle",inputs:["color","mode"]},{kind:"component",type:i2.IonCardTitle,selector:"ion-card-title",inputs:["color","mode"]},{kind:"component",type:i2.IonChip,selector:"ion-chip",inputs:["color","disabled","mode","outline"]},{kind:"component",type:i2.IonContent,selector:"ion-content",inputs:["color","forceOverscroll","fullscreen","scrollEvents","scrollX","scrollY"]},{kind:"component",type:i2.IonHeader,selector:"ion-header",inputs:["collapse","mode","translucent"]},{kind:"component",type:i2.IonIcon,selector:"ion-icon",inputs:["color","flipRtl","icon","ios","lazy","md","mode","name","sanitize","size","src"]},{kind:"component",type:i2.IonItem,selector:"ion-item",inputs:["button","color","counter","counterFormatter","detail","detailIcon","disabled","download","fill","href","lines","mode","rel","routerAnimation","routerDirection","shape","target","type"]},{kind:"component",type:i2.IonLabel,selector:"ion-label",inputs:["color","mode","position"]},{kind:"component",type:i2.IonList,selector:"ion-list",inputs:["inset","lines","mode"]},{kind:"component",type:i2.IonMenu,selector:"ion-menu",inputs:["contentId","disabled","maxEdgeStart","menuId","side","swipeGesture","type"]},{kind:"component",type:i2.IonNote,selector:"ion-note",inputs:["color","mode"]},{kind:"component",type:i2.IonSegment,selector:"ion-segment",inputs:["color","disabled","mode","scrollable","selectOnFocus","swipeGesture","value"]},{kind:"component",type:i2.IonSegmentButton,selector:"ion-segment-button",inputs:["disabled","layout","mode","type","value"]},{kind:"component",type:i2.IonTitle,selector:"ion-title",inputs:["color","size"]},{kind:"component",type:i2.IonToolbar,selector:"ion-toolbar",inputs:["color","mode"]},{kind:"directive",type:i2.SelectValueAccessor,selector:"ion-range, ion-select, ion-radio-group, ion-segment, ion-datetime"},{kind:"directive",type:i2.RouterLinkDelegate,selector:":not(a):not(area)[routerLink]",inputs:["routerDirection","routerAnimation"]},{kind:"component",type:CompAvatarRoleImageComponent,selector:"fm-avatar-role-image",inputs:["fmodeChat","role"]},{kind:"component",type:ModalChatVoiceInputComponent,selector:"fm-modal-chat-voice-input",inputs:["fmodeChat","talkMode"]},{kind:"pipe",type:HidexmlPipe,name:"hidexml"}]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompAvatarTalkComponent,decorators:[{type:Component,args:[{selector:"app-comp-avatar-talk",standalone:!0,imports:[CommonModule,RouterModule,FormsModule,IonicModule,CompAvatarParticleComponent,CompAvatarRoleImageComponent,ModalChatVoiceInputComponent,HidexmlPipe],providers:[FmodeVoiceService,NovaCloudService,ChatService,Diagnostic],template:'<ion-menu #menu contentId="main-content" side="end">\n <ion-header>\n <ion-toolbar>\n <ion-title>资料</ion-title>\n </ion-toolbar>\n </ion-header>\n <ion-content class="ion-padding">\n\n <ion-card style="margin: 0px;">\n <img [src]="avatarRole?.get(\'thumb\')" alt="">\n <ion-card-header>\n <ion-card-subtitle>{{avatarRole?.get(\'tags\')}}</ion-card-subtitle>\n <ion-card-title>{{avatarRole?.get("name")}}</ion-card-title>\n </ion-card-header>\n \n <ion-card-content>\n {{avatarRole?.get("desc")}}\n\n <ion-list [inset]="true" style="margin:0px;">\n \x3c!-- <ion-item>\n <ion-avatar *ngIf="avatarRole?.get(\'thumb\')" aria-hidden="true" slot="start">\n <img [src]="avatarRole?.get(\'thumb\')" />\n </ion-avatar>\n <ion-label>{{avatarRole?.get("name")}}</ion-label>\n </ion-item> --\x3e\n <ion-item lines="none" *ngIf="avatarRole?.get(\'age\')">\n <ion-note slot="start">年龄</ion-note>\n <ion-label>{{avatarRole?.get("age")}}</ion-label>\n </ion-item>\n <ion-item lines="none" *ngIf="avatarRole?.get(\'gender\')">\n <ion-note slot="start">性别</ion-note>\n <ion-label>{{avatarRole?.get("gender")}}</ion-label>\n </ion-item>\n <ion-item lines="none">\n <ion-note slot="start">称号</ion-note>\n <ion-label>{{avatarRole?.get("title")}}</ion-label>\n </ion-item>\n \n <ion-item lines="none">\n <ion-note slot="start">擅长</ion-note>\n <ion-label>{{avatarRole?.get("tags")?.join(\',\')}}</ion-label>\n </ion-item>\n\n </ion-list>\n </ion-card-content>\n </ion-card>\n \n \n \n </ion-content>\n</ion-menu>\n\n<div class="ion-page" id="main-content">\n <ion-header class="ion-no-border">\n <ion-toolbar>\n <ion-buttons slot="start">\n <ion-button (click)="goBack()"> <ion-icon name="chevron-back-outline"></ion-icon> </ion-button>\n </ion-buttons>\n <ion-title>\n <ion-chip *ngIf="avatarRole?.get(\'title\')">{{avatarRole?.get("title")}}</ion-chip>\n </ion-title>\n <ion-buttons slot="end">\n \x3c!-- <ion-button (click)="playTTSTeting()">TTS测试</ion-button> --\x3e\n {{avatarRole?.get("name")}}\n <ion-button (click)="menu.toggle()"> <ion-icon name="ellipsis-horizontal-outline"></ion-icon> </ion-button>\n </ion-buttons>\n </ion-toolbar>\n </ion-header>\n\n <ion-segment value="voice">\n <ion-segment-button (click)="chatServ.createChatPanel(avatarRole)" value="chat">\n <ion-label>聊天</ion-label>\n </ion-segment-button>\n <ion-segment-button routerLink="{{\'/avatar/role/\'+avatarRole?.id}}" value="voice">\n <ion-label>语音</ion-label>\n </ion-segment-button>\n </ion-segment>\n\n \x3c!-- 数字形象:动画效果 --\x3e\n <fm-avatar-role-image *ngIf="avatarRole&&fmodeChat" [fmodeChat]="fmodeChat" [role]="avatarRole" #avatar class="avatar"></fm-avatar-role-image>\n \x3c!-- <fm-avatar-role-particle #avatar class="avatar"></fm-avatar-role-particle> --\x3e\n\n \x3c!-- AI回复的最新消息 --\x3e\n <div class="ai-resp-input" #aiRespComp>{{fmodeChat?.latestAIResponse | hidexml}}</div>\n\n <fm-modal-chat-voice-input *ngIf="fmodeChat" [fmodeChat]="fmodeChat"></fm-modal-chat-voice-input>\n\n</div>\n\n',styles:["ion-menu ion-note{color:#ccc;font-weight:700}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.avatar{display:block;width:100%;height:100%}.ai-resp-input{font-size:1rem;color:#fff;position:fixed;top:5vh;max-height:15vh;overflow-y:scroll;padding:0 10px}.user-asr-input{font-size:1rem;color:#fff;position:fixed;bottom:6vh;padding:0 10px}.test-button-group{color:#00f;position:fixed;bottom:20vh}.test-button-group button{padding:10px;margin:10px}\n"]}]}],ctorParameters:function(){return[{type:FmodeVoiceService},{type:i2.Platform},{type:i3.Router},{type:i2.NavController},{type:i3.ActivatedRoute},{type:ChatService},{type:NovaCloudService}]},propDecorators:{avatarComp:[{type:ViewChild,args:["avatar"]}],aiRespComp:[{type:ViewChild,args:["aiRespComp"]}]}});const AvatarRoutes=[{path:"role/:roleId",component:CompAvatarTalkComponent,runGuardsAndResolvers:"always"}];class AvatarModule{}AvatarModule.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:AvatarModule,deps:[],target:i0.ɵɵFactoryTarget.NgModule}),AvatarModule.ɵmod=i0.ɵɵngDeclareNgModule({minVersion:"14.0.0",version:"15.1.0",ngImport:i0,type:AvatarModule,imports:[CommonModule,FormsModule,HttpClientModule,ReactiveFormsModule,i3.RouterModule,CompAvatarTalkComponent],exports:[CompAvatarTalkComponent]}),AvatarModule.ɵinj=i0.ɵɵngDeclareInjector({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:AvatarModule,imports:[CommonModule,FormsModule,HttpClientModule,ReactiveFormsModule,RouterModule.forChild(AvatarRoutes),CompAvatarTalkComponent]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:AvatarModule,decorators:[{type:NgModule,args:[{declarations:[],imports:[CommonModule,FormsModule,HttpClientModule,ReactiveFormsModule,RouterModule.forChild(AvatarRoutes),CompAvatarTalkComponent],exports:[CompAvatarTalkComponent]}]}]}),window._AMapSecurityConfig={securityJsCode:"32aa3f4ab0fa0061de03edd4eafdd50a"};class PageMapStartComponent{constructor(){this.placeList=[{name:"江财蛟桥校区",location:[115.855125,28.744335]},{name:"江财枫林校区",location:[115.835639,28.734119]},{name:"江财麦庐校区",location:[115.816717,28.728899]}]}ngAfterViewInit(){this.initMap()}initMap(){return __awaiter(this,void 0,void 0,(function*(){yield this.createMap(),this.goAndMarkPlace(this.placeList[1])}))}createMap(){return __awaiter(this,void 0,void 0,(function*(){this.AMap=yield AMapLoader.load({key:"473b52010df7d3a32db0a2f5db245c8e",version:"2.0"}),this.map=new this.AMap.Map("container")}))}addMarks(){return __awaiter(this,void 0,void 0,(function*(){let e=new this.AMap.Marker({position:[115.835639,28.734119]});this.map.add(e)}))}goAndMarkPlace(e){this.map.setCenter(e.location),this.map.setZoom(18),console.log(this.placeList),e.marker||(e.marker=new this.AMap.Marker({position:e.location}),this.map.add(e.marker))}clearMark(e){var t;null===(t=null==e?void 0:e.marker)||void 0===t||t.remove()}planRoute(e,t){let o;this.map.plugin(["AMap.Transfer"],(()=>{let n={map:this.map,city:"南昌市",panel:"panel",policy:this.AMap.TransferPolicy.LEAST_TIME};console.log(this.AMap),console.log(this.AMap.TransferPolicy),o=new this.AMap.Transfer(n),o.search(new this.AMap.LngLat(e.location[0],e.location[1]),new this.AMap.LngLat(t.location[0],t.location[1]),((e,t)=>{"complete"===e?(console.log("绘制公交路线完成:"),console.log(t)):console.error("公交路线数据查询失败"+t)}))}))}}PageMapStartComponent.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:PageMapStartComponent,deps:[],target:i0.ɵɵFactoryTarget.Component}),PageMapStartComponent.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"14.0.0",version:"15.1.0",type:PageMapStartComponent,selector:"app-page-map.start",ngImport:i0,template:'\x3c!-- 全屏地图 --\x3e\n<div id="container"></div>\n\n\x3c!-- 右侧地点 --\x3e\n<div class="place-list">\n <ng-container *ngFor="let place of placeList">\n <div class="place-item" (click)="goAndMarkPlace(place)">\n {{place.name}}\n <button (click)="clearMark(place)">清除标记</button>\n </div>\n </ng-container>\n\n <button (click)="planRoute(placeList[0],placeList[1])">从蛟桥到枫林</button>\n \n</div>',styles:["#container{width:100%;height:100%;position:fixed}.place-list{display:flex;flex-direction:column;position:fixed;justify-content:center;align-items:center;height:80%;width:200px}.place-list .place-item{background-color:#ffffff4d;height:100px;width:90%}\n"],dependencies:[{kind:"directive",type:i1$2.NgForOf,selector:"[ngFor][ngForOf]",inputs:["ngForOf","ngForTrackBy","ngForTemplate"]}]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:PageMapStartComponent,decorators:[{type:Component,args:[{selector:"app-page-map.start",template:'\x3c!-- 全屏地图 --\x3e\n<div id="container"></div>\n\n\x3c!-- 右侧地点 --\x3e\n<div class="place-list">\n <ng-container *ngFor="let place of placeList">\n <div class="place-item" (click)="goAndMarkPlace(place)">\n {{place.name}}\n <button (click)="clearMark(place)">清除标记</button>\n </div>\n </ng-container>\n\n <button (click)="planRoute(placeList[0],placeList[1])">从蛟桥到枫林</button>\n \n</div>',styles:["#container{width:100%;height:100%;position:fixed}.place-list{display:flex;flex-direction:column;position:fixed;justify-content:center;align-items:center;height:80%;width:200px}.place-list .place-item{background-color:#ffffff4d;height:100px;width:90%}\n"]}]}]}),window._AMapSecurityConfig={securityJsCode:"32aa3f4ab0fa0061de03edd4eafdd50a"};class CompPoiPickerComponent{get name(){return this._name}set name(e){this._name=e,this.nameChange.emit(e)}get address(){return this._address}set address(e){this._address=e,this.addressChange.emit(e)}get location(){return this._location}set location(e){this._location=e,this.locationChange.emit(e)}constructor(){this.nameChange=new EventEmitter,this.addressChange=new EventEmitter,this.locationChange=new EventEmitter,this.isModalOpen=!1}cancel(){this.isModalOpen=!1,this.modal.dismiss(null,"cancel")}confirm(){this.isModalOpen=!1,this.modal.dismiss(this.address,"confirm")}onWillDismiss(e){"confirm"===e.detail.role&&console.log("确认")}openModal(){this.isModalOpen=!0,setTimeout((()=>{this.initMap()}),800)}ngAfterViewInit(){}initMap(){this.createMap()}createMap(){return __awaiter(this,void 0,void 0,(function*(){this.AMap=yield AMapLoader.load({key:"473b52010df7d3a32db0a2f5db245c8e",version:"2.0"});let e=this.container.nativeElement;this.map=new this.AMap.Map(e),this.goCurrentCenter()}))}goCurrentCenter(){this.AMap.plugin(["AMap.Geolocation"],(()=>{let e=new this.AMap.Geolocation({enableHighAccuracy:!0,timeout:1e4,maximumAge:0,convert:!0,showButton:!0,buttonPosition:"RB",buttonOffset:new this.AMap.Pixel(10,10),showMarker:!1,showCircle:!1,panToLocation:!0,zoomToAccuracy:!1});this.map.addControl(e),e.getCurrentPosition((function(e,t){"complete"===e?(console.log("当前位置经度:"+t.position.getLng()),console.log("当前位置纬度:"+t.position.getLat())):console.log("定位失败:"+t.message)}))}))}searchByAddress(){let e=this.panel.nativeElement;this.AMap.plugin(["AMap.PlaceSearch"],(()=>{let t=new this.AMap.PlaceSearch({pageSize:3,pageIndex:1,map:this.map,panel:e,autoFitView:!0});t.on("selectChanged",(e=>{this.name=e.selected.data.name,this.address=e.selected.data.address,this.location=new Parse__default.GeoPoint({latitude:e.selected.data.location.lat,longitude:e.selected.data.location.lng}),this.createCenterMarker()})),t.search(this.address)}))}createCenterMarker(){this.centerMarker||(this.centerMarker=new this.AMap.Marker({position:this.map.getCenter(),offset:new this.AMap.Pixel(-15,-15)}),this.map.add(this.centerMarker),this.map.on("dragging",(()=>{this.centerMarker.setPosition(this.map.getCenter())})),this.map.on("dragend",(()=>{let e=this.centerMarker.getPosition();this.location=new Parse__default.GeoPoint({latitude:e.lat,longitude:e.lng})})))}}CompPoiPickerComponent.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompPoiPickerComponent,deps:[],target:i0.ɵɵFactoryTarget.Component}),CompPoiPickerComponent.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"14.0.0",version:"15.1.0",type:CompPoiPickerComponent,selector:"fm-map-poi-picker",inputs:{_name:["name","_name"],_address:["address","_address"],_location:["location","_location"]},outputs:{nameChange:"nameChange",addressChange:"addressChange",locationChange:"locationChange"},viewQueries:[{propertyName:"container",first:!0,predicate:["container"],descendants:!0},{propertyName:"panel",first:!0,predicate:["panel"],descendants:!0},{propertyName:"modal",first:!0,predicate:IonModal,descendants:!0}],ngImport:i0,template:'\x3c!-- 未选点 --\x3e\n<ion-button (click)="openModal()" expand="block">开始选点</ion-button>\n\n\x3c!-- 已选点 --\x3e\n\n<ion-modal [isOpen]="isModalOpen" (willDismiss)="onWillDismiss($event)">\n<ng-template>\n <ion-header>\n <ion-toolbar>\n <ion-buttons slot="start">\n <ion-button (click)="cancel()">Cancel</ion-button>\n </ion-buttons>\n <ion-title>地图选点<ng-container *ngIf="location">({{location.latitude}},{{location.longitude}})</ng-container></ion-title>\n <ion-buttons slot="end">\n <ion-button (click)="confirm()" [strong]="true">Confirm</ion-button>\n </ion-buttons>\n </ion-toolbar>\n </ion-header>\n <ion-content class="ion-padding" style="height:100%">\n \x3c!-- 详细地址 --\x3e\n <ion-item>\n <ion-input\n label="请输入详细地址"\n labelPlacement="stacked"\n type="text"\n placeholder="精确到门牌号"\n [(ngModel)]="address"\n ></ion-input>\n <ion-button slot="end" (click)="searchByAddress()">搜索</ion-button>\n </ion-item>\n \n \x3c!-- 地图选点 --\x3e\n <div #container class="container"></div>\n <div #panel class="panel"></div>\n\n </ion-content>\n</ng-template>\n</ion-modal>\n\n',styles:[".container{width:100%;height:100%}.panel{position:absolute;background-color:#fff;max-height:50%;overflow-y:auto;top:12%;right:10px;width:45%}\n"],dependencies:[{kind:"directive",type:i1$2.NgIf,selector:"[ngIf]",inputs:["ngIf","ngIfThen","ngIfElse"]},{kind:"directive",type:i2$2.NgControlStatus,selector:"[formControlName],[ngModel],[formControl]"},{kind:"directive",type:i2$2.NgModel,selector:"[ngModel]:not([formControlName]):not([formControl])",inputs:["name","disabled","ngModel","ngModelOptions"],outputs:["ngModelChange"],exportAs:["ngModel"]},{kind:"component",type:i2.IonButton,selector:"ion-button",inputs:["buttonType","color","disabled","download","expand","fill","form","href","mode","rel","routerAnimation","routerDirection","shape","size","strong","target","type"]},{kind:"component",type:i2.IonButtons,selector:"ion-buttons",inputs:["collapse"]},{kind:"component",type:i2.IonContent,selector:"ion-content",inputs:["color","forceOverscroll","fullscreen","scrollEvents","scrollX","scrollY"]},{kind:"component",type:i2.IonHeader,selector:"ion-header",inputs:["collapse","mode","translucent"]},{kind:"component",type:i2.IonInput,selector:"ion-input",inputs:["accept","autocapitalize","autocomplete","autocorrect","autofocus","clearInput","clearOnEdit","color","counter","counterFormatter","debounce","disabled","enterkeyhint","errorText","fill","helperText","inputmode","label","labelPlacement","legacy","max","maxlength","min","minlength","mode","multiple","name","pattern","placeholder","readonly","required","shape","size","spellcheck","step","type","value"]},{kind:"component",type:i2.IonItem,selector:"ion-item",inputs:["button","color","counter","counterFormatter","detail","detailIcon","disabled","download","fill","href","lines","mode","rel","routerAnimation","routerDirection","shape","target","type"]},{kind:"component",type:i2.IonTitle,selector:"ion-title",inputs:["color","size"]},{kind:"component",type:i2.IonToolbar,selector:"ion-toolbar",inputs:["color","mode"]},{kind:"component",type:i2.IonModal,selector:"ion-modal",inputs:["animated","keepContentsMounted","backdropBreakpoint","backdropDismiss","breakpoints","canDismiss","cssClass","enterAnimation","event","handle","handleBehavior","initialBreakpoint","isOpen","keyboardClose","leaveAnimation","mode","presentingElement","showBackdrop","translucent","trigger"]},{kind:"directive",type:i2.TextValueAccessor,selector:"ion-input:not([type=number]),ion-textarea,ion-searchbar"}]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompPoiPickerComponent,decorators:[{type:Component,args:[{selector:"fm-map-poi-picker",template:'\x3c!-- 未选点 --\x3e\n<ion-button (click)="openModal()" expand="block">开始选点</ion-button>\n\n\x3c!-- 已选点 --\x3e\n\n<ion-modal [isOpen]="isModalOpen" (willDismiss)="onWillDismiss($event)">\n<ng-template>\n <ion-header>\n <ion-toolbar>\n <ion-buttons slot="start">\n <ion-button (click)="cancel()">Cancel</ion-button>\n </ion-buttons>\n <ion-title>地图选点<ng-container *ngIf="location">({{location.latitude}},{{location.longitude}})</ng-container></ion-title>\n <ion-buttons slot="end">\n <ion-button (click)="confirm()" [strong]="true">Confirm</ion-button>\n </ion-buttons>\n </ion-toolbar>\n </ion-header>\n <ion-content class="ion-padding" style="height:100%">\n \x3c!-- 详细地址 --\x3e\n <ion-item>\n <ion-input\n label="请输入详细地址"\n labelPlacement="stacked"\n type="text"\n placeholder="精确到门牌号"\n [(ngModel)]="address"\n ></ion-input>\n <ion-button slot="end" (click)="searchByAddress()">搜索</ion-button>\n </ion-item>\n \n \x3c!-- 地图选点 --\x3e\n <div #container class="container"></div>\n <div #panel class="panel"></div>\n\n </ion-content>\n</ng-template>\n</ion-modal>\n\n',styles:[".container{width:100%;height:100%}.panel{position:absolute;background-color:#fff;max-height:50%;overflow-y:auto;top:12%;right:10px;width:45%}\n"]}]}],ctorParameters:function(){return[]},propDecorators:{container:[{type:ViewChild,args:["container"]}],panel:[{type:ViewChild,args:["panel"]}],_name:[{type:Input,args:["name"]}],nameChange:[{type:Output}],_address:[{type:Input,args:["address"]}],addressChange:[{type:Output}],_location:[{type:Input,args:["location"]}],locationChange:[{type:Output}],modal:[{type:ViewChild,args:[IonModal]}]}});class CompPoiPickerModule{}CompPoiPickerModule.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompPoiPickerModule,deps:[],target:i0.ɵɵFactoryTarget.NgModule}),CompPoiPickerModule.ɵmod=i0.ɵɵngDeclareNgModule({minVersion:"14.0.0",version:"15.1.0",ngImport:i0,type:CompPoiPickerModule,declarations:[CompPoiPickerComponent],imports:[CommonModule,FormsModule,ReactiveFormsModule,i2.IonicModule],exports:[CompPoiPickerComponent]}),CompPoiPickerModule.ɵinj=i0.ɵɵngDeclareInjector({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompPoiPickerModule,imports:[CommonModule,FormsModule,ReactiveFormsModule,IonicModule.forRoot({mode:"ios"})]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:CompPoiPickerModule,decorators:[{type:NgModule,args:[{declarations:[CompPoiPickerComponent],imports:[CommonModule,FormsModule,ReactiveFormsModule,IonicModule.forRoot({mode:"ios"})],exports:[CompPoiPickerComponent]}]}]}),window._AMapSecurityConfig={securityJsCode:"32aa3f4ab0fa0061de03edd4eafdd50a"};class PagePlanRouteComponent{constructor(){this.placeList=[],this.currentTab="place",this.addNewPlace(),this.addNewPlace(),this.currentTab="plan"}addNewPlace(){var e;(null===(e=this.placeList)||void 0===e?void 0:e.length)>=1?this.placeList.push({name:"秋水广场",address:"南昌市秋水广场",location:new Parse__default.GeoPoint({latitude:28.682634,longitude:115.86273})}):this.placeList.push({name:"八一广场",address:"南昌市八一广场",location:new Parse__default.GeoPoint({latitude:28.673856,longitude:115.904477})})}ngAfterViewInit(){}initMap(){return __awaiter(this,void 0,void 0,(function*(){yield this.createMap(),this.goAndMarkPlace(this.placeList[0])}))}createMap(){return __awaiter(this,void 0,void 0,(function*(){this.AMap=yield AMapLoader.load({key:"473b52010df7d3a32db0a2f5db245c8e",version:"2.0"}),this.map=new this.AMap.Map("container-plan")}))}goAndMarkPlace(e){this.map.setCenter([e.location.latitude,e.location.longitude]),this.map.setZoom(18),e.marker||(e.marker=new this.AMap.Marker({position:[e.location.latitude,e.location.longitude]}),this.map.add(e.marker))}clearMark(e){var t;null===(t=null==e?void 0:e.marker)||void 0===t||t.remove()}planRoute(e,t){let o;this.map.plugin(["AMap.Transfer"],(()=>{let n={map:this.map,city:"南昌市",panel:"panel",policy:this.AMap.TransferPolicy.LEAST_TIME};o=new this.AMap.Transfer(n);let i=new this.AMap.LngLat(e.location.longitude,e.location.latitude),a=new this.AMap.LngLat(t.location.longitude,t.location.latitude);o.search(i,a,((e,t)=>{"complete"===e?(console.log("绘制公交路线完成:"),console.log(t)):console.error("公交路线数据查询失败"+t)}))}))}createPlan(){return __awaiter(this,void 0,void 0,(function*(){yield this.initMap(),this.planRoute(this.placeList[0],this.placeList[1])}))}}PagePlanRouteComponent.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:PagePlanRouteComponent,deps:[],target:i0.ɵɵFactoryTarget.Component}),PagePlanRouteComponent.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"14.0.0",version:"15.1.0",type:PagePlanRouteComponent,selector:"app-page-plan-route",ngImport:i0,template:'<ion-segment value="place">\n <ion-segment-button (click)="currentTab=\'place\'" value="place">\n <ion-label>景点选择</ion-label>\n </ion-segment-button>\n <ion-segment-button (click)="currentTab=\'plan\'" value="plan">\n <ion-label>路线规划</ion-label>\n </ion-segment-button>\n </ion-segment>\n \n\n<ng-container *ngIf="currentTab==\'place\'">\n <h1>选择旅游计划景点</h1>\n\n <ng-container *ngFor="let place of placeList">\n <ion-card>\n <h2>{{place?.name}}</h2>\n <span *ngIf="place.address">详细地址:{{place.address}}</span>\n <span *ngIf="place.location">地图坐标:{{place.location.latitude}},{{place.location.longitude}}</span>\n <fm-map-poi-picker [(name)]="place.name" [(address)]="place.address" [(location)]="place.location"></fm-map-poi-picker>\n </ion-card>\n </ng-container>\n <ion-button (click)="addNewPlace()" expand="block">添加新景点</ion-button>\n</ng-container>\n\n<ng-container *ngIf="currentTab==\'plan\'">\n <ion-button (click)="createPlan()" expand="block">创建规划路线</ion-button>\n\n <div id="container-plan"></div>\n <div id="panel"></div>\n</ng-container>\n\n',styles:["#container-plan{width:100%;height:40%}#panel{width:100%;height:50%}\n"],dependencies:[{kind:"directive",type:i1$2.NgForOf,selector:"[ngFor][ngForOf]",inputs:["ngForOf","ngForTrackBy","ngForTemplate"]},{kind:"directive",type:i1$2.NgIf,selector:"[ngIf]",inputs:["ngIf","ngIfThen","ngIfElse"]},{kind:"component",type:i2.IonButton,selector:"ion-button",inputs:["buttonType","color","disabled","download","expand","fill","form","href","mode","rel","routerAnimation","routerDirection","shape","size","strong","target","type"]},{kind:"component",type:i2.IonCard,selector:"ion-card",inputs:["button","color","disabled","download","href","mode","rel","routerAnimation","routerDirection","target","type"]},{kind:"component",type:i2.IonLabel,selector:"ion-label",inputs:["color","mode","position"]},{kind:"component",type:i2.IonSegment,selector:"ion-segment",inputs:["color","disabled","mode","scrollable","selectOnFocus","swipeGesture","value"]},{kind:"component",type:i2.IonSegmentButton,selector:"ion-segment-button",inputs:["disabled","layout","mode","type","value"]},{kind:"directive",type:i2.SelectValueAccessor,selector:"ion-range, ion-select, ion-radio-group, ion-segment, ion-datetime"},{kind:"component",type:CompPoiPickerComponent,selector:"fm-map-poi-picker",inputs:["name","address","location"],outputs:["nameChange","addressChange","locationChange"]}]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:PagePlanRouteComponent,decorators:[{type:Component,args:[{selector:"app-page-plan-route",template:'<ion-segment value="place">\n <ion-segment-button (click)="currentTab=\'place\'" value="place">\n <ion-label>景点选择</ion-label>\n </ion-segment-button>\n <ion-segment-button (click)="currentTab=\'plan\'" value="plan">\n <ion-label>路线规划</ion-label>\n </ion-segment-button>\n </ion-segment>\n \n\n<ng-container *ngIf="currentTab==\'place\'">\n <h1>选择旅游计划景点</h1>\n\n <ng-container *ngFor="let place of placeList">\n <ion-card>\n <h2>{{place?.name}}</h2>\n <span *ngIf="place.address">详细地址:{{place.address}}</span>\n <span *ngIf="place.location">地图坐标:{{place.location.latitude}},{{place.location.longitude}}</span>\n <fm-map-poi-picker [(name)]="place.name" [(address)]="place.address" [(location)]="place.location"></fm-map-poi-picker>\n </ion-card>\n </ng-container>\n <ion-button (click)="addNewPlace()" expand="block">添加新景点</ion-button>\n</ng-container>\n\n<ng-container *ngIf="currentTab==\'plan\'">\n <ion-button (click)="createPlan()" expand="block">创建规划路线</ion-button>\n\n <div id="container-plan"></div>\n <div id="panel"></div>\n</ng-container>\n\n',styles:["#container-plan{width:100%;height:40%}#panel{width:100%;height:50%}\n"]}]}],ctorParameters:function(){return[]}}),window._AMapSecurityConfig={securityJsCode:"32aa3f4ab0fa0061de03edd4eafdd50a"};class PageLocaScatterComponent{ngAfterViewInit(){this.initMap()}initMap(){return __awaiter(this,void 0,void 0,(function*(){yield this.createMap(),yield this.createLoca()}))}createLoca(){return __awaiter(this,void 0,void 0,(function*(){let e=window.loca=new Loca.Container({map:this.map}),t=new Loca.GeoJSONSource({url:"https://a.amap.com/Loca/static/loca-v2/demos/mock_data/sz_road.json"}),o=new Loca.ScatterLayer({zIndex:111,opacity:1,visible:!0,zooms:[2,22]});o.setSource(t),o.setStyle({color:"rgba(43,156,75,1)",unit:"meter",size:[150,150],borderWidth:0}),e.add(o);let n=new Loca.GeoJSONSource({url:"https://a.amap.com/Loca/static/loca-v2/demos/mock_data/sz_road_F.json"}),i=new Loca.ScatterLayer({loca:e,zIndex:113,opacity:1,visible:!0,zooms:[2,22]});i.setSource(n),i.setStyle({unit:"meter",size:[2600,2600],borderWidth:0,texture:"https://a.amap.com/Loca/static/loca-v2/demos/images/breath_red.png",duration:500,animate:!0});let a=new Loca.GeoJSONSource({url:"https://a.amap.com/Loca/static/loca-v2/demos/mock_data/sz_road_E.json"}),r=new Loca.ScatterLayer({loca:e,zIndex:112,opacity:1,visible:!0,zooms:[2,22]});r.setSource(a),r.setStyle({unit:"meter",size:[1e3,1e3],borderWidth:0,texture:"https://a.amap.com/Loca/static/loca-v2/demos/images/breath_yellow.png",duration:1e3,animate:!0}),e.animate.start();let s=new Loca.Dat;s.addLayer(o," 贴地"),s.addLayer(i,"红色"),s.addLayer(r,"黄色")}))}createMap(){return __awaiter(this,void 0,void 0,(function*(){this.AMap=yield AMapLoader.load({key:"473b52010df7d3a32db0a2f5db245c8e",version:"2.0",Loca:{version:"2.0.0"}}),this.map=new this.AMap.Map("container",{zoom:11.7,center:[113.97199630737305,22.5807295363949],pitch:40,showLabel:!1,mapStyle:"amap://styles/dark",viewMode:"3D"})}))}}PageLocaScatterComponent.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:PageLocaScatterComponent,deps:[],target:i0.ɵɵFactoryTarget.Component}),PageLocaScatterComponent.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"14.0.0",version:"15.1.0",type:PageLocaScatterComponent,selector:"app-page-loca-scatter",ngImport:i0,template:'<div id="container"></div>',styles:["#container{width:100%;height:100%;position:fixed}\n"]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:PageLocaScatterComponent,decorators:[{type:Component,args:[{selector:"app-page-loca-scatter",template:'<div id="container"></div>',styles:["#container{width:100%;height:100%;position:fixed}\n"]}]}]});const routes=[{path:"start",component:PageMapStartComponent},{path:"plan/route",component:PagePlanRouteComponent},{path:"loca/scatter",component:PageLocaScatterComponent}];class FmodeMapModule{}FmodeMapModule.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmodeMapModule,deps:[],target:i0.ɵɵFactoryTarget.NgModule}),FmodeMapModule.ɵmod=i0.ɵɵngDeclareNgModule({minVersion:"14.0.0",version:"15.1.0",ngImport:i0,type:FmodeMapModule,declarations:[PageMapStartComponent,PagePlanRouteComponent,PageLocaScatterComponent],imports:[CommonModule,i3.RouterModule,i2.IonicModule,CompPoiPickerModule],exports:[CompPoiPickerModule]}),FmodeMapModule.ɵinj=i0.ɵɵngDeclareInjector({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmodeMapModule,imports:[CommonModule,RouterModule.forChild(routes),IonicModule.forRoot({mode:"ios"}),CompPoiPickerModule,CompPoiPickerModule]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmodeMapModule,decorators:[{type:NgModule,args:[{declarations:[PageMapStartComponent,PagePlanRouteComponent,PageLocaScatterComponent],imports:[CommonModule,RouterModule.forChild(routes),IonicModule.forRoot({mode:"ios"}),CompPoiPickerModule],exports:[CompPoiPickerModule]}]}]});class HwobsService{constructor(){this.Attachment=Parse__default.Object.extend("Attachment"),this.host="https://web3-test.obs.cn-south-1.myhuaweicloud.com/",this.bucketName="web3-test",this.obsClient=new ObsClient({access_key_id:"6UIET20WHUI5TLXWOVNA",secret_access_key:"YaoY8Kj3TeGZHEcBzplTMZiPGNL13Y3frEavC1kF",server:"https://obs.cn-south-1.myhuaweicloud.com"})}listDir(e){return new Promise(((t,o)=>{this.obsClient.listObjects({Bucket:this.bucketName,Prefix:e,Delimiter:"/"},((e,n)=>{if(e)console.error("Error--\x3e"+e),o(e);else{if(console.log("Status--\x3e"+n.CommonMsg.Status),console.log(n),n.CommonMsg.Status<300&&n.InterfaceResult)for(var i in n.InterfaceResult.Contents)console.log("Contents["+i+"]:"),console.log("Key--\x3e"+n.InterfaceResult.Contents[i].Key),console.log("Owner[ID]--\x3e"+n.InterfaceResult.Contents[i].Owner.ID);let e=n.InterfaceResult.CommonPrefixes,o=n.InterfaceResult.Contents;t({dirs:e,files:o})}}))}))}uploadFile(e,t){return __awaiter(this,void 0,void 0,(function*(){let o=yield this.checkFileExists(e);return(null==o?void 0:o.id)?o:new Promise(((o,n)=>{this.obsClient.putObject({Bucket:this.bucketName,Key:t,SourceFile:e},((i,a)=>__awaiter(this,void 0,void 0,(function*(){if(i)console.error("Error--\x3e"+i),n(i);else{console.log("Status--\x3e"+a.CommonMsg.Status);let n=yield this.saveAttachment(e,t);o(n)}}))))}))}))}checkFileExists(e){return __awaiter(this,void 0,void 0,(function*(){let t,o=yield this.getFileHash(e),n=new Parse__default.Query("Attachment");n.equalTo("hash",o),n.equalTo("size",e.size);let i=yield n.first();return(null==i?void 0:i.id)||(i=new this.Attachment),t=i,t}))}saveAttachment(e,t){return __awaiter(this,void 0,void 0,(function*(){let o=yield this.getFileHash(e),n=yield this.checkFileExists(e);return n.set("name",e.name),n.set("size",e.size),n.set("mime",e.type),n.set("url",this.host+t),n.set("hash",o),n=yield n.save(),n}))}getFileHash(e){return __awaiter(this,void 0,void 0,(function*(){return new Promise(((t,o)=>{const n=new FileReader;n.onload=e=>__awaiter(this,void 0,void 0,(function*(){const o=e.target.result,n=yield crypto.subtle.digest("SHA-256",o),i=Array.from(new Uint8Array(n)).map((e=>e.toString(16).padStart(2,"0"))).join("");t(i)})),n.onerror=e=>{o(e.target.error)},n.readAsArrayBuffer(e)}))}))}}HwobsService.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:HwobsService,deps:[],target:i0.ɵɵFactoryTarget.Injectable}),HwobsService.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:HwobsService,providedIn:"root"}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:HwobsService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:function(){return[]}});class HwobsManagerComponent{openFile(e){console.log("Opening file:",e)}openDir(e,t="pre"){if(e)this.prefix=e.Prefix,this.listDir(e.Prefix);else if("pre"==t){let e=this.prefix.split("/");if(e.length>1){let t=e.splice(0,e.length-1).join("/");console.log(t),this.prefix=t,this.listDir(t)}}}showName(e){return e.replaceAll(this.prefix,"")}constructor(e){this.hwobs=e,this.dirs=[],this.files=[],this.prefix="storage/",this.listDir(this.prefix)}listDir(e){return __awaiter(this,void 0,void 0,(function*(){let{dirs:t,files:o}=yield this.hwobs.listDir(e);this.dirs=t,this.files=o}))}}HwobsManagerComponent.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:HwobsManagerComponent,deps:[{token:HwobsService}],target:i0.ɵɵFactoryTarget.Component}),HwobsManagerComponent.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"14.0.0",version:"15.1.0",type:HwobsManagerComponent,isStandalone:!0,selector:"fm-storage-hwobs-manager",ngImport:i0,template:'<ion-header>\n <ion-toolbar>\n <ion-title>\n File Manager\n </ion-title>\n </ion-toolbar>\n </ion-header>\n \n <ion-content>\n <ion-list>\n <ion-item (click)="openDir(null,\'pre\')">\n <ion-icon [name]="\'folder\'" slot="start"></ion-icon>\n <ion-label>../</ion-label>\n </ion-item>\n <ion-item *ngFor="let item of dirs" (click)="openDir(item)">\n <ion-icon [name]="\'folder\'" slot="start"></ion-icon>\n <ion-label>{{ showName(item.Prefix) }}</ion-label>\n </ion-item>\n <ion-item *ngFor="let item of files" (click)="openFile(item)">\n <ion-icon [name]="\'document\'" slot="start"></ion-icon>\n <ion-label>{{ showName(item.Key) }}</ion-label>\n </ion-item>\n </ion-list>\n </ion-content>',styles:["ion-list ion-item ion-icon{font-size:24px;margin-right:8px}\n"],dependencies:[{kind:"ngmodule",type:CommonModule},{kind:"directive",type:i1$2.NgForOf,selector:"[ngFor][ngForOf]",inputs:["ngForOf","ngForTrackBy","ngForTemplate"]},{kind:"ngmodule",type:FormsModule},{kind:"ngmodule",type:ReactiveFormsModule},{kind:"ngmodule",type:IonicModule},{kind:"component",type:i2.IonContent,selector:"ion-content",inputs:["color","forceOverscroll","fullscreen","scrollEvents","scrollX","scrollY"]},{kind:"component",type:i2.IonHeader,selector:"ion-header",inputs:["collapse","mode","translucent"]},{kind:"component",type:i2.IonIcon,selector:"ion-icon",inputs:["color","flipRtl","icon","ios","lazy","md","mode","name","sanitize","size","src"]},{kind:"component",type:i2.IonItem,selector:"ion-item",inputs:["button","color","counter","counterFormatter","detail","detailIcon","disabled","download","fill","href","lines","mode","rel","routerAnimation","routerDirection","shape","target","type"]},{kind:"component",type:i2.IonLabel,selector:"ion-label",inputs:["color","mode","position"]},{kind:"component",type:i2.IonList,selector:"ion-list",inputs:["inset","lines","mode"]},{kind:"component",type:i2.IonTitle,selector:"ion-title",inputs:["color","size"]},{kind:"component",type:i2.IonToolbar,selector:"ion-toolbar",inputs:["color","mode"]}]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:HwobsManagerComponent,decorators:[{type:Component,args:[{standalone:!0,imports:[CommonModule,FormsModule,ReactiveFormsModule,IonicModule],selector:"fm-storage-hwobs-manager",template:'<ion-header>\n <ion-toolbar>\n <ion-title>\n File Manager\n </ion-title>\n </ion-toolbar>\n </ion-header>\n \n <ion-content>\n <ion-list>\n <ion-item (click)="openDir(null,\'pre\')">\n <ion-icon [name]="\'folder\'" slot="start"></ion-icon>\n <ion-label>../</ion-label>\n </ion-item>\n <ion-item *ngFor="let item of dirs" (click)="openDir(item)">\n <ion-icon [name]="\'folder\'" slot="start"></ion-icon>\n <ion-label>{{ showName(item.Prefix) }}</ion-label>\n </ion-item>\n <ion-item *ngFor="let item of files" (click)="openFile(item)">\n <ion-icon [name]="\'document\'" slot="start"></ion-icon>\n <ion-label>{{ showName(item.Key) }}</ion-label>\n </ion-item>\n </ion-list>\n </ion-content>',styles:["ion-list ion-item ion-icon{font-size:24px;margin-right:8px}\n"]}]}],ctorParameters:function(){return[{type:HwobsService}]}});class FmodeStorgeModule{}FmodeStorgeModule.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmodeStorgeModule,deps:[],target:i0.ɵɵFactoryTarget.NgModule}),FmodeStorgeModule.ɵmod=i0.ɵɵngDeclareNgModule({minVersion:"14.0.0",version:"15.1.0",ngImport:i0,type:FmodeStorgeModule,imports:[CommonModule,i2.IonicModule,HwobsManagerComponent],exports:[HwobsManagerComponent]}),FmodeStorgeModule.ɵinj=i0.ɵɵngDeclareInjector({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmodeStorgeModule,providers:[Diagnostic,NovaUploadService],imports:[CommonModule,IonicModule.forRoot({mode:"ios"}),HwobsManagerComponent]}),i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"15.1.0",ngImport:i0,type:FmodeStorgeModule,decorators:[{type:NgModule,args:[{declarations:[],imports:[CommonModule,IonicModule.forRoot({mode:"ios"}),HwobsManagerComponent],exports:[HwobsManagerComponent],providers:[Diagnostic,NovaUploadService]}]}]});export{AvatarModule,AvatarRoutes,ChatContentPipe,ChatService,ClipboardService,CompAvatarParticleComponent,CompAvatarRoleImageComponent,CompAvatarTalkComponent,CompPoiPickerComponent,CompPoiPickerModule,CrossService,FmaiService,FmodeChat,FmodeChatCompletion,FmodeMapModule,FmodeStorgeModule,FmodeVoiceService,HidexmlPipe,HwobsManagerComponent,HwobsService,ImagineService,MASK_LIST,MarkdownMathJax,MarkdownParse,MarkdownPreviewComponent,MarkdownPreviewModule,ModalChatVoiceInputComponent,NovaCloudService,NovaUploadService,UtilnowPipe,getMessageContentText,getMessageImageUrl};
|
|
9
9
|
var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9mZXNtMjAxNS9mbW9kZS1uZy5tanM=`
|
|
10
10
|
|