fmode-ng 0.0.231 → 0.0.233

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/esm2022/lib/aigc/chat/chat-modal-input/modal-input.component.mjs +1 -1
  2. package/esm2022/lib/core/agent/chat/fmode-chat.mjs +1 -1
  3. package/esm2022/lib/core/agent/chat/message/index.mjs +10 -0
  4. package/esm2022/lib/core/agent/chat/message/message-manager.mjs +10 -0
  5. package/esm2022/lib/core/agent/chat/message/message.mjs +10 -0
  6. package/esm2022/lib/core/ecom/index.mjs +10 -0
  7. package/esm2022/lib/core/ecom/shopee/index.mjs +10 -0
  8. package/esm2022/lib/core/ecom/shopee/src/client.mjs +10 -0
  9. package/esm2022/lib/core/ecom/shopee/src/index.mjs +10 -0
  10. package/esm2022/lib/core/ecom/shopee/src/merchant.mjs +10 -0
  11. package/esm2022/lib/core/ecom/shopee/src/public.mjs +10 -0
  12. package/esm2022/lib/core/ecom/shopee/src/shop.mjs +10 -0
  13. package/esm2022/lib/core/ecom/shopee/src/types.mjs +10 -0
  14. package/esm2022/lib/core/index.mjs +1 -1
  15. package/esm2022/lib/core/parse/fmode.cloud.mjs +1 -1
  16. package/esm2022/lib/core/parse/fmode.parse.mjs +1 -1
  17. package/esm2022/lib/user/account/account.service.mjs +1 -1
  18. package/fesm2022/fmode-ng.mjs +1 -1
  19. package/fesm2022/fmode-ng.mjs.map +1 -1
  20. package/lib/core/agent/chat/fmode-chat.d.ts +35 -1
  21. package/lib/core/agent/chat/interface.d.ts +2 -0
  22. package/lib/core/agent/chat/message/index.d.ts +2 -0
  23. package/lib/core/agent/chat/message/message-manager.d.ts +86 -0
  24. package/lib/core/agent/chat/message/message.d.ts +175 -0
  25. package/lib/core/ecom/index.d.ts +1 -0
  26. package/lib/core/ecom/shopee/index.d.ts +1 -0
  27. package/lib/core/ecom/shopee/src/client.d.ts +51 -0
  28. package/lib/core/ecom/shopee/src/index.d.ts +37 -0
  29. package/lib/core/ecom/shopee/src/merchant.d.ts +214 -0
  30. package/lib/core/ecom/shopee/src/public.d.ts +204 -0
  31. package/lib/core/ecom/shopee/src/shop.d.ts +177 -0
  32. package/lib/core/ecom/shopee/src/types.d.ts +102 -0
  33. package/lib/core/index.d.ts +1 -0
  34. package/lib/core/parse/fmode.cloud.d.ts +5 -4
  35. package/lib/user/account/account.service.d.ts +5 -0
  36. package/package.json +2 -1
@@ -5,6 +5,6 @@
5
5
  * 保留所有权利 All Rights Reserved.
6
6
  * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/aigc/chat/chat-modal-input/modal-input.component.mjs
7
7
  */
8
- import{Component,Input,ViewChild}from"@angular/core";import{Router,RouterModule}from"@angular/router";import{AlertController,ToastController}from"@ionic/angular";import{FmodeChat}from"../../service-fmai/service-chat";import{ChatService}from"../../service-fmai/service-chat";import{FmodeParse,FmodeObject}from"../../../core/parse";import{ImagineService}from"../../service-fmai/service-imagine/imagine.service";import{IonButton,IonContent,IonIcon,IonInput,IonItem,IonList,IonModal,IonPopover,IonTextarea,IonToolbar,ModalController}from"@ionic/angular/standalone";import{CommonModule}from"@angular/common";import{FormsModule,ReactiveFormsModule}from"@angular/forms";import{ModalAudioMessageComponent}from"./modal-audio-message/modal-audio-message.component";import{FmChatMessageCard}from"../chat-message-card/comp-message-card.component";import{addIcons}from"ionicons";import{imageOutline,chevronBackOutline,ellipsisHorizontalOutline,chevronDownOutline,chatboxEllipsesOutline,micOutline,paperPlaneOutline,shareSocialOutline,settingsOutline,alertOutline,colorWandOutline,peopleOutline}from"ionicons/icons";import{AccountService}from"../../../user/account/account.service";import*as i0 from"@angular/core";import*as i1 from"@ionic/angular";import*as i2 from"@ionic/angular/standalone";import*as i3 from"@angular/router";import*as i4 from"../../service-fmai/service-imagine/imagine.service";import*as i5 from"../../service-fmai/service-chat";import*as i6 from"../../../user/account/account.service";import*as i7 from"@angular/common";import*as i8 from"@angular/forms";const Parse=FmodeParse.with("nova");addIcons({colorWandOutline:colorWandOutline,peopleOutline:peopleOutline,alertOutline:alertOutline,imageOutline:imageOutline,chevronBackOutline:chevronBackOutline,ellipsisHorizontalOutline:ellipsisHorizontalOutline,chevronDownOutline:chevronDownOutline,chatboxEllipsesOutline:chatboxEllipsesOutline,micOutline:micOutline,paperPlaneOutline:paperPlaneOutline,shareSocialOutline:shareSocialOutline,settingsOutline:settingsOutline});export class FmChatModalInput{closeAudio(){this.audioComp?.cancel(),this.isAudioModal=!1}async startTalk(){if(this.isSending)return!1;let e,n=document.body.clientHeight||960;this.audioModalHeightPoint=Number((165/n).toFixed(2)),this.chat.stopPlayingVoice(),e=await this.modalCtrl.create({component:ModalAudioMessageComponent,componentProps:{chat:this.chat,modal:e,onBreakPointSet:()=>{e?.setCurrentBreakpoint(this.audioModalHeightPoint)}},breakpoints:[this.audioModalHeightPoint],initialBreakpoint:this.audioModalHeightPoint}),e.present()}constructor(e,n,t,o,i,a,s){this.toastCtrl=e,this.alertCtrl=n,this.modalCtrl=t,this.router=o,this.imagineServ=i,this.chatServ=a,this.account=s,this.errorText="",this.isAudioModal=!1,this.audioModalHeightPoint=.35,this.isSending=!1,this.lastMessageTimestamp=0,this.replyTimeout=15e3,this.isShare=!1,this.user=Parse.User.current()}ngOnInit(){this.loadModel();let e=this;this.chat.focusUserInput=()=>{e.chat.isVoiceInputMode=!1,e.userInputComp?.setFocus()}}async loadModel(){let e=this.chat?.role?.get("model");await this.chat.loadModelList(e)}async setMessageImage(){let e=await this.imagineServ.getimg();this.chat.userImage=e,console.log(this.chat?.userImage)}onInputFocus(){this.chat.isTexting=!0,this.chat.scrollToBottom&&this.chat.scrollToBottom()}onKeyDown(e){e.ctrlKey&&"Enter"===e.key&&(console.log("Ctrl+Enter 被按下"),this.sendMessage())}async sendMessage(){if(this.isSending)return!1;const e=Date.now();if(this.lastMessageTimestamp>0&&e-this.lastMessageTimestamp<this.replyTimeout){return this.errorText="请等待上一条消息的回复或稍后再试",(await this.toastCtrl.create({message:this.errorText,position:"top",icon:"alert",color:"warning",duration:1e3})).present(),!1}if(this.isSending=!0,this.lastMessageTimestamp=Date.now(),!await this.checkBalance())return this.isSending=!1,!1;if(!this.chat.userInput){return this.errorText="内容不能为空",(await this.toastCtrl.create({message:this.errorText,position:"top",icon:"alert",color:"warning-circle",duration:1e3})).present(),void(this.isSending=!1)}this.lastMessageTimeout&&clearTimeout(this.lastMessageTimeout),this.lastMessageTimeout=setTimeout((()=>{this.isSending=!1,this.lastMessageTimestamp=0}),this.replyTimeout),this.chat?.sendMessage(this.chat?.userInput,this.chat?.userImage,(e=>{}),{onMessageStart:e=>{clearTimeout(this.lastMessageTimeout),this.isSending=!1,this.lastMessageTimestamp=0},onSSMLComplete:e=>{console.log(e)}}),this.chat.userInput="",this.chat.userImage=""}async checkBalance(){let e=await this.account.getBilling();if(e?.credit?.balance>=10&&(this.chat.isDirect=!0),!this.chat?.currentModel?.get?.("payLimit"))return!0;if(e?.credit?.balance<10){return(await this.alertCtrl.create({header:"注意",subHeader:"您的余额不足,请充值后解锁高级模型",buttons:[{role:"cancel",text:"取消"},{role:"destructive",text:"充值",handler:()=>{this.router.navigateByUrl("/account/billing")}}]})).present(),!1}return!0}async getChatShare(){this.user=Parse.User.current();let e=new Parse.Query("ChatShare");e.equalTo("user",Parse.User.current().id),e.equalTo("session",this.chat?.sessionId);await e.first()}async toggleChatShare(){let e=new Parse.Query("ChatShare");e.equalTo("user",Parse.User.current().id),e.equalTo("role",this.chat?.role.id),e.equalTo("session",this.chat?.sessionId),e.select("objectId");let n=await e.first();if(n?.id)n.set("messageList",this.chat?.messageList);else{n=new(Parse.Object.extend("ChatShare")),n.set("user",{__type:"Pointer",className:"_User",objectId:Parse.User.current()?.id}),n.set("session",{__type:"Pointer",className:"ChatSession",objectId:this.chat?.sessionId}),n.set("role",{__type:"Pointer",className:"AvatarRole",objectId:this.chat?.role.id}),n.set("company",{__type:"Pointer",className:"Company",objectId:"E4KpGvTEto"}),n.set("messageList",this.chat?.messageList)}await n.save(),this.getChatShare()}async chatShareSuccessMessage(){(await this.toastCtrl.create({duration:1e3,message:"分享成功",color:"primary",icon:"information-circle",position:"top"})).present()}showShare(){this.isShare=!0}handleOkShare(){this.toggleChatShare(),this.chatShareSuccessMessage(),this.isShare=!1}handleCancelShare(){this.isShare=!1}static{this.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"17.3.12",ngImport:i0,type:FmChatModalInput,deps:[{token:i1.ToastController},{token:i1.AlertController},{token:i2.ModalController},{token:i3.Router},{token:i4.ImagineService},{token:i5.ChatService},{token:i6.AccountService}],target:i0.ɵɵFactoryTarget.Component})}static{this.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"17.0.0",version:"17.3.12",type:FmChatModalInput,isStandalone:!0,selector:"fm-chat-modal-input",inputs:{chat:"chat",message:"message",role:"role"},viewQueries:[{propertyName:"audioComp",first:!0,predicate:ModalAudioMessageComponent,descendants:!0},{propertyName:"userInputComp",first:!0,predicate:["userInput"],descendants:!0}],ngImport:i0,template:'<ion-toolbar>\n <ion-item class="button-item" lines="none">\n \x3c!-- 设置 --\x3e\n \x3c!-- <ion-button fill="outline" slot="start">\n <ion-icon name="settings-outline"></ion-icon> \n </ion-button> --\x3e\n <ng-container *ngFor="let button of chat?.leftButtons">\n <ion-button style="--padding-start:10px;--padding-end:10px;"\n shape="round" *ngIf="button?.show&&button?.show()" fill="outline" [title]="button?.title" slot="start" (click)="button.onClick()">\n <ion-icon [name]="button?.icon" [slot]="button?.showTitle?\'start\':\'icon-only\'"></ion-icon>\n {{button?.showTitle&&button?.title}}\n </ion-button>\n </ng-container>\n\n <ng-container *ngFor="let button of chat?.role?.get(\'buttons\')">\n <ion-button shape="round" (click)="chatServ.doButtonAction(button)" fill="outline" slot="start">\n {{button?.name}}\n </ion-button>\n </ng-container>\n\n \x3c!--分享按钮--\x3e\n @if(!chat?.hideShare){\n <ion-button shape="round" *ngIf="chat?.messageList?.length>1" (click)="showShare()" fill="outline" title="分享" slot="end">\n <ion-icon name="share-social-outline"></ion-icon>\n </ion-button>\n }\n <ion-modal [isOpen]="isShare">\n <ng-template>\n <ion-header>\n <ion-toolbar>\n <ion-buttons slot="start">\n <ion-button (click)="handleCancelShare()">取消</ion-button>\n </ion-buttons>\n <ion-title>对话分享</ion-title>\n <ion-buttons slot="end">\n <ion-button (click)="handleOkShare()">分享</ion-button>\n </ion-buttons>\n </ion-toolbar>\n </ion-header>\n <ion-content class="ion-padding">\n <ng-container *ngFor="let message of chat?.messageList;let index=index;">\n \x3c!-- 内容格式化区域 --\x3e\n <fm-chat-message-card [chat]="chat" *ngIf="!message?.hidden" [index]="index" [message]="message" [role]="chat?.role"></fm-chat-message-card>\n </ng-container>\n\n <div *ngIf="false" class="popup-content">\n <div *ngFor="let message of chat?.messageList">\n \x3c!-- 头像 --\x3e\n <div class="item-row user" *ngIf="message?.role!=\'system\'">\n <div>\n <img class="avatar" *ngIf="message?.role!=\'user\'" [src]="(chat?.role?.get(\'avatar\') || chat?.role?.get(\'thumb\') || \'https://file-cloud.fmode.cn/E4KpGvTEto/20230930/l413e6090731854.png\')+\'?\'+\'x-image-process=image/resize,m_fixed,w_100\'+\'&imageView2/1/w/32/h/32\'" >\n </div>\n <div class="user-question">\n <app-comp-user-avatar [user]="user" *ngIf="message?.role==\'user\'"></app-comp-user-avatar>\n </div>\n </div>\n \x3c!-- 内容 --\x3e\n <div class="message-wrapper">\n <div class="message-content-user">\n <div class="user-message" *ngIf="message?.role === \'user\'">\n <div class="item-content">\n \x3c!-- <fm-markdown-preview *ngIf="!message?.complete" class="content-style" [content]="message?.content" [render]="false"></fm-markdown-preview> --\x3e\n <fm-markdown-preview *ngIf="message?.complete" class="content-style" [content]="message?.content"></fm-markdown-preview>\n </div>\n </div>\n </div>\n <div class="message-content-role">\n <div class="role-message" *ngIf="message?.role !== \'user\' && message?.role !== \'system\'">\n <div class="item-content">\n \x3c!-- <fm-markdown-preview *ngIf="!message?.complete" class="content-style" [content]="message?.content" [render]="false"></fm-markdown-preview> --\x3e\n <fm-markdown-preview *ngIf="message?.complete" class="content-style" [content]="message?.content"></fm-markdown-preview>\n </div>\n </div>\n </div>\n <div class="message-content-system">\n <div class="system-message" *ngIf="message?.role === \'system\'">\n <div class="item-content">\n \x3c!-- <fm-markdown-preview *ngIf="!message?.complete" class="content-style" [content]="message?.content" [render]="false"></fm-markdown-preview> --\x3e\n <fm-markdown-preview *ngIf="message?.complete" class="content-style" [content]="message?.content"></fm-markdown-preview>\n </div>\n </div>\n </div>\n </div>\n <div class="chat-time" *ngIf="message?.createdAt" [ngClass]="{\'role-time\': message?.role !== \'user\'}">\n <span>{{message?.createdAt | date:"dd/MM/yyyy, HH/mm/ss a"}}</span>\n </div>\n </div>\n </div> \n </ion-content>\n </ng-template>\n </ion-modal>\n\n \x3c!-- 图片 --\x3e\n <ion-button shape="round" *ngIf="chat?.currentModel?.get?.(\'config\')?.imageEnabled" fill="outline" slot="end" (click)="setMessageImage()">\n <ion-icon name="image-outline"></ion-icon>\n </ion-button>\n \x3c!-- 模型 --\x3e\n @if(!chat?.hideModalSelect){\n <ion-button shape="round" fill="outline" slot="end" id="model-button">\n <ion-icon name="chevron-down-outline"></ion-icon>\n {{chat?.currentModel?.get&&chat?.currentModel?.get?.("name")||"Fmode-C1.0-128k"}}\n </ion-button>\n <ion-popover trigger="model-button" [dismissOnSelect]="true">\n <ng-template>\n <ion-content>\n <ion-list>\n <ng-container *ngFor="let model of chat.modelList">\n <ion-item (click)="chat.currentModel = model" [button]="true" [detail]="false">\n {{model?.get("name")}}\n <ion-note slot="end">{{model?.get("credit")}}/k</ion-note>\n </ion-item>\n </ng-container>\n </ion-list>\n </ion-content>\n </ng-template>\n </ion-popover>\n }\n\n </ion-item>\n\n <ion-item class="input-item" lines="none">\n \x3c!-- 语音消息输入 --\x3e\n <ng-container *ngIf="chat?.isVoiceInputMode">\n \x3c!-- 切换文本输入 --\x3e\n <ion-button class="btn-input-change" color="primary" (click)="chat.isVoiceInputMode=false" shape="round" size="large">\n <ion-icon name="chatbox-ellipses-outline" slot="icon-only"></ion-icon>\n </ion-button>\n \n <div class="btn-voice-start" (click)="startTalk()" [class.disabled]="isSending">\n <span>\n 点击讲话\n </span> \n </div>\n </ng-container>\n\n \x3c!-- 文本消息输入 --\x3e\n <ng-container *ngIf="!chat?.isVoiceInputMode">\n \x3c!-- 切换语音输入 --\x3e\n <ion-button [style.display]="chat.isTexting?\'none\':\'flex\'" class="btn-input-change" color="primary" *ngIf="chat?.role?.get(\'voiceConfig\')" (click)="chat.isVoiceInputMode=true" shape="round" size="large">\n <ion-icon name="mic-outline" slot="icon-only"></ion-icon>\n </ion-button>\n\n \x3c!-- 文本输入区域 --\x3e\n <ion-textarea\n #userInput\n *ngIf="chat" (keydown)="onKeyDown($event)"\n [errorText]="errorText"\n [(ngModel)]="chat.userInput"\n (ionFocus)="onInputFocus()"\n (ionBlur)="chat.isTexting=false"\n [autoGrow]="true" shape="round" fill="outline"\n label="Ctrl + Enter 发送消息" placeholder="请输入您的提示词"\n labelPlacement="floating"></ion-textarea>\n \n \x3c!-- 文本发送按钮 --\x3e\n <ion-button [disabled]="isSending"\n color="primary" shape="round" size="large" (click)="sendMessage()">\n <ion-icon name="paper-plane-outline" slot="icon-only"></ion-icon>\n </ion-button>\n </ng-container>\n </ion-item>\n</ion-toolbar>\n\n\n\x3c!-- 语音消息输入:弹出区域 --\x3e\n\x3c!-- <ion-modal #audioModal [isOpen]="isAudioModal" (willDismiss)="closeAudio()" [initialBreakpoint]="audioModalHeightPoint" [breakpoints]="[0, audioModalHeightPoint]">\n <ng-template>\n <fm-modal-audio-message #audioComp *ngIf="isAudioModal" [chat]="chat" [modal]="audioModal"></fm-modal-audio-message>\n </ng-template>\n</ion-modal> --\x3e',styles:['@charset "UTF-8";:host-context(body.dark) .btn-voice-start{background-color:#222428;color:#fff}:host-context(body.dark) ion-textarea{background-color:#222428;color:#fff}ion-toolbar{--background:none}ion-toolbar .button-item{--inner-padding-start:5px;--inner-padding-end:0px;--padding-start:5px;--padding-end:0px}ion-toolbar ion-item{--background:transparent}.disabled{opacity:.5;pointer-events:none}.avatar{border-radius:50%;width:32px;height:32px;object-fit:cover}ion-textarea.custom{--background: #373737;--color: #fff;--padding-end: 10px;--padding-start: 10px;--placeholder-color: #ddd;--placeholder-opacity: .8}ion-textarea.custom textarea{width:calc(100% - 95px)}ion-textarea.custom ion-button{position:absolute;right:0}.input-item{display:flex;min-height:77px;align-items:center;border:none;--inner-padding-start:0px;--inner-padding-end:0px;--padding-start:0px;--padding-end:0px}.input-item ion-textarea{background-color:#fff;max-height:400px;padding:0 5px;margin:0 5px;border-radius:20px;overflow-y:auto}.input-item .btn-voice-start{display:flex;flex:1;justify-content:center;align-items:center;font-weight:700;background:#fff;border-radius:20px;min-height:50px}ion-textarea{transition:width .5s ease}ion-textarea:hover .btn-input-change,ion-textarea:focus-within .btn-input-change{display:none}.input-item:hover ion-textarea,.input-item:focus-within ion-textarea{border-color:var(--logo-color-primary)}::ng-deep .ant-modal-body{max-height:600px;overflow-y:auto}::ng-deep .ant-modal-footer{display:flex;justify-content:space-around}::ng-deep .ant-btn{width:40%}.popup-content{position:relative}.popup-content .message-content-user{display:flex;justify-content:flex-end}.popup-content .message-content-role{display:flex;justify-content:flex-start}.popup-content .message-content-system{display:flex;justify-content:center}.popup-content .user-message{padding:10px 10px 0;border-radius:10px;width:fit-content;max-width:100%;background-color:#e7f8ff}.popup-content .role-message{padding:10px 10px 0;border-radius:10px;width:fit-content;max-width:100%;background-color:#f6f6f6}.popup-content .user-question{margin-bottom:5px;display:flex;justify-content:flex-end}.popup-content .chat-time{margin-bottom:10px;display:flex;justify-content:flex-end;font-size:14px;color:#a3a3a3}.popup-content .role-time{justify-content:flex-start}\n'],dependencies:[{kind:"ngmodule",type:CommonModule},{kind:"directive",type:i7.NgClass,selector:"[ngClass]",inputs:["class","ngClass"]},{kind:"directive",type:i7.NgForOf,selector:"[ngFor][ngForOf]",inputs:["ngForOf","ngForTrackBy","ngForTemplate"]},{kind:"directive",type:i7.NgIf,selector:"[ngIf]",inputs:["ngIf","ngIfThen","ngIfElse"]},{kind:"pipe",type:i7.DatePipe,name:"date"},{kind:"ngmodule",type:FormsModule},{kind:"directive",type:i8.NgControlStatus,selector:"[formControlName],[ngModel],[formControl]"},{kind:"directive",type:i8.NgModel,selector:"[ngModel]:not([formControlName]):not([formControl])",inputs:["name","disabled","ngModel","ngModelOptions"],outputs:["ngModelChange"],exportAs:["ngModel"]},{kind:"ngmodule",type:ReactiveFormsModule},{kind:"ngmodule",type:RouterModule},{kind:"component",type:IonToolbar,selector:"ion-toolbar",inputs:["color","mode"]},{kind:"component",type:IonItem,selector:"ion-item",inputs:["button","color","detail","detailIcon","disabled","download","href","lines","mode","rel","routerAnimation","routerDirection","target","type"]},{kind:"component",type: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:IonList,selector:"ion-list",inputs:["inset","lines","mode"]},{kind:"component",type:IonModal,selector:"ion-modal"},{kind:"component",type:IonIcon,selector:"ion-icon",inputs:["color","flipRtl","icon","ios","lazy","md","mode","name","sanitize","size","src"]},{kind:"component",type:IonTextarea,selector:"ion-textarea",inputs:["autoGrow","autocapitalize","autofocus","clearOnEdit","color","cols","counter","counterFormatter","debounce","disabled","enterkeyhint","errorText","fill","helperText","inputmode","label","labelPlacement","maxlength","minlength","mode","name","placeholder","readonly","required","rows","shape","spellcheck","value","wrap"]},{kind:"component",type:IonPopover,selector:"ion-popover"},{kind:"component",type:IonContent,selector:"ion-content",inputs:["color","fixedSlotPlacement","forceOverscroll","fullscreen","scrollEvents","scrollX","scrollY"]},{kind:"component",type:FmChatMessageCard,selector:"fm-chat-message-card",inputs:["index","message","role","chat"]}]})}}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"17.3.12",ngImport:i0,type:FmChatModalInput,decorators:[{type:Component,args:[{selector:"fm-chat-modal-input",standalone:!0,imports:[CommonModule,FormsModule,ReactiveFormsModule,RouterModule,IonToolbar,IonItem,IonButton,IonList,IonModal,IonInput,IonIcon,IonTextarea,IonPopover,IonContent,FmChatMessageCard,ModalAudioMessageComponent],template:'<ion-toolbar>\n <ion-item class="button-item" lines="none">\n \x3c!-- 设置 --\x3e\n \x3c!-- <ion-button fill="outline" slot="start">\n <ion-icon name="settings-outline"></ion-icon> \n </ion-button> --\x3e\n <ng-container *ngFor="let button of chat?.leftButtons">\n <ion-button style="--padding-start:10px;--padding-end:10px;"\n shape="round" *ngIf="button?.show&&button?.show()" fill="outline" [title]="button?.title" slot="start" (click)="button.onClick()">\n <ion-icon [name]="button?.icon" [slot]="button?.showTitle?\'start\':\'icon-only\'"></ion-icon>\n {{button?.showTitle&&button?.title}}\n </ion-button>\n </ng-container>\n\n <ng-container *ngFor="let button of chat?.role?.get(\'buttons\')">\n <ion-button shape="round" (click)="chatServ.doButtonAction(button)" fill="outline" slot="start">\n {{button?.name}}\n </ion-button>\n </ng-container>\n\n \x3c!--分享按钮--\x3e\n @if(!chat?.hideShare){\n <ion-button shape="round" *ngIf="chat?.messageList?.length>1" (click)="showShare()" fill="outline" title="分享" slot="end">\n <ion-icon name="share-social-outline"></ion-icon>\n </ion-button>\n }\n <ion-modal [isOpen]="isShare">\n <ng-template>\n <ion-header>\n <ion-toolbar>\n <ion-buttons slot="start">\n <ion-button (click)="handleCancelShare()">取消</ion-button>\n </ion-buttons>\n <ion-title>对话分享</ion-title>\n <ion-buttons slot="end">\n <ion-button (click)="handleOkShare()">分享</ion-button>\n </ion-buttons>\n </ion-toolbar>\n </ion-header>\n <ion-content class="ion-padding">\n <ng-container *ngFor="let message of chat?.messageList;let index=index;">\n \x3c!-- 内容格式化区域 --\x3e\n <fm-chat-message-card [chat]="chat" *ngIf="!message?.hidden" [index]="index" [message]="message" [role]="chat?.role"></fm-chat-message-card>\n </ng-container>\n\n <div *ngIf="false" class="popup-content">\n <div *ngFor="let message of chat?.messageList">\n \x3c!-- 头像 --\x3e\n <div class="item-row user" *ngIf="message?.role!=\'system\'">\n <div>\n <img class="avatar" *ngIf="message?.role!=\'user\'" [src]="(chat?.role?.get(\'avatar\') || chat?.role?.get(\'thumb\') || \'https://file-cloud.fmode.cn/E4KpGvTEto/20230930/l413e6090731854.png\')+\'?\'+\'x-image-process=image/resize,m_fixed,w_100\'+\'&imageView2/1/w/32/h/32\'" >\n </div>\n <div class="user-question">\n <app-comp-user-avatar [user]="user" *ngIf="message?.role==\'user\'"></app-comp-user-avatar>\n </div>\n </div>\n \x3c!-- 内容 --\x3e\n <div class="message-wrapper">\n <div class="message-content-user">\n <div class="user-message" *ngIf="message?.role === \'user\'">\n <div class="item-content">\n \x3c!-- <fm-markdown-preview *ngIf="!message?.complete" class="content-style" [content]="message?.content" [render]="false"></fm-markdown-preview> --\x3e\n <fm-markdown-preview *ngIf="message?.complete" class="content-style" [content]="message?.content"></fm-markdown-preview>\n </div>\n </div>\n </div>\n <div class="message-content-role">\n <div class="role-message" *ngIf="message?.role !== \'user\' && message?.role !== \'system\'">\n <div class="item-content">\n \x3c!-- <fm-markdown-preview *ngIf="!message?.complete" class="content-style" [content]="message?.content" [render]="false"></fm-markdown-preview> --\x3e\n <fm-markdown-preview *ngIf="message?.complete" class="content-style" [content]="message?.content"></fm-markdown-preview>\n </div>\n </div>\n </div>\n <div class="message-content-system">\n <div class="system-message" *ngIf="message?.role === \'system\'">\n <div class="item-content">\n \x3c!-- <fm-markdown-preview *ngIf="!message?.complete" class="content-style" [content]="message?.content" [render]="false"></fm-markdown-preview> --\x3e\n <fm-markdown-preview *ngIf="message?.complete" class="content-style" [content]="message?.content"></fm-markdown-preview>\n </div>\n </div>\n </div>\n </div>\n <div class="chat-time" *ngIf="message?.createdAt" [ngClass]="{\'role-time\': message?.role !== \'user\'}">\n <span>{{message?.createdAt | date:"dd/MM/yyyy, HH/mm/ss a"}}</span>\n </div>\n </div>\n </div> \n </ion-content>\n </ng-template>\n </ion-modal>\n\n \x3c!-- 图片 --\x3e\n <ion-button shape="round" *ngIf="chat?.currentModel?.get?.(\'config\')?.imageEnabled" fill="outline" slot="end" (click)="setMessageImage()">\n <ion-icon name="image-outline"></ion-icon>\n </ion-button>\n \x3c!-- 模型 --\x3e\n @if(!chat?.hideModalSelect){\n <ion-button shape="round" fill="outline" slot="end" id="model-button">\n <ion-icon name="chevron-down-outline"></ion-icon>\n {{chat?.currentModel?.get&&chat?.currentModel?.get?.("name")||"Fmode-C1.0-128k"}}\n </ion-button>\n <ion-popover trigger="model-button" [dismissOnSelect]="true">\n <ng-template>\n <ion-content>\n <ion-list>\n <ng-container *ngFor="let model of chat.modelList">\n <ion-item (click)="chat.currentModel = model" [button]="true" [detail]="false">\n {{model?.get("name")}}\n <ion-note slot="end">{{model?.get("credit")}}/k</ion-note>\n </ion-item>\n </ng-container>\n </ion-list>\n </ion-content>\n </ng-template>\n </ion-popover>\n }\n\n </ion-item>\n\n <ion-item class="input-item" lines="none">\n \x3c!-- 语音消息输入 --\x3e\n <ng-container *ngIf="chat?.isVoiceInputMode">\n \x3c!-- 切换文本输入 --\x3e\n <ion-button class="btn-input-change" color="primary" (click)="chat.isVoiceInputMode=false" shape="round" size="large">\n <ion-icon name="chatbox-ellipses-outline" slot="icon-only"></ion-icon>\n </ion-button>\n \n <div class="btn-voice-start" (click)="startTalk()" [class.disabled]="isSending">\n <span>\n 点击讲话\n </span> \n </div>\n </ng-container>\n\n \x3c!-- 文本消息输入 --\x3e\n <ng-container *ngIf="!chat?.isVoiceInputMode">\n \x3c!-- 切换语音输入 --\x3e\n <ion-button [style.display]="chat.isTexting?\'none\':\'flex\'" class="btn-input-change" color="primary" *ngIf="chat?.role?.get(\'voiceConfig\')" (click)="chat.isVoiceInputMode=true" shape="round" size="large">\n <ion-icon name="mic-outline" slot="icon-only"></ion-icon>\n </ion-button>\n\n \x3c!-- 文本输入区域 --\x3e\n <ion-textarea\n #userInput\n *ngIf="chat" (keydown)="onKeyDown($event)"\n [errorText]="errorText"\n [(ngModel)]="chat.userInput"\n (ionFocus)="onInputFocus()"\n (ionBlur)="chat.isTexting=false"\n [autoGrow]="true" shape="round" fill="outline"\n label="Ctrl + Enter 发送消息" placeholder="请输入您的提示词"\n labelPlacement="floating"></ion-textarea>\n \n \x3c!-- 文本发送按钮 --\x3e\n <ion-button [disabled]="isSending"\n color="primary" shape="round" size="large" (click)="sendMessage()">\n <ion-icon name="paper-plane-outline" slot="icon-only"></ion-icon>\n </ion-button>\n </ng-container>\n </ion-item>\n</ion-toolbar>\n\n\n\x3c!-- 语音消息输入:弹出区域 --\x3e\n\x3c!-- <ion-modal #audioModal [isOpen]="isAudioModal" (willDismiss)="closeAudio()" [initialBreakpoint]="audioModalHeightPoint" [breakpoints]="[0, audioModalHeightPoint]">\n <ng-template>\n <fm-modal-audio-message #audioComp *ngIf="isAudioModal" [chat]="chat" [modal]="audioModal"></fm-modal-audio-message>\n </ng-template>\n</ion-modal> --\x3e',styles:['@charset "UTF-8";:host-context(body.dark) .btn-voice-start{background-color:#222428;color:#fff}:host-context(body.dark) ion-textarea{background-color:#222428;color:#fff}ion-toolbar{--background:none}ion-toolbar .button-item{--inner-padding-start:5px;--inner-padding-end:0px;--padding-start:5px;--padding-end:0px}ion-toolbar ion-item{--background:transparent}.disabled{opacity:.5;pointer-events:none}.avatar{border-radius:50%;width:32px;height:32px;object-fit:cover}ion-textarea.custom{--background: #373737;--color: #fff;--padding-end: 10px;--padding-start: 10px;--placeholder-color: #ddd;--placeholder-opacity: .8}ion-textarea.custom textarea{width:calc(100% - 95px)}ion-textarea.custom ion-button{position:absolute;right:0}.input-item{display:flex;min-height:77px;align-items:center;border:none;--inner-padding-start:0px;--inner-padding-end:0px;--padding-start:0px;--padding-end:0px}.input-item ion-textarea{background-color:#fff;max-height:400px;padding:0 5px;margin:0 5px;border-radius:20px;overflow-y:auto}.input-item .btn-voice-start{display:flex;flex:1;justify-content:center;align-items:center;font-weight:700;background:#fff;border-radius:20px;min-height:50px}ion-textarea{transition:width .5s ease}ion-textarea:hover .btn-input-change,ion-textarea:focus-within .btn-input-change{display:none}.input-item:hover ion-textarea,.input-item:focus-within ion-textarea{border-color:var(--logo-color-primary)}::ng-deep .ant-modal-body{max-height:600px;overflow-y:auto}::ng-deep .ant-modal-footer{display:flex;justify-content:space-around}::ng-deep .ant-btn{width:40%}.popup-content{position:relative}.popup-content .message-content-user{display:flex;justify-content:flex-end}.popup-content .message-content-role{display:flex;justify-content:flex-start}.popup-content .message-content-system{display:flex;justify-content:center}.popup-content .user-message{padding:10px 10px 0;border-radius:10px;width:fit-content;max-width:100%;background-color:#e7f8ff}.popup-content .role-message{padding:10px 10px 0;border-radius:10px;width:fit-content;max-width:100%;background-color:#f6f6f6}.popup-content .user-question{margin-bottom:5px;display:flex;justify-content:flex-end}.popup-content .chat-time{margin-bottom:10px;display:flex;justify-content:flex-end;font-size:14px;color:#a3a3a3}.popup-content .role-time{justify-content:flex-start}\n']}]}],ctorParameters:()=>[{type:i1.ToastController},{type:i1.AlertController},{type:i2.ModalController},{type:i3.Router},{type:i4.ImagineService},{type:i5.ChatService},{type:i6.AccountService}],propDecorators:{audioComp:[{type:ViewChild,args:[ModalAudioMessageComponent]}],userInputComp:[{type:ViewChild,args:["userInput"]}],chat:[{type:Input}],message:[{type:Input}],role:[{type:Input}]}});
8
+ import{Component,Input,ViewChild}from"@angular/core";import{Router,RouterModule}from"@angular/router";import{AlertController,ToastController}from"@ionic/angular";import{FmodeChat}from"../../service-fmai/service-chat";import{ChatService}from"../../service-fmai/service-chat";import{FmodeParse,FmodeObject}from"../../../core/parse";import{ImagineService}from"../../service-fmai/service-imagine/imagine.service";import{IonButton,IonContent,IonIcon,IonInput,IonItem,IonList,IonModal,IonPopover,IonTextarea,IonToolbar,ModalController}from"@ionic/angular/standalone";import{CommonModule}from"@angular/common";import{FormsModule,ReactiveFormsModule}from"@angular/forms";import{ModalAudioMessageComponent}from"./modal-audio-message/modal-audio-message.component";import{FmChatMessageCard}from"../chat-message-card/comp-message-card.component";import{addIcons}from"ionicons";import{imageOutline,chevronBackOutline,ellipsisHorizontalOutline,chevronDownOutline,chatboxEllipsesOutline,micOutline,paperPlaneOutline,shareSocialOutline,settingsOutline,alertOutline,colorWandOutline,peopleOutline}from"ionicons/icons";import{AccountService}from"../../../user/account/account.service";import*as i0 from"@angular/core";import*as i1 from"@ionic/angular";import*as i2 from"@ionic/angular/standalone";import*as i3 from"@angular/router";import*as i4 from"../../service-fmai/service-imagine/imagine.service";import*as i5 from"../../service-fmai/service-chat";import*as i6 from"../../../user/account/account.service";import*as i7 from"@angular/common";import*as i8 from"@angular/forms";const Parse=FmodeParse.with("nova");addIcons({colorWandOutline:colorWandOutline,peopleOutline:peopleOutline,alertOutline:alertOutline,imageOutline:imageOutline,chevronBackOutline:chevronBackOutline,ellipsisHorizontalOutline:ellipsisHorizontalOutline,chevronDownOutline:chevronDownOutline,chatboxEllipsesOutline:chatboxEllipsesOutline,micOutline:micOutline,paperPlaneOutline:paperPlaneOutline,shareSocialOutline:shareSocialOutline,settingsOutline:settingsOutline});export class FmChatModalInput{closeAudio(){this.audioComp?.cancel(),this.isAudioModal=!1}async startTalk(){if(this.isSending)return!1;let e,n=document.body.clientHeight||960;this.audioModalHeightPoint=Number((165/n).toFixed(2)),this.chat.stopPlayingVoice(),e=await this.modalCtrl.create({component:ModalAudioMessageComponent,componentProps:{chat:this.chat,modal:e,onBreakPointSet:()=>{e?.setCurrentBreakpoint(this.audioModalHeightPoint)}},breakpoints:[this.audioModalHeightPoint],initialBreakpoint:this.audioModalHeightPoint}),e.present()}constructor(e,n,t,o,i,a,s){this.toastCtrl=e,this.alertCtrl=n,this.modalCtrl=t,this.router=o,this.imagineServ=i,this.chatServ=a,this.account=s,this.errorText="",this.isAudioModal=!1,this.audioModalHeightPoint=.35,this.isSending=!1,this.lastMessageTimestamp=0,this.replyTimeout=15e3,this.isShare=!1,this.user=Parse.User.current()}ngOnInit(){this.loadModel();let e=this;this.chat.focusUserInput=()=>{e.chat.isVoiceInputMode=!1,e.userInputComp?.setFocus()}}async loadModel(){let e=this.chat?.role?.get("model");await this.chat.loadModelList(e)}async setMessageImage(){let e=await this.imagineServ.getimg();this.chat.userImage=e,console.log(this.chat?.userImage)}onInputFocus(){this.chat.isTexting=!0,this.chat.scrollToBottom&&this.chat.scrollToBottom()}onKeyDown(e){e.ctrlKey&&"Enter"===e.key&&(console.log("Ctrl+Enter 被按下"),this.sendMessage())}async sendMessage(){if(this.isSending)return!1;const e=Date.now();if(this.lastMessageTimestamp>0&&e-this.lastMessageTimestamp<this.replyTimeout){return this.errorText="请等待上一条消息的回复或稍后再试",(await this.toastCtrl.create({message:this.errorText,position:"top",icon:"alert",color:"warning",duration:1e3})).present(),!1}if(this.isSending=!0,this.lastMessageTimestamp=Date.now(),!await this.checkBalance())return this.isSending=!1,!1;if(!this.chat.userInput){return this.errorText="内容不能为空",(await this.toastCtrl.create({message:this.errorText,position:"top",icon:"alert",color:"warning-circle",duration:1e3})).present(),void(this.isSending=!1)}this.lastMessageTimeout&&clearTimeout(this.lastMessageTimeout),this.lastMessageTimeout=setTimeout((()=>{this.isSending=!1,this.lastMessageTimestamp=0}),this.replyTimeout),this.chat?.sendMessage(this.chat?.userInput,this.chat?.userImage,(e=>{}),{onMessageStart:e=>{clearTimeout(this.lastMessageTimeout),this.isSending=!1,this.lastMessageTimestamp=0},onSSMLComplete:e=>{console.log(e)}}),this.chat.userInput="",this.chat.userImage=""}async checkBalance(){let e=await this.account.getBilling();if(e?.credit?.balance>=3&&(this.chat.isDirect=!0),!this.chat?.currentModel?.get?.("payLimit"))return!0;if(e?.credit?.balance<3){return(await this.alertCtrl.create({header:"注意",subHeader:"您的余额不足,请充值后解锁高级模型",buttons:[{role:"cancel",text:"取消"},{role:"destructive",text:"充值",handler:()=>{this.router.navigateByUrl("/account/billing")}}]})).present(),!1}return!0}async getChatShare(){this.user=Parse.User.current();let e=new Parse.Query("ChatShare");e.equalTo("user",Parse.User.current().id),e.equalTo("session",this.chat?.sessionId);await e.first()}async toggleChatShare(){let e=new Parse.Query("ChatShare");e.equalTo("user",Parse.User.current().id),e.equalTo("role",this.chat?.role.id),e.equalTo("session",this.chat?.sessionId),e.select("objectId");let n=await e.first();if(n?.id)n.set("messageList",this.chat?.messageList);else{n=new(Parse.Object.extend("ChatShare")),n.set("user",{__type:"Pointer",className:"_User",objectId:Parse.User.current()?.id}),n.set("session",{__type:"Pointer",className:"ChatSession",objectId:this.chat?.sessionId}),n.set("role",{__type:"Pointer",className:"AvatarRole",objectId:this.chat?.role.id}),n.set("company",{__type:"Pointer",className:"Company",objectId:"E4KpGvTEto"}),n.set("messageList",this.chat?.messageList)}await n.save(),this.getChatShare()}async chatShareSuccessMessage(){(await this.toastCtrl.create({duration:1e3,message:"分享成功",color:"primary",icon:"information-circle",position:"top"})).present()}showShare(){this.isShare=!0}handleOkShare(){this.toggleChatShare(),this.chatShareSuccessMessage(),this.isShare=!1}handleCancelShare(){this.isShare=!1}static{this.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"17.3.12",ngImport:i0,type:FmChatModalInput,deps:[{token:i1.ToastController},{token:i1.AlertController},{token:i2.ModalController},{token:i3.Router},{token:i4.ImagineService},{token:i5.ChatService},{token:i6.AccountService}],target:i0.ɵɵFactoryTarget.Component})}static{this.ɵcmp=i0.ɵɵngDeclareComponent({minVersion:"17.0.0",version:"17.3.12",type:FmChatModalInput,isStandalone:!0,selector:"fm-chat-modal-input",inputs:{chat:"chat",message:"message",role:"role"},viewQueries:[{propertyName:"audioComp",first:!0,predicate:ModalAudioMessageComponent,descendants:!0},{propertyName:"userInputComp",first:!0,predicate:["userInput"],descendants:!0}],ngImport:i0,template:'<ion-toolbar>\n <ion-item class="button-item" lines="none">\n \x3c!-- 设置 --\x3e\n \x3c!-- <ion-button fill="outline" slot="start">\n <ion-icon name="settings-outline"></ion-icon> \n </ion-button> --\x3e\n <ng-container *ngFor="let button of chat?.leftButtons">\n <ion-button style="--padding-start:10px;--padding-end:10px;"\n shape="round" *ngIf="button?.show&&button?.show()" fill="outline" [title]="button?.title" slot="start" (click)="button.onClick()">\n <ion-icon [name]="button?.icon" [slot]="button?.showTitle?\'start\':\'icon-only\'"></ion-icon>\n {{button?.showTitle&&button?.title}}\n </ion-button>\n </ng-container>\n\n <ng-container *ngFor="let button of chat?.role?.get(\'buttons\')">\n <ion-button shape="round" (click)="chatServ.doButtonAction(button)" fill="outline" slot="start">\n {{button?.name}}\n </ion-button>\n </ng-container>\n\n \x3c!--分享按钮--\x3e\n @if(!chat?.hideShare){\n <ion-button shape="round" *ngIf="chat?.messageList?.length>1" (click)="showShare()" fill="outline" title="分享" slot="end">\n <ion-icon name="share-social-outline"></ion-icon>\n </ion-button>\n }\n <ion-modal [isOpen]="isShare">\n <ng-template>\n <ion-header>\n <ion-toolbar>\n <ion-buttons slot="start">\n <ion-button (click)="handleCancelShare()">取消</ion-button>\n </ion-buttons>\n <ion-title>对话分享</ion-title>\n <ion-buttons slot="end">\n <ion-button (click)="handleOkShare()">分享</ion-button>\n </ion-buttons>\n </ion-toolbar>\n </ion-header>\n <ion-content class="ion-padding">\n <ng-container *ngFor="let message of chat?.messageList;let index=index;">\n \x3c!-- 内容格式化区域 --\x3e\n <fm-chat-message-card [chat]="chat" *ngIf="!message?.hidden" [index]="index" [message]="message" [role]="chat?.role"></fm-chat-message-card>\n </ng-container>\n\n <div *ngIf="false" class="popup-content">\n <div *ngFor="let message of chat?.messageList">\n \x3c!-- 头像 --\x3e\n <div class="item-row user" *ngIf="message?.role!=\'system\'">\n <div>\n <img class="avatar" *ngIf="message?.role!=\'user\'" [src]="(chat?.role?.get(\'avatar\') || chat?.role?.get(\'thumb\') || \'https://file-cloud.fmode.cn/E4KpGvTEto/20230930/l413e6090731854.png\')+\'?\'+\'x-image-process=image/resize,m_fixed,w_100\'+\'&imageView2/1/w/32/h/32\'" >\n </div>\n <div class="user-question">\n <app-comp-user-avatar [user]="user" *ngIf="message?.role==\'user\'"></app-comp-user-avatar>\n </div>\n </div>\n \x3c!-- 内容 --\x3e\n <div class="message-wrapper">\n <div class="message-content-user">\n <div class="user-message" *ngIf="message?.role === \'user\'">\n <div class="item-content">\n \x3c!-- <fm-markdown-preview *ngIf="!message?.complete" class="content-style" [content]="message?.content" [render]="false"></fm-markdown-preview> --\x3e\n <fm-markdown-preview *ngIf="message?.complete" class="content-style" [content]="message?.content"></fm-markdown-preview>\n </div>\n </div>\n </div>\n <div class="message-content-role">\n <div class="role-message" *ngIf="message?.role !== \'user\' && message?.role !== \'system\'">\n <div class="item-content">\n \x3c!-- <fm-markdown-preview *ngIf="!message?.complete" class="content-style" [content]="message?.content" [render]="false"></fm-markdown-preview> --\x3e\n <fm-markdown-preview *ngIf="message?.complete" class="content-style" [content]="message?.content"></fm-markdown-preview>\n </div>\n </div>\n </div>\n <div class="message-content-system">\n <div class="system-message" *ngIf="message?.role === \'system\'">\n <div class="item-content">\n \x3c!-- <fm-markdown-preview *ngIf="!message?.complete" class="content-style" [content]="message?.content" [render]="false"></fm-markdown-preview> --\x3e\n <fm-markdown-preview *ngIf="message?.complete" class="content-style" [content]="message?.content"></fm-markdown-preview>\n </div>\n </div>\n </div>\n </div>\n <div class="chat-time" *ngIf="message?.createdAt" [ngClass]="{\'role-time\': message?.role !== \'user\'}">\n <span>{{message?.createdAt | date:"dd/MM/yyyy, HH/mm/ss a"}}</span>\n </div>\n </div>\n </div> \n </ion-content>\n </ng-template>\n </ion-modal>\n\n \x3c!-- 图片 --\x3e\n <ion-button shape="round" *ngIf="chat?.currentModel?.get?.(\'config\')?.imageEnabled" fill="outline" slot="end" (click)="setMessageImage()">\n <ion-icon name="image-outline"></ion-icon>\n </ion-button>\n \x3c!-- 模型 --\x3e\n @if(!chat?.hideModalSelect){\n <ion-button shape="round" fill="outline" slot="end" id="model-button">\n <ion-icon name="chevron-down-outline"></ion-icon>\n {{chat?.currentModel?.get&&chat?.currentModel?.get?.("name")||"Fmode-C1.0-128k"}}\n </ion-button>\n <ion-popover trigger="model-button" [dismissOnSelect]="true">\n <ng-template>\n <ion-content>\n <ion-list>\n <ng-container *ngFor="let model of chat.modelList">\n <ion-item (click)="chat.currentModel = model" [button]="true" [detail]="false">\n {{model?.get("name")}}\n <ion-note slot="end">{{model?.get("credit")}}/k</ion-note>\n </ion-item>\n </ng-container>\n </ion-list>\n </ion-content>\n </ng-template>\n </ion-popover>\n }\n\n </ion-item>\n\n <ion-item class="input-item" lines="none">\n \x3c!-- 语音消息输入 --\x3e\n <ng-container *ngIf="chat?.isVoiceInputMode">\n \x3c!-- 切换文本输入 --\x3e\n <ion-button class="btn-input-change" color="primary" (click)="chat.isVoiceInputMode=false" shape="round" size="large">\n <ion-icon name="chatbox-ellipses-outline" slot="icon-only"></ion-icon>\n </ion-button>\n \n <div class="btn-voice-start" (click)="startTalk()" [class.disabled]="isSending">\n <span>\n 点击讲话\n </span> \n </div>\n </ng-container>\n\n \x3c!-- 文本消息输入 --\x3e\n <ng-container *ngIf="!chat?.isVoiceInputMode">\n \x3c!-- 切换语音输入 --\x3e\n <ion-button [style.display]="chat.isTexting?\'none\':\'flex\'" class="btn-input-change" color="primary" *ngIf="chat?.role?.get(\'voiceConfig\')" (click)="chat.isVoiceInputMode=true" shape="round" size="large">\n <ion-icon name="mic-outline" slot="icon-only"></ion-icon>\n </ion-button>\n\n \x3c!-- 文本输入区域 --\x3e\n <ion-textarea\n #userInput\n *ngIf="chat" (keydown)="onKeyDown($event)"\n [errorText]="errorText"\n [(ngModel)]="chat.userInput"\n (ionFocus)="onInputFocus()"\n (ionBlur)="chat.isTexting=false"\n [autoGrow]="true" shape="round" fill="outline"\n label="Ctrl + Enter 发送消息" placeholder="请输入您的提示词"\n labelPlacement="floating"></ion-textarea>\n \n \x3c!-- 文本发送按钮 --\x3e\n <ion-button [disabled]="isSending"\n color="primary" shape="round" size="large" (click)="sendMessage()">\n <ion-icon name="paper-plane-outline" slot="icon-only"></ion-icon>\n </ion-button>\n </ng-container>\n </ion-item>\n</ion-toolbar>\n\n\n\x3c!-- 语音消息输入:弹出区域 --\x3e\n\x3c!-- <ion-modal #audioModal [isOpen]="isAudioModal" (willDismiss)="closeAudio()" [initialBreakpoint]="audioModalHeightPoint" [breakpoints]="[0, audioModalHeightPoint]">\n <ng-template>\n <fm-modal-audio-message #audioComp *ngIf="isAudioModal" [chat]="chat" [modal]="audioModal"></fm-modal-audio-message>\n </ng-template>\n</ion-modal> --\x3e',styles:['@charset "UTF-8";:host-context(body.dark) .btn-voice-start{background-color:#222428;color:#fff}:host-context(body.dark) ion-textarea{background-color:#222428;color:#fff}ion-toolbar{--background:none}ion-toolbar .button-item{--inner-padding-start:5px;--inner-padding-end:0px;--padding-start:5px;--padding-end:0px}ion-toolbar ion-item{--background:transparent}.disabled{opacity:.5;pointer-events:none}.avatar{border-radius:50%;width:32px;height:32px;object-fit:cover}ion-textarea.custom{--background: #373737;--color: #fff;--padding-end: 10px;--padding-start: 10px;--placeholder-color: #ddd;--placeholder-opacity: .8}ion-textarea.custom textarea{width:calc(100% - 95px)}ion-textarea.custom ion-button{position:absolute;right:0}.input-item{display:flex;min-height:77px;align-items:center;border:none;--inner-padding-start:0px;--inner-padding-end:0px;--padding-start:0px;--padding-end:0px}.input-item ion-textarea{background-color:#fff;max-height:400px;padding:0 5px;margin:0 5px;border-radius:20px;overflow-y:auto}.input-item .btn-voice-start{display:flex;flex:1;justify-content:center;align-items:center;font-weight:700;background:#fff;border-radius:20px;min-height:50px}ion-textarea{transition:width .5s ease}ion-textarea:hover .btn-input-change,ion-textarea:focus-within .btn-input-change{display:none}.input-item:hover ion-textarea,.input-item:focus-within ion-textarea{border-color:var(--logo-color-primary)}::ng-deep .ant-modal-body{max-height:600px;overflow-y:auto}::ng-deep .ant-modal-footer{display:flex;justify-content:space-around}::ng-deep .ant-btn{width:40%}.popup-content{position:relative}.popup-content .message-content-user{display:flex;justify-content:flex-end}.popup-content .message-content-role{display:flex;justify-content:flex-start}.popup-content .message-content-system{display:flex;justify-content:center}.popup-content .user-message{padding:10px 10px 0;border-radius:10px;width:fit-content;max-width:100%;background-color:#e7f8ff}.popup-content .role-message{padding:10px 10px 0;border-radius:10px;width:fit-content;max-width:100%;background-color:#f6f6f6}.popup-content .user-question{margin-bottom:5px;display:flex;justify-content:flex-end}.popup-content .chat-time{margin-bottom:10px;display:flex;justify-content:flex-end;font-size:14px;color:#a3a3a3}.popup-content .role-time{justify-content:flex-start}\n'],dependencies:[{kind:"ngmodule",type:CommonModule},{kind:"directive",type:i7.NgClass,selector:"[ngClass]",inputs:["class","ngClass"]},{kind:"directive",type:i7.NgForOf,selector:"[ngFor][ngForOf]",inputs:["ngForOf","ngForTrackBy","ngForTemplate"]},{kind:"directive",type:i7.NgIf,selector:"[ngIf]",inputs:["ngIf","ngIfThen","ngIfElse"]},{kind:"pipe",type:i7.DatePipe,name:"date"},{kind:"ngmodule",type:FormsModule},{kind:"directive",type:i8.NgControlStatus,selector:"[formControlName],[ngModel],[formControl]"},{kind:"directive",type:i8.NgModel,selector:"[ngModel]:not([formControlName]):not([formControl])",inputs:["name","disabled","ngModel","ngModelOptions"],outputs:["ngModelChange"],exportAs:["ngModel"]},{kind:"ngmodule",type:ReactiveFormsModule},{kind:"ngmodule",type:RouterModule},{kind:"component",type:IonToolbar,selector:"ion-toolbar",inputs:["color","mode"]},{kind:"component",type:IonItem,selector:"ion-item",inputs:["button","color","detail","detailIcon","disabled","download","href","lines","mode","rel","routerAnimation","routerDirection","target","type"]},{kind:"component",type: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:IonList,selector:"ion-list",inputs:["inset","lines","mode"]},{kind:"component",type:IonModal,selector:"ion-modal"},{kind:"component",type:IonIcon,selector:"ion-icon",inputs:["color","flipRtl","icon","ios","lazy","md","mode","name","sanitize","size","src"]},{kind:"component",type:IonTextarea,selector:"ion-textarea",inputs:["autoGrow","autocapitalize","autofocus","clearOnEdit","color","cols","counter","counterFormatter","debounce","disabled","enterkeyhint","errorText","fill","helperText","inputmode","label","labelPlacement","maxlength","minlength","mode","name","placeholder","readonly","required","rows","shape","spellcheck","value","wrap"]},{kind:"component",type:IonPopover,selector:"ion-popover"},{kind:"component",type:IonContent,selector:"ion-content",inputs:["color","fixedSlotPlacement","forceOverscroll","fullscreen","scrollEvents","scrollX","scrollY"]},{kind:"component",type:FmChatMessageCard,selector:"fm-chat-message-card",inputs:["index","message","role","chat"]}]})}}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"17.3.12",ngImport:i0,type:FmChatModalInput,decorators:[{type:Component,args:[{selector:"fm-chat-modal-input",standalone:!0,imports:[CommonModule,FormsModule,ReactiveFormsModule,RouterModule,IonToolbar,IonItem,IonButton,IonList,IonModal,IonInput,IonIcon,IonTextarea,IonPopover,IonContent,FmChatMessageCard,ModalAudioMessageComponent],template:'<ion-toolbar>\n <ion-item class="button-item" lines="none">\n \x3c!-- 设置 --\x3e\n \x3c!-- <ion-button fill="outline" slot="start">\n <ion-icon name="settings-outline"></ion-icon> \n </ion-button> --\x3e\n <ng-container *ngFor="let button of chat?.leftButtons">\n <ion-button style="--padding-start:10px;--padding-end:10px;"\n shape="round" *ngIf="button?.show&&button?.show()" fill="outline" [title]="button?.title" slot="start" (click)="button.onClick()">\n <ion-icon [name]="button?.icon" [slot]="button?.showTitle?\'start\':\'icon-only\'"></ion-icon>\n {{button?.showTitle&&button?.title}}\n </ion-button>\n </ng-container>\n\n <ng-container *ngFor="let button of chat?.role?.get(\'buttons\')">\n <ion-button shape="round" (click)="chatServ.doButtonAction(button)" fill="outline" slot="start">\n {{button?.name}}\n </ion-button>\n </ng-container>\n\n \x3c!--分享按钮--\x3e\n @if(!chat?.hideShare){\n <ion-button shape="round" *ngIf="chat?.messageList?.length>1" (click)="showShare()" fill="outline" title="分享" slot="end">\n <ion-icon name="share-social-outline"></ion-icon>\n </ion-button>\n }\n <ion-modal [isOpen]="isShare">\n <ng-template>\n <ion-header>\n <ion-toolbar>\n <ion-buttons slot="start">\n <ion-button (click)="handleCancelShare()">取消</ion-button>\n </ion-buttons>\n <ion-title>对话分享</ion-title>\n <ion-buttons slot="end">\n <ion-button (click)="handleOkShare()">分享</ion-button>\n </ion-buttons>\n </ion-toolbar>\n </ion-header>\n <ion-content class="ion-padding">\n <ng-container *ngFor="let message of chat?.messageList;let index=index;">\n \x3c!-- 内容格式化区域 --\x3e\n <fm-chat-message-card [chat]="chat" *ngIf="!message?.hidden" [index]="index" [message]="message" [role]="chat?.role"></fm-chat-message-card>\n </ng-container>\n\n <div *ngIf="false" class="popup-content">\n <div *ngFor="let message of chat?.messageList">\n \x3c!-- 头像 --\x3e\n <div class="item-row user" *ngIf="message?.role!=\'system\'">\n <div>\n <img class="avatar" *ngIf="message?.role!=\'user\'" [src]="(chat?.role?.get(\'avatar\') || chat?.role?.get(\'thumb\') || \'https://file-cloud.fmode.cn/E4KpGvTEto/20230930/l413e6090731854.png\')+\'?\'+\'x-image-process=image/resize,m_fixed,w_100\'+\'&imageView2/1/w/32/h/32\'" >\n </div>\n <div class="user-question">\n <app-comp-user-avatar [user]="user" *ngIf="message?.role==\'user\'"></app-comp-user-avatar>\n </div>\n </div>\n \x3c!-- 内容 --\x3e\n <div class="message-wrapper">\n <div class="message-content-user">\n <div class="user-message" *ngIf="message?.role === \'user\'">\n <div class="item-content">\n \x3c!-- <fm-markdown-preview *ngIf="!message?.complete" class="content-style" [content]="message?.content" [render]="false"></fm-markdown-preview> --\x3e\n <fm-markdown-preview *ngIf="message?.complete" class="content-style" [content]="message?.content"></fm-markdown-preview>\n </div>\n </div>\n </div>\n <div class="message-content-role">\n <div class="role-message" *ngIf="message?.role !== \'user\' && message?.role !== \'system\'">\n <div class="item-content">\n \x3c!-- <fm-markdown-preview *ngIf="!message?.complete" class="content-style" [content]="message?.content" [render]="false"></fm-markdown-preview> --\x3e\n <fm-markdown-preview *ngIf="message?.complete" class="content-style" [content]="message?.content"></fm-markdown-preview>\n </div>\n </div>\n </div>\n <div class="message-content-system">\n <div class="system-message" *ngIf="message?.role === \'system\'">\n <div class="item-content">\n \x3c!-- <fm-markdown-preview *ngIf="!message?.complete" class="content-style" [content]="message?.content" [render]="false"></fm-markdown-preview> --\x3e\n <fm-markdown-preview *ngIf="message?.complete" class="content-style" [content]="message?.content"></fm-markdown-preview>\n </div>\n </div>\n </div>\n </div>\n <div class="chat-time" *ngIf="message?.createdAt" [ngClass]="{\'role-time\': message?.role !== \'user\'}">\n <span>{{message?.createdAt | date:"dd/MM/yyyy, HH/mm/ss a"}}</span>\n </div>\n </div>\n </div> \n </ion-content>\n </ng-template>\n </ion-modal>\n\n \x3c!-- 图片 --\x3e\n <ion-button shape="round" *ngIf="chat?.currentModel?.get?.(\'config\')?.imageEnabled" fill="outline" slot="end" (click)="setMessageImage()">\n <ion-icon name="image-outline"></ion-icon>\n </ion-button>\n \x3c!-- 模型 --\x3e\n @if(!chat?.hideModalSelect){\n <ion-button shape="round" fill="outline" slot="end" id="model-button">\n <ion-icon name="chevron-down-outline"></ion-icon>\n {{chat?.currentModel?.get&&chat?.currentModel?.get?.("name")||"Fmode-C1.0-128k"}}\n </ion-button>\n <ion-popover trigger="model-button" [dismissOnSelect]="true">\n <ng-template>\n <ion-content>\n <ion-list>\n <ng-container *ngFor="let model of chat.modelList">\n <ion-item (click)="chat.currentModel = model" [button]="true" [detail]="false">\n {{model?.get("name")}}\n <ion-note slot="end">{{model?.get("credit")}}/k</ion-note>\n </ion-item>\n </ng-container>\n </ion-list>\n </ion-content>\n </ng-template>\n </ion-popover>\n }\n\n </ion-item>\n\n <ion-item class="input-item" lines="none">\n \x3c!-- 语音消息输入 --\x3e\n <ng-container *ngIf="chat?.isVoiceInputMode">\n \x3c!-- 切换文本输入 --\x3e\n <ion-button class="btn-input-change" color="primary" (click)="chat.isVoiceInputMode=false" shape="round" size="large">\n <ion-icon name="chatbox-ellipses-outline" slot="icon-only"></ion-icon>\n </ion-button>\n \n <div class="btn-voice-start" (click)="startTalk()" [class.disabled]="isSending">\n <span>\n 点击讲话\n </span> \n </div>\n </ng-container>\n\n \x3c!-- 文本消息输入 --\x3e\n <ng-container *ngIf="!chat?.isVoiceInputMode">\n \x3c!-- 切换语音输入 --\x3e\n <ion-button [style.display]="chat.isTexting?\'none\':\'flex\'" class="btn-input-change" color="primary" *ngIf="chat?.role?.get(\'voiceConfig\')" (click)="chat.isVoiceInputMode=true" shape="round" size="large">\n <ion-icon name="mic-outline" slot="icon-only"></ion-icon>\n </ion-button>\n\n \x3c!-- 文本输入区域 --\x3e\n <ion-textarea\n #userInput\n *ngIf="chat" (keydown)="onKeyDown($event)"\n [errorText]="errorText"\n [(ngModel)]="chat.userInput"\n (ionFocus)="onInputFocus()"\n (ionBlur)="chat.isTexting=false"\n [autoGrow]="true" shape="round" fill="outline"\n label="Ctrl + Enter 发送消息" placeholder="请输入您的提示词"\n labelPlacement="floating"></ion-textarea>\n \n \x3c!-- 文本发送按钮 --\x3e\n <ion-button [disabled]="isSending"\n color="primary" shape="round" size="large" (click)="sendMessage()">\n <ion-icon name="paper-plane-outline" slot="icon-only"></ion-icon>\n </ion-button>\n </ng-container>\n </ion-item>\n</ion-toolbar>\n\n\n\x3c!-- 语音消息输入:弹出区域 --\x3e\n\x3c!-- <ion-modal #audioModal [isOpen]="isAudioModal" (willDismiss)="closeAudio()" [initialBreakpoint]="audioModalHeightPoint" [breakpoints]="[0, audioModalHeightPoint]">\n <ng-template>\n <fm-modal-audio-message #audioComp *ngIf="isAudioModal" [chat]="chat" [modal]="audioModal"></fm-modal-audio-message>\n </ng-template>\n</ion-modal> --\x3e',styles:['@charset "UTF-8";:host-context(body.dark) .btn-voice-start{background-color:#222428;color:#fff}:host-context(body.dark) ion-textarea{background-color:#222428;color:#fff}ion-toolbar{--background:none}ion-toolbar .button-item{--inner-padding-start:5px;--inner-padding-end:0px;--padding-start:5px;--padding-end:0px}ion-toolbar ion-item{--background:transparent}.disabled{opacity:.5;pointer-events:none}.avatar{border-radius:50%;width:32px;height:32px;object-fit:cover}ion-textarea.custom{--background: #373737;--color: #fff;--padding-end: 10px;--padding-start: 10px;--placeholder-color: #ddd;--placeholder-opacity: .8}ion-textarea.custom textarea{width:calc(100% - 95px)}ion-textarea.custom ion-button{position:absolute;right:0}.input-item{display:flex;min-height:77px;align-items:center;border:none;--inner-padding-start:0px;--inner-padding-end:0px;--padding-start:0px;--padding-end:0px}.input-item ion-textarea{background-color:#fff;max-height:400px;padding:0 5px;margin:0 5px;border-radius:20px;overflow-y:auto}.input-item .btn-voice-start{display:flex;flex:1;justify-content:center;align-items:center;font-weight:700;background:#fff;border-radius:20px;min-height:50px}ion-textarea{transition:width .5s ease}ion-textarea:hover .btn-input-change,ion-textarea:focus-within .btn-input-change{display:none}.input-item:hover ion-textarea,.input-item:focus-within ion-textarea{border-color:var(--logo-color-primary)}::ng-deep .ant-modal-body{max-height:600px;overflow-y:auto}::ng-deep .ant-modal-footer{display:flex;justify-content:space-around}::ng-deep .ant-btn{width:40%}.popup-content{position:relative}.popup-content .message-content-user{display:flex;justify-content:flex-end}.popup-content .message-content-role{display:flex;justify-content:flex-start}.popup-content .message-content-system{display:flex;justify-content:center}.popup-content .user-message{padding:10px 10px 0;border-radius:10px;width:fit-content;max-width:100%;background-color:#e7f8ff}.popup-content .role-message{padding:10px 10px 0;border-radius:10px;width:fit-content;max-width:100%;background-color:#f6f6f6}.popup-content .user-question{margin-bottom:5px;display:flex;justify-content:flex-end}.popup-content .chat-time{margin-bottom:10px;display:flex;justify-content:flex-end;font-size:14px;color:#a3a3a3}.popup-content .role-time{justify-content:flex-start}\n']}]}],ctorParameters:()=>[{type:i1.ToastController},{type:i1.AlertController},{type:i2.ModalController},{type:i3.Router},{type:i4.ImagineService},{type:i5.ChatService},{type:i6.AccountService}],propDecorators:{audioComp:[{type:ViewChild,args:[ModalAudioMessageComponent]}],userInputComp:[{type:ViewChild,args:["userInput"]}],chat:[{type:Input}],message:[{type:Input}],role:[{type:Input}]}});
9
9
  var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9haWdjL2NoYXQvY2hhdC1tb2RhbC1pbnB1dC9tb2RhbC1pbnB1dC5jb21wb25lbnQubWpz`
10
10
 
@@ -5,6 +5,6 @@
5
5
  * 保留所有权利 All Rights Reserved.
6
6
  * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/agent/chat/fmode-chat.mjs
7
7
  */
8
- import{finalize}from"rxjs";import{FmodeParse}from"../../../core/parse";const Parse=FmodeParse.with("nova");import{FmodeTTS,FmodeTTSProviderDoubao}from"../../voice/tts";import{PromptTemplate}from"@langchain/core/prompts";import{getFormatTpl}from"../prompt/prompt-util";import{FmodeChatCompletion}from"./completion";const PromptTplTalkSSMLOutputCode="talk-ssml-output-tpl",PromptTplTalkTextSSMLCode="talk-text-ssml-tpl";export function getMessageContentText(t){let e="";return"string"==typeof t&&(e=t),"object"==typeof t&&(e=t?.find((t=>t?.text))?.text||""),e}export function getMessageImageUrl(t){return"object"==typeof t?t?.find((t=>t?.image_url))?.image_url?.url||"":null}export class FmodeChat{async loadModelList(t){if(this.modelList?.length)return;let e=new Parse.Query("ChatModel");e.notEqualTo("isDeleted",!0),e.equalTo("isEnabled",!0),e.addAscending("index"),this.modelList=await e.find(),this.currentModel=t||this.modelList?.find((t=>"fmode-1.6-cn"==t.get("code")))}showAvatar(){this.avatarConfig=this.role?.get("avatarConfig"),this.avatarConfig&&(this.isAvatarShow=!0,this.avatarConfig?.image&&(this.avatarConfig.image.waiting=this.avatarConfig.image.waiting||this.role?.get("thumb")||this.role?.get("avatar"),this.avatarMode="image"),this.avatarConfig?.video&&(this.avatarConfig.video.waiting=this.avatarConfig.video.waiting,this.avatarMode="video"))}scrollToBottom(t){t=t||this.scrollComp,t?.nativeElement?.scrollHeight&&(t.nativeElement.scrollTop=t.nativeElement.scrollHeight)}constructor(t,e,i,s,o,a,n){this.ChatSession=Parse.Object.extend("ChatSession"),this.messageList=[{role:"system",content:"系统提示:AI仅供参考"}],this.latestAIResponse="",this.userInput="",this.userImage="",this.isDirect=!1,this.mode="page",this.hideShare=!1,this.hideModalSelect=!1,this.hideInputPreview=!1,this.isAvatarShow=!1,this.avatarMode="",this.isPromptModalOpen=!1,this.isPromptMessageAreaShow=!0,this.promptList=[],this.focusUserInput=()=>{},this.leftButtons=[{title:"灵感",icon:"color-wand-outline",onClick:()=>{this.isPromptModalOpen=!0},show:()=>this?.promptList?.length},{title:"角色",icon:"people-outline",onClick:()=>{this.navCtrl?.navigateRoot("/chat/pro/mask")},show:()=>!0},{title:"呼叫",icon:"call-outline",onClick:()=>{this.chatServ?.callRole(this.role)},show:()=>this?.role?.get("voiceConfig")}],this.isVoiceInputMode=!1,this.isTexting=!1,this.isTalkMode=!1,this.SSMLRoleVoice="zh-CN-XiaoxiaoNeural",this.playAnimation=t=>{console.log(t)},this.welcome=async()=>{let t=this.messageList?.filter((t=>"assistant"==t?.role));if(t?.length)return;let e=Parse.User.current(),i=await this.loadSelf("Person","userVerify"),s=await this.loadSelf("Profile","user"),o=i?.get("name")||i?.get("userVefiry")?.get("realname")||i?.get("userVefiry")?.get("nickname"),a=e?.get("nickname")||s?.get("name")||e?.get("realname")||e?.get("name");i?.get("userVerify")?.id==e?.id&&(o="您"),a||(a=o);let n=this.role.get("voiceConfig")?.welcome?.prompt;if(this.role.get("voiceConfig")?.welcome?.promptList?.length){let t=this.role.get("voiceConfig")?.welcome?.promptList;n=t[Math.floor(Math.random()*t.length)]}if(!n)return;let r=await PromptTemplate.fromTemplate(n,{templateFormat:"mustache"}).format({name:a,userName:a,personName:o,timeOfDay:this.getTimeOfDay()}),l=await this.getVoiceByContentText(r),h={role:"assistant",voice:l,content:r,complete:!0};this.voiceMap[l?.id],this.playChatVoice(this.voiceMap[l?.id]),this.messageList.push(h)},this.self={},this.voiceMap={},this.VoiceTTSMap={},this.chatServ=s,this.role=e,this.sessionId=t,this.navCtrl=o,this.ncloud=a,this.uploadServ=n,i?.id&&(this.chatSession=i,this.messageList=this.chatSession.get("messageList"),this.sessionId=i?.id),this.role?.id&&(this.voiceConfig=this.role?.get("voiceConfig"),this.voiceConfig?.autoTalk&&(this.isTalkMode=this.isTalkMode||this.voiceConfig?.autoTalk,this.isDirect=!0))}getTimeOfDay(){const t=(new Date).getHours();return t>=5&&t<12?"早上":t>=12&&t<14?"中午":t>=14&&t<18?"下午":"晚上"}async loadSelf(t,e){if(this.self[t])return this.self[t];let i=Parse.User.current(),s=new Parse.Query(t);return s.include(e),s.equalTo(e,i?.id),this.self[t]=await s.first(),this.self[t]}async loadTalkSystemPrompt(t){if(!this.isTalkMode)return;if(!t)return;let e=t?.get("voiceConfig");"男"==t?.get("gender")?(this.SSMLRoleVoice="zh-CN-YunyeNeural","doubao"==e.provider&&(this.SSMLRoleVoice="zh_male_yangguangqingnian_emo_v2_mars_bigtts")):(this.SSMLRoleVoice="zh-CN-XiaoxiaoNeural","doubao"==e.provider&&(this.SSMLRoleVoice="zh_female_shuangkuaisisi_emo_v2_mars_bigtts")),this.SSMLRoleVoice=t?.get("voiceConfig")?.voice||this.SSMLRoleVoice;let i=await getFormatTpl("talk-ssml-output-tpl",{SSMLRoleVoice:this.SSMLRoleVoice}),s=t.get("prompt")||"请你扮演飞码AI的人工智能专家。";s+=i;let o={role:"user",content:s,hidden:!0},a=this.messageList?.map((t=>t?.content)).join();if(a.indexOf(s)>-1)return;let n=this.messageList?.findIndex((t=>"system"==t?.role)),r=n+1;this.messageList.splice(r,0,o)}loadRolePrompt(){let t=this.role?.get("prompt"),e={role:"user",content:t,hidden:!0};if(!t)return;let i=this.messageList?.map((t=>t?.content)).join();if(i.indexOf(t)>-1)return;let s=this.messageList?.findIndex((t=>"system"==t?.role)),o=s+1;this.messageList.splice(o,0,e)}async sendMessage(t="FmodeAiTest测试问题",e,i,s,o){if(this.scrollToBottom&&this.scrollToBottom(),this.isPromptMessageAreaShow=!1,this.loadRolePrompt(),e){let i={role:"user",content:[{type:"image_url",image_url:{url:e}},{type:"text",text:t}],complete:!0,createdAt:new Date};o&&(i.voice={id:o?.id}),this.messageList.push({role:"user",content:[{type:"image_url",image_url:{url:e}},{type:"text",text:t}],complete:!0,createdAt:new Date})}else{let e={role:"user",content:t,complete:!0,createdAt:new Date};o&&(e.voice={id:o?.id,duration:o?.duration}),this.messageList.push(e)}let a=new FmodeChatCompletion(this.fixMessageList(this.messageList),{model:this.currentModel?.get?.("code")||"fmode-1.6-cn"});if(this.onUserSend){if(!await this.onUserSend(this,this.messageList[this.messageList?.length-1]))return}this.userInput="",this.userImage="";let n=this.isDirect||!1;this.isTalkMode&&(n=!0);let r=a.sendCompletion({isDirect:n,onComplete:i||null}).pipe(finalize((async()=>{if(this.isTalkMode){let t=this.messageList[a.indexOfList]?.content,e=await this.getVoiceByContentText(t,s);s?.onSSMLComplete&&s?.onSSMLComplete(e),this.messageList[a.indexOfList].voice=e,this.playChatVoice(this.voiceMap[e?.id],{onResult:t=>{t?.duration&&(this.messageList[a.indexOfList].voice.duration=t?.duration)}})}this.messageList[a.indexOfList].complete=!0}))).subscribe((t=>{this.messageList[a.indexOfList]||s?.onMessageStart?.(t),this.messageList[a.indexOfList]=t,this.latestAIResponse=this.getContentText(t?.content);let e=this.chatSession?.get("messageList")?.length;this.messageList?.length>e&&this.saveChatSession(),t?.complete&&(this.onMessage&&this.onMessage(this,this.messageList[this.messageList?.length-1]),this.saveChatSession(),r.unsubscribe()),this.scrollToBottom&&this.scrollToBottom()}))}getVoiceByContentText(t,e,i=!1){let s=this.getContentText(t),o=new(Parse.Object.extend("ChatVoice")),a="",n=this.voiceConfig||this.role?.get("voiceConfig");return this.SSMLRoleVoice=n?.voice||this.SSMLRoleVoice,new Promise((async(t,e)=>{let resolveChatVoice=async()=>{o.set("content",s),o.set("ssml",a),o.set("role","assistant");let e=localStorage.getItem("company");e&&o.set("company",{__type:"Pointer",className:"Company",objectId:e}),Parse.User.current()?.id&&o.set("user",Parse.User.current().toPointer()),this.chatSession?.id&&o.set("session",this.chatSession?.toPointer()),o=await o.save(),this.voiceMap[o?.id]=o,t({id:o?.id})};if(0==i){let t=n?.provider||"microsoft",e=n?.rate,i=e?"</prosody>":"";a=`<speak provider="${t}">${e?`<prosody rate="${e}">`:""}<voice name="${this.SSMLRoleVoice}">${s}</voice>${i}</speak>`,"doubao"==t&&(a=s),resolveChatVoice()}if(1==i){let t=await getFormatTpl("talk-text-ssml-tpl",{content:s,SSMLRoleVoice:this.SSMLRoleVoice});new FmodeChatCompletion(this.fixMessageList([{role:"user",content:t}]),{model:this.currentModel?.get?.("code")||"fmode-1.6-cn"}).sendCompletion({isDirect:!0}).subscribe((async t=>{t?.complete&&(a=this.getContentText(t?.content),resolveChatVoice())}))}}))}getContentText(t){return"string"==typeof t?t:t?.[0]?.text||""}async initTTS(){this.voiceConfig=this.voiceConfig||this.role?.get("voiceConfig");let t=await this.ncloud.apig("voice/tts/token",{company:localStorage.getItem("company"),provider:this.voiceConfig?.provider||"microsoft"});if(t.provider=this.voiceConfig?.provider,!t?.provider||t?.provider,"doubao"==t?.provider&&(t.provider=new FmodeTTSProviderDoubao),t.voiceConfig=this.voiceConfig,console.log("initTTS",t),t?.token||t?.stsToken){return new FmodeTTS(t,this.uploadServ)}return null}stopPlayingVoice(){Object.values(this.VoiceTTSMap).forEach((t=>{t?.isPlaying&&t?.stop()}))}async playChatVoice(t,e){let i=await this.initTTS();if(console.log("playChatVoice",i),i){try{i.voiceConfig=this.voiceConfig,this.playAnimation("talking"),i.speakAsync(t?.get("ssml"),t,{onStart:t=>{e?.onStart&&e?.onStart(t)},onLoaded:t=>{e?.onLoaded&&e?.onLoaded(t)},onResult:t=>{e?.onResult&&e?.onResult(t)},onStop:()=>{e?.onStop&&e?.onStop(),this.playAnimation("waiting")}})}catch(t){}return this.VoiceTTSMap[t.id]=i,i}return null}async saveChatSession(){if("new"==this.sessionId&&(this.chatSession=new this.ChatSession),this.chatSession.set("title",this.genTitle()),this.chatSession.set("role",this.role?.toPointer()),this.chatSession.set("messageList",this.messageList),this.chatSession.set("user",Parse.User.current()?.toPointer()),this.chatSession=await this.chatSession.save(),this.onChatSaved&&this.onChatSaved(this),this.sessionId=this.chatSession?.id,this.sessionId){let t=`${window.location.origin}/chat/pro/chat/${this.sessionId}`;window.location?.pathname?.indexOf("chat/session")>-1&&(t=`${window.location.origin}/chat/session/chat/${this.sessionId}`),"modal"==this.mode&&(t=window.location.href),t=this.getInviteUrl(t),window.history.replaceState(null,null,t+window.location.search);let e={sid:this.chatSession?.id,rid:this.role?.id,name:this.role?.get("name"),message:this.chatSession?.get("messageList")?.[this.chatSession?.get("messageList")?.length-1]?.content?.slice(0,20),latest:this.chatSession?.createdAt};this.chatServ&&!this.chatServ?.chatList?.length&&(this.chatServ.chatList=[]);let i=this.chatServ?.chatList?.find((t=>t?.sid==e?.sid));i>-1?this.chatServ.chatList[i]=e:this.chatServ?.chatList.unshift(e)}}getInviteUrl(t){let e=new URL(t),i=Parse.User?.current()?.id;return e.searchParams.set("invite",i),e.href}genTitle(){if(this.title)return this.title;let t=this.messageList.find((t=>"user"==t.role))?.content;return"string"==typeof t&&(this.title=t?.slice(0,15)||""),"object"==typeof t&&(this.title=t?.find((t=>t?.text))?.text||""),this.title}fixMessageList(t){return t.map((t=>({role:t.role,content:t.content})))}nowStr(){let t=new Date;return`${t.getFullYear()}/${t.getMonth()+1}/${t.getDate()} ${t.getHours()}:${t.getMinutes()}:${t.getSeconds()}`}}
8
+ import{finalize}from"rxjs";import{FmodeParse}from"../../../core/parse";const Parse=FmodeParse.with("nova");import{FmodeTTS,FmodeTTSProviderDoubao}from"../../voice/tts";import{PromptTemplate}from"@langchain/core/prompts";import{getFormatTpl}from"../prompt/prompt-util";import{FmodeChatCompletion}from"./completion";import{MessageScene,MessageManager}from"./message";const PromptTplTalkSSMLOutputCode="talk-ssml-output-tpl",PromptTplTalkTextSSMLCode="talk-text-ssml-tpl";export function getMessageContentText(e){let t="";return"string"==typeof e&&(t=e),"object"==typeof e&&(t=e?.find((e=>e?.text))?.text||""),t}export function getMessageImageUrl(e){return"object"==typeof e?e?.find((e=>e?.image_url))?.image_url?.url||"":null}export class FmodeChat{async loadModelList(e){if(this.modelList?.length)return;let t=new Parse.Query("ChatModel");t.notEqualTo("isDeleted",!0),t.equalTo("isEnabled",!0),t.addAscending("index"),this.modelList=await t.find(),this.currentModel=e||this.modelList?.find((e=>"fmode-1.6-cn"==e.get("code")))}showAvatar(){this.avatarConfig=this.role?.get("avatarConfig"),this.avatarConfig&&(this.isAvatarShow=!0,this.avatarConfig?.image&&(this.avatarConfig.image.waiting=this.avatarConfig.image.waiting||this.role?.get("thumb")||this.role?.get("avatar"),this.avatarMode="image"),this.avatarConfig?.video&&(this.avatarConfig.video.waiting=this.avatarConfig.video.waiting,this.avatarMode="video"))}scrollToBottom(e){e=e||this.scrollComp,e?.nativeElement?.scrollHeight&&(e.nativeElement.scrollTop=e.nativeElement.scrollHeight)}constructor(e,t,s,i,o,a,n){this.ChatSession=Parse.Object.extend("ChatSession"),this.messageManager=null,this.latestAIResponse="",this.userInput="",this.userImage="",this.isDirect=!1,this.mode="page",this.hideShare=!1,this.hideModalSelect=!1,this.hideInputPreview=!1,this.isAvatarShow=!1,this.avatarMode="",this.isPromptModalOpen=!1,this.isPromptMessageAreaShow=!0,this.promptList=[],this.focusUserInput=()=>{},this.leftButtons=[{title:"灵感",icon:"color-wand-outline",onClick:()=>{this.isPromptModalOpen=!0},show:()=>this?.promptList?.length},{title:"角色",icon:"people-outline",onClick:()=>{this.navCtrl?.navigateRoot("/chat/pro/mask")},show:()=>!0},{title:"呼叫",icon:"call-outline",onClick:()=>{this.chatServ?.callRole(this.role)},show:()=>this?.role?.get("voiceConfig")}],this.isVoiceInputMode=!1,this.isTexting=!1,this.isTalkMode=!1,this.SSMLRoleVoice="zh-CN-XiaoxiaoNeural",this.playAnimation=e=>{console.log(e)},this.welcome=async()=>{const e=await this.getMessageList();let t=e?.filter((e=>"assistant"==e?.role));if(t?.length)return;let s=Parse.User.current(),i=await this.loadSelf("Person","userVerify"),o=await this.loadSelf("Profile","user"),a=i?.get("name")||i?.get("userVefiry")?.get("realname")||i?.get("userVefiry")?.get("nickname"),n=s?.get("nickname")||o?.get("name")||s?.get("realname")||s?.get("name");i?.get("userVerify")?.id==s?.id&&(a="您"),n||(n=a);let r=this.role.get("voiceConfig")?.welcome?.prompt;if(this.role.get("voiceConfig")?.welcome?.promptList?.length){let e=this.role.get("voiceConfig")?.welcome?.promptList;r=e[Math.floor(Math.random()*e.length)]}if(!r)return;let l=await PromptTemplate.fromTemplate(r,{templateFormat:"mustache"}).format({name:n,userName:n,personName:a,timeOfDay:this.getTimeOfDay()}),h=await this.getVoiceByContentText(l),c={role:"assistant",voice:h,content:l,complete:!0,createdAt:new Date};await this.addMessage(c,MessageScene.ROLE),this.voiceMap[h?.id],this.playChatVoice(this.voiceMap[h?.id])},this.self={},this.voiceMap={},this.VoiceTTSMap={},this.chatServ=i,this.role=t,this.sessionId=e,this.navCtrl=o,this.ncloud=a,this.uploadServ=n,this.initCompany(),s?.id&&(this.chatSession=s,this.sessionId=s?.id,this.initMessageManager()),this.role?.id&&(this.voiceConfig=this.role?.get("voiceConfig"),this.voiceConfig?.autoTalk&&(this.isTalkMode=this.isTalkMode||this.voiceConfig?.autoTalk,this.isDirect=!0))}async getMessageList(){return this.messageManager?await this.messageManager.getMessages():[{role:"system",content:"系统提示:AI仅供参考"}]}get messageList(){return this.messageManager?[]:[{role:"system",content:"系统提示:AI仅供参考"}]}set messageList(e){this.messageManager&&this.messageManager.clearCache()}initMessageManager(){this.chatSession&&this.role&&this.company&&(this.messageManager=MessageManager.createForRole(this.chatSession,this.role,this.company))}async initCompany(){const e=localStorage.getItem("company");e&&(this.company={__type:"Pointer",className:"Company",objectId:e})}async addMessage(e,t=MessageScene.ROLE){this.messageManager&&await this.messageManager.addMessage(e,t)}async updateMessage(e,t){this.messageManager&&await this.messageManager.updateMessage(e,t)}async reloadMessages(){this.messageManager&&await this.messageManager.reloadMessages()}getTimeOfDay(){const e=(new Date).getHours();return e>=5&&e<12?"早上":e>=12&&e<14?"中午":e>=14&&e<18?"下午":"晚上"}async loadSelf(e,t){if(this.self[e])return this.self[e];let s=Parse.User.current(),i=new Parse.Query(e);return i.include(t),i.equalTo(t,s?.id),this.self[e]=await i.first(),this.self[e]}async loadTalkSystemPrompt(e){if(!this.isTalkMode)return;if(!e)return;let t=e?.get("voiceConfig");"男"==e?.get("gender")?(this.SSMLRoleVoice="zh-CN-YunyeNeural","doubao"==t.provider&&(this.SSMLRoleVoice="zh_male_yangguangqingnian_emo_v2_mars_bigtts")):(this.SSMLRoleVoice="zh-CN-XiaoxiaoNeural","doubao"==t.provider&&(this.SSMLRoleVoice="zh_female_shuangkuaisisi_emo_v2_mars_bigtts")),this.SSMLRoleVoice=e?.get("voiceConfig")?.voice||this.SSMLRoleVoice;let s=await getFormatTpl("talk-ssml-output-tpl",{SSMLRoleVoice:this.SSMLRoleVoice}),i=e.get("prompt")||"请你扮演飞码AI的人工智能专家。";i+=s;let o={role:"user",content:i,hidden:!0},a=this.messageList?.map((e=>e?.content)).join();if(a.indexOf(i)>-1)return;let n=this.messageList?.findIndex((e=>"system"==e?.role)),r=n+1;this.messageList.splice(r,0,o)}loadRolePrompt(){let e=this.role?.get("prompt"),t={role:"user",content:e,hidden:!0};if(!e)return;let s=this.messageList?.map((e=>e?.content)).join();if(s.indexOf(e)>-1)return;let i=this.messageList?.findIndex((e=>"system"==e?.role)),o=i+1;this.messageList.splice(o,0,t)}async sendMessage(e="FmodeAiTest测试问题",t,s,i,o){let a;this.scrollToBottom&&this.scrollToBottom(),this.isPromptMessageAreaShow=!1,this.loadRolePrompt(),t?(a={role:"user",content:[{type:"image_url",image_url:{url:t}},{type:"text",text:e}],complete:!0,createdAt:new Date},o&&(a.voice={id:o?.id})):(a={role:"user",content:e,complete:!0,createdAt:new Date},o&&(a.voice={id:o?.id,duration:o?.duration})),await this.addMessage(a,MessageScene.ROLE);const n=await this.getMessageList();let r=new FmodeChatCompletion(this.fixMessageList(n),{model:this.currentModel?.get?.("code")||"fmode-1.6-cn"});if(this.onUserSend){if(!await this.onUserSend(this,a))return}this.userInput="",this.userImage="";let l=this.isDirect||!1;this.isTalkMode&&(l=!0);const h={role:"assistant",content:"",complete:!1,createdAt:new Date};await this.addMessage(h,MessageScene.ROLE);const c=await this.getMessageList(),g=c.length-1;let m=r.sendCompletion({isDirect:l,onComplete:s||null}).pipe(finalize((async()=>{let e=c[g];if(this.isTalkMode){let t=e?.content,s=await this.getVoiceByContentText(t,i);i?.onSSMLComplete&&i?.onSSMLComplete(s),e.voice=s,this.playChatVoice(this.voiceMap[s?.id],{onResult:t=>{t?.duration&&(e.voice.duration=t?.duration)}})}e.complete=!0,await this.updateMessage(g,e)}))).subscribe((async e=>{await this.updateMessage(g,e),this.latestAIResponse=this.getContentText(e?.content);let t=this.chatSession?.get("messageList")?.length;const s=await this.getMessageList();if(s?.length>t&&this.saveChatSession(),e?.complete){const e=await this.getMessageList();this.onMessage&&this.onMessage(this,e[e?.length-1]),this.saveChatSession(),m.unsubscribe()}this.scrollToBottom&&this.scrollToBottom()}))}getVoiceByContentText(e,t,s=!1){let i=this.getContentText(e),o=new(Parse.Object.extend("ChatVoice")),a="",n=this.voiceConfig||this.role?.get("voiceConfig");return this.SSMLRoleVoice=n?.voice||this.SSMLRoleVoice,new Promise((async(e,t)=>{let resolveChatVoice=async()=>{o.set("content",i),o.set("ssml",a),o.set("role","assistant");let t=localStorage.getItem("company");t&&o.set("company",{__type:"Pointer",className:"Company",objectId:t}),Parse.User.current()?.id&&o.set("user",Parse.User.current().toPointer()),this.chatSession?.id&&o.set("session",this.chatSession?.toPointer()),o=await o.save(),this.voiceMap[o?.id]=o,e({id:o?.id})};if(0==s){let e=n?.provider||"microsoft",t=n?.rate,s=t?"</prosody>":"";a=`<speak provider="${e}">${t?`<prosody rate="${t}">`:""}<voice name="${this.SSMLRoleVoice}">${i}</voice>${s}</speak>`,"doubao"==e&&(a=i),resolveChatVoice()}if(1==s){let e=await getFormatTpl("talk-text-ssml-tpl",{content:i,SSMLRoleVoice:this.SSMLRoleVoice});new FmodeChatCompletion(this.fixMessageList([{role:"user",content:e}]),{model:this.currentModel?.get?.("code")||"fmode-1.6-cn"}).sendCompletion({isDirect:!0}).subscribe((async e=>{e?.complete&&(a=this.getContentText(e?.content),resolveChatVoice())}))}}))}getContentText(e){return"string"==typeof e?e:e?.[0]?.text||""}async initTTS(){this.voiceConfig=this.voiceConfig||this.role?.get("voiceConfig");let e=await this.ncloud.apig("voice/tts/token",{company:localStorage.getItem("company"),provider:this.voiceConfig?.provider||"microsoft"});if(e.provider=this.voiceConfig?.provider,!e?.provider||e?.provider,"doubao"==e?.provider&&(e.provider=new FmodeTTSProviderDoubao),e.voiceConfig=this.voiceConfig,console.log("initTTS",e),e?.token||e?.stsToken){return new FmodeTTS(e,this.uploadServ)}return null}stopPlayingVoice(){Object.values(this.VoiceTTSMap).forEach((e=>{e?.isPlaying&&e?.stop()}))}async playChatVoice(e,t){let s=await this.initTTS();if(console.log("playChatVoice",s),s){try{s.voiceConfig=this.voiceConfig,this.playAnimation("talking"),s.speakAsync(e?.get("ssml"),e,{onStart:e=>{t?.onStart&&t?.onStart(e)},onLoaded:e=>{t?.onLoaded&&t?.onLoaded(e)},onResult:e=>{t?.onResult&&t?.onResult(e)},onStop:()=>{t?.onStop&&t?.onStop(),this.playAnimation("waiting")}})}catch(e){}return this.VoiceTTSMap[e.id]=s,s}return null}async saveChatSession(){if("new"==this.sessionId&&(this.chatSession=new this.ChatSession),this.chatSession.set("title",this.genTitle()),this.chatSession.set("role",this.role?.toPointer()),this.chatSession.set("user",Parse.User.current()?.toPointer()),this.chatSession.get("messageList")||this.chatSession.set("messageList",[]),this.chatSession=await this.chatSession.save(),this.onChatSaved&&this.onChatSaved(this),this.sessionId=this.chatSession?.id,this.sessionId){let e=`${window.location.origin}/chat/pro/chat/${this.sessionId}`;window.location?.pathname?.indexOf("chat/session")>-1&&(e=`${window.location.origin}/chat/session/chat/${this.sessionId}`),"modal"==this.mode&&(e=window.location.href),e=this.getInviteUrl(e),window.history.replaceState(null,null,e+window.location.search);const t=await this.getMessageList(),s=t[t?.length-1];let i="";if("string"==typeof s?.content)i=s.content.slice(0,20);else if(Array.isArray(s?.content)){const e=s.content.find((e=>e?.text));i=e?.text?.slice(0,20)||""}let o={sid:this.chatSession?.id,rid:this.role?.id,name:this.role?.get("name"),message:i,latest:this.chatSession?.createdAt};this.chatServ&&!this.chatServ?.chatList?.length&&(this.chatServ.chatList=[]);let a=this.chatServ?.chatList?.find((e=>e?.sid==o?.sid));a>-1?this.chatServ.chatList[a]=o:this.chatServ?.chatList.unshift(o)}}getInviteUrl(e){let t=new URL(e),s=Parse.User?.current()?.id;return t.searchParams.set("invite",s),t.href}genTitle(){if(this.title)return this.title;let e=this.messageList.find((e=>"user"==e.role))?.content;return"string"==typeof e&&(this.title=e?.slice(0,15)||""),"object"==typeof e&&(this.title=e?.find((e=>e?.text))?.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()}`}}
9
9
  var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2FnZW50L2NoYXQvZm1vZGUtY2hhdC5tanM=`
10
10
 
@@ -0,0 +1,10 @@
1
+
2
+ /**
3
+ * @copyright © 未来飞马 © 未来全栈 www.fmode.cn
4
+ * 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
5
+ * 保留所有权利 All Rights Reserved.
6
+ * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/agent/chat/message/index.mjs
7
+ */
8
+ export*from"./message";export*from"./message-manager";
9
+ var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2FnZW50L2NoYXQvbWVzc2FnZS9pbmRleC5tanM=`
10
+
@@ -0,0 +1,10 @@
1
+
2
+ /**
3
+ * @copyright © 未来飞马 © 未来全栈 www.fmode.cn
4
+ * 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
5
+ * 保留所有权利 All Rights Reserved.
6
+ * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/agent/chat/message/message-manager.mjs
7
+ */
8
+ import{FmodeParse}from"../../../../core/parse";import{Message,MessageScene,MessageRole}from"./message";const Parse=FmodeParse.with("nova");export class MessageManager{constructor(e){this._newMessages=[],this._legacyMessages=[],this._mergedMessages=[],this._isDirty=!0,this.options=e}async getMessages(){return this._isDirty&&(await this.loadAndMergeMessages(),this._isDirty=!1),[...this._mergedMessages]}async addMessage(e,s){const t=s||this.options.scene||MessageScene.ROLE;try{const s={content:{type:Message.getMessageType(e),role:e.role||MessageRole.USER,content:e.content,json:e.json,hidden:e.hidden,complete:e.complete,voice:e.voice,cid:e.cid,createdAt:e.createdAt||new Date},scene:t,company:this.options.company,session:t===MessageScene.ROLE?this.options.chatSession:void 0,role:t===MessageScene.ROLE?this.options.role:void 0,group:t===MessageScene.GROUP?this.options.group:void 0,userFrom:t===MessageScene.USER?this.options.userFrom:void 0,userTo:t===MessageScene.USER?this.options.userTo:void 0,contact:t===MessageScene.SERVICE?this.options.contact:void 0},a=Message.create(s);await a.save(),this._newMessages.push(a),this._isDirty=!0}catch(s){console.error("保存新消息失败:",s),this._legacyMessages.push({...e,source:"legacy"}),this._isDirty=!0}}async updateMessage(e,s){const t=await this.getMessages();if(e<0||e>=t.length)return;const a=t[e];if("new"===a.source&&a.id){const e=this._newMessages.findIndex((e=>e.id===a.id));if(e>=0){const t={type:Message.getMessageType(s),role:s.role||MessageRole.USER,content:s.content,json:s.json,hidden:s.hidden,complete:s.complete,voice:s.voice,cid:s.cid,createdAt:s.createdAt||new Date};this._newMessages[e].updateContent(t),await this._newMessages[e].save()}}this._isDirty=!0}async reloadMessages(){this._newMessages=[],this._legacyMessages=[],this._isDirty=!0,await this.getMessages()}async loadAndMergeMessages(){this._legacyMessages=this.options.chatSession?.get("messageList")||[];try{switch(this.options.scene){case MessageScene.ROLE:this.options.chatSession&&(this._newMessages=await Message.findRoleMessages(this.options.chatSession,{ascending:!0}));break;case MessageScene.GROUP:this.options.group&&(this._newMessages=await Message.findGroupMessages(this.options.group,{ascending:!0}));break;case MessageScene.USER:this.options.userFrom&&this.options.userTo&&(this._newMessages=await Message.findUserMessages(this.options.userFrom,this.options.userTo,{ascending:!0}));break;case MessageScene.SERVICE:this.options.contact&&(this._newMessages=await Message.findServiceMessages(this.options.contact,{ascending:!0}));break;default:this._newMessages=[]}}catch(e){console.error("加载新版消息失败:",e),this._newMessages=[]}if(this._mergedMessages=[],this._legacyMessages.length>0&&this._mergedMessages.push(...this._legacyMessages.map((e=>({...e,source:"legacy"})))),this._newMessages.length>0){const e=this._newMessages.map((e=>({...e.toFmodeChatMessage(),source:"new",id:e.id})));this._mergedMessages.push(...e)}}getStats(){const e={total:this._mergedMessages.length,legacy:this._legacyMessages.length,new:this._newMessages.length,user:0,assistant:0};return this._mergedMessages.forEach((s=>{"user"===s.role&&e.user++,"assistant"===s.role&&e.assistant++})),e}async searchMessages(e){if(!e.trim())return await this.getMessages();const s=await this.getMessages(),t=e.toLowerCase();return s.filter((e=>{let s="";return"string"==typeof e.content?s=e.content:Array.isArray(e.content)&&(s=e.content.filter((e=>e?.text)).map((e=>e.text)).join(" ")),s.toLowerCase().includes(t)}))}clearCache(){this._newMessages=[],this._legacyMessages=[],this._mergedMessages=[],this._isDirty=!0}static createForRole(e,s,t){return new MessageManager({chatSession:e,role:s,company:t,scene:MessageScene.ROLE})}static createForGroup(e,s){return new MessageManager({group:e,company:s,scene:MessageScene.GROUP})}static createForUser(e,s,t){return new MessageManager({userFrom:e,userTo:s,company:t,scene:MessageScene.USER})}static createForService(e,s){return new MessageManager({contact:e,company:s,scene:MessageScene.SERVICE})}static create(e){return new MessageManager(e)}}
9
+ var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2FnZW50L2NoYXQvbWVzc2FnZS9tZXNzYWdlLW1hbmFnZXIubWpz`
10
+
@@ -0,0 +1,10 @@
1
+
2
+ /**
3
+ * @copyright © 未来飞马 © 未来全栈 www.fmode.cn
4
+ * 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
5
+ * 保留所有权利 All Rights Reserved.
6
+ * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/agent/chat/message/message.mjs
7
+ */
8
+ import{FmodeQuery,FmodeParse}from"../../../../core/parse";const Parse=FmodeParse.with("nova");export var MessageScene;!function(e){e.ROLE="role",e.USER="user",e.GROUP="group",e.SERVICE="service"}(MessageScene||(MessageScene={}));export var MessageType;!function(e){e.TEXT="text",e.IMAGE="image",e.VOICE="voice",e.AGENT_TASK="agent_task",e.SYSTEM="system",e.EXTERNAL="external"}(MessageType||(MessageType={}));export var MessageRole;!function(e){e.USER="user",e.ASSISTANT="assistant",e.SYSTEM="system",e.AGENT="agent",e.EXTERNAL="external"}(MessageRole||(MessageRole={}));export var MessageStatus;!function(e){e.SENDING="sending",e.SENT="sent",e.DELIVERED="delivered",e.READ="read",e.FAILED="failed"}(MessageStatus||(MessageStatus={}));export class Message{constructor(e){this.parseObject=e||new Parse.Object("Message")}static create(e){const s=new Message;return s.parseObject.set("company",e.company),s.parseObject.set("content",e.content),s.parseObject.set("scene",e.scene),s.parseObject.set("session",e.session),s.parseObject.set("group",e.group),s.parseObject.set("userFrom",e.userFrom),s.parseObject.set("userTo",e.userTo),s.parseObject.set("role",e.role),s.parseObject.set("external",e.external),s.parseObject.set("contact",e.contact),s.parseObject.set("attachments",e.attachments||[]),s.parseObject.set("metadata",e.metadata||{}),s.parseObject.set("status",MessageStatus.SENT),s.parseObject.set("hidden",e.content.hidden||!1),s.parseObject.set("sentAt",new Date),s}async save(e){return await this.parseObject.save(e),this}updateContent(e){return this.parseObject.set("content",e),this}updateStatus(e){return this.parseObject.set("status",e),e===MessageStatus.READ&&this.parseObject.set("readAt",new Date),this}get id(){return this.parseObject.id}get(e){return this.parseObject.get(e)}set(e,s){return this.parseObject.set(e,s),this}toFmodeChatMessage(){const e=this.parseObject.get("content");return{role:e?.role||MessageRole.USER,content:e?.content||"",json:e?.json,hidden:e?.hidden,complete:!1!==e?.complete,createdAt:this.parseObject.get("sentAt")||this.parseObject.createdAt,voice:e?.voice,cid:e?.cid}}getParseObject(){return this.parseObject}static fromParseObject(e){return new Message(e)}static query(){return new FmodeQuery("Message")}static queryByScene(e){const s=Message.query();return s.equalTo("scene",e),s}static async findRoleMessages(e,s={}){const t=Message.queryByScene(MessageScene.ROLE);t.equalTo("session",e),s.limit&&t.limit(s.limit),s.skip&&t.skip(s.skip),!1!==s.ascending?t.ascending("sentAt"):t.descending("sentAt");return(await t.find()).map((e=>Message.fromParseObject(e)))}static async findGroupMessages(e,s={}){const t=Message.queryByScene(MessageScene.GROUP);t.equalTo("group",e),s.limit&&t.limit(s.limit),s.skip&&t.skip(s.skip),!1!==s.ascending?t.ascending("sentAt"):t.descending("sentAt");return(await t.find()).map((e=>Message.fromParseObject(e)))}static async findUserMessages(e,s,t={}){const a=Message.queryByScene(MessageScene.USER);a.containedIn("userFrom",[e,s]),a.containedIn("userTo",[e,s]),t.limit&&a.limit(t.limit),t.skip&&a.skip(t.skip),!1!==t.ascending?a.ascending("sentAt"):a.descending("sentAt");return(await a.find()).map((e=>Message.fromParseObject(e)))}static async findServiceMessages(e,s={}){const t=Message.queryByScene(MessageScene.SERVICE);t.equalTo("contact",e),s.limit&&t.limit(s.limit),s.skip&&t.skip(s.skip),!1!==s.ascending?t.ascending("sentAt"):t.descending("sentAt");return(await t.find()).map((e=>Message.fromParseObject(e)))}static async findByExternalId(e,s){const t=Message.query();t.equalTo("external.source",e),t.equalTo("external.id",s);const a=await t.first();return a?Message.fromParseObject(a):null}static getMessageType(e){if(e.voice)return MessageType.VOICE;if(e.json)return MessageType.AGENT_TASK;if(e.hidden)return MessageType.SYSTEM;if(Array.isArray(e.content)){return e.content.some((e=>e?.image_url))?MessageType.IMAGE:MessageType.TEXT}return MessageType.TEXT}static fromFmodeChatMessage(e,s){const t={type:Message.getMessageType(e),role:e.role||MessageRole.USER,content:e.content,json:e.json,hidden:e.hidden,complete:e.complete,voice:e.voice,cid:e.cid,createdAt:e.createdAt};return Message.create({...s,content:t})}}
9
+ var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2FnZW50L2NoYXQvbWVzc2FnZS9tZXNzYWdlLm1qcw==`
10
+
@@ -0,0 +1,10 @@
1
+
2
+ /**
3
+ * @copyright © 未来飞马 © 未来全栈 www.fmode.cn
4
+ * 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
5
+ * 保留所有权利 All Rights Reserved.
6
+ * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/ecom/index.mjs
7
+ */
8
+ export*from"./shopee/index";
9
+ var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2Vjb20vaW5kZXgubWpz`
10
+
@@ -0,0 +1,10 @@
1
+
2
+ /**
3
+ * @copyright © 未来飞马 © 未来全栈 www.fmode.cn
4
+ * 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
5
+ * 保留所有权利 All Rights Reserved.
6
+ * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/ecom/shopee/index.mjs
7
+ */
8
+ export*from"./src/index";
9
+ var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2Vjb20vc2hvcGVlL2luZGV4Lm1qcw==`
10
+
@@ -0,0 +1,10 @@
1
+
2
+ /**
3
+ * @copyright © 未来飞马 © 未来全栈 www.fmode.cn
4
+ * 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
5
+ * 保留所有权利 All Rights Reserved.
6
+ * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/ecom/shopee/src/client.mjs
7
+ */
8
+ export class ShopeeClient{constructor(e){if(this.environment="sandbox",!e.serverUrl)throw new Error("serverUrl is required in SDK configuration");this.serverUrl=e.serverUrl.replace(/\/$/,""),this.timeout=e.timeout||3e4,this.headers={"Content-Type":"application/json","User-Agent":"ShopeeSDK/1.0",...e.headers}}async request(e,r){const t=`${this.serverUrl}/api/ecom/shopee/forward`;console.log(e,t,this.serverUrl);const s={shop_id:e.toString(),method:r.method,path:r.path,query:r.query||{},...r.body&&{body:r.body},environment:this.environment},o=new AbortController,i=setTimeout((()=>o.abort()),this.timeout);try{const r=await fetch(t,{method:"POST",headers:this.headers,body:JSON.stringify(s),signal:o.signal});if(clearTimeout(i),!r.ok){const e=await r.text();throw new Error(`HTTP ${r.status}: ${e}`)}const n=await r.json();if(!n.success&&"AUTH_REQUIRED"===n.error){throw new Error(`Authorization required for shop ${e}. Please visit: ${n.data.auth_url}`)}if(!n.success&&"AUTH_EXPIRED"===n.error){throw new Error(`Authorization expired for shop ${e}. Please visit: ${n.data.auth_url}`)}if(!n.success){const e=n;throw new Error(`API request failed: ${e.message} (Status: ${e.data.status_code})`)}return n}catch(e){if(clearTimeout(i),e instanceof Error){if("AbortError"===e.name)throw new Error(`Request timeout after ${this.timeout}ms`);throw e}throw new Error("Unknown error occurred during API request")}}async get(e,r,t){return this.request(e,{method:"GET",path:r,query:t})}async post(e,r,t,s){return this.request(e,{method:"POST",path:r,body:t,query:s})}async put(e,r,t,s){return this.request(e,{method:"PUT",path:r,body:t,query:s})}async delete(e,r,t){return this.request(e,{method:"DELETE",path:r,query:t})}getServerUrl(){return this.serverUrl}getTimeout(){return this.timeout}setHeaders(e){this.headers={...this.headers,...e}}getHeaders(){return{...this.headers}}}
9
+ var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2Vjb20vc2hvcGVlL3NyYy9jbGllbnQubWpz`
10
+
@@ -0,0 +1,10 @@
1
+
2
+ /**
3
+ * @copyright © 未来飞马 © 未来全栈 www.fmode.cn
4
+ * 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
5
+ * 保留所有权利 All Rights Reserved.
6
+ * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/ecom/shopee/src/index.mjs
7
+ */
8
+ import{ShopeeClient}from"./client";import{ShopeeShop}from"./shop";import{ShopeeMerchant}from"./merchant";import{ShopeePublic}from"./public";export{ShopeeClient};export{ShopeeShop};export{ShopeeMerchant};export{ShopeePublic};export class ShopeeSDK{constructor(e){this.client=new ShopeeClient(e),this.public=new ShopeePublic(this.client)}shop(e,t="sandbox"){return this.client.environment=t,new ShopeeShop(this.client,e)}merchant(e){return new ShopeeMerchant(this.client,e)}getClient(){return this.client}updateConfig(e){e.serverUrl?(this.client=new ShopeeClient({...e,serverUrl:e.serverUrl}),this.public=new ShopeePublic(this.client)):(e.headers&&this.client.setHeaders(e.headers),e.timeout&&console.log("Timeout update would require client reinitialization"))}}export default ShopeeSDK;
9
+ var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2Vjb20vc2hvcGVlL3NyYy9pbmRleC5tanM=`
10
+
@@ -0,0 +1,10 @@
1
+
2
+ /**
3
+ * @copyright © 未来飞马 © 未来全栈 www.fmode.cn
4
+ * 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
5
+ * 保留所有权利 All Rights Reserved.
6
+ * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/ecom/shopee/src/merchant.mjs
7
+ */
8
+ export class ShopeeMerchant{constructor(t,i){if(!i||i<=0)throw new Error("Valid main_account_id is required");this.client=t,this.mainAccountId=i}async getMerchantInfo(){return this.client.get(this.mainAccountId,"/api/v2/merchant/get_merchant_info")}async getShopList(){return this.client.get(this.mainAccountId,"/api/v2/merchant/get_shop_list")}async getProfile(){return this.client.get(this.mainAccountId,"/api/v2/merchant/get_profile")}async updateProfile(t){return this.client.post(this.mainAccountId,"/api/v2/merchant/update_profile",t)}async getFinancialInfo(){return this.client.get(this.mainAccountId,"/api/v2/financial/get_financial_info")}async getWalletBalance(){return this.client.get(this.mainAccountId,"/api/v2/financial/get_wallet_balance")}async getTransactionHistory(t={}){return this.client.get(this.mainAccountId,"/api/v2/financial/get_transaction_history",t)}async createWithdrawal(t){return this.client.post(this.mainAccountId,"/api/v2/financial/create_withdrawal",t)}async getWithdrawalHistory(t={}){return this.client.get(this.mainAccountId,"/api/v2/financial/get_withdrawal_history",t)}async getStatistics(t={}){return this.client.get(this.mainAccountId,"/api/v2/merchant/get_statistics",t)}async getNotifications(t={}){return this.client.get(this.mainAccountId,"/api/v2/merchant/get_notifications",t)}async markNotificationAsRead(t){return this.client.post(this.mainAccountId,"/api/v2/merchant/mark_notification_read",{notification_id:t})}async getSettings(){return this.client.get(this.mainAccountId,"/api/v2/merchant/get_settings")}async updateSettings(t){return this.client.post(this.mainAccountId,"/api/v2/merchant/update_settings",t)}async getPermissions(){return this.client.get(this.mainAccountId,"/api/v2/merchant/get_permissions")}async getAuditLogs(t={}){return this.client.get(this.mainAccountId,"/api/v2/merchant/get_audit_logs",t)}getMainAccountId(){return this.mainAccountId}getClient(){return this.client}}
9
+ var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2Vjb20vc2hvcGVlL3NyYy9tZXJjaGFudC5tanM=`
10
+
@@ -0,0 +1,10 @@
1
+
2
+ /**
3
+ * @copyright © 未来飞马 © 未来全栈 www.fmode.cn
4
+ * 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
5
+ * 保留所有权利 All Rights Reserved.
6
+ * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/ecom/shopee/src/public.mjs
7
+ */
8
+ export class ShopeePublic{constructor(e){this.client=e}async generateAuthUrl(e){let t=new Headers;t.append("Content-Type","application/json");let i=await fetch(this.client.getServerUrl()+"/api/ecom/shopee/auth-url",{headers:t,method:"POST",body:JSON.stringify({redirect_uri:e})});return await i.json()}async generateCancelAuthUrl(e){return this.client.post(0,"/api/ecom/shopee/cancel-auth-url",{redirect_uri:e})}async getConfig(){return this.client.get(0,"/api/ecom/shopee/config")}async healthCheck(){return this.client.get(0,"/api/ecom/shopee/health")}async verifySignature(e,t,i){return this.client.post(0,"/api/ecom/shopee/verify-signature",{path:e,params:t,timestamp:i})}async getPublicCategories(e){return this.client.get(0,"/api/v2/public/category/get_category",{region:e})}async getPublicItemDetail(e,t,i){return this.client.get(0,"/api/v2/public/item/get_item_detail",{item_id:e,shop_id:t,region:i})}async searchPublicItems(e){return this.client.get(0,"/api/v2/public/item/search",e)}async getPublicShopInfo(e,t){return this.client.get(0,"/api/v2/public/shop/get_shop_info",{shop_id:e,region:t})}async getPublicShopItems(e,t,i={}){return this.client.get(0,"/api/v2/public/shop/get_items",{shop_id:e,region:t,...i})}async getPublicLogistics(e){return this.client.get(0,"/api/v2/public/logistics/get_channels",{region:e})}async getExchangeRates(e,t){const i={};return e&&(i.from_currency=e),t&&(i.to_currency=t),this.client.get(0,"/api/v2/public/currency/get_exchange_rate",i)}async getMarketplaceStats(e){return this.client.get(0,"/api/v2/public/marketplace/get_statistics",{region:e})}async getTrendingItems(e,t){const i={region:e};return t&&(i.category_id=t),this.client.get(0,"/api/v2/public/trending/get_items",i)}async validateWebhook(e,t){return this.client.post(0,"/api/v2/public/webhook/validate",{payload:e,signature:t})}getClient(){return this.client}}
9
+ var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2Vjb20vc2hvcGVlL3NyYy9wdWJsaWMubWpz`
10
+
@@ -0,0 +1,10 @@
1
+
2
+ /**
3
+ * @copyright © 未来飞马 © 未来全栈 www.fmode.cn
4
+ * 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
5
+ * 保留所有权利 All Rights Reserved.
6
+ * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/ecom/shopee/src/shop.mjs
7
+ */
8
+ export class ShopeeShop{constructor(t,i){if(!i||i<=0)throw new Error("Valid shop_id is required");this.client=t,this.shopId=i}async getShopInfo(){return this.client.get(this.shopId,"/api/v2/shop/get_shop_info",{shop_id:this.shopId})}async getCategories(){return this.client.get(this.shopId,"/api/v2/product/get_category",{shop_id:this.shopId})}async getComments(t){return this.client.get(this.shopId,"/api/v2/product/get_comment",{shop_id:this.shopId,...t})}async getProductList(t={}){return t.offset=t?.offset||0,t.page_size=t?.page_size||10,t.item_status=t?.item_status||"NORMAL",this.client.get(this.shopId,"/api/v2/product/get_item_list",{shop_id:this.shopId,...t})}async getProductDetail(t){return this.client.get(this.shopId,"/api/v2/product/get_item_detail",{item_id:t})}async addProduct(t){return this.client.post(this.shopId,"/api/v2/product/add_item",t)}async updateProduct(t,i){return this.client.post(this.shopId,"/api/v2/product/update_item",{item_id:t,...i})}async deleteProduct(t){return this.client.post(this.shopId,"/api/v2/product/delete_item",{item_id:t})}async unlistProduct(t){return this.client.post(this.shopId,"/api/v2/product/unlist_item",{item_id:t})}async getOrderList(t={}){const i=Date.now(),s=i-2592e6,e={shop_id:this.shopId,time_from:Math.floor(s/1e3),time_to:Math.floor(i/1e3),time_range_field:"create_time",...t};return this.client.get(this.shopId,"/api/v2/order/get_order_list",e)}async getOrderDetail(t){return this.client.get(this.shopId,"/api/v2/order/get_order_detail",{order_sn:t})}async getPerformanceMetrics(){return this.client.get(this.shopId,"/api/v2/shop/get_shop_info",{shop_id:this.shopId})}async getLogistics(){return this.client.get(this.shopId,"/api/v2/logistics/get_channel_list",{shop_id:this.shopId})}async getDiscounts(){return this.client.get(this.shopId,"/api/v2/discount/get_discount_list",{shop_id:this.shopId})}async getAnalytics(t={}){return this.client.get(this.shopId,"/api/v2/shop/get_shop_info",{shop_id:this.shopId})}getShopId(){return this.shopId}getClient(){return this.client}}
9
+ var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2Vjb20vc2hvcGVlL3NyYy9zaG9wLm1qcw==`
10
+
@@ -0,0 +1,10 @@
1
+
2
+ /**
3
+ * @copyright © 未来飞马 © 未来全栈 www.fmode.cn
4
+ * 版权所有 © 未来飞马 © 江西脑控科技有限公司 Copyright © Fmode Technology Co., Ltd.
5
+ * 保留所有权利 All Rights Reserved.
6
+ * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/ecom/shopee/src/types.mjs
7
+ */
8
+ export{};
9
+ var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2Vjb20vc2hvcGVlL3NyYy90eXBlcy5tanM=`
10
+
@@ -5,6 +5,6 @@
5
5
  * 保留所有权利 All Rights Reserved.
6
6
  * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/index.mjs
7
7
  */
8
- export*from"./agent";export*from"./voice";export*from"./parse";export*from"./social";export*from"./storage";export*from"./storage/util-file-md5";export*from"./storage/util-file-metadata";
8
+ export*from"./agent";export*from"./voice";export*from"./parse";export*from"./social";export*from"./storage";export*from"./storage/util-file-md5";export*from"./storage/util-file-metadata";export*from"./ecom";
9
9
  var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL2luZGV4Lm1qcw==`
10
10
 
@@ -5,6 +5,6 @@
5
5
  * 保留所有权利 All Rights Reserved.
6
6
  * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/parse/fmode.cloud.mjs
7
7
  */
8
- export class FmodeCloud{static{this._instance=null}constructor(){this._config=null,this._cloudFunctions=new Map}static getInstance(){return this._instance||(this._instance=new FmodeCloud),this._instance}bindInstance(e){this._config=e}define(e,t){this._cloudFunctions.set(e,t)}async run(e,t={},n={}){if(!this._config)throw new Error("FmodeCloud not initialized. Call bindInstance first.");const i=`${this._config.serverURL}/functions/${e}`,o={...t,_ApplicationId:this._config.appId,_InstallationId:n.installationId||this.generateInstallationId()},s=this._config.sessionToken;s&&(o._SessionToken=s);try{const e=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json","X-Parse-Application-Id":this._config.appId,...this._config.javascriptKey&&{"X-Parse-JavaScript-Key":this._config.javascriptKey},...this._config.masterKey&&{"X-Parse-Master-Key":this._config.masterKey},...s&&{"X-Parse-Session-Token":s}},body:JSON.stringify(o)});if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);const t=await e.json();if(t.error)throw new Error(t.error.message||"Cloud function error");return t.result}catch(t){throw console.error(`Cloud function ${e} failed:`,t),t}}async afterDelete(e,t){this.define(`afterDelete_${e}`,t)}async afterSave(e,t){this.define(`afterSave_${e}`,t)}async beforeDelete(e,t){this.define(`beforeDelete_${e}`,t)}async beforeSave(e,t){this.define(`beforeSave_${e}`,t)}async beforeFind(e,t){this.define(`beforeFind_${e}`,t)}async afterFind(e,t){this.define(`afterFind_${e}`,t)}async job(e,t){this.define(`job_${e}`,t)}generateInstallationId(){return"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}}export const Cloud=FmodeCloud.getInstance();export default Cloud;
8
+ export class FmodeCloud{static{this._singletonInstance=null}constructor(){this._cloudFunctions=new Map}static getInstance(){return this._singletonInstance||(this._singletonInstance=new FmodeCloud),this._singletonInstance}static{this._instance=null}static bindInstance(e){this._instance=e}get currentConfig(){const e=FmodeCloud._instance;if(!e)throw new Error("FmodeCloud not initialized. Call FmodeParse.initialize() first.");return e.config}static get instance(){return this._instance}define(e,t){this._cloudFunctions.set(e,t)}async run(e,t={},n={}){const s=this.currentConfig,o=`${s.serverURL}/functions/${e}`,i={...t,_ApplicationId:s.appId,_InstallationId:n.installationId||this.generateInstallationId()},r=s.sessionToken;r&&(i._SessionToken=r);try{const e=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json","X-Parse-Application-Id":s.appId,...s.javascriptKey&&{"X-Parse-JavaScript-Key":s.javascriptKey},...s.masterKey&&{"X-Parse-Master-Key":s.masterKey},...r&&{"X-Parse-Session-Token":r}},body:JSON.stringify(i)});if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);const t=await e.json();if(t.error)throw new Error(t.error.message||"Cloud function error");return t.result}catch(t){throw console.error(`Cloud function ${e} failed:`,t),t}}async afterDelete(e,t){this.define(`afterDelete_${e}`,t)}async afterSave(e,t){this.define(`afterSave_${e}`,t)}async beforeDelete(e,t){this.define(`beforeDelete_${e}`,t)}async beforeSave(e,t){this.define(`beforeSave_${e}`,t)}async beforeFind(e,t){this.define(`beforeFind_${e}`,t)}async afterFind(e,t){this.define(`afterFind_${e}`,t)}async job(e,t){this.define(`job_${e}`,t)}generateInstallationId(){return"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}}export const Cloud=FmodeCloud.getInstance();export default Cloud;
9
9
  var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL3BhcnNlL2Ztb2RlLmNsb3VkLm1qcw==`
10
10
 
@@ -5,6 +5,6 @@
5
5
  * 保留所有权利 All Rights Reserved.
6
6
  * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/core/parse/fmode.parse.mjs
7
7
  */
8
- import{FmodeACL}from"./datatype/acl";import{FmodeFile}from"./datatype/file";import{FmodeGeoPoint}from"./datatype/geopoint";import{FmodeRelation}from"./datatype/relation";import{FmodeObject}from"./fmode.object";import{FmodeQuery}from"./fmode.query";import{FmodeUser}from"./fmode.user";import{FmodeCloud}from"./fmode.cloud";class FmodeParse{static{this._instances={}}static{this._defaultInstance=null}constructor(e){this.config=e,this.Object=this.createObjectFactory(),this.Query=this.createQueryFactory(),this.User=this.createUserFactory(),this.GeoPoint=FmodeGeoPoint,this.File=FmodeFile,this.ACL=FmodeACL,this.Relation=FmodeRelation,this.Cloud=FmodeCloud.getInstance(),FmodeObject._instance||FmodeObject.bindInstance(this),FmodeQuery._instance||FmodeQuery.bindInstance(this),FmodeUser._instance||FmodeUser.bindInstance(this),FmodeGeoPoint._instance||FmodeGeoPoint.bindInstance(this),FmodeRelation._instance||FmodeRelation.bindInstance(this),FmodeFile._instance||FmodeFile.bindInstance(this),FmodeACL._instance||FmodeACL.bindInstance(this),this.Cloud.bindInstance(this.config)}createObjectFactory(){const e=this;return class Object extends FmodeObject{constructor(t){super(t),this._parseInstance=e}static extend(e){const t=class extends Object{constructor(){super(e)}};return t.extend=Object.extend,t.create=Object.create,t.fetchAll=Object.fetchAll,t.fromFile=Object.fromFile,t}static async create(e,t,s){const n=new this(e);return n.set(t),n.save(s)}static async fetchAll(t,s){if(!e)throw new Error("Not initialized");if(0===t.length)return[];const n={"Content-Type":"application/json","X-Parse-Application-Id":e.appId};if(s?.useMasterKey&&e.config.masterKey)n["X-Parse-Master-Key"]=e.config.masterKey;else{const t=e.sessionToken;t&&(n["X-Parse-Session-Token"]=t)}const r=`${e.serverURL}/batch`,o=t.map((e=>({method:"GET",path:`/classes/${e.className}/${e.id}`}))),i=await fetch(r,{method:"POST",headers:n,body:JSON.stringify({requests:o})}),a=await i.json();if(a.error)throw new Error(a.error);return a.map(((e,s)=>{const n=t[s];return n.set(e.success),n}))}static async fromFile(t,s,n){if(!e)throw new Error("Not initialized");const r=new FormData;r.append("file",s,t);const o={"X-Parse-Application-Id":e.appId},i=e.sessionToken;i&&(o["X-Parse-Session-Token"]=i);const a=`${e.serverURL}/files/${t}`,c=await fetch(a,{method:"POST",headers:o,body:r}),d=await c.json();if(d.error)throw new Error(d.error);return{__type:"File",name:d.name,url:d.url}}}}createQueryFactory(){const e=this;return class Query extends FmodeQuery{constructor(t){super(t),this._parseInstance=e}static get instance(){return e}static bindInstance(e){}}}createUserFactory(){const e=this;return class User extends FmodeUser{constructor(t){super(t),this._parseInstance=e}static get instance(){return e}static{this.instanceKey=()=>"Parse/"+e.appId+"/currentUser"}static bindInstance(e){}static async logIn(t,s){const n=`${e.serverURL}/login`,r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-Parse-Application-Id":e.appId},body:JSON.stringify({username:t,password:s})}),o=await r.json();if(o.error)throw o;const i=new this({...o,username:t,password:s});return i._saveToCache(),i}static async become(t){const s=`${e.serverURL}/users/me`;let n={"X-Parse-Session-Token":t,"X-Parse-Application-Id":e.appId};const r=await fetch(s,{headers:n}),o=await r.json();if(o.error)throw o.error;const i=new this({...o,sessionToken:t});return i._saveToCache(),i}static async signUp(e,t,s={}){return new this({...s,username:e,password:t}).signUp()}static async logOut(){if(this.current())try{await fetch(`${e.serverURL}/logout`,{method:"POST",headers:{"X-Parse-Session-Token":this.current().sessionToken,"X-Parse-Application-Id":e.appId}})}finally{this._clearCurrentUser()}}static async requestPasswordReset(t){const s=`${e.serverURL}/requestPasswordReset`,n=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","X-Parse-Application-Id":e.appId},body:JSON.stringify({email:t})}),r=await n.json();if(r.error)throw r}static{this._currentUser=null}static current(){if(this._currentUser)return this._currentUser;try{const t=localStorage.getItem(this.instanceKey());if(!t)return null;const s=JSON.parse(t);if(!s.sessionToken)return null;const n=new this(s);return this._currentUser=n,n.sessionToken&&e&&(e.sessionToken=n.sessionToken),n}catch(e){return console.warn("Failed to restore user from cache",e),null}}static _clearCurrentUser(){this._currentUser=null,e&&(e.sessionToken=void 0),localStorage.removeItem(this.instanceKey())}_saveToCache(){if(!this.sessionToken)return;this.constructor._currentUser=this;const e=this._parseInstance||this.constructor.instance;e&&(e.sessionToken=this.sessionToken),localStorage.setItem(this.constructor.instanceKey(),JSON.stringify(this.toJSONForCache()))}}}static initialize(e){let t;if("string"==typeof e){let s="http://dev.fmode.cn:1337/parse";"undefined"!=typeof location&&"https:"===location.protocol&&(s="https://dev.fmode.cn/parse"),t=new FmodeParse({appId:e,serverURL:s}),this._defaultInstance=t,this._instances.default=t}else t=new FmodeParse(e),e.config&&(this._instances[e.config]=t),e.config&&"default"!==e.config||(this._defaultInstance=t);return t}static with(e){if(!this._instances.nova){let e=new FmodeParse({appId:"ncloudmaster",serverURL:"https://server.fmode.cn/parse"});this._instances.nova=e}if(!this._instances.dev){let e=new FmodeParse({appId:"dev",serverURL:"https://dev.fmode.cn/parse"});this._instances.dev=e}return"dev"!=e||this._defaultInstance||(this._defaultInstance=this._instances.dev),"default"!=e||this._instances.default||(this._instances.default=this._instances.dev,this._defaultInstance=this._instances.dev),this._instances[e]||this._defaultInstance}static getAllInstances(){return{...this._instances}}static getInstanceConfigs(){const e={};return Object.entries(this._instances).forEach((([t,s])=>{e[t]=s.config})),e}get serverURL(){return this.config.serverURL}set serverURL(e){this.config.serverURL=e}get appId(){return this.config.appId}get sessionToken(){if(this.config.sessionToken)return this.config.sessionToken;const e=this.User.current();return e?.sessionToken}set sessionToken(e){this.config.sessionToken=e}}!function(e){e.Object=FmodeObject,e.Query=FmodeQuery,e.User=FmodeUser,e.File=FmodeFile,e.Relation=FmodeRelation,e.ACL=FmodeACL,e.GeoPoint=FmodeGeoPoint,e.Cloud=FmodeCloud.getInstance()}(FmodeParse||(FmodeParse={}));const defaultExport=new Proxy(FmodeParse,{apply:(e,t,s)=>FmodeParse.initialize.apply(e,s),get:(e,t)=>t in e?e[t]:t in FmodeParse?FmodeParse[t]:FmodeParse.with("default")[t]});export{FmodeParse as default,defaultExport as FmodeParse};
8
+ import{FmodeACL}from"./datatype/acl";import{FmodeFile}from"./datatype/file";import{FmodeGeoPoint}from"./datatype/geopoint";import{FmodeRelation}from"./datatype/relation";import{FmodeObject}from"./fmode.object";import{FmodeQuery}from"./fmode.query";import{FmodeUser}from"./fmode.user";import{FmodeCloud}from"./fmode.cloud";class FmodeParse{static{this._instances={}}static{this._defaultInstance=null}constructor(e){this.config=e,this.Object=this.createObjectFactory(),this.Query=this.createQueryFactory(),this.User=this.createUserFactory(),this.GeoPoint=FmodeGeoPoint,this.File=FmodeFile,this.ACL=FmodeACL,this.Relation=FmodeRelation,this.Cloud=FmodeCloud.getInstance(),FmodeObject._instance||FmodeObject.bindInstance(this),FmodeQuery._instance||FmodeQuery.bindInstance(this),FmodeUser._instance||FmodeUser.bindInstance(this),FmodeGeoPoint._instance||FmodeGeoPoint.bindInstance(this),FmodeRelation._instance||FmodeRelation.bindInstance(this),FmodeFile._instance||FmodeFile.bindInstance(this),FmodeACL._instance||FmodeACL.bindInstance(this),FmodeCloud._instance||FmodeCloud.bindInstance(this)}createObjectFactory(){const e=this;return class Object extends FmodeObject{constructor(t){super(t),this._parseInstance=e}static extend(e){const t=class extends Object{constructor(){super(e)}};return t.extend=Object.extend,t.create=Object.create,t.fetchAll=Object.fetchAll,t.fromFile=Object.fromFile,t}static async create(e,t,s){const n=new this(e);return n.set(t),n.save(s)}static async fetchAll(t,s){if(!e)throw new Error("Not initialized");if(0===t.length)return[];const n={"Content-Type":"application/json","X-Parse-Application-Id":e.appId};if(s?.useMasterKey&&e.config.masterKey)n["X-Parse-Master-Key"]=e.config.masterKey;else{const t=e.sessionToken;t&&(n["X-Parse-Session-Token"]=t)}const o=`${e.serverURL}/batch`,r=t.map((e=>({method:"GET",path:`/classes/${e.className}/${e.id}`}))),i=await fetch(o,{method:"POST",headers:n,body:JSON.stringify({requests:r})}),a=await i.json();if(a.error)throw new Error(a.error);return a.map(((e,s)=>{const n=t[s];return n.set(e.success),n}))}static async fromFile(t,s,n){if(!e)throw new Error("Not initialized");const o=new FormData;o.append("file",s,t);const r={"X-Parse-Application-Id":e.appId},i=e.sessionToken;i&&(r["X-Parse-Session-Token"]=i);const a=`${e.serverURL}/files/${t}`,c=await fetch(a,{method:"POST",headers:r,body:o}),d=await c.json();if(d.error)throw new Error(d.error);return{__type:"File",name:d.name,url:d.url}}}}createQueryFactory(){const e=this;return class Query extends FmodeQuery{constructor(t){super(t),this._parseInstance=e}static get instance(){return e}static bindInstance(e){}}}createUserFactory(){const e=this;return class User extends FmodeUser{constructor(t){super(t),this._parseInstance=e}static get instance(){return e}static{this.instanceKey=()=>"Parse/"+e.appId+"/currentUser"}static bindInstance(e){}static async logIn(t,s){const n=`${e.serverURL}/login`,o=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-Parse-Application-Id":e.appId},body:JSON.stringify({username:t,password:s})}),r=await o.json();if(r.error)throw r;const i=new this({...r,username:t,password:s});return i._saveToCache(),i}static async become(t){const s=`${e.serverURL}/users/me`;let n={"X-Parse-Session-Token":t,"X-Parse-Application-Id":e.appId};const o=await fetch(s,{headers:n}),r=await o.json();if(r.error)throw r.error;const i=new this({...r,sessionToken:t});return i._saveToCache(),i}static async signUp(e,t,s={}){return new this({...s,username:e,password:t}).signUp()}static async logOut(){if(this.current())try{await fetch(`${e.serverURL}/logout`,{method:"POST",headers:{"X-Parse-Session-Token":this.current().sessionToken,"X-Parse-Application-Id":e.appId}})}finally{this._clearCurrentUser()}}static async requestPasswordReset(t){const s=`${e.serverURL}/requestPasswordReset`,n=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","X-Parse-Application-Id":e.appId},body:JSON.stringify({email:t})}),o=await n.json();if(o.error)throw o}static{this._currentUser=null}static current(){if(this._currentUser)return this._currentUser;try{const t=localStorage.getItem(this.instanceKey());if(!t)return null;const s=JSON.parse(t);if(!s.sessionToken)return null;const n=new this(s);return this._currentUser=n,n.sessionToken&&e&&(e.sessionToken=n.sessionToken),n}catch(e){return console.warn("Failed to restore user from cache",e),null}}static _clearCurrentUser(){this._currentUser=null,e&&(e.sessionToken=void 0),localStorage.removeItem(this.instanceKey())}_saveToCache(){if(!this.sessionToken)return;this.constructor._currentUser=this;const e=this._parseInstance||this.constructor.instance;e&&(e.sessionToken=this.sessionToken),localStorage.setItem(this.constructor.instanceKey(),JSON.stringify(this.toJSONForCache()))}}}static initialize(e){let t;if("string"==typeof e){let s="http://dev.fmode.cn:1337/parse";"undefined"!=typeof location&&"https:"===location.protocol&&(s="https://dev.fmode.cn/parse"),t=new FmodeParse({appId:e,serverURL:s}),this._defaultInstance=t,this._instances.default=t}else t=new FmodeParse(e),e.config&&(this._instances[e.config]=t),e.config&&"default"!==e.config||(this._defaultInstance=t);return t}static with(e){if(!this._instances.nova){let e=new FmodeParse({appId:"ncloudmaster",serverURL:"https://server.fmode.cn/parse"});this._instances.nova=e}if(!this._instances.dev){let e=new FmodeParse({appId:"dev",serverURL:"https://dev.fmode.cn/parse"});this._instances.dev=e}"dev"!=e||this._defaultInstance||(this._defaultInstance=this._instances.dev),"default"!=e||this._instances.default||(this._instances.default=this._instances.dev,this._defaultInstance=this._instances.dev);const t=this._instances[e]||this._defaultInstance;return FmodeObject.bindInstance(t),FmodeQuery.bindInstance(t),FmodeUser.bindInstance(t),FmodeFile.bindInstance(t),FmodeACL.bindInstance(t),FmodeGeoPoint.bindInstance(t),FmodeRelation.bindInstance(t),FmodeCloud.bindInstance(t),t}static getAllInstances(){return{...this._instances}}static getInstanceConfigs(){const e={};return Object.entries(this._instances).forEach((([t,s])=>{e[t]=s.config})),e}get serverURL(){return this.config.serverURL}set serverURL(e){this.config.serverURL=e}get appId(){return this.config.appId}get sessionToken(){if(this.config.sessionToken)return this.config.sessionToken;const e=this.User.current();return e?.sessionToken}set sessionToken(e){this.config.sessionToken=e}}!function(e){e.Object=FmodeObject,e.Query=FmodeQuery,e.User=FmodeUser,e.File=FmodeFile,e.Relation=FmodeRelation,e.ACL=FmodeACL,e.GeoPoint=FmodeGeoPoint,e.Cloud=FmodeCloud.getInstance()}(FmodeParse||(FmodeParse={}));const defaultExport=new Proxy(FmodeParse,{apply:(e,t,s)=>FmodeParse.initialize.apply(e,s),get:(e,t)=>t in e?e[t]:t in FmodeParse?FmodeParse[t]:FmodeParse.with("default")[t]});export{FmodeParse as default,defaultExport as FmodeParse};
9
9
  var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi9jb3JlL3BhcnNlL2Ztb2RlLnBhcnNlLm1qcw==`
10
10
 
@@ -5,6 +5,6 @@
5
5
  * 保留所有权利 All Rights Reserved.
6
6
  * /home/ryan/workspace/nova/nova-admin/dist/fmode-ng/esm2022/lib/user/account/account.service.mjs
7
7
  */
8
- import{Injectable}from"@angular/core";import{NovaCloudService}from"../../nova-cloud/nova-cloud.service";import{FmodeParse}from"../../core/parse";import{AuthService}from"../login/auth.service";import{HttpClient}from"@angular/common/http";import*as i0 from"@angular/core";import*as i1 from"../../nova-cloud/nova-cloud.service";import*as i2 from"../login/auth.service";import*as i3 from"@angular/common/http";const Parse=FmodeParse.with("nova");export class AccountService{constructor(e,t,o){this.ncloud=e,this.authServ=t,this.http=o,this.company="",this.billing={credit:{usedDetail:{}}},this.wxAppId="",this.wxpayEnabled=!1,this.appid=localStorage.getItem("WECHAT_APP_ID")||"",this.company=this.authServ.company||localStorage.getItem("company"),this.getBilling(),this.getProfile(),this.getUserOpenid()}async getProfile(){let e=Parse.User.current()?.id;if(!e)return;let t=new Parse.Query("Profile");t.equalTo("user",e),t.equalTo("company",this.company),t.notEqualTo("isDeleted",!0);let o=await t.first();o?.id&&(this.profile=o)}async getBilling(){let e;if(Parse.User.current()?.getSessionToken()){try{e=await this.ncloud.apig("aigc/account",null,"get")}catch(e){}return e?.credit&&(this.billing=e),e}}async getUserOpenid(){if(!this.appid)return;let e=-1!=navigator.userAgent.toLowerCase().indexOf("micromessenger"),t=this.getQueryStringByName("code"),o=localStorage.getItem("openid");if(!o){if(!Parse.User.current())return;let i=Parse.User.current().get("wechat");o=i?.[this.appid]?.openid,e&&(t?await this.getwechat(t):this.authWechat())}}authWechat(e="/account/billing"){if(!localStorage.getItem("openid")){let e=window.location.href;return e=encodeURIComponent(e),void(window.location.href="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+this.appid+"&redirect_uri="+e+"&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect")}}getQueryStringByName(e){let t=location.search.match(new RegExp("[?&]"+e+"=([^&]+)","i"));return null==t||t.length<1?"":t[1]}async getwechat(e,t="/account/billing"){return new Promise((async(o,i)=>{this.http.post("https://server.fmode.cn/api/wechat/get_wx",{company:this.company,code:e}).subscribe((async e=>{if(console.log(e),e&&200==e.code&&e.data.openid){let t=e.data.openid;localStorage.setItem("openid",t),localStorage.removeItem("code");let i={};i[this.appid]={openid:t},Parse.User.current().set("wechat",i),await Parse.User.current().save(),o(!0)}}),(async e=>{console.log("Error updating items",e),this.authWechat(t),i(!1)}))}))}getWXSignPackageInWechat(){let e={company:this.company,href:encodeURIComponent(location.href.split("?")[0])};this.http.post("https://server.fmode.cn/api/wechat/getconfig",e).subscribe((e=>{const t=e.data;this.wxAppId=t.appid,this.wxpayEnabled=!0,wx.config({debug:!1,appId:t.appid,timestamp:t.timestamp,nonceStr:t.nonceStr,signature:t.signature,jsApiList:["chooseWXPay","onMenuShareTimeline","onMenuShareAppMessage","onMenuShareQQ","onMenuShareQZone","updateAppMessageShareData","updateTimelineShareData"]});let o="https://ai.fmode.cn";location.pathname;Parse.User.current()?.id;let i=this.shareInfo||{title:"飞码AI",desc:"解放创意引领未来|国际前沿的AIGC平台",link:o,type:"link",imgUrl:"https://file-cloud.fmode.cn/E4KpGvTEto/20230822/3mkf41033623275.png",success:function(){console.log("分享成功")},error:function(){console.log("分享失败")},cancel:function(){console.log("取消分享")}};wx.ready((()=>{wx.updateAppMessageShareData(i),wx.updateTimelineShareData(i)})),wx.error((()=>{}))}))}async saveAccountLog(e,t,o,i){return new Promise(((r,a)=>{this.http.post("https://server.fmode.cn/api/apig/saveAccountLog",{company:o,uid:Parse.User.current().id,orderid:t,info:e}).subscribe((e=>{console.log(e),r(!0)}),(e=>{console.warn(e),i&&i.error("请求超时,请稍后再试"),a()}))}))}static{this.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"17.3.12",ngImport:i0,type:AccountService,deps:[{token:i1.NovaCloudService},{token:i2.AuthService},{token:i3.HttpClient}],target:i0.ɵɵFactoryTarget.Injectable})}static{this.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"17.3.12",ngImport:i0,type:AccountService,providedIn:"root"})}}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"17.3.12",ngImport:i0,type:AccountService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:()=>[{type:i1.NovaCloudService},{type:i2.AuthService},{type:i3.HttpClient}]});
8
+ import{Injectable}from"@angular/core";import{NovaCloudService}from"../../nova-cloud/nova-cloud.service";import{FmodeParse}from"../../core/parse";import{AuthService}from"../login/auth.service";import{HttpClient}from"@angular/common/http";import*as i0 from"@angular/core";import*as i1 from"../../nova-cloud/nova-cloud.service";import*as i2 from"../login/auth.service";import*as i3 from"@angular/common/http";const Parse=FmodeParse.with("nova");export class AccountService{constructor(e,t,i){this.ncloud=e,this.authServ=t,this.http=i,this.company="",this.billing={credit:{usedDetail:{}}},this.billingCache=null,this.billingCachePromise=null,this.billingCacheTime=0,this.CACHE_EXPIRY_TIME=12e4,this.wxAppId="",this.wxpayEnabled=!1,this.appid=localStorage.getItem("WECHAT_APP_ID")||"",this.company=this.authServ.company||localStorage.getItem("company"),this.getBilling(),this.getProfile(),this.getUserOpenid()}async getProfile(){let e=Parse.User.current()?.id;if(!e)return;let t=new Parse.Query("Profile");t.equalTo("user",e),t.equalTo("company",this.company),t.notEqualTo("isDeleted",!0);let i=await t.first();i?.id&&(this.profile=i)}async getBilling(){const e=Date.now();return this.billingCache?(e-this.billingCacheTime>=this.CACHE_EXPIRY_TIME&&(this.billingCachePromise||(this.billingCachePromise=this.fetchBillingData())),this.billingCache):(this.billingCachePromise||(this.billingCachePromise=this.fetchBillingData()),this.billing={credit:{balance:4,usedDetail:{}}},this.billing)}async fetchBillingData(){let e;if(!Parse.User.current()?.getSessionToken())return this.billingCachePromise=null,this.billing;try{e=await this.ncloud.apig("aigc/account",null,"get"),e?.credit&&(this.billing=e,this.billingCache=e,this.billingCacheTime=Date.now())}catch(e){console.warn("Failed to fetch billing data:",e)}return this.billingCachePromise=null,this.billingCache||this.billing}async getUserOpenid(){if(!this.appid)return;let e=-1!=navigator.userAgent.toLowerCase().indexOf("micromessenger"),t=this.getQueryStringByName("code"),i=localStorage.getItem("openid");if(!i){if(!Parse.User.current())return;let a=Parse.User.current().get("wechat");i=a?.[this.appid]?.openid,e&&(t?await this.getwechat(t):this.authWechat())}}authWechat(e="/account/billing"){if(!localStorage.getItem("openid")){let e=window.location.href;return e=encodeURIComponent(e),void(window.location.href="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+this.appid+"&redirect_uri="+e+"&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect")}}getQueryStringByName(e){let t=location.search.match(new RegExp("[?&]"+e+"=([^&]+)","i"));return null==t||t.length<1?"":t[1]}async getwechat(e,t="/account/billing"){return new Promise((async(i,a)=>{this.http.post("https://server.fmode.cn/api/wechat/get_wx",{company:this.company,code:e}).subscribe((async e=>{if(console.log(e),e&&200==e.code&&e.data.openid){let t=e.data.openid;localStorage.setItem("openid",t),localStorage.removeItem("code");let a={};a[this.appid]={openid:t},Parse.User.current().set("wechat",a),await Parse.User.current().save(),i(!0)}}),(async e=>{console.log("Error updating items",e),this.authWechat(t),a(!1)}))}))}getWXSignPackageInWechat(){let e={company:this.company,href:encodeURIComponent(location.href.split("?")[0])};this.http.post("https://server.fmode.cn/api/wechat/getconfig",e).subscribe((e=>{const t=e.data;this.wxAppId=t.appid,this.wxpayEnabled=!0,wx.config({debug:!1,appId:t.appid,timestamp:t.timestamp,nonceStr:t.nonceStr,signature:t.signature,jsApiList:["chooseWXPay","onMenuShareTimeline","onMenuShareAppMessage","onMenuShareQQ","onMenuShareQZone","updateAppMessageShareData","updateTimelineShareData"]});let i="https://ai.fmode.cn";location.pathname;Parse.User.current()?.id;let a=this.shareInfo||{title:"飞码AI",desc:"解放创意引领未来|国际前沿的AIGC平台",link:i,type:"link",imgUrl:"https://file-cloud.fmode.cn/E4KpGvTEto/20230822/3mkf41033623275.png",success:function(){console.log("分享成功")},error:function(){console.log("分享失败")},cancel:function(){console.log("取消分享")}};wx.ready((()=>{wx.updateAppMessageShareData(a),wx.updateTimelineShareData(a)})),wx.error((()=>{}))}))}async saveAccountLog(e,t,i,a){return new Promise(((o,n)=>{this.http.post("https://server.fmode.cn/api/apig/saveAccountLog",{company:i,uid:Parse.User.current().id,orderid:t,info:e}).subscribe((e=>{console.log(e),o(!0)}),(e=>{console.warn(e),a&&a.error("请求超时,请稍后再试"),n()}))}))}static{this.ɵfac=i0.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"17.3.12",ngImport:i0,type:AccountService,deps:[{token:i1.NovaCloudService},{token:i2.AuthService},{token:i3.HttpClient}],target:i0.ɵɵFactoryTarget.Injectable})}static{this.ɵprov=i0.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"17.3.12",ngImport:i0,type:AccountService,providedIn:"root"})}}i0.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"17.3.12",ngImport:i0,type:AccountService,decorators:[{type:Injectable,args:[{providedIn:"root"}]}],ctorParameters:()=>[{type:i1.NovaCloudService},{type:i2.AuthService},{type:i3.HttpClient}]});
9
9
  var MODULE_PATH_NEED = `6K+l5paH5Lu25piv5pys6aG555uu55qE5LiA6YOo5YiGIFRoaXMgZmlsZSBpcyBwYXJ0IG9mIHRoZSBDb21wb25lbnRzIGluIEZtb2RlIEluYy4KICAgIOeJiOadg+aJgOaciSDCqSDmnKrmnaXpo57pqawgwqkg5rGf6KW/6ISR5o6n56eR5oqA5pyJ6ZmQ5YWs5Y+4IENvcHlyaWdodCDCqSBGbW9kZSBUZWNobm9sb2d5IENvLiwgTHRkLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCBSaWdodHMgUmVzZXJ2ZWQuCiAgICDkuKXnpoHlnKjmnKrnu4/mjojmnYPnmoTmg4XlhrXkuIvvvIzpgJrov4fku7vkvZXlqpLku4vlpI3liLbmraTmlofku7YgVW5hdXRob3JpemVkIGNvcHlpbmcgb2YgdGhpcyBmaWxlLCB2aWEgYW55IG1lZGl1bSBpcyBzdHJpY3RseSBwcm9oaWJpdGVkCiAgICDor6Xmlofku7bmmK/kuJPmnInnmoTmnLrlr4bmlofku7YgUHJvcHJpZXRhcnkgYW5kIGNvbmZpZGVudGlhbAogICAKICAgIENvcHlyaWdodCAyMDIxLW5vdyBGbW9kZSBJbmMuIHN1cHBvcnRAZm1vZGUuY24uIDE4NjA3MDA3MDczLgogICAg5L+d55WZ5omA5pyJ5p2D5YipIEFsbCByaWdodHMgcmVzZXJ2ZWQuCgogICAgUEFUSDovaG9tZS9yeWFuL3dvcmtzcGFjZS9ub3ZhL25vdmEtYWRtaW4vZGlzdC9mbW9kZS1uZy9lc20yMDIyL2xpYi91c2VyL2FjY291bnQvYWNjb3VudC5zZXJ2aWNlLm1qcw==`
10
10