@opensumi/cli-engine 3.8.1-next-1740452092.0 → 3.8.1-next-1740452912.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/browser.js +3 -3
- package/package.json +10 -10
package/lib/browser/browser.js
CHANGED
|
@@ -29287,12 +29287,12 @@ Use the appropriate tools to fulfill the USER\u2019s request, ensuring all requi
|
|
|
29287
29287
|
|
|
29288
29288
|
<user_info>
|
|
29289
29289
|
The user's OS version is ${this.applicationService.frontendOS}. The absolute path of the user's workspace is ${this.appConfig.workspaceDir}.
|
|
29290
|
-
</user_info>`},invoke:async(f,c,b,y)=>{this.chatDeferred=new p.Deferred;const{message:S,command:A}=f;let w=S;if(A){const R=this.chatFeatureRegistry.getSlashCommandHandler(A);if(R&&R.providerPrompt){const P=this.monacoCommandRegistry.getActiveCodeEditor();w=await R.providerPrompt(S,P)}}const T=this.preferenceService.get(v.AINativeSettingSectionsId.LLMModelSelection);let D="",I="";T==="deepseek"?D=this.preferenceService.get(v.AINativeSettingSectionsId.DeepseekApiKey,""):T==="openai"?(D=this.preferenceService.get(v.AINativeSettingSectionsId.OpenaiApiKey,""),I=this.preferenceService.get(v.AINativeSettingSectionsId.OpenaiBaseURL,"")):D=this.preferenceService.get(v.AINativeSettingSectionsId.AnthropicApiKey,"");const M=await this.aiBackService.requestStream(w,{requestId:f.requestId,sessionId:f.sessionId,history:this.aiChatService.getHistoryMessages(30720),clientId:this.applicationService.clientId,apiKey:D,model:T,baseURL:I},y);return(0,s.listenReadable)(M,{onData:R=>{c(R)},onEnd:()=>{this.chatDeferred.resolve()},onError:R=>{this.messageService.error(R.message),this.aiReporter.end(f.sessionId+"_"+f.requestId,{message:R.message,success:!1,command:A})}}),await this.chatDeferred.promise,{}},provideSlashCommands:async f=>this.chatFeatureRegistry.getAllSlashCommand().map(c=>({...c,name:c.name,description:c.description||""})),provideChatWelcomeMessage:async f=>{}})),queueMicrotask(()=>{this.chatAgentService.updateAgent(n.AGENT_ID,{})})}};t.ChatProxyService=d,d.AGENT_ID="Default_Chat_Agent",r.__decorate([(0,o.Autowired)(g.IChatAgentService),r.__metadata("design:type",Object)],d.prototype,"chatAgentService",void 0),r.__decorate([(0,o.Autowired)(p.AIBackSerivcePath),r.__metadata("design:type",Object)],d.prototype,"aiBackService",void 0),r.__decorate([(0,o.Autowired)(p.ChatFeatureRegistryToken),r.__metadata("design:type",u.ChatFeatureRegistry)],d.prototype,"chatFeatureRegistry",void 0),r.__decorate([(0,o.Autowired)(m.MonacoCommandRegistry),r.__metadata("design:type",m.MonacoCommandRegistry)],d.prototype,"monacoCommandRegistry",void 0),r.__decorate([(0,o.Autowired)(p.ChatServiceToken),r.__metadata("design:type",h.ChatService)],d.prototype,"aiChatService",void 0),r.__decorate([(0,o.Autowired)(p.IAIReporter),r.__metadata("design:type",Object)],d.prototype,"aiReporter",void 0),r.__decorate([(0,o.Autowired)(p.ChatAgentViewServiceToken),r.__metadata("design:type",Object)],d.prototype,"chatAgentViewService",void 0),r.__decorate([(0,o.Autowired)(l.PreferenceService),r.__metadata("design:type",Object)],d.prototype,"preferenceService",void 0),r.__decorate([(0,o.Autowired)(p.IApplicationService),r.__metadata("design:type",Object)],d.prototype,"applicationService",void 0),r.__decorate([(0,o.Autowired)(_.IMessageService),r.__metadata("design:type",Object)],d.prototype,"messageService",void 0),r.__decorate([(0,o.Autowired)(l.AppConfig),r.__metadata("design:type",Object)],d.prototype,"appConfig",void 0),t.ChatProxyService=d=n=r.__decorate([(0,o.Injectable)()],d)},29770:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatService=void 0;const n=e(85608),r=e(76003),o=e(43718),l=e(63067),p=e(19413),v=e(59347);let m=class extends o.Disposable{constructor(){super(),this._onChatMessageLaunch=new o.Emitter,this.onChatMessageLaunch=this._onChatMessageLaunch.event,this._onChatReplyMessageLaunch=new o.Emitter,this.onChatReplyMessageLaunch=this._onChatReplyMessageLaunch.event,this._onChatMessageListLaunch=new o.Emitter,this.onChatMessageListLaunch=this._onChatMessageListLaunch.event,this._onScrollToBottom=new o.Emitter,this.onScrollToBottom=this._onScrollToBottom.event}showChatView(){this.mainLayoutService.toggleSlot(p.AI_CHAT_VIEW_ID,!0)}sendMessage(s){this.showChatView(),this._onChatMessageLaunch.fire(s)}clearHistoryMessages(){var s;(s=this.chatInternalService.sessionModel)===null||s===void 0||s.history.clearMessages()}sendReplyMessage(s){typeof s=="string"?this._onChatReplyMessageLaunch.fire({kind:"content",content:s}):this._onChatReplyMessageLaunch.fire(s)}sendMessageList(s){this._onChatMessageListLaunch.fire(s)}getHistoryMessages(s){var g;return((g=this.chatInternalService.sessionModel)===null||g===void 0?void 0:g.history.getMessages(s))||[]}scrollToBottom(){this._onScrollToBottom.fire()}};t.ChatService=m,n.__decorate([(0,r.Autowired)(p.IChatInternalService),n.__metadata("design:type",v.ChatInternalService)],m.prototype,"chatInternalService",void 0),n.__decorate([(0,r.Autowired)(l.IMainLayoutService),n.__metadata("design:type",Object)],m.prototype,"mainLayoutService",void 0),t.ChatService=m=n.__decorate([(0,r.Injectable)(),n.__metadata("design:paramtypes",[])],m)},11735:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatFeatureRegistry=void 0;const n=e(85608),r=e(76003),o=e(43718),l=e(19413),p=e(42033),v=e(51081);let m=class extends o.Disposable{constructor(){super(...arguments),this.logger=(0,o.getDebugLogger)(),this.slashCommandsMap=new Map,this.slashCommandsHandlerMap=new Map,this._onDidWelcomeMessageChange=new o.Emitter,this.onDidWelcomeMessageChange=this._onDidWelcomeMessageChange.event}dispose(){super.dispose(),this.slashCommandsMap.clear(),this.slashCommandsHandlerMap.clear()}registerWelcome(s,g){this.chatWelcomeMessageModel=new p.ChatWelcomeMessageModel(s,g),this._onDidWelcomeMessageChange.fire()}registerSlashCommand(s,g){const{name:a}=s;if(this.slashCommandsMap.has(a)){this.logger.warn(`ChatFeatureRegistry: commands name ${a} already exists`);return}this.slashCommandsMap.set(a,new p.ChatSlashCommandItemModel(s,a,v.ChatProxyService.AGENT_ID)),this.slashCommandsHandlerMap.set(a,g)}getSlashCommandHandler(s){return this.slashCommandsHandlerMap.get(s)}getSlashCommand(s){return this.slashCommandsMap.get(s)}getSlashCommandHandlerBySlashName(s){const g=this.getAllSlashCommand().find(a=>a.nameWithSlash===s);if(g)return this.getSlashCommandHandler(g.name)}getSlashCommandBySlashName(s){const g=this.getAllSlashCommand().find(a=>a.nameWithSlash===s);if(g)return this.getSlashCommand(g.name)}getAllSlashCommand(){return Array.from(this.slashCommandsMap.values())}getAllShortcutSlashCommand(){return this.getAllSlashCommand().filter(s=>s.isShortcut===!0)}parseSlashCommand(s){if(s.startsWith(l.SLASH_SYMBOL)){const g=this.getAllSlashCommand();for(const a of g){const{nameWithSlash:h}=a;if(s.startsWith(h))return{value:s.slice(h.length),nameWithSlash:h}}}return{value:s,nameWithSlash:""}}};t.ChatFeatureRegistry=m,t.ChatFeatureRegistry=m=n.__decorate([(0,r.Injectable)()],m)},59347:(L,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ChatInternalService=void 0;const r=e(85608),o=e(76003),l=e(41869),p=e(43718),v=e(19413),m=e(61282);let _=class extends p.Disposable{constructor(){super(...arguments),this._onChangeRequestId=new p.Emitter,this.onChangeRequestId=this._onChangeRequestId.event,this._onChangeSession=new p.Emitter,this.onChangeSession=this._onChangeSession.event,this._onCancelRequest=new p.Emitter,this.onCancelRequest=this._onCancelRequest.event,this._onRegenerateRequest=new p.Emitter,this.onRegenerateRequest=this._onRegenerateRequest.event,n.set(this,void 0)}get latestRequestId(){return this._latestRequestId}get sessionModel(){return r.__classPrivateFieldGet(this,n,"f")}init(){this.chatManagerService.onStorageInit(()=>{const g=this.chatManagerService.getSessions();g.length>0?this.activateSession(g[g.length-1].sessionId):this.createSessionModel()})}setLatestRequestId(g){this._latestRequestId=g,this._onChangeRequestId.fire(g)}createRequest(g,a,h){return this.chatManagerService.createRequest(r.__classPrivateFieldGet(this,n,"f").sessionId,g,a,h)}sendRequest(g,a=!1){const h=this.chatManagerService.sendRequest(r.__classPrivateFieldGet(this,n,"f").sessionId,g,a);return a&&this._onRegenerateRequest.fire(),h}cancelRequest(){this.chatManagerService.cancelRequest(r.__classPrivateFieldGet(this,n,"f").sessionId),this._onCancelRequest.fire()}createSessionModel(){r.__classPrivateFieldSet(this,n,this.chatManagerService.startSession(),"f"),this._onChangeSession.fire(r.__classPrivateFieldGet(this,n,"f").sessionId)}clearSessionModel(g){g=g||r.__classPrivateFieldGet(this,n,"f").sessionId,this.chatManagerService.clearSession(g),g===r.__classPrivateFieldGet(this,n,"f").sessionId&&r.__classPrivateFieldSet(this,n,this.chatManagerService.startSession(),"f"),this._onChangeSession.fire(r.__classPrivateFieldGet(this,n,"f").sessionId)}getSessions(){return this.chatManagerService.getSessions()}activateSession(g){const a=this.chatManagerService.getSession(g);if(!a)throw new Error(`There is no session with session id ${g}`);r.__classPrivateFieldSet(this,n,a,"f"),this._onChangeSession.fire(r.__classPrivateFieldGet(this,n,"f").sessionId)}dispose(){var g;(g=r.__classPrivateFieldGet(this,n,"f"))===null||g===void 0||g.dispose(),super.dispose()}};t.ChatInternalService=_,n=new WeakMap,r.__decorate([(0,o.Autowired)(p.AIBackSerivcePath),r.__metadata("design:type",Object)],_.prototype,"aiBackService",void 0),r.__decorate([(0,o.Autowired)(l.PreferenceService),r.__metadata("design:type",Object)],_.prototype,"preferenceService",void 0),r.__decorate([(0,o.Autowired)(v.IChatManagerService),r.__metadata("design:type",m.ChatManagerService)],_.prototype,"chatManagerService",void 0),t.ChatInternalService=_=r.__decorate([(0,o.Injectable)()],_)},70394:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatRenderRegistry=void 0;const n=e(85608),r=e(76003),o=e(43718);let l=class extends o.Disposable{registerWelcomeRender(v){this.chatWelcomeRender=v}registerAIRoleRender(v){this.chatAIRoleRender=v}registerUserRoleRender(v){this.chatUserRoleRender=v}registerThinkingRender(v){this.chatThinkingRender=v}registerInputRender(v){this.chatInputRender=v}registerThinkingResultRender(v){this.chatThinkingResultRender=v}registerChatViewHeaderRender(v){this.chatViewHeaderRender=v}};t.ChatRenderRegistry=l,t.ChatRenderRegistry=l=n.__decorate([(0,r.Injectable)()],l)},76154:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AIChatView=void 0,t.DefaultChatViewHeader=P;const n=e(85608),r=n.__importStar(e(14041)),o=e(68392),l=e(41869),p=e(81878),v=e(89195),m=e(43718),_=e(63067),s=e(72665);e(41937);const g=e(19413),a=e(46044),h=e(73307),u=e(27399),d=e(25834),E=n.__importDefault(e(90103)),f=e(57987),c=e(56474),b=e(92635),y=e(29039),S=e(78048),A=e(86556),w=e(30703),T=e(42033),D=e(51081),I=n.__importDefault(e(77256)),O="chat_scroll",M=100,R=()=>{const k=(0,l.useInjectable)(g.IChatInternalService),F=(0,l.useInjectable)(m.ChatServiceToken),x=(0,l.useInjectable)(m.IAIReporter),B=(0,l.useInjectable)(g.IChatAgentService),j=(0,l.useInjectable)(m.ChatFeatureRegistryToken),W=(0,l.useInjectable)(m.ChatRenderRegistryToken),U=(0,l.useInjectable)(a.LLMContextServiceToken),Z=(0,l.useInjectable)(h.ChatAgentPromptProvider),V=(0,l.useInjectable)(_.IMainLayoutService),$=k.sessionModel.history,Y=r.useRef(null),G=r.useRef(null),[H,K]=r.useState([]),[X,Q]=r.useReducer((et,St)=>{switch(St.type){case"add":return[...et,...St.payload||[]];case"clear":return[];case"init":return Array.isArray(St.payload)?St.payload:[];default:return et}},[]),[oe,ne]=r.useState(!1),[he,_e]=r.useState(""),[q,Oe]=r.useState(""),[ye,ie]=r.useState(""),[ge,Me]=r.useState(null);r.useEffect(()=>{const et=j.getAllShortcutSlashCommand(),St=B.onDidChangeAgents(()=>{const tt=B.getCommands().filter(yt=>yt.isShortcut).map(yt=>new T.ChatSlashCommandItemModel({icon:"",name:`${yt.name} `,description:yt.description,isShortcut:yt.isShortcut},yt.name,yt.agentId));K(et.concat(tt))});return K(et),()=>St.dispose()},[j,B]),(0,l.useUpdateOnEvent)(k.onChangeSession);const xe=r.useMemo(()=>W.chatInputRender?W.chatInputRender:f.ChatInput,[W.chatInputRender]),Ce=r.useMemo(()=>(0,S.createMessageByAI)({id:(0,m.uuid)(6),relationId:"",text:r.createElement(A.WelcomeMessage,null)}),[]),Ae=r.useCallback(()=>{if(Y&&Y.current){const et=Y.current.lastElementChild;et&&et.scrollIntoView({behavior:"smooth",block:"end"}),Y.current.scrollHeight>Y.current.clientHeight&&Y.current.classList.add(O)}},[Y]),ve=r.useCallback(et=>{Q(et),requestAnimationFrame(()=>{Ae()})},[Q,Ae]);r.useEffect(()=>{ve({type:"init",payload:[Ce]})},[]),r.useEffect(()=>{const et=new m.Disposable;return et.addDispose(F.onScrollToBottom(()=>{requestAnimationFrame(()=>{Ae()})})),et.addDispose(F.onChatMessageLaunch(async St=>{var tt;if(St.immediate!==!1){if(oe)return;await le(St)}else St.agentId&&_e(St.agentId),St.command&&ie(St.command),(tt=G?.current)===null||tt===void 0||tt.setInputValue(St.message)})),et.addDispose(F.onChatReplyMessageLaunch(St=>{if(St.kind==="content"){const tt=x.start(m.AIServiceType.CustomReplay,{message:St.content});$.addAssistantMessage({content:St.content,relationId:tt}),Fe({chunk:St.content,relationId:tt})}else{const tt=x.start(m.AIServiceType.CustomReplay,{message:"component#"+St.component});$.addAssistantMessage({componentId:St.component,componentValue:St.value,content:"",relationId:tt}),pe({chunk:St,relationId:tt})}})),et.addDispose(F.onChatMessageListLaunch(St=>{const tt=[];St.forEach(yt=>{const{role:it}=yt,ct=x.start(m.AIServiceType.Chat,{message:""});if(it==="assistant"){const ht=yt;tt.push((0,S.createMessageByAI)({id:(0,m.uuid)(6),relationId:ct,text:r.createElement(b.ChatNotify,{requestId:ct,chunk:ht})},I.default.chat_notify))}if(it==="user"){const{message:ht}=yt,At=D.ChatProxyService.AGENT_ID,Vt=W.chatUserRoleRender,Cn=At===D.ChatProxyService.AGENT_ID?"":At;tt.push((0,S.createMessageByUser)({id:(0,m.uuid)(6),relationId:ct,text:Vt?r.createElement(Vt,{content:ht,agentId:Cn}):r.createElement(d.CodeBlockWrapperInput,{relationId:ct,text:ht,agentId:Cn,command:ye})},I.default.chat_message_code))}}),ve({type:"add",payload:tt}),setTimeout(Ae,0)})),()=>et.dispose()},[F,W.chatAIRoleRender,$]),r.useEffect(()=>{const et=new m.Disposable;return et.addDispose(B.onDidSendMessage(St=>{const tt=St,yt=x.start(m.AIServiceType.Agent,{message:""}),it=(0,S.createMessageByAI)({id:(0,m.uuid)(6),relationId:yt,text:r.createElement(b.ChatNotify,{requestId:k.latestRequestId,chunk:tt})},I.default.chat_notify);ve({type:"add",payload:[it]})})),et.addDispose(B.onDidChangeAgents(async()=>{const St=B.getDefaultAgentId();Oe(St??"")})),()=>et.dispose()},[B,$,k]);const fe=r.useCallback(async et=>{const{userMessage:St,relationId:tt,requestId:yt,render:it,startTime:ct,command:ht,agentId:At}=et;$.addAssistantMessage({type:"component",content:""});const Vt=(0,S.createMessageByAI)({id:(0,m.uuid)(6),relationId:tt,className:I.default.chat_with_more_actions,text:r.createElement(y.SlashCustomRender,{userMessage:St,startTime:ct,relationId:tt,requestId:yt,renderContent:it,command:ht,agentId:At})});ve({type:"add",payload:[Vt]})},[Y,$]),Le=r.useCallback(async et=>{const St=W.chatUserRoleRender,{message:tt,agentId:yt,relationId:it,command:ct}=et,ht=yt===D.ChatProxyService.AGENT_ID?"":yt,At=(0,S.createMessageByUser)({id:(0,m.uuid)(6),relationId:it,text:St?r.createElement(St,{content:tt,agentId:ht,command:ct}):r.createElement(d.CodeBlockWrapperInput,{relationId:it,text:tt,agentId:ht,command:ct})},I.default.chat_message_code);ve({type:"add",payload:[At]})},[W,W.chatUserRoleRender,$,Ae]),Te=r.useCallback(async et=>{const{message:St,agentId:tt,request:yt,relationId:it,command:ct,startTime:ht,msgId:At}=et,Vt=tt===D.ChatProxyService.AGENT_ID?"":tt;if(tt===D.ChatProxyService.AGENT_ID&&ct){const Un=j.getSlashCommandHandler(ct);if(Un&&Un.providerRender)return ne(!1),fe({userMessage:St,render:Un.providerRender,relationId:it,requestId:yt.requestId,startTime:ht,agentId:tt,command:ct})}const Cn=(0,S.createMessageByAI)({id:(0,m.uuid)(6),relationId:it,className:I.default.chat_with_more_actions,text:r.createElement(b.ChatReply,{relationId:it,request:yt,startTime:ht,agentId:Vt,command:ct,onDidChange:()=>{Ae()},history:$,onDone:()=>{ne(!1)},onRegenerate:()=>{yt&&k.sendRequest(yt,!0)},msgId:At})});ve({type:"add",payload:[Cn]})},[W,$,Ae]),Fe=r.useCallback(et=>{const{chunk:St,relationId:tt}=et;let yt=r.createElement(c.ChatMarkdown,{markdown:St,fillInIncompleteTokens:!0,agentId:he,command:ye});if(W.chatAIRoleRender){const ct=W.chatAIRoleRender;yt=r.createElement(ct,{content:St})}const it=(0,S.createMessageByAI)({id:(0,m.uuid)(6),relationId:tt,text:yt,className:I.default.chat_with_more_actions});ve({type:"add",payload:[it]})},[W,$,Ae]),pe=r.useCallback(et=>{const{chunk:St,relationId:tt}=et,yt=(0,S.createMessageByAI)({id:(0,m.uuid)(6),relationId:tt,text:r.createElement(b.ChatNotify,{requestId:tt,chunk:St})},I.default.chat_notify);ve({type:"add",payload:[yt]})},[W,$,Ae]),re=r.useCallback(async et=>{const{message:St,agentId:tt,command:yt,reportExtra:it}=et,{actionType:ct,actionSource:ht}=it||{},At=U.serialize(),Vt=await Z.provideContextPrompt(At,St),Cn=k.createRequest(Vt,tt,yt);if(!Cn)return;ne(!0),k.setLatestRequestId(Cn.requestId);const Un=Date.now(),Ei=D.ChatProxyService.AGENT_ID===tt?m.AIServiceType.Chat:m.AIServiceType.Agent,Wn=x.start(yt||Ei,{message:St,agentId:tt,userMessage:St,actionType:ct,actionSource:ht});$.addUserMessage({content:St,agentId:tt,agentCommand:yt,relationId:Wn}),await Le({relationId:Wn,message:St,command:yt,agentId:tt}),k.sendRequest(Cn);const hn=$.addAssistantMessage({content:"",relationId:Wn,requestId:Cn.requestId,replyStartTime:Un});await Te({startTime:Un,relationId:Wn,message:St,agentId:tt,command:yt,request:Cn,msgId:hn})},[W,W.chatUserRoleRender,$,Ae]),le=r.useCallback(async et=>{const{message:St,command:tt,reportExtra:yt}=et,it=et.agentId?et.agentId:D.ChatProxyService.AGENT_ID;return re({message:St,agentId:it,command:tt,reportExtra:yt})},[re]),Ie=r.useCallback(()=>{k.clearSessionModel(),F.clearHistoryMessages(),Se()},[X]),Se=r.useCallback(()=>{var et;(et=Y?.current)===null||et===void 0||et.classList.remove(O),ve({type:"init",payload:[Ce]})},[X]),We=et=>{oe||(Me(et.nameWithSlash),_e(et.agentId),ie(et.command))},$e=r.useCallback(()=>{V.toggleSlot(g.AI_CHAT_VIEW_ID)},[V]),Ve=W.chatViewHeaderRender||P,mt=r.useCallback(async et=>{for(const St of $.getMessages()){if(et.isCancellationRequested)return;if(St.role===1)await Le({relationId:St.relationId,message:St.content,agentId:St.agentId,command:St.agentCommand});else if(St.role===2&&St.requestId){const tt=k.sessionModel.getRequest(St.requestId);tt&&!tt.response.isComplete&&ne(!0),await Te({msgId:St.id,relationId:St.relationId,message:St.content,agentId:St.agentId,command:St.agentCommand,startTime:St.replyStartTime,request:tt})}else St.role===2&&St.content?await Fe({relationId:St.relationId,chunk:St.content}):St.role===2&&St.componentId&&await pe({relationId:St.relationId,chunk:{kind:"component",component:St.componentId,value:St.componentValue}})}},[Te]);return r.useEffect(()=>{Se();const et=new m.CancellationTokenSource;return ne(!1),mt(et.token),()=>{et.cancel()}},[k.sessionModel]),r.createElement("div",{id:I.default.ai_chat_view},r.createElement("div",{className:I.default.header_container},r.createElement(Ve,{handleClear:Ie,handleCloseChatView:$e})),r.createElement("div",{className:I.default.body_container},r.createElement("div",{className:I.default.left_bar,id:"ai_chat_left_container"},r.createElement("div",{className:I.default.chat_container,ref:Y},r.createElement(o.MessageList,{className:I.default.message_list,lockable:!0,toBottomHeight:"100%",dataSource:X})),$.slicedMessageCount?r.createElement("div",{className:I.default.chat_tips_text},r.createElement("div",{className:I.default.chat_tips_container},(0,m.formatLocalize)("aiNative.chat.ai.assistant.limit.message",$.slicedMessageCount))):null,r.createElement("div",{className:I.default.chat_input_wrap},r.createElement(u.ChatContext,null),r.createElement("div",{className:I.default.header_operate},r.createElement("div",{className:I.default.header_operate_left},H.map(et=>r.createElement(p.Popover,{id:`ai-chat-shortcut-${et.name}`,key:`ai-chat-shortcut-${et.name}`,title:et.tooltip||et.name},r.createElement("div",{className:I.default.tag,onClick:()=>We(et)},et.name))))),r.createElement(xe,{onSend:(et,St,tt)=>le({message:et,agentId:St,command:tt,reportExtra:{actionSource:m.ActionSourceEnum.Chat,actionType:m.ActionTypeEnum.Send}}),disabled:oe,enableOptions:!0,theme:ge,setTheme:Me,agentId:he,setAgentId:_e,defaultAgentId:q,command:ye,setCommand:ie,ref:G})))))};t.AIChatView=R;function P({handleClear:k,handleCloseChatView:F}){const x=(0,l.useInjectable)(s.IDialogService),B=(0,l.useInjectable)(l.AINativeConfigService),j=(0,l.useInjectable)(g.TokenMCPServerProxyService),W=(0,l.useInjectable)(g.IChatInternalService),[U,Z]=r.useState([]),[V,$]=r.useState(""),Y=r.useCallback(()=>{W.sessionModel.history.getMessages().length>0&&W.createSessionModel()},[W]),G=r.useCallback(X=>{W.activateSession(X.id)},[W]),H=r.useCallback(X=>{W.clearSessionModel(X.id)},[W]),K=r.useCallback(async()=>{const X=await j.getAllMCPTools();x.open({message:r.createElement(w.MCPToolsDialog,{tools:X}),type:m.MessageType.Empty,buttons:["\u5173\u95ED"]})},[j,x]);return r.useEffect(()=>{const X=()=>{const ne=W.sessionModel.history.getMessages();$(ne.length>0?ne[ne.length-1].content.slice(0,M):""),Z(W.getSessions().map(he=>{const q=he.history.getMessages(),Oe=q.length>0?q[0].content.slice(0,M):"",ye=q.length>0&&q[q.length-1].replyStartTime||0;return{id:he.sessionId,title:Oe,updatedAt:ye,loading:!1}}))};X();const Q=new m.DisposableCollection,oe=new Set;return Q.push(W.onChangeSession(ne=>{X(),!oe.has(ne)&&(oe.add(ne),Q.push(W.sessionModel.history.onMessageChange(()=>{X()})))})),Q.push(W.sessionModel.history.onMessageChange(()=>{X()})),()=>{Q.dispose()}},[W]),r.createElement("div",{className:I.default.header},r.createElement(E.default,{className:I.default.chat_history,currentId:W.sessionModel.sessionId,title:V||(0,m.localize)("aiNative.chat.ai.assistant.name"),historyList:U,onNewChat:Y,onHistoryItemSelect:G,onHistoryItemDelete:H,onHistoryItemChange:()=>{}}),r.createElement(p.Popover,{overlayClassName:I.default.popover_icon,id:"ai-chat-header-clear",title:(0,m.localize)("aiNative.operate.clear.title")},r.createElement(v.EnhanceIcon,{wrapperClassName:I.default.action_btn,className:(0,l.getIcon)("clear"),onClick:k,tabIndex:0,role:"button",ariaLabel:(0,m.localize)("aiNative.operate.clear.title")})),B.capabilities.supportsMCP&&r.createElement(p.Popover,{overlayClassName:I.default.popover_icon,id:"ai-chat-header-tools",position:p.PopoverPosition.left,title:(0,m.localize)("aiNative.operate.tools.title")},r.createElement(v.EnhanceIcon,{wrapperClassName:I.default.action_btn,className:(0,l.getIcon)("menubar-tool"),onClick:K,tabIndex:0,role:"button",ariaLabel:(0,m.localize)("aiNative.operate.tools.title")})),r.createElement(p.Popover,{overlayClassName:I.default.popover_icon,id:"ai-chat-header-close",position:p.PopoverPosition.left,title:(0,m.localize)("aiNative.operate.close.title")},r.createElement(v.EnhanceIcon,{wrapperClassName:I.default.action_btn,className:(0,l.getIcon)("window-close"),onClick:F,tabIndex:0,role:"button",ariaLabel:(0,m.localize)("aiNative.operate.close.title")})))}},55369:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContextSelector=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=e(45250),l=n.__importStar(e(14041)),p=e(58998),v=e(41869),m=e(81878),_=e(95263),s=e(95422),g=e(15625),a=e(70392),h=n.__importDefault(e(97431)),u=(0,l.memo)(({uri:d,active:E,selected:f,onDidSelect:c,onDidDeselect:b})=>{var y;const S=(0,s.useInjectable)(v.LabelService),A=(0,s.useInjectable)(v.AppConfig),w=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(E&&w.current){const T={behavior:"instant",block:"end"};w.current.scrollIntoView(T)}},[E,w.current]),l.default.createElement("div",{className:(0,r.default)(h.default.candidate_file,E&&h.default.active),ref:T=>w.current=T,onClick:()=>f?b(d):c(d)},l.default.createElement(m.Icon,{iconClass:S.getIcon(d)}),l.default.createElement("span",{className:h.default.basename},d.path.base),l.default.createElement("span",{className:h.default.dir},(y=a.URI.file(A.workspaceDir).relative(d.parent))===null||y===void 0?void 0:y.toString()),f&&l.default.createElement(m.Icon,{icon:"check",style:{marginLeft:"auto",color:"var(--editorGutter-addedBackground)"}}))});t.ContextSelector=(0,l.memo)(({addedFiles:d,onDidDeselect:E,onDidSelect:f,onDidClose:c})=>{const[b,y]=(0,l.useState)([]),[S,A]=(0,l.useState)(null),[w,T]=(0,l.useState)(!1),[D,I]=(0,l.useState)([]),O=(0,s.useInjectable)(_.RecentFilesManager),M=(0,s.useInjectable)(v.AppConfig),R=(0,s.useInjectable)(g.FileSearchServicePath),P=(0,l.useRef)();(0,l.useEffect)(()=>{b.length===0&&O.getMostRecentlyOpenedFiles().then(x=>{const B=d.map(W=>W.uri),j=x.filter(W=>!B.includes(new a.URI(W))).map(W=>new a.URI(W));y(j),A(j[0]||null)})},[d]);const k=(0,l.useCallback)((0,o.debounce)(x=>{if(x.target.value.trim()===""){I([]),A(b[0]);return}T(!0),R.find(x.target.value,{rootUris:[M.workspaceDir],limit:200,useGitIgnore:!0,noIgnoreParent:!0,fuzzyMatch:!0}).then(B=>{const j=B.map(W=>new a.URI(W));I(j),A(j[0])}).finally(()=>{T(!1)})},500),[]),F=(0,l.useCallback)(x=>{const{key:B}=x;if(B==="Escape"){c();return}if(B==="Enter"&&S){f(S);return}if(!["ArrowUp","ArrowDown"].includes(B))return;const W=D.length>0?D:b;if(W.length===0)return;const U=W.indexOf(S),Z=U===-1?0:U,V=W.length-1,$=B==="ArrowUp"?Z>0?Z-1:V:Z<V?Z+1:0;A(W[$])},[S,D,b]);return l.default.createElement(p.ClickOutside,{mouseEvents:["click","contextmenu"],onOutsideClick:()=>c()},l.default.createElement("div",{className:h.default.context_selector,onKeyDown:F,tabIndex:-1},l.default.createElement("div",{style:{padding:"4px"}},l.default.createElement(m.Input,{placeholder:"Search files by name",autoFocus:!0,onInput:k})),l.default.createElement(m.Scrollbars,{forwardedRef:x=>x?P.current=x.ref:null},l.default.createElement("div",{className:h.default.context_list},w&&l.default.createElement("div",{className:h.default.context_search_layer}),l.default.createElement("span",{className:h.default.list_desc},D.length>0?"Search Results":"Recent Opened Files"),(D.length>0?D:b).map(x=>l.default.createElement(u,{key:x.toString(),uri:x,active:S===x,onDidSelect:f,onDidDeselect:E,selected:!!d.find(B=>B.uri.isEqual(x))}))))))})},27399:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatContext=void 0;const n=e(85608),r=n.__importStar(e(1171)),o=n.__importStar(e(14041));e(628);const l=e(80564),p=e(81878),v=e(89195),m=e(95422),_=e(11050),s=e(63214),g=e(33783),a=e(86560),h=e(82196),u=e(46044),d=e(55369),E=n.__importDefault(e(97431)),f=()=>({height:0,opacity:0}),c=S=>({height:S.scrollHeight,opacity:1}),b=S=>({height:S.offsetHeight}),y=(S,A)=>A.propertyName==="height";t.ChatContext=(0,o.memo)(()=>{const[S,A]=(0,o.useState)([]),[w,T]=(0,o.useState)(!1),D=(0,m.useInjectable)(s.LabelService),I=(0,m.useInjectable)(_.AppConfig),O=(0,m.useInjectable)(h.WorkbenchEditorService),M=(0,m.useInjectable)(u.LLMContextServiceToken);(0,o.useEffect)(()=>{const j=a.Event.debounce(M.onDidContextFilesChangeEvent,(W,U)=>U,50)(W=>{W&&A([...W.attached])},M);return()=>{j.dispose()}},[]);const R=(0,o.useCallback)(()=>{T(!0)},[S]),P=(0,o.useCallback)(j=>{M.addFileToContext(j,void 0,!0)},[]),k=(0,o.useCallback)(j=>{M.removeFileFromContext(j,!0)},[]),F=(0,o.useCallback)(j=>{O.open(j)},[]),x=(0,o.useCallback)(j=>{j.stopPropagation(),j.preventDefault(),M.cleanFileContext()},[]),B=(0,o.useCallback)((j,W)=>{j.stopPropagation(),j.preventDefault(),k(W)},[]);return o.default.createElement("div",{className:E.default.chat_context},o.default.createElement(r.default,{expandIcon:({isActive:j})=>j?o.default.createElement(l.Icon,{icon:"down"}):o.default.createElement(l.Icon,{icon:"right"}),openMotion:{motionName:"rc-collapse-motion",onEnterStart:f,onEnterActive:c,onLeaveStart:b,onLeaveActive:f,onEnterEnd:y,onLeaveEnd:y,motionDeadline:100,leavedClassName:E.default.collapse_hide}},o.default.createElement(r.Panel,{header:o.default.createElement("div",{className:E.default.context_header},o.default.createElement("h3",{className:E.default.chat_context_title},"Context ",S.length>0?` (${S.length} files)`:""),o.default.createElement(p.Popover,{overlayClassName:E.default.popover_icon,id:"ai-context-header-clear",title:(0,g.localize)("aiNative.operate.clear.title")},o.default.createElement(v.EnhanceIcon,{wrapperClassName:E.default.action_btn,className:(0,p.getIcon)("clear"),onClick:x,tabIndex:0,role:"button",ariaLabel:(0,g.localize)("aiNative.operate.clear.title")}))),key:"context-panel"},o.default.createElement("div",{className:E.default.file_list},S.map(j=>{var W;return o.default.createElement("div",{className:E.default.selected_item,key:j.uri.toString(),onClick:()=>F(j.uri)},o.default.createElement(l.Icon,{iconClass:D.getIcon(j.uri)}),o.default.createElement("span",{className:E.default.basename},j.uri.path.base,j.selection?` (${j.selection[0]}-${j.selection[1]})`:""),o.default.createElement("span",{className:E.default.dir},(W=a.URI.file(I.workspaceDir).relative(j.uri.parent))===null||W===void 0?void 0:W.toString()),o.default.createElement(l.Icon,{icon:"close",className:E.default.close_icon,onClick:U=>B(U,j.uri)}))})),o.default.createElement("div",{className:E.default.add_context,onClick:R},o.default.createElement(l.Icon,{icon:"add"}),"Add Files"))),w&&o.default.createElement(d.ContextSelector,{onDidClose:()=>T(!1),onDidDeselect:k,onDidSelect:P,addedFiles:S}))})},25834:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CodeBlockWrapperInput=t.CodeBlockWrapper=t.CodeEditorWithHighlight=void 0;const n=e(85608),r=n.__importDefault(e(56005)),o=n.__importStar(e(14041)),l=n.__importDefault(e(10580)),p=e(41869),v=e(81878),m=e(89195),_=e(43718),s=e(71624),g=e(9447),a=e(52416),h=n.__importDefault(e(6960)),u=e(83933);e(38191);const d=b=>{const{input:y,language:S,relationId:A,agentId:w,command:T,hideInsert:D}=b,I=o.default.useRef(null),O=(0,p.useInjectable)(g.MonacoCommandRegistry),M=(0,p.useInjectable)(p.IClipboardService),R=(0,p.useInjectable)(a.IThemeService),P=(0,p.useInjectable)(_.IAIReporter),[k,F]=(0,o.useState)(!1),x=(0,o.useMemo)(()=>(0,p.uuid)(12),[I,I.current]);(0,o.useEffect)(()=>{const W=V=>{V.type==="dark"||V.type==="hcDark"?e.e(622).then(e.bind(e,51622)):(V.type==="light"||V.type==="hcLight")&&e.e(412).then(e.bind(e,50412))},U=R.onThemeChange(V=>{W(V)}),Z=R.getCurrentThemeSync();return W(Z),()=>U.dispose()},[]);const B=(0,o.useCallback)(async()=>{F(!0),await M.writeText(y),P.end(A,{copy:!0,code:y,language:S,agentId:w,command:T,actionSource:_.ActionSourceEnum.Chat,actionType:_.ActionTypeEnum.ChatCopyCode}),(0,_.runWhenIdle)(()=>{F(!1)},1e3)},[M,y,A]),j=(0,o.useCallback)(()=>{const W=O.getActiveCodeEditor();if(W){const U=W.getSelection();U&&((0,s.insertSnippetWithMonacoEditor)(W,y,[U],{undoStopBefore:!1,undoStopAfter:!1}),P.end(A,{insert:!0,code:y,language:S,agentId:w,command:T,actionSource:_.ActionSourceEnum.Chat,actionType:_.ActionTypeEnum.ChatInsertCode}))}},[O]);return o.default.createElement("div",{className:h.default.monaco_wrapper},o.default.createElement("div",{className:h.default.action_toolbar},!D&&o.default.createElement(v.Popover,{id:`ai-chat-inser-${x}`,title:(0,_.localize)("aiNative.chat.code.insert")},o.default.createElement(m.EnhanceIcon,{className:(0,p.getIcon)("insert"),onClick:()=>j(),tabIndex:0,role:"button",ariaLabel:(0,_.localize)("aiNative.chat.code.insert")})),o.default.createElement(v.Popover,{id:`ai-chat-copy-${x}`,title:(0,_.localize)(k?"aiNative.chat.code.copy.success":"aiNative.chat.code.copy")},o.default.createElement(m.EnhanceIcon,{className:(0,p.getIcon)("copy"),onClick:()=>B(),tabIndex:0,role:"button",ariaLabel:(0,_.localize)("aiNative.chat.code.copy")}))),o.default.createElement(l.default,{language:S,ref:I,className:h.default.editor},y))};t.CodeEditorWithHighlight=d;const E=({content:b="",relationId:y,renderText:S,agentId:A="",command:w=""})=>{const T=/`([^`]+)`/g,D=/```([^]+?)```/g,I=/```([^]+)?/g,O=R=>{const P=R.split(`
|
|
29290
|
+
</user_info>`},invoke:async(f,c,b,y)=>{this.chatDeferred=new p.Deferred;const{message:S,command:A}=f;let w=S;if(A){const R=this.chatFeatureRegistry.getSlashCommandHandler(A);if(R&&R.providerPrompt){const P=this.monacoCommandRegistry.getActiveCodeEditor();w=await R.providerPrompt(S,P)}}const T=this.preferenceService.get(v.AINativeSettingSectionsId.LLMModelSelection);let D="",I="";T==="deepseek"?D=this.preferenceService.get(v.AINativeSettingSectionsId.DeepseekApiKey,""):T==="openai"?(D=this.preferenceService.get(v.AINativeSettingSectionsId.OpenaiApiKey,""),I=this.preferenceService.get(v.AINativeSettingSectionsId.OpenaiBaseURL,"")):D=this.preferenceService.get(v.AINativeSettingSectionsId.AnthropicApiKey,"");const M=await this.aiBackService.requestStream(w,{requestId:f.requestId,sessionId:f.sessionId,history:this.aiChatService.getHistoryMessages(30720),clientId:this.applicationService.clientId,apiKey:D,model:T,baseURL:I},y);return(0,s.listenReadable)(M,{onData:R=>{c(R)},onEnd:()=>{this.chatDeferred.resolve()},onError:R=>{this.messageService.error(R.message),this.aiReporter.end(f.sessionId+"_"+f.requestId,{message:R.message,success:!1,command:A})}}),await this.chatDeferred.promise,{}},provideSlashCommands:async f=>this.chatFeatureRegistry.getAllSlashCommand().map(c=>({...c,name:c.name,description:c.description||""})),provideChatWelcomeMessage:async f=>{}})),queueMicrotask(()=>{this.chatAgentService.updateAgent(n.AGENT_ID,{})})}};t.ChatProxyService=d,d.AGENT_ID="Default_Chat_Agent",r.__decorate([(0,o.Autowired)(g.IChatAgentService),r.__metadata("design:type",Object)],d.prototype,"chatAgentService",void 0),r.__decorate([(0,o.Autowired)(p.AIBackSerivcePath),r.__metadata("design:type",Object)],d.prototype,"aiBackService",void 0),r.__decorate([(0,o.Autowired)(p.ChatFeatureRegistryToken),r.__metadata("design:type",u.ChatFeatureRegistry)],d.prototype,"chatFeatureRegistry",void 0),r.__decorate([(0,o.Autowired)(m.MonacoCommandRegistry),r.__metadata("design:type",m.MonacoCommandRegistry)],d.prototype,"monacoCommandRegistry",void 0),r.__decorate([(0,o.Autowired)(p.ChatServiceToken),r.__metadata("design:type",h.ChatService)],d.prototype,"aiChatService",void 0),r.__decorate([(0,o.Autowired)(p.IAIReporter),r.__metadata("design:type",Object)],d.prototype,"aiReporter",void 0),r.__decorate([(0,o.Autowired)(p.ChatAgentViewServiceToken),r.__metadata("design:type",Object)],d.prototype,"chatAgentViewService",void 0),r.__decorate([(0,o.Autowired)(l.PreferenceService),r.__metadata("design:type",Object)],d.prototype,"preferenceService",void 0),r.__decorate([(0,o.Autowired)(p.IApplicationService),r.__metadata("design:type",Object)],d.prototype,"applicationService",void 0),r.__decorate([(0,o.Autowired)(_.IMessageService),r.__metadata("design:type",Object)],d.prototype,"messageService",void 0),r.__decorate([(0,o.Autowired)(l.AppConfig),r.__metadata("design:type",Object)],d.prototype,"appConfig",void 0),t.ChatProxyService=d=n=r.__decorate([(0,o.Injectable)()],d)},29770:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatService=void 0;const n=e(85608),r=e(76003),o=e(43718),l=e(63067),p=e(19413),v=e(59347);let m=class extends o.Disposable{constructor(){super(),this._onChatMessageLaunch=new o.Emitter,this.onChatMessageLaunch=this._onChatMessageLaunch.event,this._onChatReplyMessageLaunch=new o.Emitter,this.onChatReplyMessageLaunch=this._onChatReplyMessageLaunch.event,this._onChatMessageListLaunch=new o.Emitter,this.onChatMessageListLaunch=this._onChatMessageListLaunch.event,this._onScrollToBottom=new o.Emitter,this.onScrollToBottom=this._onScrollToBottom.event}showChatView(){this.mainLayoutService.toggleSlot(p.AI_CHAT_VIEW_ID,!0)}sendMessage(s){this.showChatView(),this._onChatMessageLaunch.fire(s)}clearHistoryMessages(){var s;(s=this.chatInternalService.sessionModel)===null||s===void 0||s.history.clearMessages()}sendReplyMessage(s){typeof s=="string"?this._onChatReplyMessageLaunch.fire({kind:"content",content:s}):this._onChatReplyMessageLaunch.fire(s)}sendMessageList(s){this._onChatMessageListLaunch.fire(s)}getHistoryMessages(s){var g;return((g=this.chatInternalService.sessionModel)===null||g===void 0?void 0:g.history.getMessages(s))||[]}scrollToBottom(){this._onScrollToBottom.fire()}};t.ChatService=m,n.__decorate([(0,r.Autowired)(p.IChatInternalService),n.__metadata("design:type",v.ChatInternalService)],m.prototype,"chatInternalService",void 0),n.__decorate([(0,r.Autowired)(l.IMainLayoutService),n.__metadata("design:type",Object)],m.prototype,"mainLayoutService",void 0),t.ChatService=m=n.__decorate([(0,r.Injectable)(),n.__metadata("design:paramtypes",[])],m)},11735:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatFeatureRegistry=void 0;const n=e(85608),r=e(76003),o=e(43718),l=e(19413),p=e(42033),v=e(51081);let m=class extends o.Disposable{constructor(){super(...arguments),this.logger=(0,o.getDebugLogger)(),this.slashCommandsMap=new Map,this.slashCommandsHandlerMap=new Map,this._onDidWelcomeMessageChange=new o.Emitter,this.onDidWelcomeMessageChange=this._onDidWelcomeMessageChange.event}dispose(){super.dispose(),this.slashCommandsMap.clear(),this.slashCommandsHandlerMap.clear()}registerWelcome(s,g){this.chatWelcomeMessageModel=new p.ChatWelcomeMessageModel(s,g),this._onDidWelcomeMessageChange.fire()}registerSlashCommand(s,g){const{name:a}=s;if(this.slashCommandsMap.has(a)){this.logger.warn(`ChatFeatureRegistry: commands name ${a} already exists`);return}this.slashCommandsMap.set(a,new p.ChatSlashCommandItemModel(s,a,v.ChatProxyService.AGENT_ID)),this.slashCommandsHandlerMap.set(a,g)}getSlashCommandHandler(s){return this.slashCommandsHandlerMap.get(s)}getSlashCommand(s){return this.slashCommandsMap.get(s)}getSlashCommandHandlerBySlashName(s){const g=this.getAllSlashCommand().find(a=>a.nameWithSlash===s);if(g)return this.getSlashCommandHandler(g.name)}getSlashCommandBySlashName(s){const g=this.getAllSlashCommand().find(a=>a.nameWithSlash===s);if(g)return this.getSlashCommand(g.name)}getAllSlashCommand(){return Array.from(this.slashCommandsMap.values())}getAllShortcutSlashCommand(){return this.getAllSlashCommand().filter(s=>s.isShortcut===!0)}parseSlashCommand(s){if(s.startsWith(l.SLASH_SYMBOL)){const g=this.getAllSlashCommand();for(const a of g){const{nameWithSlash:h}=a;if(s.startsWith(h))return{value:s.slice(h.length),nameWithSlash:h}}}return{value:s,nameWithSlash:""}}};t.ChatFeatureRegistry=m,t.ChatFeatureRegistry=m=n.__decorate([(0,r.Injectable)()],m)},59347:(L,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ChatInternalService=void 0;const r=e(85608),o=e(76003),l=e(41869),p=e(43718),v=e(19413),m=e(61282);let _=class extends p.Disposable{constructor(){super(...arguments),this._onChangeRequestId=new p.Emitter,this.onChangeRequestId=this._onChangeRequestId.event,this._onChangeSession=new p.Emitter,this.onChangeSession=this._onChangeSession.event,this._onCancelRequest=new p.Emitter,this.onCancelRequest=this._onCancelRequest.event,this._onRegenerateRequest=new p.Emitter,this.onRegenerateRequest=this._onRegenerateRequest.event,n.set(this,void 0)}get latestRequestId(){return this._latestRequestId}get sessionModel(){return r.__classPrivateFieldGet(this,n,"f")}init(){this.chatManagerService.onStorageInit(()=>{const g=this.chatManagerService.getSessions();g.length>0?this.activateSession(g[g.length-1].sessionId):this.createSessionModel()})}setLatestRequestId(g){this._latestRequestId=g,this._onChangeRequestId.fire(g)}createRequest(g,a,h){return this.chatManagerService.createRequest(r.__classPrivateFieldGet(this,n,"f").sessionId,g,a,h)}sendRequest(g,a=!1){const h=this.chatManagerService.sendRequest(r.__classPrivateFieldGet(this,n,"f").sessionId,g,a);return a&&this._onRegenerateRequest.fire(),h}cancelRequest(){this.chatManagerService.cancelRequest(r.__classPrivateFieldGet(this,n,"f").sessionId),this._onCancelRequest.fire()}createSessionModel(){r.__classPrivateFieldSet(this,n,this.chatManagerService.startSession(),"f"),this._onChangeSession.fire(r.__classPrivateFieldGet(this,n,"f").sessionId)}clearSessionModel(g){g=g||r.__classPrivateFieldGet(this,n,"f").sessionId,this.chatManagerService.clearSession(g),g===r.__classPrivateFieldGet(this,n,"f").sessionId&&r.__classPrivateFieldSet(this,n,this.chatManagerService.startSession(),"f"),this._onChangeSession.fire(r.__classPrivateFieldGet(this,n,"f").sessionId)}getSessions(){return this.chatManagerService.getSessions()}activateSession(g){const a=this.chatManagerService.getSession(g);if(!a)throw new Error(`There is no session with session id ${g}`);r.__classPrivateFieldSet(this,n,a,"f"),this._onChangeSession.fire(r.__classPrivateFieldGet(this,n,"f").sessionId)}dispose(){var g;(g=r.__classPrivateFieldGet(this,n,"f"))===null||g===void 0||g.dispose(),super.dispose()}};t.ChatInternalService=_,n=new WeakMap,r.__decorate([(0,o.Autowired)(p.AIBackSerivcePath),r.__metadata("design:type",Object)],_.prototype,"aiBackService",void 0),r.__decorate([(0,o.Autowired)(l.PreferenceService),r.__metadata("design:type",Object)],_.prototype,"preferenceService",void 0),r.__decorate([(0,o.Autowired)(v.IChatManagerService),r.__metadata("design:type",m.ChatManagerService)],_.prototype,"chatManagerService",void 0),t.ChatInternalService=_=r.__decorate([(0,o.Injectable)()],_)},70394:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatRenderRegistry=void 0;const n=e(85608),r=e(76003),o=e(43718);let l=class extends o.Disposable{registerWelcomeRender(v){this.chatWelcomeRender=v}registerAIRoleRender(v){this.chatAIRoleRender=v}registerUserRoleRender(v){this.chatUserRoleRender=v}registerThinkingRender(v){this.chatThinkingRender=v}registerInputRender(v){this.chatInputRender=v}registerThinkingResultRender(v){this.chatThinkingResultRender=v}registerChatViewHeaderRender(v){this.chatViewHeaderRender=v}};t.ChatRenderRegistry=l,t.ChatRenderRegistry=l=n.__decorate([(0,r.Injectable)()],l)},76154:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AIChatView=void 0,t.DefaultChatViewHeader=P;const n=e(85608),r=n.__importStar(e(14041)),o=e(68392),l=e(41869),p=e(81878),v=e(89195),m=e(43718),_=e(63067),s=e(72665);e(41937);const g=e(19413),a=e(46044),h=e(73307),u=e(27399),d=e(25834),E=n.__importDefault(e(90103)),f=e(57987),c=e(56474),b=e(92635),y=e(29039),S=e(78048),A=e(86556),w=e(30703),T=e(42033),D=e(51081),I=n.__importDefault(e(77256)),O="chat_scroll",M=100,R=()=>{const k=(0,l.useInjectable)(g.IChatInternalService),F=(0,l.useInjectable)(m.ChatServiceToken),x=(0,l.useInjectable)(m.IAIReporter),B=(0,l.useInjectable)(g.IChatAgentService),j=(0,l.useInjectable)(m.ChatFeatureRegistryToken),W=(0,l.useInjectable)(m.ChatRenderRegistryToken),U=(0,l.useInjectable)(a.LLMContextServiceToken),Z=(0,l.useInjectable)(h.ChatAgentPromptProvider),V=(0,l.useInjectable)(_.IMainLayoutService),$=k.sessionModel.history,Y=r.useRef(null),G=r.useRef(null),[H,K]=r.useState([]),[X,Q]=r.useReducer((et,St)=>{switch(St.type){case"add":return[...et,...St.payload||[]];case"clear":return[];case"init":return Array.isArray(St.payload)?St.payload:[];default:return et}},[]),[oe,ne]=r.useState(!1),[he,_e]=r.useState(""),[q,Oe]=r.useState(""),[ye,ie]=r.useState(""),[ge,Me]=r.useState(null);r.useEffect(()=>{const et=j.getAllShortcutSlashCommand(),St=B.onDidChangeAgents(()=>{const tt=B.getCommands().filter(yt=>yt.isShortcut).map(yt=>new T.ChatSlashCommandItemModel({icon:"",name:`${yt.name} `,description:yt.description,isShortcut:yt.isShortcut},yt.name,yt.agentId));K(et.concat(tt))});return K(et),()=>St.dispose()},[j,B]),(0,l.useUpdateOnEvent)(k.onChangeSession);const xe=r.useMemo(()=>W.chatInputRender?W.chatInputRender:f.ChatInput,[W.chatInputRender]),Ce=r.useMemo(()=>(0,S.createMessageByAI)({id:(0,m.uuid)(6),relationId:"",text:r.createElement(A.WelcomeMessage,null)}),[]),Ae=r.useCallback(()=>{if(Y&&Y.current){const et=Y.current.lastElementChild;et&&et.scrollIntoView({behavior:"smooth",block:"end"}),Y.current.scrollHeight>Y.current.clientHeight&&Y.current.classList.add(O)}},[Y]),ve=r.useCallback(et=>{Q(et),requestAnimationFrame(()=>{Ae()})},[Q,Ae]);r.useEffect(()=>{ve({type:"init",payload:[Ce]})},[]),r.useEffect(()=>{const et=new m.Disposable;return et.addDispose(F.onScrollToBottom(()=>{requestAnimationFrame(()=>{Ae()})})),et.addDispose(F.onChatMessageLaunch(async St=>{var tt;if(St.immediate!==!1){if(oe)return;await le(St)}else St.agentId&&_e(St.agentId),St.command&&ie(St.command),(tt=G?.current)===null||tt===void 0||tt.setInputValue(St.message)})),et.addDispose(F.onChatReplyMessageLaunch(St=>{if(St.kind==="content"){const tt=x.start(m.AIServiceType.CustomReplay,{message:St.content});$.addAssistantMessage({content:St.content,relationId:tt}),Fe({chunk:St.content,relationId:tt})}else{const tt=x.start(m.AIServiceType.CustomReplay,{message:"component#"+St.component});$.addAssistantMessage({componentId:St.component,componentValue:St.value,content:"",relationId:tt}),pe({chunk:St,relationId:tt})}})),et.addDispose(F.onChatMessageListLaunch(St=>{const tt=[];St.forEach(yt=>{const{role:it}=yt,ct=x.start(m.AIServiceType.Chat,{message:""});if(it==="assistant"){const ht=yt;tt.push((0,S.createMessageByAI)({id:(0,m.uuid)(6),relationId:ct,text:r.createElement(b.ChatNotify,{requestId:ct,chunk:ht})},I.default.chat_notify))}if(it==="user"){const{message:ht}=yt,At=D.ChatProxyService.AGENT_ID,Vt=W.chatUserRoleRender,Cn=At===D.ChatProxyService.AGENT_ID?"":At;tt.push((0,S.createMessageByUser)({id:(0,m.uuid)(6),relationId:ct,text:Vt?r.createElement(Vt,{content:ht,agentId:Cn}):r.createElement(d.CodeBlockWrapperInput,{relationId:ct,text:ht,agentId:Cn,command:ye})},I.default.chat_message_code))}}),ve({type:"add",payload:tt}),setTimeout(Ae,0)})),()=>et.dispose()},[F,W.chatAIRoleRender,$]),r.useEffect(()=>{const et=new m.Disposable;return et.addDispose(B.onDidSendMessage(St=>{const tt=St,yt=x.start(m.AIServiceType.Agent,{message:""}),it=(0,S.createMessageByAI)({id:(0,m.uuid)(6),relationId:yt,text:r.createElement(b.ChatNotify,{requestId:k.latestRequestId,chunk:tt})},I.default.chat_notify);ve({type:"add",payload:[it]})})),et.addDispose(B.onDidChangeAgents(async()=>{const St=B.getDefaultAgentId();Oe(St??"")})),()=>et.dispose()},[B,$,k]);const fe=r.useCallback(async et=>{const{userMessage:St,relationId:tt,requestId:yt,render:it,startTime:ct,command:ht,agentId:At}=et;$.addAssistantMessage({type:"component",content:""});const Vt=(0,S.createMessageByAI)({id:(0,m.uuid)(6),relationId:tt,className:I.default.chat_with_more_actions,text:r.createElement(y.SlashCustomRender,{userMessage:St,startTime:ct,relationId:tt,requestId:yt,renderContent:it,command:ht,agentId:At})});ve({type:"add",payload:[Vt]})},[Y,$]),Le=r.useCallback(async et=>{const St=W.chatUserRoleRender,{message:tt,agentId:yt,relationId:it,command:ct}=et,ht=yt===D.ChatProxyService.AGENT_ID?"":yt,At=(0,S.createMessageByUser)({id:(0,m.uuid)(6),relationId:it,text:St?r.createElement(St,{content:tt,agentId:ht,command:ct}):r.createElement(d.CodeBlockWrapperInput,{relationId:it,text:tt,agentId:ht,command:ct})},I.default.chat_message_code);ve({type:"add",payload:[At]})},[W,W.chatUserRoleRender,$,Ae]),Te=r.useCallback(async et=>{const{message:St,agentId:tt,request:yt,relationId:it,command:ct,startTime:ht,msgId:At}=et,Vt=tt===D.ChatProxyService.AGENT_ID?"":tt;if(tt===D.ChatProxyService.AGENT_ID&&ct){const Un=j.getSlashCommandHandler(ct);if(Un&&Un.providerRender)return ne(!1),fe({userMessage:St,render:Un.providerRender,relationId:it,requestId:yt.requestId,startTime:ht,agentId:tt,command:ct})}const Cn=(0,S.createMessageByAI)({id:(0,m.uuid)(6),relationId:it,className:I.default.chat_with_more_actions,text:r.createElement(b.ChatReply,{relationId:it,request:yt,startTime:ht,agentId:Vt,command:ct,onDidChange:()=>{Ae()},history:$,onDone:()=>{ne(!1)},onRegenerate:()=>{yt&&k.sendRequest(yt,!0)},msgId:At})});ve({type:"add",payload:[Cn]})},[W,$,Ae]),Fe=r.useCallback(et=>{const{chunk:St,relationId:tt}=et;let yt=r.createElement(c.ChatMarkdown,{markdown:St,fillInIncompleteTokens:!0,agentId:he,command:ye});if(W.chatAIRoleRender){const ct=W.chatAIRoleRender;yt=r.createElement(ct,{content:St})}const it=(0,S.createMessageByAI)({id:(0,m.uuid)(6),relationId:tt,text:yt,className:I.default.chat_with_more_actions});ve({type:"add",payload:[it]})},[W,$,Ae]),pe=r.useCallback(et=>{const{chunk:St,relationId:tt}=et,yt=(0,S.createMessageByAI)({id:(0,m.uuid)(6),relationId:tt,text:r.createElement(b.ChatNotify,{requestId:tt,chunk:St})},I.default.chat_notify);ve({type:"add",payload:[yt]})},[W,$,Ae]),re=r.useCallback(async et=>{const{message:St,agentId:tt,command:yt,reportExtra:it}=et,{actionType:ct,actionSource:ht}=it||{},At=U.serialize(),Vt=await Z.provideContextPrompt(At,St),Cn=k.createRequest(Vt,tt,yt);if(!Cn)return;ne(!0),k.setLatestRequestId(Cn.requestId);const Un=Date.now(),Ei=D.ChatProxyService.AGENT_ID===tt?m.AIServiceType.Chat:m.AIServiceType.Agent,Wn=x.start(yt||Ei,{message:St,agentId:tt,userMessage:St,actionType:ct,actionSource:ht});$.addUserMessage({content:St,agentId:tt,agentCommand:yt,relationId:Wn}),await Le({relationId:Wn,message:St,command:yt,agentId:tt}),k.sendRequest(Cn);const hn=$.addAssistantMessage({content:"",relationId:Wn,requestId:Cn.requestId,replyStartTime:Un});await Te({startTime:Un,relationId:Wn,message:St,agentId:tt,command:yt,request:Cn,msgId:hn})},[W,W.chatUserRoleRender,$,Ae]),le=r.useCallback(async et=>{const{message:St,command:tt,reportExtra:yt}=et,it=et.agentId?et.agentId:D.ChatProxyService.AGENT_ID;return re({message:St,agentId:it,command:tt,reportExtra:yt})},[re]),Ie=r.useCallback(()=>{k.clearSessionModel(),F.clearHistoryMessages(),Se()},[X]),Se=r.useCallback(()=>{var et;(et=Y?.current)===null||et===void 0||et.classList.remove(O),ve({type:"init",payload:[Ce]})},[X]),We=et=>{oe||(Me(et.nameWithSlash),_e(et.agentId),ie(et.command))},$e=r.useCallback(()=>{V.toggleSlot(g.AI_CHAT_VIEW_ID)},[V]),Ve=W.chatViewHeaderRender||P,mt=r.useCallback(async et=>{for(const St of $.getMessages()){if(et.isCancellationRequested)return;if(St.role===1)await Le({relationId:St.relationId,message:St.content,agentId:St.agentId,command:St.agentCommand});else if(St.role===2&&St.requestId){const tt=k.sessionModel.getRequest(St.requestId);tt&&!tt.response.isComplete&&ne(!0),await Te({msgId:St.id,relationId:St.relationId,message:St.content,agentId:St.agentId,command:St.agentCommand,startTime:St.replyStartTime,request:tt})}else St.role===2&&St.content?await Fe({relationId:St.relationId,chunk:St.content}):St.role===2&&St.componentId&&await pe({relationId:St.relationId,chunk:{kind:"component",component:St.componentId,value:St.componentValue}})}},[Te]);return r.useEffect(()=>{Se();const et=new m.CancellationTokenSource;return ne(!1),mt(et.token),()=>{et.cancel()}},[k.sessionModel]),r.createElement("div",{id:I.default.ai_chat_view},r.createElement("div",{className:I.default.header_container},r.createElement(Ve,{handleClear:Ie,handleCloseChatView:$e})),r.createElement("div",{className:I.default.body_container},r.createElement("div",{className:I.default.left_bar,id:"ai_chat_left_container"},r.createElement("div",{className:I.default.chat_container,ref:Y},r.createElement(o.MessageList,{className:I.default.message_list,lockable:!0,toBottomHeight:"100%",dataSource:X})),$.slicedMessageCount?r.createElement("div",{className:I.default.chat_tips_text},r.createElement("div",{className:I.default.chat_tips_container},(0,m.formatLocalize)("aiNative.chat.ai.assistant.limit.message",$.slicedMessageCount))):null,r.createElement("div",{className:I.default.chat_input_wrap},r.createElement(u.ChatContext,null),r.createElement("div",{className:I.default.header_operate},r.createElement("div",{className:I.default.header_operate_left},H.map(et=>r.createElement(p.Popover,{id:`ai-chat-shortcut-${et.name}`,key:`ai-chat-shortcut-${et.name}`,title:et.tooltip||et.name},r.createElement("div",{className:I.default.tag,onClick:()=>We(et)},et.name))))),r.createElement(xe,{onSend:(et,St,tt)=>le({message:et,agentId:St,command:tt,reportExtra:{actionSource:m.ActionSourceEnum.Chat,actionType:m.ActionTypeEnum.Send}}),disabled:oe,enableOptions:!0,theme:ge,setTheme:Me,agentId:he,setAgentId:_e,defaultAgentId:q,command:ye,setCommand:ie,ref:G})))))};t.AIChatView=R;function P({handleClear:k,handleCloseChatView:F}){const x=(0,l.useInjectable)(s.IDialogService),B=(0,l.useInjectable)(l.AINativeConfigService),j=(0,l.useInjectable)(g.TokenMCPServerProxyService),W=(0,l.useInjectable)(g.IChatInternalService),[U,Z]=r.useState([]),[V,$]=r.useState(""),Y=r.useCallback(()=>{W.sessionModel.history.getMessages().length>0&&W.createSessionModel()},[W]),G=r.useCallback(X=>{W.activateSession(X.id)},[W]),H=r.useCallback(X=>{W.clearSessionModel(X.id)},[W]),K=r.useCallback(async()=>{const X=await j.getAllMCPTools();x.open({message:r.createElement(w.MCPToolsDialog,{tools:X}),type:m.MessageType.Empty,buttons:["\u5173\u95ED"]})},[j,x]);return r.useEffect(()=>{const X=()=>{const ne=W.sessionModel.history.getMessages();$(ne.length>0?ne[ne.length-1].content.slice(0,M):""),Z(W.getSessions().map(he=>{const q=he.history.getMessages(),Oe=q.length>0?q[0].content.slice(0,M):"",ye=q.length>0&&q[q.length-1].replyStartTime||0;return{id:he.sessionId,title:Oe,updatedAt:ye,loading:!1}}))};X();const Q=new m.DisposableCollection,oe=new Set;return Q.push(W.onChangeSession(ne=>{X(),!oe.has(ne)&&(oe.add(ne),Q.push(W.sessionModel.history.onMessageChange(()=>{X()})))})),Q.push(W.sessionModel.history.onMessageChange(()=>{X()})),()=>{Q.dispose()}},[W]),r.createElement("div",{className:I.default.header},r.createElement(E.default,{className:I.default.chat_history,currentId:W.sessionModel.sessionId,title:V||(0,m.localize)("aiNative.chat.ai.assistant.name"),historyList:U,onNewChat:Y,onHistoryItemSelect:G,onHistoryItemDelete:H,onHistoryItemChange:()=>{}}),r.createElement(p.Popover,{overlayClassName:I.default.popover_icon,id:"ai-chat-header-clear",title:(0,m.localize)("aiNative.operate.clear.title")},r.createElement(v.EnhanceIcon,{wrapperClassName:I.default.action_btn,className:(0,l.getIcon)("clear"),onClick:k,tabIndex:0,role:"button",ariaLabel:(0,m.localize)("aiNative.operate.clear.title")})),B.capabilities.supportsMCP&&r.createElement(p.Popover,{overlayClassName:I.default.popover_icon,id:"ai-chat-header-tools",position:p.PopoverPosition.left,title:(0,m.localize)("aiNative.operate.tools.title")},r.createElement(v.EnhanceIcon,{wrapperClassName:I.default.action_btn,className:(0,l.getIcon)("menubar-tool"),onClick:K,tabIndex:0,role:"button",ariaLabel:(0,m.localize)("aiNative.operate.tools.title")})),r.createElement(p.Popover,{overlayClassName:I.default.popover_icon,id:"ai-chat-header-close",position:p.PopoverPosition.left,title:(0,m.localize)("aiNative.operate.close.title")},r.createElement(v.EnhanceIcon,{wrapperClassName:I.default.action_btn,className:(0,l.getIcon)("window-close"),onClick:F,tabIndex:0,role:"button",ariaLabel:(0,m.localize)("aiNative.operate.close.title")})))}},55369:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContextSelector=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=e(45250),l=n.__importStar(e(14041)),p=e(58998),v=e(41869),m=e(81878),_=e(95263),s=e(95422),g=e(15625),a=e(70392),h=n.__importDefault(e(97431)),u=(0,l.memo)(({uri:d,active:E,selected:f,onDidSelect:c,onDidDeselect:b})=>{var y;const S=(0,s.useInjectable)(v.LabelService),A=(0,s.useInjectable)(v.AppConfig),w=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(E&&w.current){const T={behavior:"instant",block:"end"};w.current.scrollIntoView(T)}},[E,w.current]),l.default.createElement("div",{className:(0,r.default)(h.default.candidate_file,E&&h.default.active),ref:T=>w.current=T,onClick:()=>f?b(d):c(d)},l.default.createElement(m.Icon,{iconClass:S.getIcon(d)}),l.default.createElement("span",{className:h.default.basename},d.path.base),l.default.createElement("span",{className:h.default.dir},(y=a.URI.file(A.workspaceDir).relative(d.parent))===null||y===void 0?void 0:y.toString()),f&&l.default.createElement(m.Icon,{icon:"check",style:{marginLeft:"auto",color:"var(--editorGutter-addedBackground)"}}))});t.ContextSelector=(0,l.memo)(({addedFiles:d,onDidDeselect:E,onDidSelect:f,onDidClose:c})=>{const[b,y]=(0,l.useState)([]),[S,A]=(0,l.useState)(null),[w,T]=(0,l.useState)(!1),[D,I]=(0,l.useState)([]),O=(0,s.useInjectable)(_.RecentFilesManager),M=(0,s.useInjectable)(v.AppConfig),R=(0,s.useInjectable)(g.FileSearchServicePath),P=(0,l.useRef)();(0,l.useEffect)(()=>{b.length===0&&O.getMostRecentlyOpenedFiles().then(x=>{const B=d.map(W=>W.uri),j=x.filter(W=>!B.includes(new a.URI(W))).map(W=>new a.URI(W));y(j),A(j[0]||null)})},[d]);const k=(0,l.useCallback)((0,o.debounce)(x=>{if(x.target.value.trim()===""){I([]),A(b[0]);return}T(!0),R.find(x.target.value,{rootUris:[M.workspaceDir],limit:200,useGitIgnore:!0,noIgnoreParent:!0,fuzzyMatch:!0}).then(B=>{const j=B.map(W=>new a.URI(W));I(j),A(j[0])}).finally(()=>{T(!1)})},500),[]),F=(0,l.useCallback)(x=>{const{key:B}=x;if(B==="Escape"){c();return}if(B==="Enter"&&S){f(S);return}if(!["ArrowUp","ArrowDown"].includes(B))return;const W=D.length>0?D:b;if(W.length===0)return;const U=W.indexOf(S),Z=U===-1?0:U,V=W.length-1,$=B==="ArrowUp"?Z>0?Z-1:V:Z<V?Z+1:0;A(W[$])},[S,D,b]);return l.default.createElement(p.ClickOutside,{mouseEvents:["click","contextmenu"],onOutsideClick:()=>c()},l.default.createElement("div",{className:h.default.context_selector,onKeyDown:F,tabIndex:-1},l.default.createElement("div",{style:{padding:"4px"}},l.default.createElement(m.Input,{placeholder:"Search files by name",autoFocus:!0,onInput:k})),l.default.createElement(m.Scrollbars,{forwardedRef:x=>x?P.current=x.ref:null},l.default.createElement("div",{className:h.default.context_list},w&&l.default.createElement("div",{className:h.default.context_search_layer}),l.default.createElement("span",{className:h.default.list_desc},D.length>0?"Search Results":"Recent Opened Files"),(D.length>0?D:b).map(x=>l.default.createElement(u,{key:x.toString(),uri:x,active:S===x,onDidSelect:f,onDidDeselect:E,selected:!!d.find(B=>B.uri.isEqual(x))}))))))})},27399:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatContext=void 0;const n=e(85608),r=n.__importStar(e(1171)),o=n.__importStar(e(14041));e(628);const l=e(80564),p=e(81878),v=e(89195),m=e(95422),_=e(11050),s=e(63214),g=e(33783),a=e(86560),h=e(82196),u=e(46044),d=e(55369),E=n.__importDefault(e(97431)),f=()=>({height:0,opacity:0}),c=S=>({height:S.scrollHeight,opacity:1}),b=S=>({height:S.offsetHeight}),y=(S,A)=>A.propertyName==="height";t.ChatContext=(0,o.memo)(()=>{const[S,A]=(0,o.useState)([]),[w,T]=(0,o.useState)(!1),D=(0,m.useInjectable)(s.LabelService),I=(0,m.useInjectable)(_.AppConfig),O=(0,m.useInjectable)(h.WorkbenchEditorService),M=(0,m.useInjectable)(u.LLMContextServiceToken);(0,o.useEffect)(()=>{const j=a.Event.debounce(M.onDidContextFilesChangeEvent,(W,U)=>U,50)(W=>{W&&A(W)},M);return()=>{j.dispose()}},[]);const R=(0,o.useCallback)(()=>{T(!0)},[S]),P=(0,o.useCallback)(j=>{M.addFileToContext(j,void 0,!0)},[]),k=(0,o.useCallback)(j=>{M.removeFileFromContext(j)},[]),F=(0,o.useCallback)(j=>{O.open(j)},[]),x=(0,o.useCallback)(j=>{j.stopPropagation(),j.preventDefault(),M.cleanFileContext()},[]),B=(0,o.useCallback)((j,W)=>{j.stopPropagation(),j.preventDefault(),k(W)},[]);return o.default.createElement("div",{className:E.default.chat_context},o.default.createElement(r.default,{expandIcon:({isActive:j})=>j?o.default.createElement(l.Icon,{icon:"down"}):o.default.createElement(l.Icon,{icon:"right"}),openMotion:{motionName:"rc-collapse-motion",onEnterStart:f,onEnterActive:c,onLeaveStart:b,onLeaveActive:f,onEnterEnd:y,onLeaveEnd:y,motionDeadline:100,leavedClassName:E.default.collapse_hide}},o.default.createElement(r.Panel,{header:o.default.createElement("div",{className:E.default.context_header},o.default.createElement("h3",{className:E.default.chat_context_title},"Context ",S.length>0?` (${S.length} files)`:""),o.default.createElement(p.Popover,{overlayClassName:E.default.popover_icon,id:"ai-context-header-clear",title:(0,g.localize)("aiNative.operate.clear.title")},o.default.createElement(v.EnhanceIcon,{wrapperClassName:E.default.action_btn,className:(0,p.getIcon)("clear"),onClick:x,tabIndex:0,role:"button",ariaLabel:(0,g.localize)("aiNative.operate.clear.title")}))),key:"context-panel"},o.default.createElement("div",{className:E.default.file_list},S.map(j=>{var W;return o.default.createElement("div",{className:E.default.selected_item,key:j.uri.toString(),onClick:()=>F(j.uri)},o.default.createElement(l.Icon,{iconClass:D.getIcon(j.uri)}),o.default.createElement("span",{className:E.default.basename},j.uri.path.base,j.selection?` (${j.selection[0]}-${j.selection[1]})`:""),o.default.createElement("span",{className:E.default.dir},(W=a.URI.file(I.workspaceDir).relative(j.uri.parent))===null||W===void 0?void 0:W.toString()),o.default.createElement(l.Icon,{icon:"close",className:E.default.close_icon,onClick:U=>B(U,j.uri)}))})),o.default.createElement("div",{className:E.default.add_context,onClick:R},o.default.createElement(l.Icon,{icon:"add"}),"Add Files"))),w&&o.default.createElement(d.ContextSelector,{onDidClose:()=>T(!1),onDidDeselect:k,onDidSelect:P,addedFiles:S}))})},25834:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CodeBlockWrapperInput=t.CodeBlockWrapper=t.CodeEditorWithHighlight=void 0;const n=e(85608),r=n.__importDefault(e(56005)),o=n.__importStar(e(14041)),l=n.__importDefault(e(10580)),p=e(41869),v=e(81878),m=e(89195),_=e(43718),s=e(71624),g=e(9447),a=e(52416),h=n.__importDefault(e(6960)),u=e(83933);e(38191);const d=b=>{const{input:y,language:S,relationId:A,agentId:w,command:T,hideInsert:D}=b,I=o.default.useRef(null),O=(0,p.useInjectable)(g.MonacoCommandRegistry),M=(0,p.useInjectable)(p.IClipboardService),R=(0,p.useInjectable)(a.IThemeService),P=(0,p.useInjectable)(_.IAIReporter),[k,F]=(0,o.useState)(!1),x=(0,o.useMemo)(()=>(0,p.uuid)(12),[I,I.current]);(0,o.useEffect)(()=>{const W=V=>{V.type==="dark"||V.type==="hcDark"?e.e(622).then(e.bind(e,51622)):(V.type==="light"||V.type==="hcLight")&&e.e(412).then(e.bind(e,50412))},U=R.onThemeChange(V=>{W(V)}),Z=R.getCurrentThemeSync();return W(Z),()=>U.dispose()},[]);const B=(0,o.useCallback)(async()=>{F(!0),await M.writeText(y),P.end(A,{copy:!0,code:y,language:S,agentId:w,command:T,actionSource:_.ActionSourceEnum.Chat,actionType:_.ActionTypeEnum.ChatCopyCode}),(0,_.runWhenIdle)(()=>{F(!1)},1e3)},[M,y,A]),j=(0,o.useCallback)(()=>{const W=O.getActiveCodeEditor();if(W){const U=W.getSelection();U&&((0,s.insertSnippetWithMonacoEditor)(W,y,[U],{undoStopBefore:!1,undoStopAfter:!1}),P.end(A,{insert:!0,code:y,language:S,agentId:w,command:T,actionSource:_.ActionSourceEnum.Chat,actionType:_.ActionTypeEnum.ChatInsertCode}))}},[O]);return o.default.createElement("div",{className:h.default.monaco_wrapper},o.default.createElement("div",{className:h.default.action_toolbar},!D&&o.default.createElement(v.Popover,{id:`ai-chat-inser-${x}`,title:(0,_.localize)("aiNative.chat.code.insert")},o.default.createElement(m.EnhanceIcon,{className:(0,p.getIcon)("insert"),onClick:()=>j(),tabIndex:0,role:"button",ariaLabel:(0,_.localize)("aiNative.chat.code.insert")})),o.default.createElement(v.Popover,{id:`ai-chat-copy-${x}`,title:(0,_.localize)(k?"aiNative.chat.code.copy.success":"aiNative.chat.code.copy")},o.default.createElement(m.EnhanceIcon,{className:(0,p.getIcon)("copy"),onClick:()=>B(),tabIndex:0,role:"button",ariaLabel:(0,_.localize)("aiNative.chat.code.copy")}))),o.default.createElement(l.default,{language:S,ref:I,className:h.default.editor},y))};t.CodeEditorWithHighlight=d;const E=({content:b="",relationId:y,renderText:S,agentId:A="",command:w=""})=>{const T=/`([^`]+)`/g,D=/```([^]+?)```/g,I=/```([^]+)?/g,O=R=>{const P=R.split(`
|
|
29291
29291
|
`)[0].trim().toLowerCase(),k=u.highLightLanguageSupport.find(F=>F===P)||"plaintext";return R=R.replace(/.*?\n/,""),R=R.trim(),o.default.createElement("div",{className:h.default.code_block},o.default.createElement("div",{className:h.default.code_language},(0,r.default)(k)),o.default.createElement(t.CodeEditorWithHighlight,{input:R,language:P,relationId:y,agentId:A,command:w}))},M=(0,o.useMemo)(()=>{const R=b.split(D),P=[];return R.map((k,F)=>{F%2===0?k.split(T).map((x,B)=>{if(B%2===0){if(x.includes("```")){const j=x.split(I).filter(Boolean);if(j.length===2){P.push(j[0]),P.push(O(j[1]));return}}S?P.push(S(x)):P.push(x)}else P.push(o.default.createElement("span",{className:h.default.code_inline,key:B},x))}):P.push(O(k))}),P},[b,S]);return o.default.createElement(o.default.Fragment,null,M)},f=({text:b,renderText:y,relationId:S,agentId:A})=>o.default.createElement("div",{className:h.default.ai_chat_code_wrapper},o.default.createElement("div",{className:h.default.render_text},o.default.createElement(E,{content:b,renderText:y,relationId:S,agentId:A})));t.CodeBlockWrapper=f;const c=({text:b,relationId:y,agentId:S,command:A})=>{const w=(0,p.useInjectable)(_.ChatFeatureRegistryToken),[T,D]=(0,o.useState)(""),[I,O]=(0,o.useState)(b);return o.default.useEffect(()=>{const{value:M,nameWithSlash:R}=w.parseSlashCommand(b);if(R){D(R),O(M);return}else O(b)},[b,w]),o.default.createElement("div",{className:h.default.ai_chat_code_wrapper},o.default.createElement("div",{className:h.default.render_text},T&&o.default.createElement("div",{className:h.default.tag_wrapper},o.default.createElement("span",{className:h.default.tag},T)),S&&o.default.createElement("div",{className:h.default.tag,style:{marginRight:4}},"@",S),A&&o.default.createElement("div",{className:h.default.tag},"/ ",A),o.default.createElement(E,{content:I,relationId:y,agentId:S,command:A})))};t.CodeBlockWrapperInput=c},90103:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),l=e(97267);e(84183);const p=e(41869),v=e(89195),m=100,_=(0,o.memo)(({title:s,historyList:g,currentId:a,onNewChat:h,onHistoryItemSelect:u,onHistoryItemChange:d,onHistoryItemDelete:E,className:f})=>{const[c,b]=(0,o.useState)(null),[y,S]=(0,o.useState)(""),A=(0,o.useRef)(null),w=(0,o.useCallback)(j=>{S(j.target.value)},[y]),T=(0,o.useCallback)(j=>{u(j),S("")},[u,y]),D=(0,o.useCallback)(j=>{b({[j.id]:!0})},[c]),I=(0,o.useCallback)((j,W)=>{b({[j.id]:!1}),d(j,W)},[d,c]),O=(0,o.useCallback)(j=>{b({[j.id]:!1})},[c]),M=(0,o.useCallback)(()=>{h()},[h]);(0,o.useEffect)(()=>{var j;c&&((j=A.current)===null||j===void 0||j.focus({cursor:"end"}))},[c]);const R=(0,o.useCallback)(j=>{E(j)},[E]),P=(0,o.useCallback)(j=>{if(j<60*60*1e3){const U=Math.floor(j/6e4);return U===0?"Just now":`${U}m ago`}else{if(j<24*60*60*1e3)return`${Math.floor(j/36e5)}h ago`;if(j<7*24*60*60*1e3)return`${Math.floor(j/864e5)}d ago`;if(j<30*24*60*60*1e3)return`${Math.floor(j/6048e5)}w ago`;if(j<365*24*60*60*1e3)return`${Math.floor(j/2592e6)}mo ago`}return`${Math.floor(j/(365*24*60*60*1e3))}y ago`},[]),k=(0,o.useCallback)(j=>{const W=new Date,U=[];return j.forEach(Z=>{const V=new Date(Z.updatedAt),$=W.getTime()-V.getTime(),Y=P($),G=U.find(H=>H.key===Y);G?G.items.push(Z):U.push({key:Y,items:[Z]})}),U},[P]),F=(0,o.useCallback)(j=>o.default.createElement("div",{key:j.id,className:(0,r.default)("dm-chat-history-item",j.id===a?"dm-chat-history-item-selected":""),onClick:()=>T(j)},o.default.createElement("div",{className:"dm-chat-history-item-content"},j.loading?o.default.createElement(l.Loading,null):o.default.createElement(l.Icon,{icon:"message",style:{width:"16px",height:"16px",marginRight:4}}),c?.[j.id]?o.default.createElement(l.Input,{className:"dm-chat-history-item-title",defaultValue:j.title,ref:A,onPressEnter:W=>{I(j,W.target.value)},onBlur:()=>O(j)}):o.default.createElement("span",{id:`dm-chat-history-item-title-${j.id}`,className:"dm-chat-history-item-title"},j.title)),o.default.createElement("div",{className:"dm-chat-history-item-actions"},o.default.createElement(v.EnhanceIcon,{className:(0,r.default)("dm-chat-history-item-actions-delete",(0,l.getIcon)("delete")),onClick:W=>{W.preventDefault(),W.stopPropagation(),R(j)},ariaLabel:(0,p.localize)("aiNative.operate.chatHistory.delete")}))),[c,T,I,O,D,R,a,A]),x=(0,o.useCallback)(()=>{const j=g.slice(0,m).filter(U=>U.title&&U.title.includes(y)),W=k(j);return o.default.createElement("div",null,o.default.createElement(l.Input,{placeholder:(0,p.localize)("aiNative.operate.chatHistory.searchPlaceholder"),style:{width:"100%",maxWidth:"100%"},value:y,onChange:w}),o.default.createElement("div",{className:"dm-chat-history-list"},W.map(U=>o.default.createElement("div",{key:U.key,style:{padding:"4px"}},o.default.createElement("div",{className:"dm-chat-history-time"},U.key),U.items.map(F)))))},[g,y,k,w,F]),B=(0,o.useCallback)(j=>j.parentElement,[]);return o.default.createElement("div",{className:(0,r.default)("dm-chat-history-header",f)},o.default.createElement("div",{className:"dm-chat-history-header-title"},o.default.createElement("span",null,s)),o.default.createElement("div",{className:"dm-chat-history-header-actions"},o.default.createElement(l.Popover,{id:"dm-chat-history-header-actions-history",content:x(),trigger:l.PopoverTriggerType.click,position:l.PopoverPosition.bottomRight,title:(0,p.localize)("aiNative.operate.chatHistory.title"),getPopupContainer:B},o.default.createElement("div",{className:"dm-chat-history-header-actions-history",title:(0,p.localize)("aiNative.operate.chatHistory.title")},o.default.createElement(v.EnhanceIcon,{className:(0,r.default)("dm-chat-history-header-actions-history","codicon codicon-history")}))),o.default.createElement(l.Popover,{id:"ai-chat-header-close",position:l.PopoverPosition.top,title:(0,p.localize)("aiNative.operate.newChat.title")},o.default.createElement(v.EnhanceIcon,{className:(0,r.default)("dm-chat-history-header-actions-new",(0,l.getIcon)("plus")),onClick:M}))))});t.default=_},57987:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatInput=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),l=e(41869),p=e(81878),v=e(89195),m=e(83913),_=e(43718),s=e(9447),g=e(19413),a=e(42033),h=e(51081),u=n.__importDefault(e(6960)),d=8,E=68,f=({icon:S,name:A,description:w,agentId:T,command:D,selectedAgentId:I})=>{const O=(0,o.useMemo)(()=>!I&&T&&T!==h.ChatProxyService.AGENT_ID&&D?o.default.createElement("span",{className:u.default.agent_label},"@",T):null,[]);return o.default.createElement("div",{className:u.default.block},S&&o.default.createElement(v.EnhanceIcon,{className:S}),A&&o.default.createElement("span",{className:u.default.name},A),w&&o.default.createElement("span",{className:u.default.text},w),O)},c=({onClick:S,bottom:A,trigger:w,agentId:T})=>{const D=(0,l.useInjectable)(g.IChatAgentService),I=(0,l.useInjectable)(_.ChatAgentViewServiceToken),O=(0,o.useMemo)(()=>w===g.AT_SIGN_SYMBOL?I.getRenderAgents().map(R=>new a.ChatSlashCommandItemModel({icon:"",name:`${g.AT_SIGN_SYMBOL}${R.id} `,description:R.metadata.description},"",R.id)):D.getCommands().map(R=>new a.ChatSlashCommandItemModel({icon:"",name:`${g.SLASH_SYMBOL} ${R.name} `,description:R.description},R.name,R.agentId)).filter(R=>!T||R.agentId===T),[w,D]),M=(0,o.useCallback)((R,P,k)=>{S&&S(R||"",P,k)},[S]);return O.length===0?null:o.default.createElement("div",{className:u.default.instruction_options_container,style:{bottom:A+"px"}},o.default.createElement("div",{className:u.default.options},o.default.createElement("ul",null,O.map(({icon:R,name:P,nameWithSlash:k,description:F,agentId:x,command:B})=>o.default.createElement("li",{key:`${x||""}-${P}`,onMouseDown:()=>M(k,x,B)},o.default.createElement(f,{icon:R,name:P,description:F,agentId:x,command:B,selectedAgentId:T}))))))},b=({themeBlock:S})=>o.default.createElement("div",{className:u.default.theme_container},o.default.createElement("div",{className:u.default.theme_block},S)),y=({agentId:S,command:A})=>o.default.createElement("div",{className:u.default.theme_container},S!==h.ChatProxyService.AGENT_ID&&o.default.createElement("div",{className:u.default.theme_block,style:{marginRight:4}},"@",S),A&&o.default.createElement("div",{className:u.default.theme_block},g.SLASH_SYMBOL," ",A));t.ChatInput=o.default.forwardRef((S,A)=>{const{onSend:w,onValueChange:T,enableOptions:D=!1,disabled:I=!1,defaultHeight:O=32,autoFocus:M,setTheme:R,theme:P,setAgentId:k,agentId:F,defaultAgentId:x,setCommand:B,command:j,sendBtnClassName:W}=S,U=F||x,Z=(0,o.useRef)(null),V=(0,o.useRef)(null),[$,Y]=(0,o.useState)(S.value||""),[G,H]=(0,o.useState)(!1),[K,X]=(0,o.useState)(O),[Q,oe]=(0,o.useState)(!1),[ne,he]=(0,o.useState)(!1),[_e,q]=(0,o.useState)(!1),[Oe,ye]=(0,o.useState)((0,_.localize)("aiNative.chat.input.placeholder.default")),ie=(0,l.useInjectable)(s.MonacoCommandRegistry),ge=(0,l.useInjectable)(g.IChatAgentService),Me=(0,l.useInjectable)(_.ChatFeatureRegistryToken),xe=(0,l.useLatest)(U);(0,o.useImperativeHandle)(A,()=>({setInputValue:le=>{Y(le),(0,_.runWhenIdle)(()=>{var Ie;(Ie=Z.current)===null||Ie===void 0||Ie.focus()},120)}})),(0,o.useEffect)(()=>{S.value!==$&&Y(S.value||"")},[S.value]),(0,o.useEffect)(()=>{var le;(le=Z.current)===null||le===void 0||le.focus();const Ie=(0,_.localize)("aiNative.chat.input.placeholder.default"),Se=Me.getSlashCommandHandler(j);if(Se&&Se.providerInputPlaceholder){const We=ie.getActiveCodeEditor(),$e=Se.providerInputPlaceholder($,We);ye($e||Ie)}else ye(Ie)},[Me,j]),(0,o.useEffect)(()=>{ve(P||"",U,j)},[P,U,j]),(0,o.useEffect)(()=>{var le;Z&&M&&((le=Z.current)===null||le===void 0||le.focus())},[Z,M,S.value]),(0,o.useEffect)(()=>{if(D&&(($===g.SLASH_SYMBOL||$===g.AT_SIGN_SYMBOL&&ge.getAgents().length>0)&&!_e?H(!0):H(!1)),$.startsWith(g.SLASH_SYMBOL)){const{value:le,nameWithSlash:Ie}=Me.parseSlashCommand($);if(Ie){const Se=Me.getSlashCommandBySlashName(Ie);Y(le),R(Ie),Se&&(k(Se.agentId),B(Se.command));return}}if(ge.getAgents().length){const le=ge.parseMessage($,xe.current);(le.agentId||le.command)&&(R(""),Y(le.message),le.agentId&&k(le.agentId),le.command&&B(le.command))}},[Z,$,D,Me]),(0,o.useEffect)(()=>{$||(X(O),he(!1),q(!1))},[$]);const Ce=(0,o.useCallback)(le=>{Y(le),T&&T(le)},[]),Ae=(0,o.useCallback)(async()=>{if(I)return;const le=(Ie=$)=>{w(Ie,U,j),Y(""),R(""),k(""),B("")};if(j){const Ie=Me.getSlashCommandHandler(j);if(Ie&&Ie.execute){const Se=ie.getActiveCodeEditor();await Ie.execute($,We=>le(We),Se);return}}le()},[w,$,U,j,Me]),ve=(0,o.useCallback)((le,Ie,Se)=>{if(Ie){if(H(!1),R(""),k(Ie),B(Se||""),Z?.current){const We=Z.current.value;(We===g.AT_SIGN_SYMBOL||Se&&We===g.SLASH_SYMBOL)&&Y(""),(0,_.runWhenIdle)(()=>Z.current.focus())}}else if(le){H(!1),k(""),B("");const We=Me.getSlashCommandBySlashName(le);if(R(We?We.nameWithSlash:""),Z&&Z.current){const $e=Z.current.value;$e.length===1&&$e.startsWith(g.SLASH_SYMBOL)&&Y(""),(0,_.runWhenIdle)(()=>Z.current.focus())}}},[Z,Me]),fe=(0,o.useMemo)(()=>{const le=d+K;return _e&&H(!1),le},[K]),Le=le=>{var Ie,Se;if(le.key==="Backspace"&&((Ie=Z.current)===null||Ie===void 0?void 0:Ie.selectionEnd)===0&&((Se=Z.current)===null||Se===void 0?void 0:Se.selectionStart)===0){if(R(""),U===h.ChatProxyService.AGENT_ID){B(""),k("");return}U&&(j?B(""):k(""))}},Te=(0,o.useCallback)(le=>{X(le),le>E?he(!0):he(!1)},[]),Fe=(0,o.useCallback)(()=>{oe(!1),H(!1)},[Z]),pe=(0,o.useCallback)(()=>{oe(!0)},[Z]),re=(0,o.useCallback)(()=>{const le=_e;if(q(!le),le)X(O),he(!1);else{const Se=document.querySelector("#ai_chat_left_container").clientHeight-68-(P?32:0)-16;X(Se)}},[_e]);return o.default.createElement("div",{className:(0,r.default)(u.default.chat_input_container,Q?u.default.active:null)},G&&o.default.createElement("div",{ref:V},o.default.createElement(c,{onClick:ve,bottom:fe,trigger:$,agentId:U})),P&&o.default.createElement(b,{themeBlock:P}),U&&o.default.createElement(y,{agentId:U,command:j}),ne&&o.default.createElement("div",{className:u.default.expand_icon,onClick:()=>re()},o.default.createElement(p.Popover,{id:"ai_chat_input_expand",title:(0,_.localize)(_e?"aiNative.chat.expand.unfullscreen":"aiNative.chat.expand.fullescreen")},o.default.createElement(p.Icon,{className:(0,r.default)(_e?(0,p.getIcon)("unfullscreen"):(0,p.getIcon)("fullescreen"))}))),o.default.createElement(m.InteractiveInput,{ref:Z,placeholder:Oe,value:$,onKeyDown:Le,onBlur:Fe,onFocus:pe,onValueChange:Ce,disabled:I,className:u.default.input_wrapper,onSend:Ae,sendBtnClassName:W,onHeightChange:Te,height:K,popoverPosition:p.PopoverPosition.left}))})},56474:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatMarkdown=void 0,t.postProcessCodeBlockLanguageId=a,t.fillInIncompleteTokens=h;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),l=e(13719),p=e(84605),v=e(41869),m=e(90684),_=e(25834),s=n.__importDefault(e(6960)),g=I=>{const O=(0,o.useRef)(null),M=(0,v.useInjectable)(v.AppConfig),[R,P]=(0,o.useState)(),[k,F]=(0,o.useState)();return(0,o.useEffect)(()=>{var x,B;if(!O.current)return;const W=typeof I.markdown=="string"?new m.MarkdownString(I.markdown):I.markdown,U=new l.MarkdownReactRenderer;U.code=(H,K)=>{const X=a(K);return o.default.createElement("div",{className:s.default.code},o.default.createElement(v.ConfigProvider,{value:M},o.default.createElement("div",{className:s.default.code_block},o.default.createElement("div",{className:(0,r.default)(s.default.code_language,"language-badge")},X),o.default.createElement(_.CodeEditorWithHighlight,{input:H,language:X,relationId:I.relationId||"",agentId:I.agentId,command:I.command,hideInsert:I.hideInsert}))))},U.codespan=H=>o.default.createElement("code",{className:s.default.code_inline},H);const Z=new l.MarkdownReactParser({renderer:U}),V=(x=I.markedOptions)!==null&&x!==void 0?x:{};V.renderer=Z;let $=(B=W.value)!==null&&B!==void 0?B:"";$.length>1e5&&($=`${$.slice(0,1e5)}\u2026`);let Y,G;if(I.fillInIncompleteTokens){const H={...p.marked.defaults,...V},K=p.marked.lexer($,H),X=h(K);Y=p.marked.parser(X,H),G=X}else{const H=p.marked.lexer($,p.marked.defaults);Y=p.marked.parser(H,V),G=H}F(G),P(Z)},[I.markdown]),o.default.createElement("div",{className:(0,r.default)(s.default.markdown_container,I.className),ref:O,tabIndex:0},k&&R&&R.parse(k))};t.ChatMarkdown=g;function a(I){if(!I)return"";const O=I.split(/[\s+|:|,|\{|\?]/,1);return O.length?O[0]:I}function h(I){let O,M;for(O=0;O<I.length;O++){const R=I[O];if(R.type==="paragraph"&&R.raw.match(/(\n|^)```/)){M=u(I.slice(O));break}if(R.type==="paragraph"&&R.raw.match(/(\n|^)\|/)){M=w(I.slice(O));break}if(R.type==="paragraph"&&O===I.length-1){const P=D(R);if(P){M=[P];break}}}if(M){const R=[...I.slice(0,O),...M];return R.links=I.links,R}return I}function u(I){const O=T(I);return p.marked.lexer(O+"\n```")}function d(I){return A(I,"`")}function E(I){return A(I,"*")}function f(I){return A(I,"_")}function c(I){return A(I,")")}function b(I){return A(I,"](about:blank)")}function y(I){return A(I,"**")}function S(I){return A(I,"__")}function A(I,O){const M=T(Array.isArray(I)?I:[I]);return p.marked.lexer(M+O)[0]}function w(I){const O=T(I),M=O.split(`
|
|
29292
29292
|
`);let R=0,P=!1;for(let k=0;k<M.length;k++){const F=M[k].trim();if(typeof R>"u"&&F.match(/^\s*\|/)){const x=F.match(/(\|[^\|]+)(?=\||$)/g);x&&(R=x.length)}else if(typeof R=="number")if(F.match(/^\s*\|/)&&k===M.length-1)P=!0;else return}if(R>0){const k=P?M.slice(0,-1).join(`
|
|
29293
29293
|
`):O,F=!!k.match(/\|\s*$/),x=k+(F?"":"|")+`
|
|
29294
29294
|
|${" --- |".repeat(R)}`;return p.marked.lexer(x)}}function T(I){return I.reduce((O,M)=>O+M.raw,"")}function D(I){for(const{type:O,raw:M}of I.tokens){if(O!=="text")continue;const R=M.split(`
|
|
29295
|
-
`),P=R[R.length-1],k=[{condition:P.includes("`"),action:d},{condition:P.includes("**"),action:y},{condition:P.match(/\*\w/),action:E},{condition:P.match(/(^|\s)__\w/),action:S},{condition:P.match(/(^|\s)_\w/),action:f},{condition:P.match(/(^|\s)\[.*\]\(\w*/),action:c},{condition:P.match(/(^|\s)\[\w/),action:b}];for(const F of k)if(F.condition)return F.action(I)}}},92635:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatNotify=t.ChatReply=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(48412),l=e(91416),p=e(78569),v=e(72871),m=e(41869),_=e(81878),s=e(89195),g=e(43718),a=e(52416),h=e(90684),u=e(19413),d=e(56474),E=e(17319),f=n.__importDefault(e(6960)),c=w=>{const T=(0,m.useInjectable)(m.LabelService),D=(0,m.useInjectable)(m.CommandService),I=(F,x,B)=>{let j=T.getIcon(F,{isDirectory:x});return x&&B&&(j+=" expanded"),j},O=(0,r.useMemo)(()=>{const F=x=>{const B=typeof x.type=="number"?x.type===g.FileType.Directory:!!x.children,j=new g.URI(x.uri);return{label:x.label,iconClassName:I(j,B,B),expandable:!0,expanded:!0,children:B?(x.children||[]).map(F):null,uri:j}};return(w.treeData.children||[]).map(F)},[w.treeData]),[M,R]=(0,r.useState)(22),P=(0,r.useRef)(null),k=F=>{P.current=F;const x=()=>{let B=F.getModel().root.branchSize;B<1?B=1:B>20&&(B=20),R(B*22)};x(),F.onDidUpdate(x)};return O.length?r.default.createElement("div",{className:f.default.tree_container},r.default.createElement(l.BasicRecycleTree,{height:M,treeData:O,onContextMenu:F=>F.preventDefault(),onClick:(F,x)=>{!P.current||!x||(p.BasicCompositeTreeNode.is(x)?x.raw.iconClassName=I(x.raw.uri,!0,x.expanded):D.executeCommand(m.EDITOR_COMMANDS.OPEN_RESOURCE.id,x.raw.uri,{disableNavigate:!0,preview:!0}))},onReady:k,treeName:w.treeData.label,leaveBottomBlank:!1,baseIndent:0})):null},b=w=>{const{toolCall:T,messageId:D}=w,I=(0,m.useInjectable)(g.ChatAgentViewServiceToken),[O,M]=(0,r.useState)(null);return(0,r.useEffect)(()=>{const R=I.getChatComponent("toolCall");if(R){const{component:k,initialProps:F}=R;M(r.default.createElement(k,{...F,value:T,messageId:D}));return}M(r.default.createElement("div",null,r.default.createElement(s.Loading,null),r.default.createElement("span",{style:{marginLeft:4}},"\u6B63\u5728\u52A0\u8F7D\u7EC4\u4EF6"))),I.getChatComponentDeferred("toolCall").promise.then(({component:k,initialProps:F})=>{M(r.default.createElement(k,{...F,value:T,messageId:D}))})},[T.state]),O},y=w=>{const T=(0,m.useInjectable)(g.ChatAgentViewServiceToken),[D,I]=(0,r.useState)(null);return(0,r.useEffect)(()=>{const O=T.getChatComponent(w.component);if(O){const{component:R,initialProps:P}=O;I(r.default.createElement(R,{...P,value:w.value,messageId:w.messageId}));return}I(r.default.createElement("div",null,r.default.createElement(s.Loading,null),r.default.createElement("span",{style:{marginLeft:4}},"\u6B63\u5728\u52A0\u8F7D\u7EC4\u4EF6"))),T.getChatComponentDeferred(w.component).promise.then(({component:R,initialProps:P})=>{I(r.default.createElement(R,{...P,value:w.value}))})},[w.component,w.value]),D},S=w=>{var T,D;const{relationId:I,request:O,startTime:M=0,onRegenerate:R,onDidChange:P,onDone:k,agentId:F,command:x,history:B,msgId:j}=w,[,W]=(0,r.useReducer)(q=>(q+1)%1e6,0),U=(0,m.useInjectable)(g.IAIReporter),Z=(0,m.useInjectable)(a.IIconService),V=(0,m.useInjectable)(m.IContextKeyService),$=(0,m.useInjectable)(u.IChatInternalService),Y=(0,m.useInjectable)(g.ChatServiceToken),G=(0,m.useInjectable)(u.IChatAgentService),H=(0,m.useInjectable)(g.ChatRenderRegistryToken);(0,r.useEffect)(()=>{const q=new m.DisposableCollection;return q.push(O.response.onDidChange(()=>{B.updateAssistantMessage(j,{content:O.response.responseText}),O.response.isComplete&&(k&&k(),U.end(I,{assistantMessage:O.response.responseText,replytime:Date.now()-M,success:!0,isStop:!1,command:x,agentId:F})),(0,r.startTransition)(()=>{P?.(),W()})})),()=>q.dispose()},[I,P,k]);const K=(0,r.useCallback)(()=>{O.response.reset(),R?.()},[R]),X=()=>{k&&k(),U.end(I,{assistantMessage:O.response.responseText,replytime:Date.now()-M,success:!1,isStop:!0,command:x,agentId:F}),$.cancelRequest()},Q=(0,r.useCallback)(q=>{if(H.chatAIRoleRender){const Oe=H.chatAIRoleRender;return r.default.createElement(Oe,{content:q.value})}return r.default.createElement(d.ChatMarkdown,{markdown:q,fillInIncompleteTokens:!0})},[H,H.chatAIRoleRender]),oe=q=>r.default.createElement(c,{treeData:q}),ne=q=>r.default.createElement("div",{className:f.default.placeholder},r.default.createElement(_.Icon,{iconClass:Z.fromString("$(codicon/sync~spin)")}),r.default.createElement("div",{className:f.default.placeholder_content},Q(q))),he=r.default.useMemo(()=>O.response.responseContents.map((q,Oe)=>{let ye;return q.kind==="asyncContent"?ye=ne(new h.MarkdownString(q.content)):q.kind==="treeData"?ye=oe(q.treeData):q.kind==="component"?ye=r.default.createElement(y,{component:q.component,value:q.value,messageId:j}):q.kind==="toolCall"?ye=r.default.createElement(b,{toolCall:q.content,messageId:j}):ye=Q(q.content),r.default.createElement(r.Fragment,{key:`${q.kind}-${Oe}`},ye)}),[O.response.responseContents]),_e=r.default.useMemo(()=>O.response.followups?O.response.followups.map((q,Oe)=>{let ye=null;if(q.kind==="reply"){const ie=r.default.createElement("a",{onClick:()=>{Y.sendMessage({...G.parseMessage(q.message),reportExtra:{actionSource:g.ActionSourceEnum.Chat,actionType:g.ActionTypeEnum.Followup}})}},q.title||q.message);ye=q.tooltip?r.default.createElement(v.Tooltip,{title:q.tooltip},ie):ie}else q.when&&!V.match(q.when)&&(ye=null),ye=r.default.createElement(o.Button,{type:"default"},q.title);return ye&&r.default.createElement(r.Fragment,{key:Oe},ye)}):null,[O.response.followups]);return O.response.isComplete?r.default.createElement(E.ChatThinkingResult,{hasMessage:O.response.responseParts.length>0||O.response.responseContents.length>0||!!(!((T=O.response.errorDetails)===null||T===void 0)&&T.message),onRegenerate:K,requestId:O.requestId},r.default.createElement("div",{className:f.default.ai_chat_response_container},!((D=O.response.errorDetails)===null||D===void 0)&&D.message?r.default.createElement("div",{className:f.default.error},r.default.createElement(_.Icon,{className:(0,_.getIcon)("close-circle")}),r.default.createElement("span",null,O.response.errorDetails.message)):r.default.createElement(r.default.Fragment,null,he,_e?.length!==0&&r.default.createElement("div",{className:f.default.followups},_e)))):r.default.createElement(E.ChatThinking,{message:O.response.responseText,onStop:X},he)};t.ChatReply=S;const A=w=>{const{chunk:T}=w,D=(0,m.useInjectable)(g.ChatRenderRegistryToken),I=r.default.useMemo(()=>{let O;if(T.kind==="component")O=r.default.createElement(y,{component:T.component,value:T.value});else{let M=r.default.createElement(d.ChatMarkdown,{markdown:T.content,fillInIncompleteTokens:!0});if(D.chatAIRoleRender){const R=D.chatAIRoleRender;M=r.default.createElement(R,{content:T.content})}O=M}return O},[T]);return r.default.createElement(E.ChatThinkingResult,{hasMessage:!0,requestId:w.requestId,showRegenerate:!1},r.default.createElement("div",{className:f.default.ai_chat_response_container},I))};t.ChatNotify=A},17319:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatThinkingResult=t.ChatThinking=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(41869),l=e(81878),p=e(89195),v=e(68974),m=e(43718),_=e(19413),s=n.__importDefault(e(6960)),g=h=>{const{children:u,message:d,onStop:E,showStop:f=!0,thinkingText:c}=h,b=(0,o.useInjectable)(m.ChatRenderRegistryToken),y=(0,r.useMemo)(()=>b.chatThinkingRender,[b,b.chatThinkingRender]),S=(0,r.useCallback)(async()=>{E&&E()},[]),A=(0,r.useCallback)(()=>!u||!d?.trim()?y?r.default.createElement(y,{thinkingText:c}):r.default.createElement("span",{className:s.default.thinking_text},c||"Thinking..."):u,[d,u,c,y]);return r.default.createElement(r.default.Fragment,null,r.default.createElement("div",{className:s.default.content},A()),r.default.createElement("div",{className:s.default.thinking_container},r.default.createElement("div",{className:s.default.stop},!y&&r.default.createElement("span",{className:s.default.progress_bar},!u&&r.default.createElement(v.Progress,{loading:!0,wrapperClassName:s.default.ai_native_progress_wrapper})),f&&r.default.createElement("div",{className:s.default.block,onClick:S,tabIndex:0,role:"button"},r.default.createElement(l.Icon,{className:(0,l.getIcon)("circle-pause")}),r.default.createElement("span",null,(0,m.localize)("aiNative.operate.stop.title"))))))};t.ChatThinking=g;const a=({children:h,message:u,onRegenerate:d,requestId:E,hasMessage:f=!0,showRegenerate:c})=>{const b=(0,o.useInjectable)(_.IChatInternalService),[y,S]=(0,r.useState)(b.latestRequestId),A=(0,o.useInjectable)(m.ChatRenderRegistryToken);(0,r.useEffect)(()=>{const O=b.onChangeRequestId(M=>{S(M)});return()=>O.dispose()},[b]);const w=(0,r.useMemo)(()=>A.chatThinkingResultRender,[A,A.chatThinkingResultRender]),T=(0,r.useCallback)(()=>{d&&d()},[d]),D=(0,r.useCallback)(()=>{if(typeof f=="boolean"?!f:!u?.trim()){const O=(0,m.localize)("aiNative.chat.stop.immediately");return w?r.default.createElement(w,{thinkingResult:O}):r.default.createElement("span",null,O)}return h},[u,f,h]),I=(0,r.useMemo)(()=>(0,m.isUndefined)(c)?y===E&&!!E:!!c,[y,E,c]);return r.default.createElement(r.default.Fragment,null,r.default.createElement("div",{className:s.default.content},D()),r.default.createElement("div",{className:s.default.thinking_container},r.default.createElement("div",{className:s.default.bottom_container},r.default.createElement("div",{className:s.default.reset},I?r.default.createElement(p.EnhanceIcon,{icon:"refresh",wrapperClassName:s.default.text_btn,className:s.default.transform,onClick:T,tabIndex:0,role:"button"},r.default.createElement("span",null,(0,m.localize)("aiNative.operate.afresh.title"))):null),r.default.createElement("div",{className:s.default.thumbs},r.default.createElement(p.Thumbs,{relationId:E,wrapperClassName:s.default.icon_btn})))))};t.ChatThinkingResult=a},34817:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatToolRender=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),l=e(41869),p=e(81878),v=e(89195),m=e(43718),_=e(77633),s=e(25834),g=n.__importDefault(e(16796)),a=h=>{var u,d,E;const{value:f,messageId:c}=h,[b,y]=(0,o.useState)(!1),S=(0,l.useInjectable)(_.TokenMCPServerRegistry);if(!f||!f.function||!f.id)return null;const A=((u=S.getMCPTool(f.function.name))===null||u===void 0?void 0:u.label)||f.function.name,w=S.getToolComponent(f.function.name),T=M=>{switch(M){case"streaming-start":case"streaming":return{label:"Generating",icon:o.default.createElement(v.Loading,null)};case"complete":return{label:"Complete",icon:o.default.createElement(p.Icon,{iconClass:"codicon codicon-check"})};case"result":return{label:"Result Ready",icon:o.default.createElement(p.Icon,{iconClass:"codicon codicon-check-all"})};default:return{label:M||"Unknown",icon:o.default.createElement(p.Icon,{iconClass:"codicon codicon-question"})}}},D=()=>{var M;try{return f.state!=="complete"&&f.state!=="result"?{}:JSON.parse(((M=f.function)===null||M===void 0?void 0:M.arguments)||"{}")}catch{return{}}},I=()=>{y(!b)},O=T(f.state);return w&&(f.state==="complete"||f.state==="result")?o.default.createElement(w,{state:f.state,args:D(),result:f.result,index:f.index,messageId:c,toolCallId:f.id}):o.default.createElement("div",{className:g.default["chat-tool-render"]},o.default.createElement("div",{className:g.default["tool-header"],onClick:I},o.default.createElement("div",{className:g.default["tool-name"]},o.default.createElement("span",{className:(0,r.default)(g.default["expand-icon"],{[g.default.expanded]:b})},"\u25B6"),A),f.state&&o.default.createElement("div",{className:g.default["tool-state"]},o.default.createElement("span",{className:g.default["state-icon"]},O.icon),o.default.createElement("span",{className:g.default["state-label"]},O.label))),o.default.createElement("div",{className:(0,r.default)(g.default["tool-content"],{[g.default.expanded]:b})},((d=f?.function)===null||d===void 0?void 0:d.arguments)&&o.default.createElement("div",{className:g.default["tool-arguments"]},o.default.createElement("div",{className:g.default["section-label"]},"Arguments"),o.default.createElement(s.CodeEditorWithHighlight,{input:(E=f?.function)===null||E===void 0?void 0:E.arguments,language:"json",relationId:(0,m.uuid)(4)})),f?.result&&o.default.createElement("div",{className:g.default["tool-result"]},o.default.createElement("div",{className:g.default["section-label"]},"Result"),o.default.createElement(s.CodeEditorWithHighlight,{input:f.result,language:"json",relationId:(0,m.uuid)(4)}))))};t.ChatToolRender=a},29039:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SlashCustomRender=void 0;const r=e(85608).__importStar(e(14041)),o=e(41869),l=e(43718),p=e(19413),v=m=>{const{userMessage:_,relationId:s,requestId:g,renderContent:a,startTime:h,agentId:u,command:d}=m,E=(0,o.useInjectable)(p.IChatInternalService),f=(0,o.useInjectable)(l.IAIReporter);return r.useEffect(()=>{E.setLatestRequestId(g),f.end(s,{message:_,replytime:Date.now()-h,success:!0,isStop:!1,agentId:u,command:d})},[a,g,s]),r.createElement("div",null,a({userMessage:_}))};t.SlashCustomRender=v},86556:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WelcomeMessage=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(41869),l=e(81878),p=e(4246),v=e(43718),m=e(90684);e(41937);const _=e(19413),s=e(56474),g=e(17319),a=e(78048),h=n.__importDefault(e(6960)),u=()=>{var d,E;const f=(0,o.useInjectable)(v.ChatServiceToken),c=(0,o.useInjectable)(_.IChatAgentService),b=(0,o.useInjectable)(v.ChatFeatureRegistryToken),y=(0,o.useInjectable)(v.ChatRenderRegistryToken),[S,A]=r.useState([]);(0,o.useUpdateOnEvent)(b.onDidWelcomeMessageChange);const w=r.useMemo(()=>{if(!b.chatWelcomeMessageModel)return[];const{sampleQuestions:O=[]}=b.chatWelcomeMessageModel;return O.map(a.extractIcon)},[(d=b.chatWelcomeMessageModel)===null||d===void 0?void 0:d.sampleQuestions]),T=r.useMemo(()=>{if(!b.chatWelcomeMessageModel)return"";const{content:O}=b.chatWelcomeMessageModel;return O},[(E=b.chatWelcomeMessageModel)===null||E===void 0?void 0:E.content]);if(r.useEffect(()=>{const O=c.onDidChangeAgents(async()=>{const R=(await c.getAllSampleQuestions()).map(a.extractIcon);A(R)});return()=>O.dispose()},[]),!T)return r.createElement(g.ChatThinking,{showStop:!1,thinkingText:(0,v.localize)("aiNative.chat.welcome.loading.text")});const D=r.useMemo(()=>w.concat(S),[w,S]);return r.useMemo(()=>{if(y.chatWelcomeRender){const O=y.chatWelcomeRender;return r.createElement(O,{message:T,sampleQuestions:D})}return r.createElement("div",{className:h.default.chat_welcome_head},r.createElement("div",{className:h.default.chat_container_des},(0,m.isMarkdownString)(T)?r.createElement(s.ChatMarkdown,{markdown:T}):T),r.createElement("div",{className:h.default.chat_container_content},D.map((O,M)=>{const R=r.createElement("a",{className:h.default.link_item,onClick:(0,p.withPrevented)(()=>{f.sendMessage({...c.parseMessage(O.message),reportExtra:{actionType:v.ActionTypeEnum.Welcome,actionSource:v.ActionSourceEnum.Chat}})})},O.icon?r.createElement(l.Icon,{className:O.icon,style:{color:"inherit",marginRight:"4px"}}):"",r.createElement("span",null,O.title));return O.tooltip?r.createElement(l.Tooltip,{title:O.tooltip,key:M},R):r.createElement(r.Fragment,{key:M},R)})))},[y.chatWelcomeRender,T,D])};t.WelcomeMessage=u},83933:(L,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.highLightLanguageSupport=void 0,t.highLightLanguageSupport=["1c","abnf","accesslog","actionscript","ada","angelscript","apache","applescript","arcade","arduino","armasm","xml","asciidoc","aspectj","autohotkey","autoit","avrasm","awk","axapta","bash","basic","bnf","brainfuck","c-like","c","cal","capnproto","ceylon","clean","clojure","clojure-repl","cmake","coffeescript","coq","cos","cpp","crmsh","crystal","csharp","csp","css","d","markdown","dart","delphi","diff","django","dns","dockerfile","dos","dsconfig","dts","dust","ebnf","elixir","elm","ruby","erb","erlang-repl","erlang","excel","fix","flix","fortran","fsharp","gams","gauss","gcode","gherkin","glsl","gml","go","golo","gradle","groovy","haml","handlebars","haskell","haxe","hsp","htmlbars","http","hy","inform7","ini","irpf90","isbl","java","javascript","jboss-cli","json","julia","julia-repl","kotlin","lasso","latex","ldif","leaf","less","lisp","livecodeserver","livescript","llvm","lsl","lua","makefile","mathematica","matlab","maxima","mel","mercury","mipsasm","mizar","perl","mojolicious","monkey","moonscript","n1ql","nginx","nim","nix","node-repl","nsis","objectivec","ocaml","openscad","oxygene","parser3","pf","pgsql","php","php-template","plaintext","pony","powershell","processing","profile","prolog","properties","protobuf","puppet","purebasic","python","python-repl","q","qml","r","reasonml","rib","roboconf","routeros","rsl","ruleslanguage","rust","sas","scala","scheme","scilab","scss","shell","smali","smalltalk","sml","sqf","sql_more","sql","stan","stata","step21","stylus","subunit","swift","taggerscript","yaml","tap","tcl","thrift","tp","twig","typescript","vala","vbnet","vbscript","vbscript-html","verilog","vhdl","vim","x86asm","xl","xquery","zephir"]},78048:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractIcon=t.createMessageByAI=t.createMessageByUser=void 0;const n=e(41869),r="",o=m=>({...m,type:"text",className:`${m.position==="left"?"rce-ai-msg":"rce-user-msg"} ${m.className?m.className:""}`}),l=(m,_)=>o({...m,position:"right",title:r,className:_,role:1});t.createMessageByUser=l;const p=(m,_)=>o({...m,position:"left",title:"",className:_,role:2});t.createMessageByAI=p;const v=m=>{let{title:_}=m;const{message:s,tooltip:g}=m;let a=m.icon||"";if(!_)return{icon:a,title:s,message:s,tooltip:g};const h=_.match(/^\$\(([a-z.]+\/)?([a-z0-9-]+)(~[a-z]+)?\)/i);if(h){const[u,d,E,f]=h,c=d?d.slice(0,-1):n.CODICON_OWNER;a=(0,n.getExternalIcon)(E,c),f&&(a+=` ${f.slice(1)}`),_=_.slice(u.length)}return{icon:a,title:_,message:s,tooltip:g}};t.extractIcon=v},19957:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LlmContextContribution=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(46044);let p=class{initialize(){this.llmContextService.startAutoCollection()}};t.LlmContextContribution=p,n.__decorate([(0,r.Autowired)(l.LLMContextServiceToken),n.__metadata("design:type",Object)],p.prototype,"llmContextService",void 0),t.LlmContextContribution=p=n.__decorate([(0,o.Domain)(o.ClientAppContribution)],p)},63536:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LLMContextServiceImpl=void 0;const n=e(85608),r=e(76003),o=e(11050),l=e(25234),p=e(19083),v=e(86560),m=e(96689),_=e(82196),s=e(6287);let g=class extends l.WithEventBus{constructor(){super(...arguments),this.isAutoCollecting=!1,this.maxAttachFilesLimit=10,this.maxViewFilesLimit=20,this.attachedFiles=[],this.recentlyViewFiles=[],this.onDidContextFilesChangeEmitter=new v.Emitter,this.onDidContextFilesChangeEvent=this.onDidContextFilesChangeEmitter.event}addFileToList(h,u,d){const E=u.findIndex(f=>f.uri.toString()===h.uri.toString());E>-1&&u.splice(E,1),u.push(h),u.length>d&&u.shift()}addFileToContext(h,u,d=!1){if(!h)return;const E={uri:h,selection:u},f=d?this.attachedFiles:this.recentlyViewFiles,c=d?this.maxAttachFilesLimit:this.maxViewFilesLimit;this.addFileToList(E,f,c),this.notifyContextChange()}notifyContextChange(){this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles())}cleanFileContext(){this.attachedFiles.length=0,this.notifyContextChange()}getAllContextFiles(){return{viewed:this.recentlyViewFiles,attached:this.attachedFiles}}removeFileFromContext(h,u=!1){const d=u?this.attachedFiles:this.recentlyViewFiles,E=d.findIndex(f=>f.uri.toString()===h.toString());E>-1&&d.splice(E,1),this.notifyContextChange()}startAutoCollection(){this.isAutoCollecting||(this.isAutoCollecting=!0,this.startAutoCollectionInternal())}startAutoCollectionInternal(){this.disposables.push(this.eventBus.on(m.EditorDocumentModelCreationEvent,h=>{h.payload.uri.scheme==="file"&&this.addFileToContext(h.payload.uri,void 0,!1)})),this.disposables.push(this.eventBus.on(m.EditorDocumentModelRemovalEvent,h=>{h.payload.scheme==="file"&&this.removeFileFromContext(h.payload,!1)})),this.disposables.push(this.eventBus.on(m.EditorDocumentModelSavedEvent,h=>{h.payload.scheme})),this.disposables.push(this.eventBus.on(_.EditorSelectionChangeEvent,h=>{if(h.payload.selections.length>0){const u=[h.payload.selections[0].selectionStartLineNumber,h.payload.selections[0].positionLineNumber].sort();u[0]===u[1]?this.addFileToContext(h.payload.editorUri,void 0,!1):this.addFileToContext(h.payload.editorUri,u.sort((d,E)=>d-E),!1)}}))}stopAutoCollection(){this.dispose()}serialize(){const h=this.getAllContextFiles(),u=v.URI.file(this.appConfig.workspaceDir);return{recentlyViewFiles:this.serializeRecentlyViewFiles(h.viewed,u),attachedFiles:this.serializeAttachedFiles(h.attached,u)}}serializeRecentlyViewFiles(h,u){return h.map(d=>{var E;return((E=u.relative(d.uri))===null||E===void 0?void 0:E.toString())||d.uri.parent.toString()}).filter(Boolean)}serializeAttachedFiles(h,u){return h.map(d=>this.serializeAttachedFile(d,u)).filter(Boolean)}serializeAttachedFile(h,u){try{const d=this.docModelManager.getModelReference(h.uri);return d?{content:d.instance.getText(),lineErrors:this.getFileErrors(h.uri),path:u.relative(h.uri).toString(),language:d.instance.languageId}:null}catch{return null}}getFileErrors(h){return this.markerService.getManager().getMarkers({resource:h.toString(),severities:p.MarkerSeverity.Error}).map(u=>u.message)}};t.LLMContextServiceImpl=g,n.__decorate([(0,r.Autowired)(o.AppConfig),n.__metadata("design:type",Object)],g.prototype,"appConfig",void 0),n.__decorate([(0,r.Autowired)(m.IEditorDocumentModelService),n.__metadata("design:type",Object)],g.prototype,"docModelManager",void 0),n.__decorate([(0,r.Autowired)(s.IMarkerService),n.__metadata("design:type",Object)],g.prototype,"markerService",void 0),t.LLMContextServiceImpl=g=n.__decorate([(0,r.Injectable)()],g)},99906:(L,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.BaseAIMonacoEditorController=t.BaseAIMonacoContribHandler=void 0;const r=e(85608),o=e(76003),l=e(43718);class p extends l.Disposable{constructor(){super(),this.allowAnyScheme=!1,this.allowedSchemes=[l.Schemes.file],this.sessionDisposable=new l.Disposable}shouldHandle(_){return!!(this.allowAnyScheme||this.allowedSchemes.includes(_.scheme))}unload(){this.sessionDisposable.dispose(),this.sessionDisposable=new l.Disposable}load(){this.unload(),this.sessionDisposable.addDispose(this.doContribute())}mountEditor(_){return this.monacoEditor=_,{dispose:()=>{this.monacoEditor=void 0}}}}t.BaseAIMonacoContribHandler=p;let v=n=class extends l.Disposable{static get(_){return _.getContribution(n.ID)}get token(){return this.cancellationTokenSource.token}cancelToken(){this.cancellationTokenSource.cancel(),this.cancellationTokenSource=new l.CancellationTokenSource}constructor(_,s){super(),this.injector=_,this.monacoEditor=s,this.cancellationTokenSource=new l.CancellationTokenSource,this.featureDisposable=new l.Disposable,this.allowedSchemes=[l.Schemes.file,l.Schemes.notebookCell];const g=new l.Disposable;let a=!1;this.addDispose(this.monacoEditor.onDidChangeModel(({newModelUrl:u})=>{if(!u)return;const d=this.allowedSchemes.includes(u.scheme);d!==a&&(a=!!d,a?g.addDispose(this.mount()):g.dispose())}));const h=s.getModel();h&&this.allowedSchemes.includes(h.uri.scheme)&&(a=!0,g.addDispose(this.mount())),this.addDispose(g)}};t.BaseAIMonacoEditorController=v,t.BaseAIMonacoEditorController=v=n=r.__decorate([r.__param(0,(0,o.Optional)()),r.__param(1,(0,o.Optional)()),r.__metadata("design:paramtypes",[o.Injector,Object])],v)},72713:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AICodeActionContribution=void 0;const n=e(85608),r=e(76003),o=e(57925),l=e(43718),p=e(89132);let v=class extends l.Disposable{registerCommands(_){_.registerCommand(o.AI_CODE_ACTION,{execute:(s,g)=>{this.codeActionService.fireCodeActionRun(g,s)}})}};t.AICodeActionContribution=v,n.__decorate([(0,r.Autowired)(p.CodeActionService),n.__metadata("design:type",p.CodeActionService)],v.prototype,"codeActionService",void 0),t.AICodeActionContribution=v=n.__decorate([(0,l.Domain)(l.CommandContribution)],v)},79559:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CodeActionSingleHandler=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(43718),p=n.__importStar(e(20868)),v=e(52902),m=e(77714),_=e(85679),s=e(99906),g=e(89132);let a=class extends s.BaseAIMonacoContribHandler{constructor(){super(),this.inlineChatActionEnabled=this.preferenceService.getValid(l.AINativeSettingSectionsId.InlineChatCodeActionEnabled,!0),this.addDispose(this.preferenceService.onSpecificPreferenceChange(l.AINativeSettingSectionsId.InlineChatCodeActionEnabled,({newValue:u})=>{this.inlineChatActionEnabled=u,u?this.load():this.unload()}))}doContribute(){return v.monacoApi.languages.registerCodeActionProvider("*",{provideCodeActions:async(u,d)=>{if(!this.inlineChatActionEnabled)return;const E=u.getLineContent(d.startLineNumber);if(E?.trim()===m.empty||!this.shouldHandle(u.uri))return;const{languageParserService:f,codeActionService:c}=this,b=u.getLanguageId(),y=f.createParser(b);if(!y)return;const S=c.getCodeActions();if(!S||S.length===0)return;const A=d.getStartPosition();if(!A)return;function w(I){return{actions:S.map(O=>{const M={};O.command&&(M.id=O.command.id,M.arguments=[I.range,...O.command.arguments]);let R=O.title;switch(I.infoCategory){case"function":R=R+` for Function: ${I.name}`}return{...O,title:R,ranges:[I.range],command:M}}),dispose(){}}}const T=await y.provideCodeBlockInfo(u,A);if(T)return w(T);if(u.getLineLength(A.lineNumber)===0&&this.monacoEditor){const I=this.monacoEditor.getVisibleRanges();if(I.length===0)return;const O=new p.Range(A.lineNumber,0,I[0].endLineNumber+1,0),M=await y.provideCodeBlockInfoInRange(u,O);if(M)return w(M)}}})}};t.CodeActionSingleHandler=a,n.__decorate([(0,r.Autowired)(g.CodeActionService),n.__metadata("design:type",g.CodeActionService)],a.prototype,"codeActionService",void 0),n.__decorate([(0,r.Autowired)(o.PreferenceService),n.__metadata("design:type",Object)],a.prototype,"preferenceService",void 0),n.__decorate([(0,r.Autowired)(_.LanguageParserService),n.__metadata("design:type",_.LanguageParserService)],a.prototype,"languageParserService",void 0),t.CodeActionSingleHandler=a=n.__decorate([(0,r.Injectable)(),n.__metadata("design:paramtypes",[])],a)},89132:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CodeActionService=void 0;const n=e(85608),r=e(76003),o=e(57925),l=e(43718);let p=class extends l.Disposable{constructor(){super(...arguments),this.codeActionsMap=new Map,this._onCodeActionRun=new l.Emitter,this.onCodeActionRun=this._onCodeActionRun.event}dispose(){super.dispose(),this.codeActionsMap.clear()}fireCodeActionRun(m,_){this._onCodeActionRun.fire({id:m,range:_})}getCodeActions(){return Array.from(this.codeActionsMap.values())}deleteCodeActionById(m){this.codeActionsMap.delete(m)}registerCodeAction(m){var _;const{codeAction:s,id:g}=m;if(!s)return;const a={title:s.title||m.name,isAI:!0,isPreferred:(_=s.isPreferred)!==null&&_!==void 0?_:!0,kind:s.kind||"InlineChat",disabled:s.disabled,command:{id:o.AI_CODE_ACTION.id,title:s.title||m.name,arguments:[m.id]}};this.codeActionsMap.set(g,a)}};t.CodeActionService=p,t.CodeActionService=p=n.__decorate([(0,r.Injectable)()],p)},57232:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AIInlineCompletionsProvider=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(43718),p=n.__importStar(e(20868)),v=e(687),m=e(71863),_={line:-1,column:-1,last:null};class s{constructor(){this.queue=[]}addReq(h){this.queue.push(h)}runReq(){return this.queue.length===0?void 0:this.queue.pop().run()}cancelReq(){this.queue.length!==0&&(this.queue.forEach(h=>{h.cancelRequest()}),this.queue=[])}}let g=class extends l.WithEventBus{constructor(){super(),this.inlineComletionsDebounceTime=this.preferenceService.getValid(l.AINativeSettingSectionsId.IntelligentCompletionsDebounceTime,150),this.addDispose(this.preferenceService.onSpecificPreferenceChange(l.AINativeSettingSectionsId.IntelligentCompletionsDebounceTime,({newValue:h})=>{this.inlineComletionsDebounceTime=h})),this.mount()}mount(){this.isManual=!1,this.isDelEvent=!1,this.reqStack=new s}setVisibleCompletion(h){this.aiCompletionsService.setVisibleCompletion(h)}hideStatusBarItem(){this.aiCompletionsService.hideStatusBarItem()}cancelRequest(){this.aiCompletionsService.cancelRequest(),this.reqStack&&this.reqStack.cancelReq()}async provideInlineCompletionItems(h,u,d,E){if(d.triggerKind===p.InlineCompletionTriggerKind.Automatic&&_.column===u.column&&_.line===u.lineNumber&&_.last!==void 0)return _.column=-1,_.line=-1,_.last;this.cancelRequest(),this.hideStatusBarItem();const f=this.isManual;if(this.isDelEvent&&!f)return;this.updateIsManual(!1);const c=this.injector.get(v.InlineCompletionRequestTask,[h,u,E]);if(this.reqStack.addReq(c),f||await(0,l.raceCancellation)((0,l.sleep)(this.inlineComletionsDebounceTime),E),E?.isCancellationRequested)return;const b=await this.reqStack.runReq();if(b)return _.column=u.column,_.line=u.lineNumber,_.last={items:b},_.last}updateIsManual(h){this.isManual=h}};t.AIInlineCompletionsProvider=g,n.__decorate([(0,r.Autowired)(m.AICompletionsService),n.__metadata("design:type",m.AICompletionsService)],g.prototype,"aiCompletionsService",void 0),n.__decorate([(0,r.Autowired)(r.INJECTOR_TOKEN),n.__metadata("design:type",r.Injector)],g.prototype,"injector",void 0),n.__decorate([(0,r.Autowired)(o.PreferenceService),n.__metadata("design:type",Object)],g.prototype,"preferenceService",void 0),t.AIInlineCompletionsProvider=g=n.__decorate([(0,r.Injectable)(),n.__metadata("design:paramtypes",[])],g)},2409:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lineBasedCompletionModelConfigs=t.DEFAULT_COMPLECTION_MODEL=void 0;const n=e(71585);t.DEFAULT_COMPLECTION_MODEL={maxPromptTokenSize:3e3,maxExecuteTimeMillSecond:1e3,tokenizerName:n.TokenizerName.cl100k_base,wishList:{afterCursor:{enable:!0,attributeName:n.WishListAttributeName.afterCursor,extOption:{suffixPercent:.25,minBlockSize:25},priority:1,strategy:n.StrategyType.InterceptBasedOnLine},beforeCursor:{enable:!0,attributeName:n.WishListAttributeName.beforeCursor,extOption:{prefixPercent:.75,minBlockSize:75},priority:0,strategy:n.StrategyType.InterceptBasedOnLine},importedFile:{attributeName:n.WishListAttributeName.importedFile,enable:!0,extOption:{maxTime:200,importedFilesMaxNum:10,language:["typescript"],maxPercent:.8,patternPrefix:"Import Files from ",patternSuffix:`
|
|
29295
|
+
`),P=R[R.length-1],k=[{condition:P.includes("`"),action:d},{condition:P.includes("**"),action:y},{condition:P.match(/\*\w/),action:E},{condition:P.match(/(^|\s)__\w/),action:S},{condition:P.match(/(^|\s)_\w/),action:f},{condition:P.match(/(^|\s)\[.*\]\(\w*/),action:c},{condition:P.match(/(^|\s)\[\w/),action:b}];for(const F of k)if(F.condition)return F.action(I)}}},92635:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatNotify=t.ChatReply=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(48412),l=e(91416),p=e(78569),v=e(72871),m=e(41869),_=e(81878),s=e(89195),g=e(43718),a=e(52416),h=e(90684),u=e(19413),d=e(56474),E=e(17319),f=n.__importDefault(e(6960)),c=w=>{const T=(0,m.useInjectable)(m.LabelService),D=(0,m.useInjectable)(m.CommandService),I=(F,x,B)=>{let j=T.getIcon(F,{isDirectory:x});return x&&B&&(j+=" expanded"),j},O=(0,r.useMemo)(()=>{const F=x=>{const B=typeof x.type=="number"?x.type===g.FileType.Directory:!!x.children,j=new g.URI(x.uri);return{label:x.label,iconClassName:I(j,B,B),expandable:!0,expanded:!0,children:B?(x.children||[]).map(F):null,uri:j}};return(w.treeData.children||[]).map(F)},[w.treeData]),[M,R]=(0,r.useState)(22),P=(0,r.useRef)(null),k=F=>{P.current=F;const x=()=>{let B=F.getModel().root.branchSize;B<1?B=1:B>20&&(B=20),R(B*22)};x(),F.onDidUpdate(x)};return O.length?r.default.createElement("div",{className:f.default.tree_container},r.default.createElement(l.BasicRecycleTree,{height:M,treeData:O,onContextMenu:F=>F.preventDefault(),onClick:(F,x)=>{!P.current||!x||(p.BasicCompositeTreeNode.is(x)?x.raw.iconClassName=I(x.raw.uri,!0,x.expanded):D.executeCommand(m.EDITOR_COMMANDS.OPEN_RESOURCE.id,x.raw.uri,{disableNavigate:!0,preview:!0}))},onReady:k,treeName:w.treeData.label,leaveBottomBlank:!1,baseIndent:0})):null},b=w=>{const{toolCall:T,messageId:D}=w,I=(0,m.useInjectable)(g.ChatAgentViewServiceToken),[O,M]=(0,r.useState)(null);return(0,r.useEffect)(()=>{const R=I.getChatComponent("toolCall");if(R){const{component:k,initialProps:F}=R;M(r.default.createElement(k,{...F,value:T,messageId:D}));return}M(r.default.createElement("div",null,r.default.createElement(s.Loading,null),r.default.createElement("span",{style:{marginLeft:4}},"\u6B63\u5728\u52A0\u8F7D\u7EC4\u4EF6"))),I.getChatComponentDeferred("toolCall").promise.then(({component:k,initialProps:F})=>{M(r.default.createElement(k,{...F,value:T,messageId:D}))})},[T.state]),O},y=w=>{const T=(0,m.useInjectable)(g.ChatAgentViewServiceToken),[D,I]=(0,r.useState)(null);return(0,r.useEffect)(()=>{const O=T.getChatComponent(w.component);if(O){const{component:R,initialProps:P}=O;I(r.default.createElement(R,{...P,value:w.value,messageId:w.messageId}));return}I(r.default.createElement("div",null,r.default.createElement(s.Loading,null),r.default.createElement("span",{style:{marginLeft:4}},"\u6B63\u5728\u52A0\u8F7D\u7EC4\u4EF6"))),T.getChatComponentDeferred(w.component).promise.then(({component:R,initialProps:P})=>{I(r.default.createElement(R,{...P,value:w.value}))})},[w.component,w.value]),D},S=w=>{var T,D;const{relationId:I,request:O,startTime:M=0,onRegenerate:R,onDidChange:P,onDone:k,agentId:F,command:x,history:B,msgId:j}=w,[,W]=(0,r.useReducer)(q=>(q+1)%1e6,0),U=(0,m.useInjectable)(g.IAIReporter),Z=(0,m.useInjectable)(a.IIconService),V=(0,m.useInjectable)(m.IContextKeyService),$=(0,m.useInjectable)(u.IChatInternalService),Y=(0,m.useInjectable)(g.ChatServiceToken),G=(0,m.useInjectable)(u.IChatAgentService),H=(0,m.useInjectable)(g.ChatRenderRegistryToken);(0,r.useEffect)(()=>{const q=new m.DisposableCollection;return q.push(O.response.onDidChange(()=>{B.updateAssistantMessage(j,{content:O.response.responseText}),O.response.isComplete&&(k&&k(),U.end(I,{assistantMessage:O.response.responseText,replytime:Date.now()-M,success:!0,isStop:!1,command:x,agentId:F})),(0,r.startTransition)(()=>{P?.(),W()})})),()=>q.dispose()},[I,P,k]);const K=(0,r.useCallback)(()=>{O.response.reset(),R?.()},[R]),X=()=>{k&&k(),U.end(I,{assistantMessage:O.response.responseText,replytime:Date.now()-M,success:!1,isStop:!0,command:x,agentId:F}),$.cancelRequest()},Q=(0,r.useCallback)(q=>{if(H.chatAIRoleRender){const Oe=H.chatAIRoleRender;return r.default.createElement(Oe,{content:q.value})}return r.default.createElement(d.ChatMarkdown,{markdown:q,fillInIncompleteTokens:!0})},[H,H.chatAIRoleRender]),oe=q=>r.default.createElement(c,{treeData:q}),ne=q=>r.default.createElement("div",{className:f.default.placeholder},r.default.createElement(_.Icon,{iconClass:Z.fromString("$(codicon/sync~spin)")}),r.default.createElement("div",{className:f.default.placeholder_content},Q(q))),he=r.default.useMemo(()=>O.response.responseContents.map((q,Oe)=>{let ye;return q.kind==="asyncContent"?ye=ne(new h.MarkdownString(q.content)):q.kind==="treeData"?ye=oe(q.treeData):q.kind==="component"?ye=r.default.createElement(y,{component:q.component,value:q.value,messageId:j}):q.kind==="toolCall"?ye=r.default.createElement(b,{toolCall:q.content,messageId:j}):ye=Q(q.content),r.default.createElement(r.Fragment,{key:`${q.kind}-${Oe}`},ye)}),[O.response.responseContents]),_e=r.default.useMemo(()=>O.response.followups?O.response.followups.map((q,Oe)=>{let ye=null;if(q.kind==="reply"){const ie=r.default.createElement("a",{onClick:()=>{Y.sendMessage({...G.parseMessage(q.message),reportExtra:{actionSource:g.ActionSourceEnum.Chat,actionType:g.ActionTypeEnum.Followup}})}},q.title||q.message);ye=q.tooltip?r.default.createElement(v.Tooltip,{title:q.tooltip},ie):ie}else q.when&&!V.match(q.when)&&(ye=null),ye=r.default.createElement(o.Button,{type:"default"},q.title);return ye&&r.default.createElement(r.Fragment,{key:Oe},ye)}):null,[O.response.followups]);return O.response.isComplete?r.default.createElement(E.ChatThinkingResult,{hasMessage:O.response.responseParts.length>0||O.response.responseContents.length>0||!!(!((T=O.response.errorDetails)===null||T===void 0)&&T.message),onRegenerate:K,requestId:O.requestId},r.default.createElement("div",{className:f.default.ai_chat_response_container},!((D=O.response.errorDetails)===null||D===void 0)&&D.message?r.default.createElement("div",{className:f.default.error},r.default.createElement(_.Icon,{className:(0,_.getIcon)("close-circle")}),r.default.createElement("span",null,O.response.errorDetails.message)):r.default.createElement(r.default.Fragment,null,he,_e?.length!==0&&r.default.createElement("div",{className:f.default.followups},_e)))):r.default.createElement(E.ChatThinking,{message:O.response.responseText,onStop:X},he)};t.ChatReply=S;const A=w=>{const{chunk:T}=w,D=(0,m.useInjectable)(g.ChatRenderRegistryToken),I=r.default.useMemo(()=>{let O;if(T.kind==="component")O=r.default.createElement(y,{component:T.component,value:T.value});else{let M=r.default.createElement(d.ChatMarkdown,{markdown:T.content,fillInIncompleteTokens:!0});if(D.chatAIRoleRender){const R=D.chatAIRoleRender;M=r.default.createElement(R,{content:T.content})}O=M}return O},[T]);return r.default.createElement(E.ChatThinkingResult,{hasMessage:!0,requestId:w.requestId,showRegenerate:!1},r.default.createElement("div",{className:f.default.ai_chat_response_container},I))};t.ChatNotify=A},17319:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatThinkingResult=t.ChatThinking=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(41869),l=e(81878),p=e(89195),v=e(68974),m=e(43718),_=e(19413),s=n.__importDefault(e(6960)),g=h=>{const{children:u,message:d,onStop:E,showStop:f=!0,thinkingText:c}=h,b=(0,o.useInjectable)(m.ChatRenderRegistryToken),y=(0,r.useMemo)(()=>b.chatThinkingRender,[b,b.chatThinkingRender]),S=(0,r.useCallback)(async()=>{E&&E()},[]),A=(0,r.useCallback)(()=>!u||!d?.trim()?y?r.default.createElement(y,{thinkingText:c}):r.default.createElement("span",{className:s.default.thinking_text},c||"Thinking..."):u,[d,u,c,y]);return r.default.createElement(r.default.Fragment,null,r.default.createElement("div",{className:s.default.content},A()),r.default.createElement("div",{className:s.default.thinking_container},r.default.createElement("div",{className:s.default.stop},!y&&r.default.createElement("span",{className:s.default.progress_bar},!u&&r.default.createElement(v.Progress,{loading:!0,wrapperClassName:s.default.ai_native_progress_wrapper})),f&&r.default.createElement("div",{className:s.default.block,onClick:S,tabIndex:0,role:"button"},r.default.createElement(l.Icon,{className:(0,l.getIcon)("circle-pause")}),r.default.createElement("span",null,(0,m.localize)("aiNative.operate.stop.title"))))))};t.ChatThinking=g;const a=({children:h,message:u,onRegenerate:d,requestId:E,hasMessage:f=!0,showRegenerate:c})=>{const b=(0,o.useInjectable)(_.IChatInternalService),[y,S]=(0,r.useState)(b.latestRequestId),A=(0,o.useInjectable)(m.ChatRenderRegistryToken);(0,r.useEffect)(()=>{const O=b.onChangeRequestId(M=>{S(M)});return()=>O.dispose()},[b]);const w=(0,r.useMemo)(()=>A.chatThinkingResultRender,[A,A.chatThinkingResultRender]),T=(0,r.useCallback)(()=>{d&&d()},[d]),D=(0,r.useCallback)(()=>{if(typeof f=="boolean"?!f:!u?.trim()){const O=(0,m.localize)("aiNative.chat.stop.immediately");return w?r.default.createElement(w,{thinkingResult:O}):r.default.createElement("span",null,O)}return h},[u,f,h]),I=(0,r.useMemo)(()=>(0,m.isUndefined)(c)?y===E&&!!E:!!c,[y,E,c]);return r.default.createElement(r.default.Fragment,null,r.default.createElement("div",{className:s.default.content},D()),r.default.createElement("div",{className:s.default.thinking_container},r.default.createElement("div",{className:s.default.bottom_container},r.default.createElement("div",{className:s.default.reset},I?r.default.createElement(p.EnhanceIcon,{icon:"refresh",wrapperClassName:s.default.text_btn,className:s.default.transform,onClick:T,tabIndex:0,role:"button"},r.default.createElement("span",null,(0,m.localize)("aiNative.operate.afresh.title"))):null),r.default.createElement("div",{className:s.default.thumbs},r.default.createElement(p.Thumbs,{relationId:E,wrapperClassName:s.default.icon_btn})))))};t.ChatThinkingResult=a},34817:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChatToolRender=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importStar(e(14041)),l=e(41869),p=e(81878),v=e(89195),m=e(43718),_=e(77633),s=e(25834),g=n.__importDefault(e(16796)),a=h=>{var u,d,E;const{value:f,messageId:c}=h,[b,y]=(0,o.useState)(!1),S=(0,l.useInjectable)(_.TokenMCPServerRegistry);if(!f||!f.function||!f.id)return null;const A=((u=S.getMCPTool(f.function.name))===null||u===void 0?void 0:u.label)||f.function.name,w=S.getToolComponent(f.function.name),T=M=>{switch(M){case"streaming-start":case"streaming":return{label:"Generating",icon:o.default.createElement(v.Loading,null)};case"complete":return{label:"Complete",icon:o.default.createElement(p.Icon,{iconClass:"codicon codicon-check"})};case"result":return{label:"Result Ready",icon:o.default.createElement(p.Icon,{iconClass:"codicon codicon-check-all"})};default:return{label:M||"Unknown",icon:o.default.createElement(p.Icon,{iconClass:"codicon codicon-question"})}}},D=()=>{var M;try{return f.state!=="complete"&&f.state!=="result"?{}:JSON.parse(((M=f.function)===null||M===void 0?void 0:M.arguments)||"{}")}catch{return{}}},I=()=>{y(!b)},O=T(f.state);return w&&(f.state==="complete"||f.state==="result")?o.default.createElement(w,{state:f.state,args:D(),result:f.result,index:f.index,messageId:c,toolCallId:f.id}):o.default.createElement("div",{className:g.default["chat-tool-render"]},o.default.createElement("div",{className:g.default["tool-header"],onClick:I},o.default.createElement("div",{className:g.default["tool-name"]},o.default.createElement("span",{className:(0,r.default)(g.default["expand-icon"],{[g.default.expanded]:b})},"\u25B6"),A),f.state&&o.default.createElement("div",{className:g.default["tool-state"]},o.default.createElement("span",{className:g.default["state-icon"]},O.icon),o.default.createElement("span",{className:g.default["state-label"]},O.label))),o.default.createElement("div",{className:(0,r.default)(g.default["tool-content"],{[g.default.expanded]:b})},((d=f?.function)===null||d===void 0?void 0:d.arguments)&&o.default.createElement("div",{className:g.default["tool-arguments"]},o.default.createElement("div",{className:g.default["section-label"]},"Arguments"),o.default.createElement(s.CodeEditorWithHighlight,{input:(E=f?.function)===null||E===void 0?void 0:E.arguments,language:"json",relationId:(0,m.uuid)(4)})),f?.result&&o.default.createElement("div",{className:g.default["tool-result"]},o.default.createElement("div",{className:g.default["section-label"]},"Result"),o.default.createElement(s.CodeEditorWithHighlight,{input:f.result,language:"json",relationId:(0,m.uuid)(4)}))))};t.ChatToolRender=a},29039:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SlashCustomRender=void 0;const r=e(85608).__importStar(e(14041)),o=e(41869),l=e(43718),p=e(19413),v=m=>{const{userMessage:_,relationId:s,requestId:g,renderContent:a,startTime:h,agentId:u,command:d}=m,E=(0,o.useInjectable)(p.IChatInternalService),f=(0,o.useInjectable)(l.IAIReporter);return r.useEffect(()=>{E.setLatestRequestId(g),f.end(s,{message:_,replytime:Date.now()-h,success:!0,isStop:!1,agentId:u,command:d})},[a,g,s]),r.createElement("div",null,a({userMessage:_}))};t.SlashCustomRender=v},86556:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WelcomeMessage=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(41869),l=e(81878),p=e(4246),v=e(43718),m=e(90684);e(41937);const _=e(19413),s=e(56474),g=e(17319),a=e(78048),h=n.__importDefault(e(6960)),u=()=>{var d,E;const f=(0,o.useInjectable)(v.ChatServiceToken),c=(0,o.useInjectable)(_.IChatAgentService),b=(0,o.useInjectable)(v.ChatFeatureRegistryToken),y=(0,o.useInjectable)(v.ChatRenderRegistryToken),[S,A]=r.useState([]);(0,o.useUpdateOnEvent)(b.onDidWelcomeMessageChange);const w=r.useMemo(()=>{if(!b.chatWelcomeMessageModel)return[];const{sampleQuestions:O=[]}=b.chatWelcomeMessageModel;return O.map(a.extractIcon)},[(d=b.chatWelcomeMessageModel)===null||d===void 0?void 0:d.sampleQuestions]),T=r.useMemo(()=>{if(!b.chatWelcomeMessageModel)return"";const{content:O}=b.chatWelcomeMessageModel;return O},[(E=b.chatWelcomeMessageModel)===null||E===void 0?void 0:E.content]);if(r.useEffect(()=>{const O=c.onDidChangeAgents(async()=>{const R=(await c.getAllSampleQuestions()).map(a.extractIcon);A(R)});return()=>O.dispose()},[]),!T)return r.createElement(g.ChatThinking,{showStop:!1,thinkingText:(0,v.localize)("aiNative.chat.welcome.loading.text")});const D=r.useMemo(()=>w.concat(S),[w,S]);return r.useMemo(()=>{if(y.chatWelcomeRender){const O=y.chatWelcomeRender;return r.createElement(O,{message:T,sampleQuestions:D})}return r.createElement("div",{className:h.default.chat_welcome_head},r.createElement("div",{className:h.default.chat_container_des},(0,m.isMarkdownString)(T)?r.createElement(s.ChatMarkdown,{markdown:T}):T),r.createElement("div",{className:h.default.chat_container_content},D.map((O,M)=>{const R=r.createElement("a",{className:h.default.link_item,onClick:(0,p.withPrevented)(()=>{f.sendMessage({...c.parseMessage(O.message),reportExtra:{actionType:v.ActionTypeEnum.Welcome,actionSource:v.ActionSourceEnum.Chat}})})},O.icon?r.createElement(l.Icon,{className:O.icon,style:{color:"inherit",marginRight:"4px"}}):"",r.createElement("span",null,O.title));return O.tooltip?r.createElement(l.Tooltip,{title:O.tooltip,key:M},R):r.createElement(r.Fragment,{key:M},R)})))},[y.chatWelcomeRender,T,D])};t.WelcomeMessage=u},83933:(L,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.highLightLanguageSupport=void 0,t.highLightLanguageSupport=["1c","abnf","accesslog","actionscript","ada","angelscript","apache","applescript","arcade","arduino","armasm","xml","asciidoc","aspectj","autohotkey","autoit","avrasm","awk","axapta","bash","basic","bnf","brainfuck","c-like","c","cal","capnproto","ceylon","clean","clojure","clojure-repl","cmake","coffeescript","coq","cos","cpp","crmsh","crystal","csharp","csp","css","d","markdown","dart","delphi","diff","django","dns","dockerfile","dos","dsconfig","dts","dust","ebnf","elixir","elm","ruby","erb","erlang-repl","erlang","excel","fix","flix","fortran","fsharp","gams","gauss","gcode","gherkin","glsl","gml","go","golo","gradle","groovy","haml","handlebars","haskell","haxe","hsp","htmlbars","http","hy","inform7","ini","irpf90","isbl","java","javascript","jboss-cli","json","julia","julia-repl","kotlin","lasso","latex","ldif","leaf","less","lisp","livecodeserver","livescript","llvm","lsl","lua","makefile","mathematica","matlab","maxima","mel","mercury","mipsasm","mizar","perl","mojolicious","monkey","moonscript","n1ql","nginx","nim","nix","node-repl","nsis","objectivec","ocaml","openscad","oxygene","parser3","pf","pgsql","php","php-template","plaintext","pony","powershell","processing","profile","prolog","properties","protobuf","puppet","purebasic","python","python-repl","q","qml","r","reasonml","rib","roboconf","routeros","rsl","ruleslanguage","rust","sas","scala","scheme","scilab","scss","shell","smali","smalltalk","sml","sqf","sql_more","sql","stan","stata","step21","stylus","subunit","swift","taggerscript","yaml","tap","tcl","thrift","tp","twig","typescript","vala","vbnet","vbscript","vbscript-html","verilog","vhdl","vim","x86asm","xl","xquery","zephir"]},78048:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractIcon=t.createMessageByAI=t.createMessageByUser=void 0;const n=e(41869),r="",o=m=>({...m,type:"text",className:`${m.position==="left"?"rce-ai-msg":"rce-user-msg"} ${m.className?m.className:""}`}),l=(m,_)=>o({...m,position:"right",title:r,className:_,role:1});t.createMessageByUser=l;const p=(m,_)=>o({...m,position:"left",title:"",className:_,role:2});t.createMessageByAI=p;const v=m=>{let{title:_}=m;const{message:s,tooltip:g}=m;let a=m.icon||"";if(!_)return{icon:a,title:s,message:s,tooltip:g};const h=_.match(/^\$\(([a-z.]+\/)?([a-z0-9-]+)(~[a-z]+)?\)/i);if(h){const[u,d,E,f]=h,c=d?d.slice(0,-1):n.CODICON_OWNER;a=(0,n.getExternalIcon)(E,c),f&&(a+=` ${f.slice(1)}`),_=_.slice(u.length)}return{icon:a,title:_,message:s,tooltip:g}};t.extractIcon=v},19957:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LlmContextContribution=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(46044);let p=class{initialize(){this.llmContextService.startAutoCollection()}};t.LlmContextContribution=p,n.__decorate([(0,r.Autowired)(l.LLMContextServiceToken),n.__metadata("design:type",Object)],p.prototype,"llmContextService",void 0),t.LlmContextContribution=p=n.__decorate([(0,o.Domain)(o.ClientAppContribution)],p)},63536:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LLMContextServiceImpl=void 0;const n=e(85608),r=e(76003),o=e(11050),l=e(25234),p=e(19083),v=e(86560),m=e(96689),_=e(82196),s=e(6287);let g=class extends l.WithEventBus{constructor(){super(...arguments),this.isAutoCollecting=!1,this.contextFiles=[],this.maxFiles=10,this.onDidContextFilesChangeEmitter=new v.Emitter,this.onDidContextFilesChangeEvent=this.onDidContextFilesChangeEmitter.event}addFileToContext(h,u,d=!0){this.removeFileFromContext(h),this.contextFiles.push({uri:h,selection:u,isManual:d}),this.contextFiles.length>this.maxFiles&&this.contextFiles.shift(),this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles())}cleanFileContext(){this.contextFiles=[],this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles())}getAllContextFiles(){return[...this.contextFiles]}removeFileFromContext(h){const u=this.contextFiles.findIndex(d=>d.uri.toString()===h.toString());u>-1&&(this.contextFiles.splice(u,1),this.onDidContextFilesChangeEmitter.fire(this.getAllContextFiles()))}startAutoCollection(){this.isAutoCollecting||(this.isAutoCollecting=!0,this.startAutoCollectionInternal())}startAutoCollectionInternal(){this.disposables.push(this.eventBus.on(m.EditorDocumentModelCreationEvent,h=>{h.payload.uri.scheme})),this.disposables.push(this.eventBus.on(m.EditorDocumentModelRemovalEvent,h=>{h.payload.scheme})),this.disposables.push(this.eventBus.on(m.EditorDocumentModelSavedEvent,h=>{h.payload.scheme})),this.disposables.push(this.eventBus.on(_.EditorSelectionChangeEvent,h=>{if(h.payload.selections.length>0){const u=[h.payload.selections[0].selectionStartLineNumber,h.payload.selections[0].positionLineNumber].sort();u[0]===u[1]?this.addFileToContext(h.payload.editorUri,void 0):this.addFileToContext(h.payload.editorUri,u.sort((d,E)=>d-E))}}))}stopAutoCollection(){this.dispose()}serialize(){const h=this.getAllContextFiles(),u=h.filter(E=>!E.selection).map(E=>{const f=v.URI.file(this.appConfig.workspaceDir).relative(E.uri);return f?f.toString():E.uri.parent.toString()}).filter(Boolean),d=h.filter(E=>E.selection).map(E=>{const f=this.docModelManager.getModelReference(E.uri),c=f.instance.getText(),b=this.markerService.getManager().getMarkers({resource:E.uri.toString(),severities:p.MarkerSeverity.Error}).map(y=>y.message);return{content:c,lineErrors:b,path:v.URI.file(this.appConfig.workspaceDir).relative(E.uri).toString(),language:f?.instance.languageId}}).filter(Boolean);return{recentlyViewFiles:u,attachedFiles:d}}};t.LLMContextServiceImpl=g,n.__decorate([(0,r.Autowired)(o.AppConfig),n.__metadata("design:type",Object)],g.prototype,"appConfig",void 0),n.__decorate([(0,r.Autowired)(m.IEditorDocumentModelService),n.__metadata("design:type",Object)],g.prototype,"docModelManager",void 0),n.__decorate([(0,r.Autowired)(s.IMarkerService),n.__metadata("design:type",Object)],g.prototype,"markerService",void 0),t.LLMContextServiceImpl=g=n.__decorate([(0,r.Injectable)()],g)},99906:(L,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.BaseAIMonacoEditorController=t.BaseAIMonacoContribHandler=void 0;const r=e(85608),o=e(76003),l=e(43718);class p extends l.Disposable{constructor(){super(),this.allowAnyScheme=!1,this.allowedSchemes=[l.Schemes.file],this.sessionDisposable=new l.Disposable}shouldHandle(_){return!!(this.allowAnyScheme||this.allowedSchemes.includes(_.scheme))}unload(){this.sessionDisposable.dispose(),this.sessionDisposable=new l.Disposable}load(){this.unload(),this.sessionDisposable.addDispose(this.doContribute())}mountEditor(_){return this.monacoEditor=_,{dispose:()=>{this.monacoEditor=void 0}}}}t.BaseAIMonacoContribHandler=p;let v=n=class extends l.Disposable{static get(_){return _.getContribution(n.ID)}get token(){return this.cancellationTokenSource.token}cancelToken(){this.cancellationTokenSource.cancel(),this.cancellationTokenSource=new l.CancellationTokenSource}constructor(_,s){super(),this.injector=_,this.monacoEditor=s,this.cancellationTokenSource=new l.CancellationTokenSource,this.featureDisposable=new l.Disposable,this.allowedSchemes=[l.Schemes.file,l.Schemes.notebookCell];const g=new l.Disposable;let a=!1;this.addDispose(this.monacoEditor.onDidChangeModel(({newModelUrl:u})=>{if(!u)return;const d=this.allowedSchemes.includes(u.scheme);d!==a&&(a=!!d,a?g.addDispose(this.mount()):g.dispose())}));const h=s.getModel();h&&this.allowedSchemes.includes(h.uri.scheme)&&(a=!0,g.addDispose(this.mount())),this.addDispose(g)}};t.BaseAIMonacoEditorController=v,t.BaseAIMonacoEditorController=v=n=r.__decorate([r.__param(0,(0,o.Optional)()),r.__param(1,(0,o.Optional)()),r.__metadata("design:paramtypes",[o.Injector,Object])],v)},72713:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AICodeActionContribution=void 0;const n=e(85608),r=e(76003),o=e(57925),l=e(43718),p=e(89132);let v=class extends l.Disposable{registerCommands(_){_.registerCommand(o.AI_CODE_ACTION,{execute:(s,g)=>{this.codeActionService.fireCodeActionRun(g,s)}})}};t.AICodeActionContribution=v,n.__decorate([(0,r.Autowired)(p.CodeActionService),n.__metadata("design:type",p.CodeActionService)],v.prototype,"codeActionService",void 0),t.AICodeActionContribution=v=n.__decorate([(0,l.Domain)(l.CommandContribution)],v)},79559:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CodeActionSingleHandler=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(43718),p=n.__importStar(e(20868)),v=e(52902),m=e(77714),_=e(85679),s=e(99906),g=e(89132);let a=class extends s.BaseAIMonacoContribHandler{constructor(){super(),this.inlineChatActionEnabled=this.preferenceService.getValid(l.AINativeSettingSectionsId.InlineChatCodeActionEnabled,!0),this.addDispose(this.preferenceService.onSpecificPreferenceChange(l.AINativeSettingSectionsId.InlineChatCodeActionEnabled,({newValue:u})=>{this.inlineChatActionEnabled=u,u?this.load():this.unload()}))}doContribute(){return v.monacoApi.languages.registerCodeActionProvider("*",{provideCodeActions:async(u,d)=>{if(!this.inlineChatActionEnabled)return;const E=u.getLineContent(d.startLineNumber);if(E?.trim()===m.empty||!this.shouldHandle(u.uri))return;const{languageParserService:f,codeActionService:c}=this,b=u.getLanguageId(),y=f.createParser(b);if(!y)return;const S=c.getCodeActions();if(!S||S.length===0)return;const A=d.getStartPosition();if(!A)return;function w(I){return{actions:S.map(O=>{const M={};O.command&&(M.id=O.command.id,M.arguments=[I.range,...O.command.arguments]);let R=O.title;switch(I.infoCategory){case"function":R=R+` for Function: ${I.name}`}return{...O,title:R,ranges:[I.range],command:M}}),dispose(){}}}const T=await y.provideCodeBlockInfo(u,A);if(T)return w(T);if(u.getLineLength(A.lineNumber)===0&&this.monacoEditor){const I=this.monacoEditor.getVisibleRanges();if(I.length===0)return;const O=new p.Range(A.lineNumber,0,I[0].endLineNumber+1,0),M=await y.provideCodeBlockInfoInRange(u,O);if(M)return w(M)}}})}};t.CodeActionSingleHandler=a,n.__decorate([(0,r.Autowired)(g.CodeActionService),n.__metadata("design:type",g.CodeActionService)],a.prototype,"codeActionService",void 0),n.__decorate([(0,r.Autowired)(o.PreferenceService),n.__metadata("design:type",Object)],a.prototype,"preferenceService",void 0),n.__decorate([(0,r.Autowired)(_.LanguageParserService),n.__metadata("design:type",_.LanguageParserService)],a.prototype,"languageParserService",void 0),t.CodeActionSingleHandler=a=n.__decorate([(0,r.Injectable)(),n.__metadata("design:paramtypes",[])],a)},89132:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CodeActionService=void 0;const n=e(85608),r=e(76003),o=e(57925),l=e(43718);let p=class extends l.Disposable{constructor(){super(...arguments),this.codeActionsMap=new Map,this._onCodeActionRun=new l.Emitter,this.onCodeActionRun=this._onCodeActionRun.event}dispose(){super.dispose(),this.codeActionsMap.clear()}fireCodeActionRun(m,_){this._onCodeActionRun.fire({id:m,range:_})}getCodeActions(){return Array.from(this.codeActionsMap.values())}deleteCodeActionById(m){this.codeActionsMap.delete(m)}registerCodeAction(m){var _;const{codeAction:s,id:g}=m;if(!s)return;const a={title:s.title||m.name,isAI:!0,isPreferred:(_=s.isPreferred)!==null&&_!==void 0?_:!0,kind:s.kind||"InlineChat",disabled:s.disabled,command:{id:o.AI_CODE_ACTION.id,title:s.title||m.name,arguments:[m.id]}};this.codeActionsMap.set(g,a)}};t.CodeActionService=p,t.CodeActionService=p=n.__decorate([(0,r.Injectable)()],p)},57232:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AIInlineCompletionsProvider=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(43718),p=n.__importStar(e(20868)),v=e(687),m=e(71863),_={line:-1,column:-1,last:null};class s{constructor(){this.queue=[]}addReq(h){this.queue.push(h)}runReq(){return this.queue.length===0?void 0:this.queue.pop().run()}cancelReq(){this.queue.length!==0&&(this.queue.forEach(h=>{h.cancelRequest()}),this.queue=[])}}let g=class extends l.WithEventBus{constructor(){super(),this.inlineComletionsDebounceTime=this.preferenceService.getValid(l.AINativeSettingSectionsId.IntelligentCompletionsDebounceTime,150),this.addDispose(this.preferenceService.onSpecificPreferenceChange(l.AINativeSettingSectionsId.IntelligentCompletionsDebounceTime,({newValue:h})=>{this.inlineComletionsDebounceTime=h})),this.mount()}mount(){this.isManual=!1,this.isDelEvent=!1,this.reqStack=new s}setVisibleCompletion(h){this.aiCompletionsService.setVisibleCompletion(h)}hideStatusBarItem(){this.aiCompletionsService.hideStatusBarItem()}cancelRequest(){this.aiCompletionsService.cancelRequest(),this.reqStack&&this.reqStack.cancelReq()}async provideInlineCompletionItems(h,u,d,E){if(d.triggerKind===p.InlineCompletionTriggerKind.Automatic&&_.column===u.column&&_.line===u.lineNumber&&_.last!==void 0)return _.column=-1,_.line=-1,_.last;this.cancelRequest(),this.hideStatusBarItem();const f=this.isManual;if(this.isDelEvent&&!f)return;this.updateIsManual(!1);const c=this.injector.get(v.InlineCompletionRequestTask,[h,u,E]);if(this.reqStack.addReq(c),f||await(0,l.raceCancellation)((0,l.sleep)(this.inlineComletionsDebounceTime),E),E?.isCancellationRequested)return;const b=await this.reqStack.runReq();if(b)return _.column=u.column,_.line=u.lineNumber,_.last={items:b},_.last}updateIsManual(h){this.isManual=h}};t.AIInlineCompletionsProvider=g,n.__decorate([(0,r.Autowired)(m.AICompletionsService),n.__metadata("design:type",m.AICompletionsService)],g.prototype,"aiCompletionsService",void 0),n.__decorate([(0,r.Autowired)(r.INJECTOR_TOKEN),n.__metadata("design:type",r.Injector)],g.prototype,"injector",void 0),n.__decorate([(0,r.Autowired)(o.PreferenceService),n.__metadata("design:type",Object)],g.prototype,"preferenceService",void 0),t.AIInlineCompletionsProvider=g=n.__decorate([(0,r.Injectable)(),n.__metadata("design:paramtypes",[])],g)},2409:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lineBasedCompletionModelConfigs=t.DEFAULT_COMPLECTION_MODEL=void 0;const n=e(71585);t.DEFAULT_COMPLECTION_MODEL={maxPromptTokenSize:3e3,maxExecuteTimeMillSecond:1e3,tokenizerName:n.TokenizerName.cl100k_base,wishList:{afterCursor:{enable:!0,attributeName:n.WishListAttributeName.afterCursor,extOption:{suffixPercent:.25,minBlockSize:25},priority:1,strategy:n.StrategyType.InterceptBasedOnLine},beforeCursor:{enable:!0,attributeName:n.WishListAttributeName.beforeCursor,extOption:{prefixPercent:.75,minBlockSize:75},priority:0,strategy:n.StrategyType.InterceptBasedOnLine},importedFile:{attributeName:n.WishListAttributeName.importedFile,enable:!0,extOption:{maxTime:200,importedFilesMaxNum:10,language:["typescript"],maxPercent:.8,patternPrefix:"Import Files from ",patternSuffix:`
|
|
29296
29296
|
`},priority:3,strategy:n.StrategyType.InterceptBasedOnLine},languageMarker:{attributeName:n.WishListAttributeName.languageMarker,enable:!0,extOption:{language:["python","html"],maxPercent:0},priority:4,strategy:n.StrategyType.InterceptBasedOnLine},pathMarker:{attributeName:n.WishListAttributeName.pathMarker,enable:!0,priority:1,strategy:n.StrategyType.InterceptBasedOnLine},similarFile:{attributeName:n.WishListAttributeName.similarFile,enable:!0,extOption:{maxTime:200,fileMaxLength:5e3,maxPercent:.3,neighboringTabsMaxNum:20,neighboringTabsOption:[n.NeighboringTabsOption.openFileHistory,n.NeighboringTabsOption.editFileRecent,n.NeighboringTabsOption.editFileHistory],patternPrefix:"Compare this snippet from ",patternSuffix:`
|
|
29297
29297
|
`,similarityThreshold:.6,snippetMaxNum:4,windowSize:60,snippetSelectionMode:n.SnippetSelectionOption.BestMatch},priority:2,strategy:n.StrategyType.InterceptBasedOnLine}}},t.lineBasedCompletionModelConfigs={completionPromptMaxLineSize:1024,completionSuffixMaxLineSize:500}},72991:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineCompletionsController=void 0;const r=e(85608).__importDefault(e(12784)),o=e(57925),l=e(43718),p=e(57517),v=e(20868),m=e(52902),_=e(77714),s=e(37355),g=e(19413),a=e(77659),h=e(99906);class u extends h.BaseAIMonacoEditorController{constructor(){super(...arguments),this.sequencer=new l.Sequencer}static get(E){return E.getContribution(u.ID)}get eventBus(){return this.injector.get(l.IEventBus)}get commandService(){return this.injector.get(l.CommandService)}get aiInlineCompletionsProvider(){return this.injector.get(g.IAIInlineCompletionsProvider)}get intelligentCompletionsRegistry(){return this.injector.get(l.IntelligentCompletionsRegistryToken)}mount(){this.aiNativeContextKey=this.injector.get(a.AINativeContextKey,[this.monacoEditor.contextKeyService]);const E=()=>{this.aiInlineCompletionsProvider.hideStatusBarItem();const y=this.monacoEditor.getSelection();y&&(y.startLineNumber!==y.endLineNumber||y.startColumn!==y.endColumn)&&this.aiInlineCompletionsProvider.cancelRequest()},f=(0,r.default)(E,50,{maxWait:200,leading:!0,trailing:!0}),c=new Set([s.InlineCompletionContextKeys.inlineSuggestionVisible.key]);this.featureDisposable.addDispose(this.monacoEditor.contextKeyService.onDidChangeContext(y=>{y.affectsSome(c)&&!s.InlineCompletionContextKeys.inlineSuggestionVisible.getValue(this.monacoEditor.contextKeyService)&&this.preDidShowItems&&(0,l.runWhenIdle)(()=>{this.preDidShowItems=void 0,this.commandService.executeCommand(o.AI_INLINE_COMPLETION_VISIBLE.id,!1)})})),this.featureDisposable.addDispose(this.eventBus.on(p.EditorSelectionChangeEvent,y=>{y.payload.source==="mouse"?f():(f.cancel(),E())})),this.featureDisposable.addDispose(this.monacoEditor.onDidChangeModelContent(y=>{const S=y.changes;for(const A of S)A.text===_.empty?(this.aiInlineCompletionsProvider.isDelEvent=!0,this.aiInlineCompletionsProvider.cancelRequest()):this.aiInlineCompletionsProvider.isDelEvent=!1})),this.featureDisposable.addDispose(this.monacoEditor.onDidBlurEditorText(()=>{this.commandService.executeCommand(o.AI_INLINE_COMPLETION_VISIBLE.id,!1)}));let b;return this.featureDisposable.addDispose(m.monacoApi.languages.registerInlineCompletionsProvider("*",{groupId:"ai-native-intelligent-completions",provideInlineCompletions:async(y,S,A,w)=>{if(this.preDidShowItems){b||(b=S.delta(0,-1));const D=y.getValueInRange(v.Range.fromPositions(b,S));if(this.preDidShowItems.items[0].insertText.toString().startsWith(D))return this.preDidShowItems;b=void 0}return await this.sequencer.queue(()=>this.aiInlineCompletionsProvider.provideInlineCompletionItems(y,S,A,w))},freeInlineCompletions(){},handleItemDidShow:y=>{y.items.length>0&&(this.preDidShowItems=y,this.aiInlineCompletionsProvider.setVisibleCompletion(!0))}})),this.featureDisposable}async fetchProvider(E){const f=this.intelligentCompletionsRegistry.getInlineCompletionsProvider();if(!f||this.aiNativeContextKey.multiLineEditsIsVisible.get())return;const b=this.monacoEditor.getPosition();return await f(this.monacoEditor,b,E,this.token)}}t.InlineCompletionsController=u,u.ID="editor.contrib.ai.inline.completions"},687:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InlineCompletionRequestTask=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(57925),p=e(43718),v=e(52664),m=e(54414),_=e(51553),s=n.__importStar(e(20868)),g=e(74292),a=e(72991),h=e(64016),u=e(74151),d=e(71863),E=b=>{const y=new Set;for(const S of b)y.add(S);return y},f=(b,y)=>{let S="";const A=E(b);for(const w of y)(w===" "||!A.has(w))&&(S+=w);return S};let c=class extends p.Disposable{constructor(y,S,A){super(),this.model=y,this.position=S,this.token=A,this._disposables=new p.DisposableStore,this.isEnablePromptEngineering=!0,this.isCancelFlag=!1,this.isEnablePromptEngineering=this.preferenceService.getValid(p.AINativeSettingSectionsId.IntelligentCompletionsPromptEngineeringEnabled,this.isEnablePromptEngineering),this._disposables.add(this.preferenceService.onSpecificPreferenceChange(p.AINativeSettingSectionsId.IntelligentCompletionsPromptEngineeringEnabled,({newValue:w})=>{this.isEnablePromptEngineering=w}))}async constructRequestBean(y,S){const A=u.lineBasedPromptProcessor.processPrefix(y.prefix),w=u.lineBasedPromptProcessor.processSuffix(y.suffix);return{prompt:A,suffix:w,sessionId:(0,p.uuid)(),language:y.language,fileUrl:y.fileUrl,workspaceDir:y.workspaceDir}}async run(){const{model:y,position:S,token:A}=this;if(!y)return[];if(A.isCancellationRequested)return[];if(this.isCancelFlag)return[];const w=new s.Range(0,0,S.lineNumber,S.column);let T=y.getValueInRange(w);T===""&&(T+=`
|
|
29298
29298
|
`);const D=new s.Range(S.lineNumber,S.column,y.getLineCount(),Number.MAX_SAFE_INTEGER),I=y.getValueInRange(D),O=y.getLanguageId(),M={fileUrl:y.uri.fsPath,filename:y.uri.toString().split("/").pop(),language:O,prefix:T,suffix:I,uri:p.URI.from(y.uri),workspaceDir:this.appConfig.workspaceDir},R=await this.constructRequestBean(M,A);if(this.isCancelFlag)return[];const P=Date.now();let k;const F=this.promptCache.getCache(R),x=F?.relationId||this.aiReporter.start(v.AIServiceType.Completion,{message:v.AIServiceType.Completion});if(this.aiCompletionsService.setLastRelationId(x),F)k=F;else try{if(this.aiCompletionsService.updateStatusBarItem("running",!0),this.intelligentCompletionsRegistry.getInlineCompletionsProvider()){const j=this.workbenchEditorService.currentCodeEditor;if(!j)return[];const W=a.InlineCompletionsController.get(j.monacoEditor);k=await W?.fetchProvider(R)}else k=await this.aiCompletionsService.complete(R)}catch(B){return this.aiCompletionsService.reporterEnd(x,{success:!1,replytime:Date.now()-P,message:B.toString()}),this.aiCompletionsService.hideStatusBarItem(),[]}finally{this.aiCompletionsService.hideStatusBarItem()}return k?this.pushLineCompletions(k,R,P,x):[]}pushLineCompletions(y,S,A,w){var T;const{position:D}=this;if(this.aiCompletionsService.setLastSessionId(S.sessionId),!((T=y?.extra)===null||T===void 0)&&T.isCancel||this.token.isCancellationRequested||this.isCancelFlag)return this.aiCompletionsService.reporterEnd(w,{success:!0,replytime:Date.now()-A,isStop:!0,completionNum:0}),this.aiCompletionsService.updateStatusBarItem("canceled",!1),[];if(!y||!y.items||y.items.length===0)return this.aiCompletionsService.reporterEnd(w,{success:!0,replytime:Date.now()-A,completionNum:0}),this.aiCompletionsService.updateStatusBarItem("no result",!1),[];y.items.length>0&&this.promptCache.setCache(S,{...y,relationId:w}),this.aiCompletionsService.updateStatusBarItem("completion result: "+y.items.length,!1),this.dispose();const I=new Array;for(const O of y.items){const R=O.insertText.toString().trimEnd(),P=this.model,k=P.getValueInRange({startLineNumber:D.lineNumber,startColumn:D.column,endLineNumber:D.lineNumber,endColumn:P.getLineMaxColumn(D.lineNumber)}),F=f(R,k),x=R+F;this.aiCompletionsService.setLastCompletionContent(x),I.push({...O,insertText:x,range:new s.Range(D.lineNumber,D.column,D.lineNumber,D.column+R.length+k.length),sessionId:S.sessionId,relationId:w,command:{id:l.AI_INLINE_COMPLETION_REPORTER.id,title:"",arguments:[w,S.sessionId,!0,x]}})}return I}dispose(){this._disposables.dispose()}cancelRequest(){this.isCancelFlag=!0,this.dispose()}};t.InlineCompletionRequestTask=c,n.__decorate([(0,r.Autowired)(v.IAIReporter),n.__metadata("design:type",Object)],c.prototype,"aiReporter",void 0),n.__decorate([(0,r.Autowired)(h.PromptCache),n.__metadata("design:type",h.PromptCache)],c.prototype,"promptCache",void 0),n.__decorate([(0,r.Autowired)(d.AICompletionsService),n.__metadata("design:type",d.AICompletionsService)],c.prototype,"aiCompletionsService",void 0),n.__decorate([(0,r.Autowired)(o.PreferenceService),n.__metadata("design:type",Object)],c.prototype,"preferenceService",void 0),n.__decorate([(0,r.Autowired)(o.AppConfig),n.__metadata("design:type",Object)],c.prototype,"appConfig",void 0),n.__decorate([(0,r.Autowired)(p.IntelligentCompletionsRegistryToken),n.__metadata("design:type",g.IntelligentCompletionsRegistry)],c.prototype,"intelligentCompletionsRegistry",void 0),n.__decorate([(0,r.Autowired)(m.WorkbenchEditorService),n.__metadata("design:type",_.WorkbenchEditorServiceImpl)],c.prototype,"workbenchEditorService",void 0),t.InlineCompletionRequestTask=c=n.__decorate([(0,r.Injectable)({multiple:!0}),n.__metadata("design:paramtypes",[Object,s.Position,Object])],c)},64208:(L,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MAX_NEIGHBOR_AGGREGATE_LENGTH=t.EXCLUDED_NEIGHBORS=t.LANGUAGE_COMMENT_MARKERS=void 0,t.LANGUAGE_COMMENT_MARKERS={abap:{start:'"',end:""},bat:{start:"REM",end:""},bibtex:{start:"%",end:""},blade:{start:"#",end:""},c:{start:"//",end:""},clojure:{start:";",end:""},coffeescript:{start:"//",end:""},cpp:{start:"//",end:""},csharp:{start:"//",end:""},css:{start:"/*",end:"*/"},dart:{start:"//",end:""},dockerfile:{start:"#",end:""},elixir:{start:"#",end:""},erb:{start:"<%#",end:"%>"},erlang:{start:"%",end:""},fsharp:{start:"//",end:""},go:{start:"//",end:""},groovy:{start:"//",end:""},haml:{start:"-#",end:""},handlebars:{start:"{{!",end:"}}"},haskell:{start:"--",end:""},html:{start:"<!--",end:"-->"},ini:{start:";",end:""},java:{start:"//",end:""},javascript:{start:"//",end:""},javascriptreact:{start:"//",end:""},jsonc:{start:"//",end:""},jsx:{start:"//",end:""},julia:{start:"#",end:""},kotlin:{start:"//",end:""},latex:{start:"%",end:""},less:{start:"//",end:""},lua:{start:"--",end:""},makefile:{start:"#",end:""},markdown:{start:"[]: #",end:""},"objective-c":{start:"//",end:""},"objective-cpp":{start:"//",end:""},perl:{start:"#",end:""},php:{start:"//",end:""},powershell:{start:"#",end:""},pug:{start:"//",end:""},python:{start:"#",end:""},ql:{start:"//",end:""},r:{start:"#",end:""},razor:{start:"<!--",end:"-->"},ruby:{start:"#",end:""},rust:{start:"//",end:""},sass:{start:"//",end:""},scala:{start:"//",end:""},scss:{start:"//",end:""},shellscript:{start:"#",end:""},slim:{start:"/",end:""},solidity:{start:"//",end:""},sql:{start:"--",end:""},stylus:{start:"//",end:""},svelte:{start:"<!--",end:"-->"},swift:{start:"//",end:""},terraform:{start:"#",end:""},tex:{start:"%",end:""},typescript:{start:"//",end:""},typescriptreact:{start:"//",end:""},vb:{start:"'",end:""},verilog:{start:"//",end:""},"vue-html":{start:"<!--",end:"-->"},vue:{start:"//",end:""},xml:{start:"<!--",end:"-->"},xsl:{start:"<!--",end:"-->"},yaml:{start:"#",end:""},diff:{start:"#",end:""}},t.EXCLUDED_NEIGHBORS=["node_modules","dist","site-packages"],t.MAX_NEIGHBOR_AGGREGATE_LENGTH=2e5},68728:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getImportedFile=t.extractLocalImportContext=t.getImportedFilesInterface=void 0;const n=e(43718),r=e(14951),o=e(55121),l=e(51500),p=e(85679),v=e(69056),m=async(g,a,h,u)=>{var d;const E=u.get(p.LanguageParserService);let f=[];const c=[],b=E.createParser(a.languageId);b&&(f=await b.extractImportPaths(g));const y=(d=h.maxTime)!==null&&d!==void 0?d:200,S=Date.now();for(const A of f){let w="";const T=a.uri.parent.codeUri.fsPath;if(!(A.startsWith("@/")||A.startsWith("~")||!A.startsWith("."))){A==="."?w=new o.Path(T).join("index.ts").toString():w=new o.Path(T).join(`${A}${v.LANGUAGE_TO_SUFFIX[a.languageId]}`).toString();try{const D=u.get(r.IFileServiceClient),I=u.get(l.IWorkspaceService),O=n.URI.file(w),M=await D.readFile(O.codeUri.fsPath),R=await b?.extractInterfaceOrTypeCode(M.content.toString());if(R&&R.length>0){const P=await I.asRelativePath(O);P?.path&&c.push([P.path,R])}}catch{}if(Date.now()-S>y)break}}return c};t.getImportedFilesInterface=m;const _=async(g,a,h)=>{const{source:u}=g;return g.languageId==="typescript"?(0,t.getImportedFilesInterface)(u,g,a,h):[]};t.extractLocalImportContext=_;const s=async(g,a,h)=>{if(g.language&&!a.language.includes(g.language))return[];const u=g.prefix;return(0,t.extractLocalImportContext)({source:u,uri:g.uri,languageId:g.language,offset:u.length},a,h)};t.getImportedFile=s},277:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FixedWindowSizeJaccardMatcher=t.getCursorContext=void 0;const n=e(71585),r=e(79253),o=e(64806),l=(m,_={})=>{const s={tokenizerName:n.TokenizerName.cl100k_base,..._},g=(0,o.getTokenizer)(s.tokenizerName);if(s.maxLineCount&&s.maxLineCount<0)throw new Error("maxLineCount must be non-negative if defined");if(s.maxTokenLength&&s.maxTokenLength<0)throw new Error("maxTokenLength must be non-negative if defined");if(s.maxLineCount===0||s.maxTokenLength===0)return{context:"",lineCount:0,tokenLength:0,tokenizerName:s.tokenizerName};let a=m.source.slice(0,m.offset);return s.maxLineCount&&(a=a.split(`
|
|
@@ -29484,7 +29484,7 @@ Adhere to these rules:
|
|
|
29484
29484
|
${v}
|
|
29485
29485
|
</user_query>`}};t.DefaultChatAgentPromptProvider=o,t.DefaultChatAgentPromptProvider=o=n.__decorate([(0,r.Injectable)()],o)},69820:(L,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NearestCodeBlockType=void 0;var e;(function(n){n.Block="block",n.Line="line"})(e||(t.NearestCodeBlockType=e={}))},98864:(L,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getToolName=t.extractCodeBlocks=t.isDocumentValid=t.isDocumentTooShort=t.isDocumentTooLarge=void 0;const e="```",n=10,r=m=>{try{m.getText()}catch(_){if(_ instanceof RangeError)return!0}return!1};t.isDocumentTooLarge=r;const o=m=>m.getText().length<n;t.isDocumentTooShort=o;const l=m=>!((0,t.isDocumentTooLarge)(m)||(0,t.isDocumentTooShort)(m));t.isDocumentValid=l;const p=m=>{const _=m.split(`
|
|
29486
29486
|
`);let s=[],g=!1,a=0;return _.forEach((h,u)=>{if(!g&&h.trim().startsWith(e))g=!0,a=u+1;else if(g&&h.trim().startsWith(e)){g=!1;const d=u;s=_.slice(a,d)}g&&a!==u+1&&s.push(h)}),s.join(`
|
|
29487
|
-
`)};t.extractCodeBlocks=p;const v=(m,_="sumi-builtin")=>`mcp_${_}_${m}`;t.getToolName=v},26471:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),e(85608).__exportStar(e(19413),t)},15504:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentReactions=t.CommentReactionSwitcher=void 0;const n=e(85608),r=n.__importDefault(e(14041)),o=e(41869),l=e(81878),p=e(25918),v=e(93899),m=e(52416),_=e(69635),s=n.__importDefault(e(38877)),g=({thread:h,comment:u,className:d})=>{const E=`${h.providerId}_${h.id}_${u.id}`,f=`${v.MenuId.CommentReactionSwitcherMenu}_${E}`,c=(0,o.useInjectable)(v.IMenuRegistry),b=(0,o.useInjectable)(v.AbstractMenuService);r.default.useEffect(()=>{const S=new o.Disposable,A=`${v.MenuId.CommentReactionSwitcherSubmenu}_${E}`;return S.addDispose(c.registerMenuItem(f,{submenu:A,label:A,iconClass:(0,o.getExternalIcon)("reactions"),group:"navigation"})),S.addDispose(c.registerMenuItems(A,u.reactions.map(w=>({command:{id:_.SwitchCommandReaction,label:w.label},extraTailArgs:[{thread:h,comment:u,reaction:w}]})))),()=>S.dispose()},[]);const y=r.default.useMemo(()=>b.createMenu(f),[]);return r.default.createElement(p.InlineActionBar,{className:d,menus:y,regroup:S=>[S,[]],type:"icon"})};t.CommentReactionSwitcher=g;const a=({thread:h,comment:u})=>{var d;const E=(0,o.useInjectable)(o.IEventBus),f=(0,o.useInjectable)(m.IIconService),c=r.default.useCallback(b=>{E.fire(new _.CommentReactionClick({thread:h,comment:u,reaction:b}))},[]);return r.default.createElement("div",{className:s.default.comment_reactions},(d=u.reactions)===null||d===void 0?void 0:d.filter(b=>b.count!==0).map(b=>r.default.createElement(l.Button,{key:b.label,onClick:()=>c(b),type:"secondary",size:"small",title:b.label,className:s.default.comment_reaction,iconClass:f.fromIcon("",b.iconPath.toString(),m.IconType.Background)},"\xA0",b.count)))};t.CommentReactions=a},54143:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentsBody=void 0;const n=e(85608),r=n.__importDefault(e(14041)),o=n.__importDefault(e(43144)),l=e(84605),p=n.__importDefault(e(38877)),v=e(70154),m=({root:_,children:s})=>o.default.createPortal(s,_);t.CommentsBody=r.default.memo(({body:_})=>{const s=r.default.useRef(null),[g,a]=r.default.useState(null),h=r.default.useMemo(()=>{const u=(0,l.createMarkedRenderer)();return u.link=(d,E,f)=>`<a target="_blank" rel="noopener" href="${d}" title="${E}">${f}</a>`,u},[]);return r.default.useEffect(()=>{if(s.current){const u=s.current.attachShadow({mode:"open"});g||a(u)}},[]),r.default.createElement("div",{ref:s,className:p.default.comment_shadow_box},g&&r.default.createElement(m,{root:g},r.default.createElement("style",null,v.markdownCss),r.default.createElement("div",{dangerouslySetInnerHTML:{__html:(0,l.toMarkdownHtml)(typeof _=="string"?_:_.value,{gfm:!0,breaks:!1,pedantic:!1,smartLists:!0,smartypants:!1,renderer:h})}})))})},66480:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentsFeatureRegistry=void 0;const n=e(85608),r=e(76003);let o=class{constructor(){this.config={},this.options={},this.panelTreeNodeHandlers=[],this.mentionsOptions={},this.providerFeature=new Map}registerConfig(p){this.config={...this.config,...p}}registerPanelTreeNodeHandler(p){this.panelTreeNodeHandlers.push(p)}registerPanelOptions(p){this.options={...this.options,...p}}registerFileUploadHandler(p){this.fileUploadHandler=p}registerMentionsOptions(p){this.mentionsOptions=p}registerZoneWidgetRender(p){this.zoneWidgetRender=p}getConfig(){return this.config}getCommentsPanelOptions(){return this.options}getCommentsPanelTreeNodeHandlers(){return this.panelTreeNodeHandlers}getFileUploadHandler(){return this.fileUploadHandler}getMentionsOptions(){return this.mentionsOptions}getZoneWidgetRender(){return this.zoneWidgetRender}registerProviderFeature(p,v){this.providerFeature.set(p,v)}getProviderFeature(p){return this.providerFeature.get(p)}};t.CommentsFeatureRegistry=o,t.CommentsFeatureRegistry=o=n.__decorate([(0,r.Injectable)()],o)},37357:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentItem=void 0;const n=e(85608),r=n.__importDefault(e(14041)),o=e(97267),l=e(41869),p=e(25918),v=e(93899),m=e(69635),_=e(15504),s=e(54143),g=e(42018),a=n.__importDefault(e(38877)),h=({timestamp:f})=>{const c=r.default.useMemo(()=>{const b=new Date(f);return(0,l.toLocalString)(b)},[f]);return r.default.createElement("span",{className:a.default.comment_item_timestamp},c)},u=(f,c)=>{const b=(0,l.useInjectable)(v.AbstractMenuService),{body:y,contextValue:S}=c,[A,w]=r.default.useState(""),T=(0,l.useInjectable)(m.ICommentsFeatureRegistry),D=r.default.useMemo(()=>T.getFileUploadHandler(),[]);r.default.useEffect(()=>{w(y)},[y]);const I=r.default.useMemo(()=>f.createScoped(),[]),O=r.default.useMemo(()=>I.createKey("commentIsEmpty",!c.body),[]),M=r.default.useMemo(()=>b.createMenu(v.MenuId.CommentsCommentContext,I),[]),R=r.default.useMemo(()=>b.createMenu(v.MenuId.CommentsCommentTitle,I),[]),P=r.default.useRef(I.createKey("comment",S));r.default.useEffect(()=>{P.current.set(S)},[S]);const k=r.default.useCallback(x=>{O.set(!x.target.value),w(x.target.value)},[]),F=r.default.useCallback(async x=>{if(D){const B=await D(A,x);w(j=>{const W=j+B;return O.set(!W),W})}},[A]);return[A,w,k,M,R,F]},d=({reply:f,thread:c})=>{var b;const{contextKeyService:y}=c,{author:S,label:A,body:w,mode:T,timestamp:D}=f,I=(b=S.iconPath)===null||b===void 0?void 0:b.toString(),[O,M,R,P,k,F]=u(y,f),x=r.default.useMemo(()=>{const B=(0,l.toMarkdownHtml)(typeof w=="string"?w:w.value);return/^\<p\>[^<>]+\<\/p\>\n$/.test(B)},[w]);return r.default.createElement("div",{className:a.default.reply_item},(0,l.isUndefined)(T)||T===m.CommentMode.Preview?r.default.createElement("div",null,x?r.default.createElement(r.default.Fragment,null,I&&r.default.createElement("img",{className:a.default.reply_item_icon,src:I,alt:S.name}),r.default.createElement("span",{className:a.default.comment_item_author_name},S.name),D&&r.default.createElement(h,{timestamp:D}),typeof A=="string"?r.default.createElement("span",{className:a.default.comment_item_label},A):A," : ",r.default.createElement("span",{className:a.default.comment_item_body},typeof w=="string"?w:w.value),f.reactions&&f.reactions.length>0&&r.default.createElement(_.CommentReactionSwitcher,{className:a.default.reply_item_title,thread:c,comment:f}),r.default.createElement(p.InlineActionBar,{separator:"inline",className:a.default.reply_item_title,menus:k,context:[{thread:c,comment:f,menuId:v.MenuId.CommentsCommentTitle}],type:"icon"})):r.default.createElement(r.default.Fragment,null,r.default.createElement("div",{className:a.default.comment_item_markdown_header},r.default.createElement("div",null,I&&r.default.createElement("img",{className:a.default.reply_item_icon,src:I,alt:S.name}),r.default.createElement("span",{className:a.default.comment_item_author_name},S.name),D&&r.default.createElement(h,{timestamp:D}),typeof A=="string"?r.default.createElement("span",{className:a.default.comment_item_label},A):A," : "),r.default.createElement(p.InlineActionBar,{separator:"inline",className:a.default.reply_item_title,menus:k,context:[{thread:c,comment:f,menuId:v.MenuId.CommentsCommentTitle}],type:"icon"})),r.default.createElement(s.CommentsBody,{body:w}))):r.default.createElement("div",null,r.default.createElement(g.CommentsTextArea,{value:typeof O=="string"?O:O.value,autoFocus:!0,onChange:R,dragFiles:F}),r.default.createElement(p.InlineActionBar,{className:a.default.comment_item_reply,menus:P,context:[{thread:c,comment:f,body:O,menuId:v.MenuId.CommentsCommentContext}],type:"button",separator:"inline",afterClick:()=>{M(w)}})),f.reactions&&f.reactions.length>0&&r.default.createElement(_.CommentReactions,{thread:c,comment:f}))},E=({thread:f,commentThreadContext:c,widget:b})=>{var y,S;const[A,w]=r.default.useState(!1),[T,D]=r.default.useState(""),{contextKeyService:I}=f,O=(0,l.useAutorun)(f.readOnly),[M,...R]=(0,l.useAutorun)(f.comments),{author:P,label:k,body:F,mode:x,timestamp:B}=M,j=(0,l.isString)(P.iconPath)?P.iconPath:!((y=P.iconPath)===null||y===void 0)&&y.authority?(S=P.iconPath)===null||S===void 0?void 0:S.toString():"",[W,U,Z,V,$,Y]=u(I,M),G=(0,l.useInjectable)(m.ICommentsFeatureRegistry),H=r.default.useMemo(()=>G.getFileUploadHandler(),[]),K=r.default.useMemo(()=>I.createKey("commentIsEmpty",!0),[]);function X(oe){K.set(!oe.target.value),D(oe.target.value)}const Q=r.default.useCallback(async oe=>{if(H){const ne=await H(W,oe);D(he=>{const _e=he+ne;return K.set(!_e),_e})}},[T]);return r.default.createElement("div",{className:a.default.comment_item},j&&r.default.createElement("img",{className:a.default.comment_item_icon,src:j,alt:P.name}),r.default.createElement("div",{className:a.default.comment_item_content},r.default.createElement("div",{className:a.default.comment_item_head},r.default.createElement("div",{className:a.default.comment_item_name},r.default.createElement("span",{className:a.default.comment_item_author_name},P.name),B&&r.default.createElement(h,{timestamp:B}),typeof k=="string"?r.default.createElement("span",{className:a.default.comment_item_label},k):k),r.default.createElement("div",{className:a.default.comment_item_actions},M.reactions&&M.reactions.length>0&&r.default.createElement(_.CommentReactionSwitcher,{thread:f,comment:M}),!O&&r.default.createElement(o.Button,{className:a.default.comment_item_reply_button,size:"small",type:"secondary",onClick:()=>w(!0)},(0,l.localize)("comments.thread.action.reply")),r.default.createElement(p.InlineActionBar,{menus:$,context:[{thread:f,comment:M,menuId:v.MenuId.CommentsCommentTitle}],type:"button"}))),(0,l.isUndefined)(x)||x===m.CommentMode.Preview?r.default.createElement(s.CommentsBody,{body:F}):r.default.createElement("div",null,r.default.createElement(g.CommentsTextArea,{value:typeof W=="string"?W:W.value,autoFocus:!0,onChange:Z,dragFiles:Y}),r.default.createElement(p.InlineActionBar,{className:a.default.comment_item_context,menus:V,context:[{thread:f,comment:M,body:W,menuId:v.MenuId.CommentsCommentContext}],separator:"inline",type:"button",afterClick:()=>{U(F)}})),M.reactions&&M.reactions.length>0&&r.default.createElement(_.CommentReactions,{thread:f,comment:M}),(R.length>0||A)&&r.default.createElement("div",{className:a.default.comment_item_reply_wrap},R.map(oe=>r.default.createElement(d,{key:oe.id,thread:f,reply:oe})),A&&r.default.createElement("div",null,r.default.createElement(g.CommentsTextArea,{autoFocus:!0,value:T,onChange:X,placeholder:`${(0,l.localize)("comments.reply.placeholder")}...`,dragFiles:Q}),r.default.createElement(p.InlineActionBar,{className:a.default.comment_item_reply,menus:c,context:[{thread:f,text:T,widget:b,menuId:v.MenuId.CommentsCommentThreadContext}],separator:"inline",type:"button",afterClick:()=>{D(""),w(!1)}})))))};t.CommentItem=E},53878:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentsPanel=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(97267),l=e(41869),p=e(69635),v=n.__importDefault(e(38877)),m=e(5167),_=e(47842),s=({viewState:g})=>{const a=(0,l.useInjectable)(_.CommentModelService),[h,u]=(0,r.useState)(),d=(0,r.useRef)(null),E=(0,l.useInjectable)(p.ICommentsFeatureRegistry),{handleTreeBlur:f}=a;(0,r.useEffect)(()=>{u(a.treeModel);const T=a.onDidUpdateTreeModel(D=>{u(D)});return()=>{T.dispose()}},[]);const c=(0,r.useCallback)(T=>{a.handleTreeHandler(T)},[a]),b=(0,r.useCallback)(T=>r.default.createElement(m.CommentNodeRendered,{item:T.item,itemType:T.itemType,decorations:a.decorations.getDecorations(T.item),defaultLeftPadding:8,onTwistierClick:a.handleTwistierClick,onClick:a.handleItemClick,leftPadding:8}),[h]),y=(0,r.useMemo)(()=>E.getCommentsPanelOptions(),[]),S=(0,r.useMemo)(()=>y.header,[y]),A=(0,r.useMemo)(()=>r.default.createElement("div",{className:v.default.panel_placeholder},y.defaultPlaceholder||(0,l.localize)("comments.panel.placeholder")),[y]),w=(0,r.useCallback)(()=>h?r.default.createElement(o.RecycleTree,{height:g.height-(S?.height||0),itemHeight:m.COMMENT_TREE_NODE_HEIGHT,onReady:c,model:h,placeholder:()=>A},b):A,[h,S,g.height]);return r.default.createElement("div",{className:v.default.comment_panel,tabIndex:-1,onBlur:f,ref:d},S?.component,w())};t.CommentsPanel=s},42018:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentsTextArea=void 0;const n=e(85608),r=n.__importDefault(e(14041)),o=e(34801),l=e(97267),p=e(41869),v=e(69635),m=e(54143),_=n.__importDefault(e(38877)),s=e(73136),g="@",a="@[__display__](__id__)",h=(u,d)=>`@${d}`;t.CommentsTextArea=r.default.forwardRef((u,d)=>{const{focusDelay:E=0,autoFocus:f=!1,placeholder:c="",onFocus:b,onBlur:y,onChange:S,maxRows:A=10,minRows:w=2,value:T,initialHeight:D,dragFiles:I}=u,[O,M]=r.default.useState(0),R=(0,p.useInjectable)(v.ICommentsFeatureRegistry),P=r.default.useRef(null),k=r.default.useRef(null),F=r.default.useRef(null);r.default.useImperativeHandle(d,()=>P.current);const x=r.default.useCallback(async V=>{var $;V.stopPropagation(),V.preventDefault();const Y=($=V.dataTransfer)===null||$===void 0?void 0:$.files;Y&&I&&await I(Y),P.current&&(P.current.focus(),j(P.current.value))},[I]),B=r.default.useCallback(V=>{V.stopPropagation(),V.preventDefault(),V.dataTransfer.dropEffect="copy"},[]),j=r.default.useCallback(V=>{const $=P.current;if($){const Y=V.toString().length;$.setSelectionRange(Y,Y)}},[]);r.default.useEffect(()=>{var V;const $=P.current;if(!$)return;D&&$.style&&($.style.height=D),E&&setTimeout(()=>{$.focus({preventScroll:!0})},E),j(T);function Y(G){var H,K,X;const Q=G.target;Q&&(Q.nodeName.toUpperCase()==="TEXTAREA"&&Q.scrollHeight>Q.clientHeight||Q.nodeName.toUpperCase()==="UL"||((H=Q.parentElement)===null||H===void 0?void 0:H.nodeName.toUpperCase())==="UL"||((X=(K=Q.parentElement)===null||K===void 0?void 0:K.parentElement)===null||X===void 0?void 0:X.nodeName.toUpperCase())==="UL")&&G.stopPropagation()}return(V=k.current)===null||V===void 0||V.addEventListener("mousewheel",Y,!0),()=>{var G;(G=k.current)===null||G===void 0||G.removeEventListener("mousewheel",Y,!0)}},[]),r.default.useEffect(()=>{O===0&&(setTimeout(()=>{var V;(V=P.current)===null||V===void 0||V.focus({preventScroll:!0})},E),j(T))},[O]);const W=r.default.useMemo(()=>(0,s.getMentionBoxStyle)({minRows:w,maxRows:A}),[w,A]),U=r.default.useMemo(()=>R.getMentionsOptions(),[R]),Z=r.default.useCallback(async(V,$)=>{if(U.providerData){const Y=await U.providerData(V);$(Y)}else $([])},[U]);return r.default.createElement("div",{className:_.default.textarea_container},r.default.createElement(l.Tabs,{mini:!0,value:O,onChange:V=>M(V),tabs:[(0,p.localize)("comments.thread.textarea.write"),(0,p.localize)("comments.thread.textarea.preview")]}),r.default.createElement("div",null,O===0?r.default.createElement("div",{ref:k},r.default.createElement(o.MentionsInput,{autoFocus:f,onDragOver:B,onDrop:x,inputRef:P,ref:F,value:T,placeholder:c,onChange:S,onFocus:b,onBlur:y,style:W},r.default.createElement(o.Mention,{markup:U.markup||a,renderSuggestion:U.renderSuggestion,trigger:g,data:Z,displayTransform:U.displayTransform||h}))):r.default.createElement("div",{className:_.default.textarea_preview},r.default.createElement(m.CommentsBody,{body:T}))))})},49867:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentsThread=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(91830),p=e(54414),v=e(28423),m=e(69635),_=e(90366);let s=class extends o.Disposable{set contextValue(a){this._contextKeyService.createKey("thread",a)}get contextValue(){return this._contextKeyService.getContextKeyValue("thread")}get onDidChangeCollapsibleState(){return this.onDidChangeCollapsibleStateEmitter.event}get onDidChange(){return this.onDidChangeEmitter.event}constructor(a,h,u,d){super(),this.uri=a,this.range=h,this.providerId=u,this.options=d,this.comments=(0,v.observableValue)(this,[]),this.label=(0,v.observableValue)(this,void 0),this.readOnly=(0,v.observableValue)(this,!1),this.isCollapsed=(0,v.observableValue)(this,!1),this.onDidChangeCollapsibleStateEmitter=new o.Emitter,this.widgets=new Map,this._id=`thread_${(0,o.uuid)()}`,this.onDidChangeEmitter=new o.Emitter,this.threadHeaderTitle=(0,v.derived)(this,S=>{const A=this.label.read(S);if(A)return A;const w=this.comments.read(S);if(w.length){const T=new Set(w.map(D=>`@${D.author.name}`));return`${(0,o.localize)("comments.participants")}: `+[...T].join(" ")}else return(0,o.localize)("comments.zone.title")}),this.toggle=S=>{if(this.comments.get().length>0){const w=this.widgets.get(S);w&&w.toggle()}else this.dispose()},this.updateComments(d.comments?d.comments.map(S=>({...S,id:(0,o.uuid)()})):[]),this.data=this.options.data,this._contextKeyService=this.registerDispose(this.globalContextKeyService.createScoped()),new l.ResourceContextKey(this._contextKeyService).set(a),this._contextKeyService.createKey("thread",d.contextValue),(0,v.transaction)(S=>{this.setReadOnly(!!d.readOnly),this.label.set(d.label,S),this.isCollapsed.set(!!this.options.isCollapsed,S)});const f=this._contextKeyService.createKey("threadsLength",this.commentsService.getThreadsByUri(a).length),c=this.comments.get(),b=this._contextKeyService.createKey("commentsLength",c.length),y=this._contextKeyService.createKey("commentThreadIsEmpty",!c.length);this._contextKeyService.createKey("commentController",u),this.addDispose((0,v.autorun)(S=>{const A=this.comments.read(S).length;b.set(A),y.set(!A)})),this.addDispose((0,v.autorun)(S=>{this.isCollapsed.read(S)?this.hideAll():this.showAll()})),this.addDispose(this.commentsService.onThreadsChanged(S=>{S.uri.isEqual(a)&&f.set(this.commentsService.getThreadsByUri(a).length)})),this.addDispose({dispose:()=>{this.updateComments([])}}),this.onDidChangeEmitter.fire()}updateComments(a){(0,v.transaction)(h=>{this.comments.set(a,h)})}getWidgetByEditor(a){return this.widgets.get(a)}get id(){return this._id}get contextKeyService(){return this._contextKeyService}setReadOnly(a){(0,v.transaction)(h=>{this.readOnly.set(a,h),this._contextKeyService.createKey("readOnly",a)})}getEditorsByUri(a){return this.editorCollectionService.listEditors().filter(h=>{var u;return(u=h.currentUri)===null||u===void 0?void 0:u.isEqual(a)})}addWidgetByEditor(a){const h=this.injector.get(_.CommentsZoneWidget,[a,this,{arrowColor:"var(--peekView-border)"}]);return this.addDispose(h.onChangeZoneWidget(()=>{const u=this.commentsService.commentsThreads.filter(f=>this.isEqual(f)),d=u.findIndex(f=>f===this),E=u.slice(d+1);for(const f of E)if(f.isShowWidget(a)){const c=f.getWidgetByEditor(a);c?.resize()}})),this.addDispose(h),this.widgets.set(a,h),a.onDispose(()=>{h.dispose(),this.widgets.delete(a)}),h}show(a){if(a){let h=this.widgets.get(a);h||(h=this.addWidgetByEditor(a)),h.show()}else this.getEditorsByUri(this.uri).forEach(u=>{var d;let E=this.widgets.get(u);E||(E=this.addWidgetByEditor(u)),!((d=u.currentUri)===null||d===void 0)&&d.isEqual(this.uri)&&E.show()})}showWidgetsIfShowed(){var a;for(const h of this.getEditorsByUri(this.uri)){let u=this.widgets.get(h);u||(u=this.addWidgetByEditor(h)),!((a=h.currentUri)===null||a===void 0)&&a.isEqual(this.uri)&&u.isShow&&u.show()}}hideWidgetsByDispose(){var a;for(const[h,u]of this.widgets)!(!((a=h.currentUri)===null||a===void 0)&&a.isEqual(this.uri))&&u.dispose()}isShowWidget(a){if(a){const h=this.widgets.get(a);return h?h.isShow:!1}else{for(const[,h]of this.widgets)return h.isShow;return!1}}hide(a){if(a){const h=this.widgets.get(a);h?.hide()}else this.hideAll()}showAll(){(0,v.transaction)(a=>{this.isCollapsed.set(!1,a)});for(const[,a]of this.widgets)a.show();this.onDidChangeCollapsibleStateEmitter.fire(m.CommentThreadCollapsibleState.Expanded)}hideAll(a){var h;(0,v.transaction)(u=>{this.isCollapsed.set(!0,u)});for(const[u,d]of this.widgets)a?!(!((h=u.currentUri)===null||h===void 0)&&h.isEqual(this.uri))&&d.dispose():d.hide();this.onDidChangeCollapsibleStateEmitter.fire(m.CommentThreadCollapsibleState.Collapsed)}addComment(...a){const h=this.comments.get();(0,v.transaction)(u=>{this.comments.set([...h,...a.map(d=>({...d,id:(0,o.uuid)()}))],u)}),this.onDidChangeEmitter.fire()}removeComment(a){(0,v.transaction)(h=>{this.comments.set(this.comments.get().filter(u=>u!==a),h)}),this.onDidChangeEmitter.fire()}isEqual(a){return a.uri.isEqual(this.uri)&&a.range.startLineNumber===this.range.startLineNumber&&a.range.endLineNumber===this.range.endLineNumber}};t.CommentsThread=s,n.__decorate([(0,r.Autowired)(m.ICommentsService),n.__metadata("design:type",Object)],s.prototype,"commentsService",void 0),n.__decorate([(0,r.Autowired)(o.IContextKeyService),n.__metadata("design:type",Object)],s.prototype,"globalContextKeyService",void 0),n.__decorate([(0,r.Autowired)(p.EditorCollectionService),n.__metadata("design:type",p.EditorCollectionService)],s.prototype,"editorCollectionService",void 0),n.__decorate([(0,r.Autowired)(r.INJECTOR_TOKEN),n.__metadata("design:type",r.Injector)],s.prototype,"injector",void 0),t.CommentsThread=s=n.__decorate([(0,r.Injectable)({multiple:!0}),n.__metadata("design:paramtypes",[o.URI,Object,String,Object])],s)},73804:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentsZoneService=void 0;const n=e(85608),r=e(76003),o=e(93899),l=e(43718),p=e(69635),v=e(49867);let m=class extends l.Disposable{constructor(s){super(),this.thread=s}setCurrentCommentThread(s){this.commentService.setCurrentCommentThread(s)}get commentThreadTitle(){return this.registerDispose(this.menuService.createMenu(o.MenuId.CommentsCommentThreadTitle,this.thread.contextKeyService))}get commentThreadContext(){return this.registerDispose(this.menuService.createMenu(o.MenuId.CommentsCommentThreadContext,this.thread.contextKeyService))}};t.CommentsZoneService=m,n.__decorate([(0,r.Autowired)(o.AbstractMenuService),n.__metadata("design:type",o.AbstractMenuService)],m.prototype,"menuService",void 0),n.__decorate([(0,r.Autowired)(p.ICommentsService),n.__metadata("design:type",Object)],m.prototype,"commentService",void 0),n.__decorate([l.memoize,n.__metadata("design:type",Object),n.__metadata("design:paramtypes",[])],m.prototype,"commentThreadTitle",null),n.__decorate([l.memoize,n.__metadata("design:type",Object),n.__metadata("design:paramtypes",[])],m.prototype,"commentThreadContext",null),t.CommentsZoneService=m=n.__decorate([(0,r.Injectable)({multiple:!0}),n.__param(0,(0,r.Optional)()),n.__metadata("design:paramtypes",[v.CommentsThread])],m)},90366:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentsZoneWidget=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importDefault(e(14041)),l=n.__importDefault(e(25873)),p=e(76003),v=e(41869),m=e(25918),_=e(93899),s=e(20303),g=e(69635),a=e(37357),h=e(42018),u=e(73804),d=n.__importDefault(e(38877)),E=({thread:c,widget:b})=>{const{contextKeyService:y}=c,S=(0,v.useAutorun)(c.comments),A=(0,v.useAutorun)(c.threadHeaderTitle),T=(0,v.useInjectable)(p.INJECTOR_TOKEN).get(u.CommentsZoneService,[c]),D=(0,v.useInjectable)(g.ICommentsFeatureRegistry),I=o.default.useMemo(()=>D.getFileUploadHandler(),[]),[O,M]=o.default.useState(""),R=o.default.useMemo(()=>y.createKey("commentIsEmpty",!O),[]),P=T.commentThreadTitle,k=T.commentThreadContext,F=o.default.useCallback(V=>{const{value:$}=V.target;M($),R.set(!$)},[]),x=o.default.useMemo(()=>{var V;return((V=D.getProviderFeature(c.providerId))===null||V===void 0?void 0:V.placeholder)||`${(0,v.localize)("comments.reply.placeholder")}...`},[]),B=o.default.useCallback(async V=>{if(I){const $=await I(O,V);M(Y=>{const G=Y+$;return R.set(!G),G})}},[O]);o.default.useEffect(()=>{const V=b.onFirstDisplay(()=>{setTimeout(()=>{b.coreEditor.monacoEditor.revealLine(c.range.endLineNumber+1)},0)});return()=>{V.dispose()}},[]);const j=o.default.useCallback(()=>{T.setCurrentCommentThread(T.thread)},[]),W=o.default.useCallback(()=>{T.setCurrentCommentThread(void 0)},[]),U=o.default.useCallback(()=>{T.setCurrentCommentThread(T.thread)},[]),Z=o.default.useCallback(()=>{T.setCurrentCommentThread(void 0)},[]);return o.default.createElement("div",{tabIndex:-1,onMouseOver:j,onMouseOut:W,onFocus:U,onBlur:Z,className:(0,r.default)(c.options.threadClassName,d.default.comment_container)},o.default.createElement("div",{className:(0,r.default)(c.options.threadHeadClassName,d.default.head)},o.default.createElement("div",{className:d.default.review_title},A),o.default.createElement(m.InlineActionBar,{menus:P,context:[{thread:c,widget:b,menuId:_.MenuId.CommentsCommentThreadTitle}],separator:"inline",type:"icon"})),o.default.createElement("div",{className:d.default.comment_body},S.length>0?o.default.createElement(a.CommentItem,{widget:b,commentThreadContext:k,thread:c}):o.default.createElement("div",null,o.default.createElement(h.CommentsTextArea,{focusDelay:100,initialHeight:"auto",value:O,onChange:F,placeholder:x,dragFiles:B}),o.default.createElement("div",{className:d.default.comment_bottom_actions},o.default.createElement(m.InlineActionBar,{className:d.default.comment_reply_actions,separator:"inline",type:"button",context:[{text:O,widget:b,thread:c,menuId:_.MenuId.CommentsCommentThreadContext}],menus:k})))))};let f=class extends s.ResizeZoneWidget{_fillContainer(){}constructor(b,y,S){super(b.monacoEditor,y.range,{...S,showInHiddenAreas:!0}),this.thread=y,this._onShow=new v.Emitter,this.onShow=this._onShow.event,this._onHide=new v.Emitter,this.onHide=this._onHide.event,this._editor=b,this._isShow=!y.isCollapsed.get();const A=document.createElement("div");this._container.appendChild(A),this.observeContainer(A);const w=this.commentsFeatureRegistry.getZoneWidgetRender();this.wrapperRoot=l.default.createRoot(A),this.wrapperRoot.render(o.default.createElement(v.ConfigProvider,{value:this.appConfig},w?w(this.thread,this):o.default.createElement(E,{thread:this.thread,widget:this}))),this.addDispose({dispose:()=>{var T;(T=this.wrapperRoot)===null||T===void 0||T.unmount(),this.wrapperRoot=void 0}})}get coreEditor(){return this._editor}get isShow(){return this._isShow}show(){super.show(),this._isShow=!0,this._onShow.fire()}hide(){super.hide(),this._isShow=!1,this._onHide.fire()}toggle(){this._isShow?this.hide():this.show()}applyClass(){}applyStyle(){}};t.CommentsZoneWidget=f,n.__decorate([(0,p.Autowired)(v.AppConfig),n.__metadata("design:type",Object)],f.prototype,"appConfig",void 0),n.__decorate([(0,p.Autowired)(g.ICommentsFeatureRegistry),n.__metadata("design:type",Object)],f.prototype,"commentsFeatureRegistry",void 0),t.CommentsZoneWidget=f=n.__decorate([(0,p.Injectable)({multiple:!0}),n.__metadata("design:paramtypes",[Object,Object,Object])],f)},62604:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentsBrowserContribution=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(93899),p=e(57517),v=e(63067),m=e(69635),_=e(47842);let s=class extends o.Disposable{onStart(){this.registerCommentsFeature(),this.listenToCreateCommentsPanel(),this.commentsService.init()}get panelBadge(){const a=this.commentsService.commentsThreads.length;return a?a+"":""}registerCommands(a){a.registerCommand({id:m.CollapseId,label:"%comments.panel.action.collapse%",iconClass:(0,o.getIcon)("collapse-all")},{execute:()=>{this.commentModelService.collapsedAll()}}),a.registerCommand({id:m.CloseThreadId,label:"%comments.thread.action.close%",iconClass:(0,o.getIcon)("up")},{execute:h=>{const{thread:u,widget:d}=h;u.comments.get().length?d.isShow&&d.toggle():u.dispose()}}),a.registerCommand({id:m.SwitchCommandReaction},{execute:h=>{this.eventBus.fire(new m.CommentReactionClick(h))}})}registerMenus(a){a.registerMenuItem(l.MenuId.CommentsCommentThreadTitle,{command:m.CloseThreadId,group:"inline",order:Number.MAX_SAFE_INTEGER})}registerToolbarItems(a){a.registerItem({id:m.CollapseId,viewId:m.CommentPanelId,command:m.CollapseId,tooltip:(0,o.localize)("comments.panel.action.collapse")})}registerCommentsFeature(){this.contributions.getContributions().forEach((a,h)=>{this.addDispose(this.commentsService.registerCommentRangeProvider(`contribution_${h}`,{getCommentingRanges:u=>a.provideCommentingRanges(u)})),a.registerCommentsFeature&&a.registerCommentsFeature(this.commentsFeatureRegistry)})}listenToCreateCommentsPanel(){this.commentsFeatureRegistry.getCommentsPanelOptions().defaultShow?this.commentsService.registerCommentPanel():o.Event.once(this.commentsService.onThreadsCreated)(()=>{this.commentsService.registerCommentPanel()}),this.addDispose(o.Event.debounce(this.commentsService.onThreadsChanged,()=>{},100)(()=>{const a=this.layoutService.getTabbarHandler(m.CommentPanelId);a?.setBadge(this.panelBadge)},this))}registerEditorFeature(a){a.registerEditorFeatureContribution({contribute:h=>this.commentsService.handleOnCreateEditor(h),provideEditorOptionsForUri:async h=>(await this.commentsService.getContributionRanges(h)).length?{lineDecorationsWidth:25,lineNumbersMinChars:5}:{}})}};t.CommentsBrowserContribution=s,n.__decorate([(0,r.Autowired)(m.ICommentsService),n.__metadata("design:type",Object)],s.prototype,"commentsService",void 0),n.__decorate([(0,r.Autowired)(v.IMainLayoutService),n.__metadata("design:type",Object)],s.prototype,"layoutService",void 0),n.__decorate([(0,r.Autowired)(m.ICommentsFeatureRegistry),n.__metadata("design:type",Object)],s.prototype,"commentsFeatureRegistry",void 0),n.__decorate([(0,r.Autowired)(m.CommentsContribution),n.__metadata("design:type",Object)],s.prototype,"contributions",void 0),n.__decorate([(0,r.Autowired)(o.IEventBus),n.__metadata("design:type",Object)],s.prototype,"eventBus",void 0),n.__decorate([(0,r.Autowired)(_.CommentModelService),n.__metadata("design:type",_.CommentModelService)],s.prototype,"commentModelService",void 0),t.CommentsBrowserContribution=s=n.__decorate([(0,o.Domain)(o.ClientAppContribution,p.BrowserEditorContribution,o.CommandContribution,o.TabBarToolbarContribution,l.MenuContribution)],s)},55011:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentsService=void 0;const n=e(85608),r=n.__importDefault(e(53435)),o=n.__importDefault(e(87809)),l=e(76003),p=e(41869),v=e(57517),m=e(63067),_=e(20868),s=n.__importStar(e(20868)),g=e(62663),a=e(52416),h=n.__importStar(e(24347)),u=e(69635),d=e(53878),E=e(49867),f=e(53711);let c=class extends p.Disposable{constructor(){super(...arguments),this.decorationChangeEmitter=new p.Emitter,this.threads=new Map,this.threadsChangeEmitter=new p.Emitter,this.threadsCommentChangeEmitter=new p.Emitter,this.commentRangeProviderChangeEmitter=new p.Emitter,this.onDidChangeCurrentCommentThreadEmitter=new p.Emitter,this.threadsCreatedEmitter=new p.Emitter,this.rangeProviderMap=new Map,this.rangeOwner=new Map,this.providerDecorationCache=new p.LRUCache(1e4),this.commentRangeDecorationMap=new Map,this.shouldShowCommentsSchemes=new Set(["file","git","diff"]),this.decorationProviderDisposer=p.Disposable.NULL,this.activeThreadDecorationIds=[],this.allEditors=[],this.editorCommentingRangeSpaceReservedMap=new Map,this.editorLineDecorationsWidthMap=new Map}get commentsThreads(){return[...this.threads.values()]}get isMultiCommentsForSingleLine(){var y;return!!(!((y=this.commentsFeatureRegistry.getConfig())===null||y===void 0)&&y.isMultiCommentsForSingleLine)}get currentAuthorAvatar(){var y,S;return(S=(y=this.commentsFeatureRegistry.getConfig())===null||y===void 0?void 0:y.author)===null||S===void 0?void 0:S.avatar}get filterThreadDecoration(){var y;return(y=this.commentsFeatureRegistry.getConfig())===null||y===void 0?void 0:y.filterThreadDecoration}get onThreadsChanged(){return this.threadsChangeEmitter.event}get onThreadsCommentChange(){return this.threadsCommentChangeEmitter.event}get onThreadsCreated(){return this.threadsCreatedEmitter.event}get onCommentRangeProviderChange(){return this.commentRangeProviderChangeEmitter.event}get onDidChangeCurrentCommentThread(){return this.onDidChangeCurrentCommentThreadEmitter.event}setCurrentCommentThread(y){this.onDidChangeCurrentCommentThreadEmitter.fire(y)}createThreadDecoration(y){var S;const A=y.comments.get(),w=A.length===0?this.currentAuthorAvatar:(S=A[0].author.iconPath)===null||S===void 0?void 0:S.toString(),T=w?`${this.iconService.fromIcon("",w,a.IconType.Background)} avatar-icon`:this.iconService.fromString("$(comment)"),D={description:"comments-thread-decoration",glyphMarginClassName:w?["comment-thread",T].join(" "):["comment-range","comment-thread",T].join(" ")};return h.ModelDecorationOptions.createDynamic(D)}updateActiveThreadDecoration(y){var S;const A=this.getCurrentEditor(y?.uri);if(!A)return;(S=this.currentThreadCollapseStateListener)===null||S===void 0||S.dispose();const w=[];if(y){const T=y.range;y.isCollapsed.get()||(this.currentThreadCollapseStateListener=y.onDidChangeCollapsibleState(D=>{D===u.CommentThreadCollapsibleState.Collapsed&&this.updateActiveThreadDecoration(void 0)}),w.push({range:T,options:this.createThreadRangeActiveDecoration()}))}this.activeThreadDecorationIds=A.monacoEditor.deltaDecorations(this.activeThreadDecorationIds,w)}createDottedRangeDecoration(){const y={description:"comments-multiline-hover-decoration",linesDecorationsClassName:["comment-range","multiline-add"].join(" ")};return h.ModelDecorationOptions.createDynamic(y)}createHoverDecoration(){const y={description:"comments-hover-decoration",linesDecorationsClassName:["comment-range","line-hover","comment-add"].join(" ")};return h.ModelDecorationOptions.createDynamic(y)}createThreadRangeActiveDecoration(){const y={description:"comments-thread-range-active-decoration",isWholeLine:!1,zIndex:20,className:"comment-thread-range-current",shouldFillLineOnLineBreak:!0};return h.ModelDecorationOptions.createDynamic(y)}createThreadRangeDecoration(){const y={description:"comments-thread-range-decoration",isWholeLine:!1,zIndex:20,className:"comment-thread-range",shouldFillLineOnLineBreak:!0};return h.ModelDecorationOptions.createDynamic(y)}createCommentRangeDecoration(){const y={description:"comments-range-decoration",linesDecorationsClassName:["comment-range","comment-diff-added"].join(" ")};return h.ModelDecorationOptions.createDynamic(y)}init(){const y=this.resourceService.getSupportedSchemes();for(const S of y)this.shouldShowCommentsSchemes.add(S);this.addDispose(this.resourceService.onRegisterResourceProvider(S=>{S.scheme&&(this.shouldShowCommentsSchemes.add(S.scheme),this.registerDecorationProvider())})),this.addDispose(this.resourceService.onUnregisterResourceProvider(S=>{S.scheme&&(this.shouldShowCommentsSchemes.delete(S.scheme),this.registerDecorationProvider())})),this.registerDecorationProvider()}getCurrentEditor(y){var S;if(y){for(const A of this.allEditors)if(!((S=A.currentUri)===null||S===void 0)&&S.isEqual(y))return this.editor=A,A}return this.editor}handleOnCreateEditor(y){this.allEditors.push(y),this.editor=y;const S=new p.Disposable;let A=[],w=!1;return S.addDispose(y.monacoEditor.onMouseDown(T=>{if(T.target.type===g.monacoBrowser.editor.MouseTargetType.GUTTER_LINE_DECORATIONS&&T.target.element&&T.target.element.className.indexOf("comment-add")>-1){const{target:D}=T;if(D&&D.range){const{range:I}=D;this.startCommentRange=I,T.event.stopPropagation()}}else if(T.target.type===g.monacoBrowser.editor.MouseTargetType.GUTTER_GLYPH_MARGIN&&T.target.element&&T.target.element.className.indexOf("comment-thread")>-1){const{target:D}=T;if(D&&D.range){const{range:I}=D,O=this.commentsThreads.filter(M=>y.currentUri&&M.uri.isEqual(y.currentUri)&&M.range.endLineNumber===I.endLineNumber);O.length&&(O.some(R=>R.isShowWidget(y))?O.forEach(R=>R.hide(y)):O.forEach(R=>R.show(y)))}T.event.stopPropagation()}})),S.addDispose(y.monacoEditor.onMouseUp(async T=>{if(this.startCommentRange){if(w){this.renderCommentRange(y),w=!1,this.startCommentRange=null,this.endCommentRange=null;return}let D=this.startCommentRange;this.endCommentRange&&(this.endCommentRange.startLineNumber<this.startCommentRange.startLineNumber?(D.startColumn=this.endCommentRange.startColumn,D.startLineNumber=this.endCommentRange.startLineNumber):(D.endColumn=this.endCommentRange.endColumn,D.endLineNumber=this.endCommentRange.endLineNumber)),y.currentUri&&(D=await this.getValidRange(D,y.currentUri)),D&&(this.commentsThreads.some(I=>I.comments.get().length===0&&y.currentUri&&I.uri.isEqual(y.currentUri)&&I.range.startLineNumber===D.startLineNumber&&I.range.endLineNumber===D.endLineNumber)||this.createThread(y.currentUri,D).show(y),T.event.stopPropagation())}else if(T.target.type===g.monacoBrowser.editor.MouseTargetType.GUTTER_LINE_DECORATIONS&&T.target.element&&T.target.element.className.indexOf("comment-range")>-1&&T.target.element.className.indexOf("comment-thread")<0){const{target:D}=T,I=D.range;I&&(this.commentsThreads.some(O=>O.comments.get().length===0&&y.currentUri&&O.uri.isEqual(y.currentUri)&&O.range.startLineNumber===I.startLineNumber&&O.range.endLineNumber===I.endLineNumber)||this.createThread(y.currentUri,I).show(y),T.event.stopPropagation())}this.startCommentRange=null,this.endCommentRange=null})),S.addDispose(y.monacoEditor.onMouseMove(async T=>{var D,I,O;const M=y.currentUri,R=T.target.range;if(this.startCommentRange){if(!((D=T.target.element)===null||D===void 0)&&D.className||!((O=(I=T.target.element)===null||I===void 0?void 0:I.offsetParent)===null||O===void 0)&&O.className.includes("diff-hidden-lines")&&(w=!0),M&&R){let P={startLineNumber:this.startCommentRange.startLineNumber,endLineNumber:R.endLineNumber,startColumn:this.startCommentRange.startColumn,endColumn:R.endColumn};this.startCommentRange.startLineNumber>R.startLineNumber&&(P={startLineNumber:R.startLineNumber,endLineNumber:this.startCommentRange.endLineNumber,startColumn:R.startColumn,endColumn:this.startCommentRange.endColumn}),this.renderCommentRange(y,P),this.endCommentRange=R}}else if(M&&R&&await this.shouldShowHoverDecoration(M,R)){const P=[{range:(0,_.positionToRange)(R.startLineNumber),options:this.createHoverDecoration()}];A=y.monacoEditor.deltaDecorations(A,P)}})),S.addDispose(y.monacoEditor.onMouseLeave(async T=>{var D;const I=(D=T.target)===null||D===void 0?void 0:D.range,O=[];!this.startCommentRange&&I&&O.push({range:(0,_.positionToRange)(I.startLineNumber),options:this.createCommentRangeDecoration()}),A=y.monacoEditor.deltaDecorations(A,O)})),S.addDispose(this.onCommentRangeProviderChange(()=>{this.renderCommentRange(y)})),S.addDispose(p.Event.any(this.onThreadsChanged,this.onThreadsCommentChange,this.onThreadsCreated)(T=>{const D=this.getCurrentEditor(T.uri);D&&this.renderCommentRange(D),this.updateActiveThreadDecoration(void 0)})),S.addDispose(this.onDidChangeCurrentCommentThread(T=>{this.updateActiveThreadDecoration(T)})),this.tryUpdateReservedSpace(y),S.addDispose(y.monacoEditor.onDidChangeModel(()=>{this.renderCommentRange(y),this.tryUpdateReservedSpace(y)})),S}async getValidRange(y,S){if(!S)return y;const A=await this.getContributionRanges(S);if(A.length===0)return y;const w=A.find(T=>{if(y.startLineNumber>=T.startLineNumber&&y.startLineNumber<=T.endLineNumber)return!0});return w&&w.endLineNumber<y.endLineNumber?{startLineNumber:y.startLineNumber,startColumn:y.startColumn,endLineNumber:w.endLineNumber,endColumn:w.endColumn}:y}ensureCommentingRangeReservedAmount(y){const S=this.getExistingCommentEditorOptions(y),A=this.editorLineDecorationsWidthMap.get(y.getId());S.lineDecorationsWidth!==A&&y.updateOptions({lineDecorationsWidth:this.getWithCommentsLineDecorationWidth(y,S.lineDecorationsWidth)})}async tryUpdateReservedSpace(y){if(!y)return;let S=this.editorCommentingRangeSpaceReservedMap.get(y.getId())||!1;const A=y.currentUri?this.shouldShowCommentsSchemes.has(y.currentUri.scheme):!1,w=this.commentsThreads.some(D=>y.currentUri&&D.uri.isEqual(y.currentUri)&&D.comments.get().length>0),T=A||w;if(T)if(S)this.ensureCommentingRangeReservedAmount(y);else{S=!0;const{lineDecorationsWidth:D,extraEditorClassName:I}=this.getExistingCommentEditorOptions(y),O=this.getWithCommentsEditorOptions(y,I,D);this.updateEditorLayoutOptions(y,O.extraEditorClassName,O.lineDecorationsWidth)}else if(!T&&S){S=!1;const{lineDecorationsWidth:D,extraEditorClassName:I}=this.getExistingCommentEditorOptions(y),O=this.getWithoutCommentsEditorOptions(y,I,D);this.updateEditorLayoutOptions(y,O.extraEditorClassName,O.lineDecorationsWidth)}this.editorCommentingRangeSpaceReservedMap.set(y.getId(),S)}getExistingCommentEditorOptions(y){const S=y.monacoEditor.getOption(s.EditorOption.lineDecorationsWidth);let A=[];const w=y.monacoEditor.getRawOptions().extraEditorClassName;return w&&(A=w.split(" ")),{lineDecorationsWidth:S,extraEditorClassName:A}}getWithoutCommentsEditorOptions(y,S,A){let w=A;const T=S.findIndex(I=>I==="inline-comment");T>=0&&S.splice(T,1);const D=y.monacoEditor.getOptions();return D.get(s.EditorOption.folding)&&D.get(s.EditorOption.showFoldingControls)!=="never"&&(w+=11),w-=24,{extraEditorClassName:S,lineDecorationsWidth:w}}updateEditorLayoutOptions(y,S,A){y.updateOptions({extraEditorClassName:S.join(" "),lineDecorationsWidth:A})}getWithCommentsEditorOptions(y,S,A){return S.push("inline-comment"),{lineDecorationsWidth:this.getWithCommentsLineDecorationWidth(y,A),extraEditorClassName:S}}getWithCommentsLineDecorationWidth(y,S){let A=S;const w=y.monacoEditor.getOptions();return w.get(s.EditorOption.folding)&&w.get(s.EditorOption.showFoldingControls)!=="never"&&(A-=11),A+=24,this.editorLineDecorationsWidthMap.set(y.getId(),A),A}async renderCommentRange(y,S={startLineNumber:0,endLineNumber:0,startColumn:0,endColumn:0}){if(!y.currentUri)return;const A=await this.getContributionRanges(y.currentUri);if(A.length>0){const w=[];A.map(D=>{if(S.startLineNumber===0&&S.endLineNumber===0)w.push({range:D,options:this.createCommentRangeDecoration()});else if(S.startLineNumber<=D.startLineNumber&&S.endLineNumber>=D.endLineNumber)w.push({range:D,options:this.createDottedRangeDecoration()},{range:D,options:this.createThreadRangeDecoration()});else if(S.endLineNumber>=D.endLineNumber)if(S.startLineNumber<=D.endLineNumber){const I={startLineNumber:S.startLineNumber,endLineNumber:D.endLineNumber,startColumn:S.startColumn,endColumn:D.endColumn},O={startLineNumber:D.startLineNumber,endLineNumber:I.startLineNumber-1,startColumn:D.startColumn,endColumn:I.endColumn};w.push({range:O,options:this.createCommentRangeDecoration()},{range:I,options:this.createDottedRangeDecoration()},{range:I,options:this.createThreadRangeDecoration()})}else w.push({range:D,options:this.createCommentRangeDecoration()});else if(S.endLineNumber<D.endLineNumber)if(S.endLineNumber>=D.startLineNumber)if(S.startLineNumber>=D.startLineNumber){const I={startLineNumber:D.startLineNumber,startColumn:D.startColumn,endLineNumber:S.startLineNumber-1,endColumn:S.startColumn},O={startLineNumber:S.endLineNumber+1,startColumn:S.endColumn,endLineNumber:D.endLineNumber,endColumn:D.endColumn},M=S.startLineNumber!==D.startLineNumber?[{range:I,options:this.createCommentRangeDecoration()}]:[];M.push({range:S,options:this.createDottedRangeDecoration()}),M.push({range:S,options:this.createThreadRangeDecoration()}),M.push({range:O,options:this.createCommentRangeDecoration()}),w.push(...M)}else{const I={startLineNumber:D.startLineNumber,startColumn:D.startColumn,endLineNumber:S.endLineNumber,endColumn:S.endColumn},O={startLineNumber:I.endLineNumber+1,startColumn:I.endColumn,endLineNumber:D.endLineNumber,endColumn:D.endColumn};w.push({range:I,options:this.createDottedRangeDecoration()},{range:I,options:this.createThreadRangeDecoration()},{range:O,options:this.createCommentRangeDecoration()})}else w.push({range:D,options:this.createCommentRangeDecoration()})});const T=this.commentRangeDecorationMap.get(y.currentUri.toString())||[];this.commentRangeDecorationMap.set(y.currentUri.toString(),y.monacoEditor.deltaDecorations(T,w))}else this.commentRangeDecorationMap.set(y.currentUri.toString(),[])}async shouldShowHoverDecoration(y,S){return this.shouldShowCommentsSchemes.has(y.scheme)?(await this.getContributionRanges(y)).some(T=>S.startLineNumber<=T.endLineNumber):!1}createThread(y,S,A={comments:[],readOnly:!1}){const w=this.getProviderIdsByLine(S.endLineNumber)[0],T=this.injector.get(E.CommentsThread,[y,S,w,A]);return T.onDispose(()=>{this.threads.delete(T.id),this.threadsChangeEmitter.fire(T),this.decorationChangeEmitter.fire(y)}),T.onDidChange(()=>{this.threadsChangeEmitter.fire(T)}),this.threads.set(T.id,T),this.addDispose(T),this.threadsChangeEmitter.fire(T),this.threadsCreatedEmitter.fire(T),this.decorationChangeEmitter.fire(y),T}getThreadsByUri(y){return this.commentsThreads.filter(S=>S.uri.isEqual(y)).sort((S,A)=>S.range.startLineNumber-A.range.startLineNumber)}handleCommentFileNode(y){const S=[],A=[...this.threads.values()].filter(T=>T.comments.get().length),w=(0,o.default)(A,T=>T.uri);return Object.keys(w).map(T=>{var D;const I=w[T];if(I.length===0)return;const O=new p.URI(this.appConfig.workspaceDir),M=new p.URI(T),R=(D=O.relative(M))===null||D===void 0?void 0:D.toString();S.push(new f.CommentFileNode(this,I,R,M.codeUri.fsPath,this.labelService.getIcon(M),M,y))}),S}handleCommentContentNode(y){var S;const A=[];for(const w of y.threads){const T=w.comments.get(),[D]=T,I=typeof D.body=="string"?D.body:D.body.value;let O=`[Ln ${w.range.startLineNumber}]`;w.range.startLineNumber!==w.range.endLineNumber&&(O=`[Ln ${w.range.startLineNumber}-${w.range.endLineNumber}]`),A.push(new f.CommentContentNode(this,w,I,O,D.author.iconPath&&(!((S=D.author.iconPath)===null||S===void 0)&&S.authority)?this.iconService.fromIcon("",D.author.iconPath.toString(),a.IconType.Background):(0,p.getIcon)("message"),D.author,y.resource,y))}return A}handleCommentReplyNode(y){const S=[],A=y.thread,w=A.comments.get(),[T,...D]=w,I=D[D.length-1].author.name;return S.push(new f.CommentReplyNode(this,A,(0,p.formatLocalize)("comment.reply.count",D?.length||0),(0,p.formatLocalize)("comment.reply.lastReply",I),"",y.resource,y)),S}async resolveChildren(y){let S=[];if(y?f.CommentRoot.isRoot(y)?S=this.handleCommentFileNode(y):f.CommentFileNode.is(y)?S=this.handleCommentContentNode(y):f.CommentContentNode.is(y)&&(S=this.handleCommentReplyNode(y)):S.push(new f.CommentRoot(this)),S.length===1&&f.CommentRoot.isRoot(S[0]))return S;const A=this.commentsFeatureRegistry.getCommentsPanelTreeNodeHandlers();if(A.length>0)for(const w of A)S=w(S);return S}async getContributionRanges(y){const S=this.providerDecorationCache.get(y.toString());if(S)return await S.promise;const A=this.documentService.getModelReference(y,"Get Comment Range"),w=[];for(const O of this.rangeProviderMap){const[M,R]=O;w.push((async()=>{if(!A?.instance)return;const P=await R.getCommentingRanges(A.instance);return P&&P.length&&this.rangeOwner.set(M,P),P})())}const T=new p.Deferred;this.providerDecorationCache.set(y.toString(),T);const D=(await Promise.all(w)).filter(Boolean);A?.dispose();const I=(0,r.default)(D).filter(Boolean);return T.resolve(I),I}fireThreadCommentChange(y){this.threadsCommentChangeEmitter.fire(y)}registerDecorationProvider(){this.decorationProviderDisposer.dispose(),this.decorationProviderDisposer=this.editorDecorationCollectionService.registerDecorationProvider({schemes:[...this.shouldShowCommentsSchemes.values()],key:"comments",onDidDecorationChange:this.decorationChangeEmitter.event,provideEditorDecoration:y=>this.commentsThreads.map(S=>(S.uri.isEqual(y)?S.comments.get().length&&S.showWidgetsIfShowed():S.hide(),S)).filter(S=>{const A=S.uri.isEqual(y);return this.filterThreadDecoration?A&&this.filterThreadDecoration(S):A}).map(S=>({range:{startLineNumber:S.range.endLineNumber,endLineNumber:S.range.endLineNumber,startColumn:S.range.endColumn,endColumn:S.range.endColumn},options:this.createThreadDecoration(S)}))}),this.addDispose(this.decorationProviderDisposer)}registerCommentPanel(){this.layoutService.getTabbarHandler(u.CommentPanelId)||this.layoutService.collectTabbarComponent([{id:u.CommentPanelId,component:d.CommentsPanel}],{badge:this.panelBadge,containerId:u.CommentPanelId,title:(0,p.localize)("comments").toUpperCase(),hidden:!1,activateKeyBinding:"ctrlcmd+shift+c",...this.commentsFeatureRegistry.getCommentsPanelOptions()},"bottom")}get panelBadge(){const y=this.commentsThreads.length;return y?y+"":""}registerCommentRangeProvider(y,S){return this.rangeProviderMap.set(y,S),this.providerDecorationCache.clear(),this.commentRangeProviderChangeEmitter.fire(),p.Disposable.create(()=>{this.rangeProviderMap.delete(y),this.rangeOwner.delete(y),this.providerDecorationCache.clear()})}forceUpdateDecoration(){var y,S,A;const w=(y=this.workbenchEditorService.currentEditor)===null||y===void 0?void 0:y.currentUri;w&&this.decorationChangeEmitter.fire(w);const T=(A=(S=this.workbenchEditorService.currentEditorGroup)===null||S===void 0?void 0:S.diffEditor)===null||A===void 0?void 0:A.originalEditor.currentUri;T&&this.decorationChangeEmitter.fire(T)}getProviderIdsByLine(y){const S=[];if(this.rangeOwner.size===1)return[this.rangeOwner.keys().next().value];for(const A of this.rangeOwner){const[w,T]=A;T&&T.some(D=>D.startLineNumber<=y&&y<=D.endLineNumber)&&S.push(w)}return S}};t.CommentsService=c,n.__decorate([(0,l.Autowired)(l.INJECTOR_TOKEN),n.__metadata("design:type",l.Injector)],c.prototype,"injector",void 0),n.__decorate([(0,l.Autowired)(p.AppConfig),n.__metadata("design:type",Object)],c.prototype,"appConfig",void 0),n.__decorate([(0,l.Autowired)(v.IEditorDecorationCollectionService),n.__metadata("design:type",Object)],c.prototype,"editorDecorationCollectionService",void 0),n.__decorate([(0,l.Autowired)(a.IIconService),n.__metadata("design:type",Object)],c.prototype,"iconService",void 0),n.__decorate([(0,l.Autowired)(p.LabelService),n.__metadata("design:type",p.LabelService)],c.prototype,"labelService",void 0),n.__decorate([(0,l.Autowired)(u.ICommentsFeatureRegistry),n.__metadata("design:type",Object)],c.prototype,"commentsFeatureRegistry",void 0),n.__decorate([(0,l.Autowired)(v.IEditorDocumentModelService),n.__metadata("design:type",Object)],c.prototype,"documentService",void 0),n.__decorate([(0,l.Autowired)(m.IMainLayoutService),n.__metadata("design:type",Object)],c.prototype,"layoutService",void 0),n.__decorate([(0,l.Autowired)(v.WorkbenchEditorService),n.__metadata("design:type",v.WorkbenchEditorService)],c.prototype,"workbenchEditorService",void 0),n.__decorate([(0,l.Autowired)(v.ResourceService),n.__metadata("design:type",v.ResourceService)],c.prototype,"resourceService",void 0),n.__decorate([p.memoize,n.__metadata("design:type",Object),n.__metadata("design:paramtypes",[])],c.prototype,"isMultiCommentsForSingleLine",null),n.__decorate([p.memoize,n.__metadata("design:type",Object),n.__metadata("design:paramtypes",[])],c.prototype,"currentAuthorAvatar",null),n.__decorate([p.memoize,n.__metadata("design:type",Object),n.__metadata("design:paramtypes",[])],c.prototype,"filterThreadDecoration",null),t.CommentsService=c=n.__decorate([(0,l.Injectable)()],c)},54230:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentsModule=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(69635),p=e(66480),v=e(62604),m=e(55011),_=e(47842);let s=class extends o.BrowserModule{constructor(){super(...arguments),this.contributionProvider=l.CommentsContribution,this.providers=[{token:l.ICommentsService,useClass:m.CommentsService},{token:_.CommentModelService,useClass:_.CommentModelService},{token:l.ICommentsFeatureRegistry,useClass:p.CommentsFeatureRegistry},v.CommentsBrowserContribution]}};t.CommentsModule=s,t.CommentsModule=s=n.__decorate([(0,r.Injectable)()],s)},70154:(L,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.markdownCss=void 0,t.markdownCss=`
|
|
29487
|
+
`)};t.extractCodeBlocks=p;const v=(m,_="sumi-builtin")=>`mcp_${_}_${m}`;t.getToolName=v},26471:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),e(85608).__exportStar(e(19413),t)},15504:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentReactions=t.CommentReactionSwitcher=void 0;const n=e(85608),r=n.__importDefault(e(14041)),o=e(41869),l=e(81878),p=e(25918),v=e(93899),m=e(52416),_=e(69635),s=n.__importDefault(e(38877)),g=({thread:h,comment:u,className:d})=>{const E=`${h.providerId}_${h.id}_${u.id}`,f=`${v.MenuId.CommentReactionSwitcherMenu}_${E}`,c=(0,o.useInjectable)(v.IMenuRegistry),b=(0,o.useInjectable)(v.AbstractMenuService);r.default.useEffect(()=>{const S=new o.Disposable,A=`${v.MenuId.CommentReactionSwitcherSubmenu}_${E}`;return S.addDispose(c.registerMenuItem(f,{submenu:A,label:A,iconClass:(0,o.getExternalIcon)("reactions"),group:"navigation"})),S.addDispose(c.registerMenuItems(A,u.reactions.map(w=>({command:{id:_.SwitchCommandReaction,label:w.label},extraTailArgs:[{thread:h,comment:u,reaction:w}]})))),()=>S.dispose()},[]);const y=r.default.useMemo(()=>b.createMenu(f),[]);return r.default.createElement(p.InlineActionBar,{className:d,menus:y,regroup:S=>[S,[]],type:"icon"})};t.CommentReactionSwitcher=g;const a=({thread:h,comment:u})=>{var d;const E=(0,o.useInjectable)(o.IEventBus),f=(0,o.useInjectable)(m.IIconService),c=r.default.useCallback(b=>{E.fire(new _.CommentReactionClick({thread:h,comment:u,reaction:b}))},[]);return r.default.createElement("div",{className:s.default.comment_reactions},(d=u.reactions)===null||d===void 0?void 0:d.filter(b=>b.count!==0).map(b=>r.default.createElement(l.Button,{key:b.label,onClick:()=>c(b),type:"secondary",size:"small",title:b.label,className:s.default.comment_reaction,iconClass:f.fromIcon("",b.iconPath.toString(),m.IconType.Background)},"\xA0",b.count)))};t.CommentReactions=a},54143:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentsBody=void 0;const n=e(85608),r=n.__importDefault(e(14041)),o=n.__importDefault(e(43144)),l=e(84605),p=n.__importDefault(e(38877)),v=e(70154),m=({root:_,children:s})=>o.default.createPortal(s,_);t.CommentsBody=r.default.memo(({body:_})=>{const s=r.default.useRef(null),[g,a]=r.default.useState(null),h=r.default.useMemo(()=>{const u=(0,l.createMarkedRenderer)();return u.link=(d,E,f)=>`<a target="_blank" rel="noopener" href="${d}" title="${E}">${f}</a>`,u},[]);return r.default.useEffect(()=>{if(s.current){const u=s.current.attachShadow({mode:"open"});g||a(u)}},[]),r.default.createElement("div",{ref:s,className:p.default.comment_shadow_box},g&&r.default.createElement(m,{root:g},r.default.createElement("style",null,v.markdownCss),r.default.createElement("div",{dangerouslySetInnerHTML:{__html:(0,l.toMarkdownHtml)(typeof _=="string"?_:_.value,{gfm:!0,breaks:!1,pedantic:!1,smartLists:!0,smartypants:!1,renderer:h})}})))})},66480:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentsFeatureRegistry=void 0;const n=e(85608),r=e(76003);let o=class{constructor(){this.config={},this.options={},this.panelTreeNodeHandlers=[],this.mentionsOptions={},this.providerFeature=new Map}registerConfig(p){this.config={...this.config,...p}}registerPanelTreeNodeHandler(p){this.panelTreeNodeHandlers.push(p)}registerPanelOptions(p){this.options={...this.options,...p}}registerFileUploadHandler(p){this.fileUploadHandler=p}registerMentionsOptions(p){this.mentionsOptions=p}registerZoneWidgetRender(p){this.zoneWidgetRender=p}getConfig(){return this.config}getCommentsPanelOptions(){return this.options}getCommentsPanelTreeNodeHandlers(){return this.panelTreeNodeHandlers}getFileUploadHandler(){return this.fileUploadHandler}getMentionsOptions(){return this.mentionsOptions}getZoneWidgetRender(){return this.zoneWidgetRender}registerProviderFeature(p,v){this.providerFeature.set(p,v)}getProviderFeature(p){return this.providerFeature.get(p)}};t.CommentsFeatureRegistry=o,t.CommentsFeatureRegistry=o=n.__decorate([(0,r.Injectable)()],o)},37357:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentItem=void 0;const n=e(85608),r=n.__importDefault(e(14041)),o=e(97267),l=e(41869),p=e(25918),v=e(93899),m=e(69635),_=e(15504),s=e(54143),g=e(42018),a=n.__importDefault(e(38877)),h=({timestamp:f})=>{const c=r.default.useMemo(()=>{const b=new Date(f);return(0,l.toLocalString)(b)},[f]);return r.default.createElement("span",{className:a.default.comment_item_timestamp},c)},u=(f,c)=>{const b=(0,l.useInjectable)(v.AbstractMenuService),{body:y,contextValue:S}=c,[A,w]=r.default.useState(""),T=(0,l.useInjectable)(m.ICommentsFeatureRegistry),D=r.default.useMemo(()=>T.getFileUploadHandler(),[]);r.default.useEffect(()=>{w(y)},[y]);const I=r.default.useMemo(()=>f.createScoped(),[]),O=r.default.useMemo(()=>I.createKey("commentIsEmpty",!c.body),[]),M=r.default.useMemo(()=>b.createMenu(v.MenuId.CommentsCommentContext,I),[]),R=r.default.useMemo(()=>b.createMenu(v.MenuId.CommentsCommentTitle,I),[]),P=r.default.useRef(I.createKey("comment",S));r.default.useEffect(()=>{P.current.set(S)},[S]);const k=r.default.useCallback(x=>{O.set(!x.target.value),w(x.target.value)},[]),F=r.default.useCallback(async x=>{if(D){const B=await D(A,x);w(j=>{const W=j+B;return O.set(!W),W})}},[A]);return[A,w,k,M,R,F]},d=({reply:f,thread:c})=>{var b;const{contextKeyService:y}=c,{author:S,label:A,body:w,mode:T,timestamp:D}=f,I=(b=S.iconPath)===null||b===void 0?void 0:b.toString(),[O,M,R,P,k,F]=u(y,f),x=r.default.useMemo(()=>{const B=(0,l.toMarkdownHtml)(typeof w=="string"?w:w.value);return/^\<p\>[^<>]+\<\/p\>\n$/.test(B)},[w]);return r.default.createElement("div",{className:a.default.reply_item},(0,l.isUndefined)(T)||T===m.CommentMode.Preview?r.default.createElement("div",null,x?r.default.createElement(r.default.Fragment,null,I&&r.default.createElement("img",{className:a.default.reply_item_icon,src:I,alt:S.name}),r.default.createElement("span",{className:a.default.comment_item_author_name},S.name),D&&r.default.createElement(h,{timestamp:D}),typeof A=="string"?r.default.createElement("span",{className:a.default.comment_item_label},A):A," : ",r.default.createElement("span",{className:a.default.comment_item_body},typeof w=="string"?w:w.value),f.reactions&&f.reactions.length>0&&r.default.createElement(_.CommentReactionSwitcher,{className:a.default.reply_item_title,thread:c,comment:f}),r.default.createElement(p.InlineActionBar,{separator:"inline",className:a.default.reply_item_title,menus:k,context:[{thread:c,comment:f,menuId:v.MenuId.CommentsCommentTitle}],type:"icon"})):r.default.createElement(r.default.Fragment,null,r.default.createElement("div",{className:a.default.comment_item_markdown_header},r.default.createElement("div",null,I&&r.default.createElement("img",{className:a.default.reply_item_icon,src:I,alt:S.name}),r.default.createElement("span",{className:a.default.comment_item_author_name},S.name),D&&r.default.createElement(h,{timestamp:D}),typeof A=="string"?r.default.createElement("span",{className:a.default.comment_item_label},A):A," : "),r.default.createElement(p.InlineActionBar,{separator:"inline",className:a.default.reply_item_title,menus:k,context:[{thread:c,comment:f,menuId:v.MenuId.CommentsCommentTitle}],type:"icon"})),r.default.createElement(s.CommentsBody,{body:w}))):r.default.createElement("div",null,r.default.createElement(g.CommentsTextArea,{value:typeof O=="string"?O:O.value,autoFocus:!0,onChange:R,dragFiles:F}),r.default.createElement(p.InlineActionBar,{className:a.default.comment_item_reply,menus:P,context:[{thread:c,comment:f,body:O,menuId:v.MenuId.CommentsCommentContext}],type:"button",separator:"inline",afterClick:()=>{M(w)}})),f.reactions&&f.reactions.length>0&&r.default.createElement(_.CommentReactions,{thread:c,comment:f}))},E=({thread:f,commentThreadContext:c,widget:b})=>{var y,S;const[A,w]=r.default.useState(!1),[T,D]=r.default.useState(""),{contextKeyService:I}=f,O=(0,l.useAutorun)(f.readOnly),[M,...R]=(0,l.useAutorun)(f.comments),{author:P,label:k,body:F,mode:x,timestamp:B}=M,j=(0,l.isString)(P.iconPath)?P.iconPath:!((y=P.iconPath)===null||y===void 0)&&y.authority?(S=P.iconPath)===null||S===void 0?void 0:S.toString():"",[W,U,Z,V,$,Y]=u(I,M),G=(0,l.useInjectable)(m.ICommentsFeatureRegistry),H=r.default.useMemo(()=>G.getFileUploadHandler(),[]),K=r.default.useMemo(()=>I.createKey("commentIsEmpty",!0),[]);function X(oe){K.set(!oe.target.value),D(oe.target.value)}const Q=r.default.useCallback(async oe=>{if(H){const ne=await H(W,oe);D(he=>{const _e=he+ne;return K.set(!_e),_e})}},[T]);return r.default.createElement("div",{className:a.default.comment_item},j&&r.default.createElement("img",{className:a.default.comment_item_icon,src:j,alt:P.name}),r.default.createElement("div",{className:a.default.comment_item_content},r.default.createElement("div",{className:a.default.comment_item_head},r.default.createElement("div",{className:a.default.comment_item_name},r.default.createElement("span",{className:a.default.comment_item_author_name},P.name),B&&r.default.createElement(h,{timestamp:B}),typeof k=="string"?r.default.createElement("span",{className:a.default.comment_item_label},k):k),r.default.createElement("div",{className:a.default.comment_item_actions},M.reactions&&M.reactions.length>0&&r.default.createElement(_.CommentReactionSwitcher,{thread:f,comment:M}),!O&&r.default.createElement(o.Button,{className:a.default.comment_item_reply_button,size:"small",type:"secondary",onClick:()=>w(!0)},(0,l.localize)("comments.thread.action.reply")),r.default.createElement(p.InlineActionBar,{menus:$,context:[{thread:f,comment:M,menuId:v.MenuId.CommentsCommentTitle}],type:"button"}))),(0,l.isUndefined)(x)||x===m.CommentMode.Preview?r.default.createElement(s.CommentsBody,{body:F}):r.default.createElement("div",null,r.default.createElement(g.CommentsTextArea,{value:typeof W=="string"?W:W.value,autoFocus:!0,onChange:Z,dragFiles:Y}),r.default.createElement(p.InlineActionBar,{className:a.default.comment_item_context,menus:V,context:[{thread:f,comment:M,body:W,menuId:v.MenuId.CommentsCommentContext}],separator:"inline",type:"button",afterClick:()=>{U(F)}})),M.reactions&&M.reactions.length>0&&r.default.createElement(_.CommentReactions,{thread:f,comment:M}),(R.length>0||A)&&r.default.createElement("div",{className:a.default.comment_item_reply_wrap},R.map(oe=>r.default.createElement(d,{key:oe.id,thread:f,reply:oe})),A&&r.default.createElement("div",null,r.default.createElement(g.CommentsTextArea,{autoFocus:!0,value:T,onChange:X,placeholder:`${(0,l.localize)("comments.reply.placeholder")}...`,dragFiles:Q}),r.default.createElement(p.InlineActionBar,{className:a.default.comment_item_reply,menus:c,context:[{thread:f,text:T,widget:b,menuId:v.MenuId.CommentsCommentThreadContext}],separator:"inline",type:"button",afterClick:()=>{D(""),w(!1)}})))))};t.CommentItem=E},53878:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentsPanel=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(97267),l=e(41869),p=e(69635),v=n.__importDefault(e(38877)),m=e(5167),_=e(47842),s=({viewState:g})=>{const a=(0,l.useInjectable)(_.CommentModelService),[h,u]=(0,r.useState)(),d=(0,r.useRef)(null),E=(0,l.useInjectable)(p.ICommentsFeatureRegistry),{handleTreeBlur:f}=a;(0,r.useEffect)(()=>{u(a.treeModel);const T=a.onDidUpdateTreeModel(D=>{u(D)});return()=>{T.dispose()}},[]);const c=(0,r.useCallback)(T=>{a.handleTreeHandler(T)},[a]),b=(0,r.useCallback)(T=>r.default.createElement(m.CommentNodeRendered,{item:T.item,itemType:T.itemType,decorations:a.decorations.getDecorations(T.item),defaultLeftPadding:8,onTwistierClick:a.handleTwistierClick,onClick:a.handleItemClick,leftPadding:8}),[h]),y=(0,r.useMemo)(()=>E.getCommentsPanelOptions(),[]),S=(0,r.useMemo)(()=>y.header,[y]),A=(0,r.useMemo)(()=>r.default.createElement("div",{className:v.default.panel_placeholder},y.defaultPlaceholder||(0,l.localize)("comments.panel.placeholder")),[y]),w=(0,r.useCallback)(()=>h?r.default.createElement(o.RecycleTree,{height:g.height-(S?.height||0),itemHeight:m.COMMENT_TREE_NODE_HEIGHT,onReady:c,model:h,placeholder:()=>A},b):A,[h,S,g.height]);return r.default.createElement("div",{className:v.default.comment_panel,tabIndex:-1,onBlur:f,ref:d},S?.component,w())};t.CommentsPanel=s},42018:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentsTextArea=void 0;const n=e(85608),r=n.__importDefault(e(14041)),o=e(34801),l=e(97267),p=e(41869),v=e(69635),m=e(54143),_=n.__importDefault(e(38877)),s=e(73136),g="@",a="@[__display__](__id__)",h=(u,d)=>`@${d}`;t.CommentsTextArea=r.default.forwardRef((u,d)=>{const{focusDelay:E=0,autoFocus:f=!1,placeholder:c="",onFocus:b,onBlur:y,onChange:S,maxRows:A=10,minRows:w=2,value:T,initialHeight:D,dragFiles:I}=u,[O,M]=r.default.useState(0),R=(0,p.useInjectable)(v.ICommentsFeatureRegistry),P=r.default.useRef(null),k=r.default.useRef(null),F=r.default.useRef(null);r.default.useImperativeHandle(d,()=>P.current);const x=r.default.useCallback(async V=>{var $;V.stopPropagation(),V.preventDefault();const Y=($=V.dataTransfer)===null||$===void 0?void 0:$.files;Y&&I&&await I(Y),P.current&&(P.current.focus(),j(P.current.value))},[I]),B=r.default.useCallback(V=>{V.stopPropagation(),V.preventDefault(),V.dataTransfer.dropEffect="copy"},[]),j=r.default.useCallback(V=>{const $=P.current;if($){const Y=V.toString().length;$.setSelectionRange(Y,Y)}},[]);r.default.useEffect(()=>{var V;const $=P.current;if(!$)return;D&&$.style&&($.style.height=D),E&&setTimeout(()=>{$.focus({preventScroll:!0})},E),j(T);function Y(G){var H,K,X;const Q=G.target;Q&&(Q.nodeName.toUpperCase()==="TEXTAREA"&&Q.scrollHeight>Q.clientHeight||Q.nodeName.toUpperCase()==="UL"||((H=Q.parentElement)===null||H===void 0?void 0:H.nodeName.toUpperCase())==="UL"||((X=(K=Q.parentElement)===null||K===void 0?void 0:K.parentElement)===null||X===void 0?void 0:X.nodeName.toUpperCase())==="UL")&&G.stopPropagation()}return(V=k.current)===null||V===void 0||V.addEventListener("mousewheel",Y,!0),()=>{var G;(G=k.current)===null||G===void 0||G.removeEventListener("mousewheel",Y,!0)}},[]),r.default.useEffect(()=>{O===0&&(setTimeout(()=>{var V;(V=P.current)===null||V===void 0||V.focus({preventScroll:!0})},E),j(T))},[O]);const W=r.default.useMemo(()=>(0,s.getMentionBoxStyle)({minRows:w,maxRows:A}),[w,A]),U=r.default.useMemo(()=>R.getMentionsOptions(),[R]),Z=r.default.useCallback(async(V,$)=>{if(U.providerData){const Y=await U.providerData(V);$(Y)}else $([])},[U]);return r.default.createElement("div",{className:_.default.textarea_container},r.default.createElement(l.Tabs,{mini:!0,value:O,onChange:V=>M(V),tabs:[(0,p.localize)("comments.thread.textarea.write"),(0,p.localize)("comments.thread.textarea.preview")]}),r.default.createElement("div",null,O===0?r.default.createElement("div",{ref:k},r.default.createElement(o.MentionsInput,{autoFocus:f,onDragOver:B,onDrop:x,inputRef:P,ref:F,value:T,placeholder:c,onChange:S,onFocus:b,onBlur:y,style:W},r.default.createElement(o.Mention,{markup:U.markup||a,renderSuggestion:U.renderSuggestion,trigger:g,data:Z,displayTransform:U.displayTransform||h}))):r.default.createElement("div",{className:_.default.textarea_preview},r.default.createElement(m.CommentsBody,{body:T}))))})},49867:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentsThread=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(91830),p=e(54414),v=e(28423),m=e(69635),_=e(90366);let s=class extends o.Disposable{set contextValue(a){this._contextKeyService.createKey("thread",a)}get contextValue(){return this._contextKeyService.getContextKeyValue("thread")}get onDidChangeCollapsibleState(){return this.onDidChangeCollapsibleStateEmitter.event}get onDidChange(){return this.onDidChangeEmitter.event}constructor(a,h,u,d){super(),this.uri=a,this.range=h,this.providerId=u,this.options=d,this.comments=(0,v.observableValue)(this,[]),this.label=(0,v.observableValue)(this,void 0),this.readOnly=(0,v.observableValue)(this,!1),this.isCollapsed=(0,v.observableValue)(this,!1),this.onDidChangeCollapsibleStateEmitter=new o.Emitter,this.widgets=new Map,this._id=`thread_${(0,o.uuid)()}`,this.onDidChangeEmitter=new o.Emitter,this.threadHeaderTitle=(0,v.derived)(this,S=>{const A=this.label.read(S);if(A)return A;const w=this.comments.read(S);if(w.length){const T=new Set(w.map(D=>`@${D.author.name}`));return`${(0,o.localize)("comments.participants")}: `+[...T].join(" ")}else return(0,o.localize)("comments.zone.title")}),this.toggle=S=>{if(this.comments.get().length>0){const w=this.widgets.get(S);w&&w.toggle()}else this.dispose()},this.updateComments(d.comments?d.comments.map(S=>({...S,id:(0,o.uuid)()})):[]),this.data=this.options.data,this._contextKeyService=this.registerDispose(this.globalContextKeyService.createScoped()),new l.ResourceContextKey(this._contextKeyService).set(a),this._contextKeyService.createKey("thread",d.contextValue),(0,v.transaction)(S=>{this.setReadOnly(!!d.readOnly),this.label.set(d.label,S),this.isCollapsed.set(!!this.options.isCollapsed,S)});const f=this._contextKeyService.createKey("threadsLength",this.commentsService.getThreadsByUri(a).length),c=this.comments.get(),b=this._contextKeyService.createKey("commentsLength",c.length),y=this._contextKeyService.createKey("commentThreadIsEmpty",!c.length);this._contextKeyService.createKey("commentController",u),this.addDispose((0,v.autorun)(S=>{const A=this.comments.read(S).length;b.set(A),y.set(!A)})),this.addDispose((0,v.autorun)(S=>{this.isCollapsed.read(S)?this.hideAll():this.showAll()})),this.addDispose(this.commentsService.onThreadsChanged(S=>{S.uri.isEqual(a)&&f.set(this.commentsService.getThreadsByUri(a).length)})),this.addDispose({dispose:()=>{this.updateComments([])}}),this.onDidChangeEmitter.fire()}updateComments(a){(0,v.transaction)(h=>{this.comments.set(a,h)})}getWidgetByEditor(a){return this.widgets.get(a)}get id(){return this._id}get contextKeyService(){return this._contextKeyService}setReadOnly(a){(0,v.transaction)(h=>{this.readOnly.set(a,h),this._contextKeyService.createKey("readOnly",a)})}getEditorsByUri(a){return this.editorCollectionService.listEditors().filter(h=>{var u;return(u=h.currentUri)===null||u===void 0?void 0:u.isEqual(a)})}addWidgetByEditor(a){const h=this.injector.get(_.CommentsZoneWidget,[a,this,{arrowColor:"var(--peekView-border)"}]);return this.addDispose(h.onChangeZoneWidget(()=>{const u=this.commentsService.commentsThreads.filter(f=>this.isEqual(f)),d=u.findIndex(f=>f===this),E=u.slice(d+1);for(const f of E)if(f.isShowWidget(a)){const c=f.getWidgetByEditor(a);c?.resize()}})),this.addDispose(h),this.widgets.set(a,h),a.onDispose(()=>{h.dispose(),this.widgets.delete(a)}),h}show(a){if(a){let h=this.widgets.get(a);h||(h=this.addWidgetByEditor(a)),h.show()}else this.getEditorsByUri(this.uri).forEach(u=>{var d;let E=this.widgets.get(u);E||(E=this.addWidgetByEditor(u)),!((d=u.currentUri)===null||d===void 0)&&d.isEqual(this.uri)&&E.show()})}showWidgetsIfShowed(){var a;for(const h of this.getEditorsByUri(this.uri)){let u=this.widgets.get(h);u||(u=this.addWidgetByEditor(h)),!((a=h.currentUri)===null||a===void 0)&&a.isEqual(this.uri)&&u.show()}}hideWidgetsByDispose(){var a;for(const[h,u]of this.widgets)!(!((a=h.currentUri)===null||a===void 0)&&a.isEqual(this.uri))&&u.dispose()}isShowWidget(a){if(a){const h=this.widgets.get(a);return h?h.isShow:!1}else{for(const[,h]of this.widgets)return h.isShow;return!1}}hide(a){if(a){const h=this.widgets.get(a);h?.hide()}else this.hideAll()}showAll(){(0,v.transaction)(a=>{this.isCollapsed.set(!1,a)});for(const[,a]of this.widgets)a.show();this.onDidChangeCollapsibleStateEmitter.fire(m.CommentThreadCollapsibleState.Expanded)}hideAll(a){var h;(0,v.transaction)(u=>{this.isCollapsed.set(!0,u)});for(const[u,d]of this.widgets)a?!(!((h=u.currentUri)===null||h===void 0)&&h.isEqual(this.uri))&&d.dispose():d.hide();this.onDidChangeCollapsibleStateEmitter.fire(m.CommentThreadCollapsibleState.Collapsed)}addComment(...a){const h=this.comments.get();(0,v.transaction)(u=>{this.comments.set([...h,...a.map(d=>({...d,id:(0,o.uuid)()}))],u)}),this.onDidChangeEmitter.fire()}removeComment(a){(0,v.transaction)(h=>{this.comments.set(this.comments.get().filter(u=>u!==a),h)}),this.onDidChangeEmitter.fire()}isEqual(a){return a.uri.isEqual(this.uri)&&a.range.startLineNumber===this.range.startLineNumber&&a.range.endLineNumber===this.range.endLineNumber}};t.CommentsThread=s,n.__decorate([(0,r.Autowired)(m.ICommentsService),n.__metadata("design:type",Object)],s.prototype,"commentsService",void 0),n.__decorate([(0,r.Autowired)(o.IContextKeyService),n.__metadata("design:type",Object)],s.prototype,"globalContextKeyService",void 0),n.__decorate([(0,r.Autowired)(p.EditorCollectionService),n.__metadata("design:type",p.EditorCollectionService)],s.prototype,"editorCollectionService",void 0),n.__decorate([(0,r.Autowired)(r.INJECTOR_TOKEN),n.__metadata("design:type",r.Injector)],s.prototype,"injector",void 0),t.CommentsThread=s=n.__decorate([(0,r.Injectable)({multiple:!0}),n.__metadata("design:paramtypes",[o.URI,Object,String,Object])],s)},73804:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentsZoneService=void 0;const n=e(85608),r=e(76003),o=e(93899),l=e(43718),p=e(69635),v=e(49867);let m=class extends l.Disposable{constructor(s){super(),this.thread=s}setCurrentCommentThread(s){this.commentService.setCurrentCommentThread(s)}get commentThreadTitle(){return this.registerDispose(this.menuService.createMenu(o.MenuId.CommentsCommentThreadTitle,this.thread.contextKeyService))}get commentThreadContext(){return this.registerDispose(this.menuService.createMenu(o.MenuId.CommentsCommentThreadContext,this.thread.contextKeyService))}};t.CommentsZoneService=m,n.__decorate([(0,r.Autowired)(o.AbstractMenuService),n.__metadata("design:type",o.AbstractMenuService)],m.prototype,"menuService",void 0),n.__decorate([(0,r.Autowired)(p.ICommentsService),n.__metadata("design:type",Object)],m.prototype,"commentService",void 0),n.__decorate([l.memoize,n.__metadata("design:type",Object),n.__metadata("design:paramtypes",[])],m.prototype,"commentThreadTitle",null),n.__decorate([l.memoize,n.__metadata("design:type",Object),n.__metadata("design:paramtypes",[])],m.prototype,"commentThreadContext",null),t.CommentsZoneService=m=n.__decorate([(0,r.Injectable)({multiple:!0}),n.__param(0,(0,r.Optional)()),n.__metadata("design:paramtypes",[v.CommentsThread])],m)},90366:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentsZoneWidget=void 0;const n=e(85608),r=n.__importDefault(e(53373)),o=n.__importDefault(e(14041)),l=n.__importDefault(e(25873)),p=e(76003),v=e(41869),m=e(25918),_=e(93899),s=e(20303),g=e(69635),a=e(37357),h=e(42018),u=e(73804),d=n.__importDefault(e(38877)),E=({thread:c,widget:b})=>{const{contextKeyService:y}=c,S=(0,v.useAutorun)(c.comments),A=(0,v.useAutorun)(c.threadHeaderTitle),T=(0,v.useInjectable)(p.INJECTOR_TOKEN).get(u.CommentsZoneService,[c]),D=(0,v.useInjectable)(g.ICommentsFeatureRegistry),I=o.default.useMemo(()=>D.getFileUploadHandler(),[]),[O,M]=o.default.useState(""),R=o.default.useMemo(()=>y.createKey("commentIsEmpty",!O),[]),P=T.commentThreadTitle,k=T.commentThreadContext,F=o.default.useCallback(V=>{const{value:$}=V.target;M($),R.set(!$)},[]),x=o.default.useMemo(()=>{var V;return((V=D.getProviderFeature(c.providerId))===null||V===void 0?void 0:V.placeholder)||`${(0,v.localize)("comments.reply.placeholder")}...`},[]),B=o.default.useCallback(async V=>{if(I){const $=await I(O,V);M(Y=>{const G=Y+$;return R.set(!G),G})}},[O]);o.default.useEffect(()=>{const V=b.onFirstDisplay(()=>{setTimeout(()=>{b.coreEditor.monacoEditor.revealLine(c.range.endLineNumber+1)},0)});return()=>{V.dispose()}},[]);const j=o.default.useCallback(()=>{T.setCurrentCommentThread(T.thread)},[]),W=o.default.useCallback(()=>{T.setCurrentCommentThread(void 0)},[]),U=o.default.useCallback(()=>{T.setCurrentCommentThread(T.thread)},[]),Z=o.default.useCallback(()=>{T.setCurrentCommentThread(void 0)},[]);return o.default.createElement("div",{tabIndex:-1,onMouseOver:j,onMouseOut:W,onFocus:U,onBlur:Z,className:(0,r.default)(c.options.threadClassName,d.default.comment_container)},o.default.createElement("div",{className:(0,r.default)(c.options.threadHeadClassName,d.default.head)},o.default.createElement("div",{className:d.default.review_title},A),o.default.createElement(m.InlineActionBar,{menus:P,context:[{thread:c,widget:b,menuId:_.MenuId.CommentsCommentThreadTitle}],separator:"inline",type:"icon"})),o.default.createElement("div",{className:d.default.comment_body},S.length>0?o.default.createElement(a.CommentItem,{widget:b,commentThreadContext:k,thread:c}):o.default.createElement("div",null,o.default.createElement(h.CommentsTextArea,{focusDelay:100,initialHeight:"auto",value:O,onChange:F,placeholder:x,dragFiles:B}),o.default.createElement("div",{className:d.default.comment_bottom_actions},o.default.createElement(m.InlineActionBar,{className:d.default.comment_reply_actions,separator:"inline",type:"button",context:[{text:O,widget:b,thread:c,menuId:_.MenuId.CommentsCommentThreadContext}],menus:k})))))};let f=class extends s.ResizeZoneWidget{_fillContainer(){}constructor(b,y,S){super(b.monacoEditor,y.range,{...S,showInHiddenAreas:!0}),this.thread=y,this._onShow=new v.Emitter,this.onShow=this._onShow.event,this._onHide=new v.Emitter,this.onHide=this._onHide.event,this._editor=b,this._isShow=!y.isCollapsed.get();const A=document.createElement("div");this._container.appendChild(A),this.observeContainer(A);const w=this.commentsFeatureRegistry.getZoneWidgetRender();this.wrapperRoot=l.default.createRoot(A),this.wrapperRoot.render(o.default.createElement(v.ConfigProvider,{value:this.appConfig},w?w(this.thread,this):o.default.createElement(E,{thread:this.thread,widget:this}))),this.addDispose({dispose:()=>{var T;(T=this.wrapperRoot)===null||T===void 0||T.unmount(),this.wrapperRoot=void 0}})}get coreEditor(){return this._editor}get isShow(){return this._isShow}show(){super.show(),this._isShow=!0,this._onShow.fire()}hide(){super.hide(),this._isShow=!1,this._onHide.fire()}toggle(){this._isShow?this.hide():this.show()}applyClass(){}applyStyle(){}};t.CommentsZoneWidget=f,n.__decorate([(0,p.Autowired)(v.AppConfig),n.__metadata("design:type",Object)],f.prototype,"appConfig",void 0),n.__decorate([(0,p.Autowired)(g.ICommentsFeatureRegistry),n.__metadata("design:type",Object)],f.prototype,"commentsFeatureRegistry",void 0),t.CommentsZoneWidget=f=n.__decorate([(0,p.Injectable)({multiple:!0}),n.__metadata("design:paramtypes",[Object,Object,Object])],f)},62604:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentsBrowserContribution=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(93899),p=e(57517),v=e(63067),m=e(69635),_=e(47842);let s=class extends o.Disposable{onStart(){this.registerCommentsFeature(),this.listenToCreateCommentsPanel(),this.commentsService.init()}get panelBadge(){const a=this.commentsService.commentsThreads.length;return a?a+"":""}registerCommands(a){a.registerCommand({id:m.CollapseId,label:"%comments.panel.action.collapse%",iconClass:(0,o.getIcon)("collapse-all")},{execute:()=>{this.commentModelService.collapsedAll()}}),a.registerCommand({id:m.CloseThreadId,label:"%comments.thread.action.close%",iconClass:(0,o.getIcon)("up")},{execute:h=>{const{thread:u,widget:d}=h;u.comments.get().length?d.isShow&&d.toggle():u.dispose()}}),a.registerCommand({id:m.SwitchCommandReaction},{execute:h=>{this.eventBus.fire(new m.CommentReactionClick(h))}})}registerMenus(a){a.registerMenuItem(l.MenuId.CommentsCommentThreadTitle,{command:m.CloseThreadId,group:"inline",order:Number.MAX_SAFE_INTEGER})}registerToolbarItems(a){a.registerItem({id:m.CollapseId,viewId:m.CommentPanelId,command:m.CollapseId,tooltip:(0,o.localize)("comments.panel.action.collapse")})}registerCommentsFeature(){this.contributions.getContributions().forEach((a,h)=>{this.addDispose(this.commentsService.registerCommentRangeProvider(`contribution_${h}`,{getCommentingRanges:u=>a.provideCommentingRanges(u)})),a.registerCommentsFeature&&a.registerCommentsFeature(this.commentsFeatureRegistry)})}listenToCreateCommentsPanel(){this.commentsFeatureRegistry.getCommentsPanelOptions().defaultShow?this.commentsService.registerCommentPanel():o.Event.once(this.commentsService.onThreadsCreated)(()=>{this.commentsService.registerCommentPanel()}),this.addDispose(o.Event.debounce(this.commentsService.onThreadsChanged,()=>{},100)(()=>{const a=this.layoutService.getTabbarHandler(m.CommentPanelId);a?.setBadge(this.panelBadge)},this))}registerEditorFeature(a){a.registerEditorFeatureContribution({contribute:h=>this.commentsService.handleOnCreateEditor(h),provideEditorOptionsForUri:async h=>(await this.commentsService.getContributionRanges(h)).length?{lineDecorationsWidth:25,lineNumbersMinChars:5}:{}})}};t.CommentsBrowserContribution=s,n.__decorate([(0,r.Autowired)(m.ICommentsService),n.__metadata("design:type",Object)],s.prototype,"commentsService",void 0),n.__decorate([(0,r.Autowired)(v.IMainLayoutService),n.__metadata("design:type",Object)],s.prototype,"layoutService",void 0),n.__decorate([(0,r.Autowired)(m.ICommentsFeatureRegistry),n.__metadata("design:type",Object)],s.prototype,"commentsFeatureRegistry",void 0),n.__decorate([(0,r.Autowired)(m.CommentsContribution),n.__metadata("design:type",Object)],s.prototype,"contributions",void 0),n.__decorate([(0,r.Autowired)(o.IEventBus),n.__metadata("design:type",Object)],s.prototype,"eventBus",void 0),n.__decorate([(0,r.Autowired)(_.CommentModelService),n.__metadata("design:type",_.CommentModelService)],s.prototype,"commentModelService",void 0),t.CommentsBrowserContribution=s=n.__decorate([(0,o.Domain)(o.ClientAppContribution,p.BrowserEditorContribution,o.CommandContribution,o.TabBarToolbarContribution,l.MenuContribution)],s)},55011:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentsService=void 0;const n=e(85608),r=n.__importDefault(e(53435)),o=n.__importDefault(e(87809)),l=e(76003),p=e(41869),v=e(57517),m=e(63067),_=e(20868),s=n.__importStar(e(20868)),g=e(62663),a=e(52416),h=n.__importStar(e(24347)),u=e(69635),d=e(53878),E=e(49867),f=e(53711);let c=class extends p.Disposable{constructor(){super(...arguments),this.decorationChangeEmitter=new p.Emitter,this.threads=new Map,this.threadsChangeEmitter=new p.Emitter,this.threadsCommentChangeEmitter=new p.Emitter,this.commentRangeProviderChangeEmitter=new p.Emitter,this.onDidChangeCurrentCommentThreadEmitter=new p.Emitter,this.threadsCreatedEmitter=new p.Emitter,this.rangeProviderMap=new Map,this.rangeOwner=new Map,this.providerDecorationCache=new p.LRUCache(1e4),this.commentRangeDecorationMap=new Map,this.shouldShowCommentsSchemes=new Set(["file","git","diff"]),this.decorationProviderDisposer=p.Disposable.NULL,this.activeThreadDecorationIds=[],this.allEditors=[],this.editorCommentingRangeSpaceReservedMap=new Map,this.editorLineDecorationsWidthMap=new Map}get commentsThreads(){return[...this.threads.values()]}get isMultiCommentsForSingleLine(){var y;return!!(!((y=this.commentsFeatureRegistry.getConfig())===null||y===void 0)&&y.isMultiCommentsForSingleLine)}get currentAuthorAvatar(){var y,S;return(S=(y=this.commentsFeatureRegistry.getConfig())===null||y===void 0?void 0:y.author)===null||S===void 0?void 0:S.avatar}get filterThreadDecoration(){var y;return(y=this.commentsFeatureRegistry.getConfig())===null||y===void 0?void 0:y.filterThreadDecoration}get onThreadsChanged(){return this.threadsChangeEmitter.event}get onThreadsCommentChange(){return this.threadsCommentChangeEmitter.event}get onThreadsCreated(){return this.threadsCreatedEmitter.event}get onCommentRangeProviderChange(){return this.commentRangeProviderChangeEmitter.event}get onDidChangeCurrentCommentThread(){return this.onDidChangeCurrentCommentThreadEmitter.event}setCurrentCommentThread(y){this.onDidChangeCurrentCommentThreadEmitter.fire(y)}createThreadDecoration(y){var S;const A=y.comments.get(),w=A.length===0?this.currentAuthorAvatar:(S=A[0].author.iconPath)===null||S===void 0?void 0:S.toString(),T=w?`${this.iconService.fromIcon("",w,a.IconType.Background)} avatar-icon`:this.iconService.fromString("$(comment)"),D={description:"comments-thread-decoration",glyphMarginClassName:w?["comment-thread",T].join(" "):["comment-range","comment-thread",T].join(" ")};return h.ModelDecorationOptions.createDynamic(D)}updateActiveThreadDecoration(y){var S;const A=this.getCurrentEditor(y?.uri);if(!A)return;(S=this.currentThreadCollapseStateListener)===null||S===void 0||S.dispose();const w=[];if(y){const T=y.range;y.isCollapsed.get()||(this.currentThreadCollapseStateListener=y.onDidChangeCollapsibleState(D=>{D===u.CommentThreadCollapsibleState.Collapsed&&this.updateActiveThreadDecoration(void 0)}),w.push({range:T,options:this.createThreadRangeActiveDecoration()}))}this.activeThreadDecorationIds=A.monacoEditor.deltaDecorations(this.activeThreadDecorationIds,w)}createDottedRangeDecoration(){const y={description:"comments-multiline-hover-decoration",linesDecorationsClassName:["comment-range","multiline-add"].join(" ")};return h.ModelDecorationOptions.createDynamic(y)}createHoverDecoration(){const y={description:"comments-hover-decoration",linesDecorationsClassName:["comment-range","line-hover","comment-add"].join(" ")};return h.ModelDecorationOptions.createDynamic(y)}createThreadRangeActiveDecoration(){const y={description:"comments-thread-range-active-decoration",isWholeLine:!1,zIndex:20,className:"comment-thread-range-current",shouldFillLineOnLineBreak:!0};return h.ModelDecorationOptions.createDynamic(y)}createThreadRangeDecoration(){const y={description:"comments-thread-range-decoration",isWholeLine:!1,zIndex:20,className:"comment-thread-range",shouldFillLineOnLineBreak:!0};return h.ModelDecorationOptions.createDynamic(y)}createCommentRangeDecoration(){const y={description:"comments-range-decoration",linesDecorationsClassName:["comment-range","comment-diff-added"].join(" ")};return h.ModelDecorationOptions.createDynamic(y)}init(){const y=this.resourceService.getSupportedSchemes();for(const S of y)this.shouldShowCommentsSchemes.add(S);this.addDispose(this.resourceService.onRegisterResourceProvider(S=>{S.scheme&&(this.shouldShowCommentsSchemes.add(S.scheme),this.registerDecorationProvider())})),this.addDispose(this.resourceService.onUnregisterResourceProvider(S=>{S.scheme&&(this.shouldShowCommentsSchemes.delete(S.scheme),this.registerDecorationProvider())})),this.registerDecorationProvider()}getCurrentEditor(y){var S;if(y){for(const A of this.allEditors)if(!((S=A.currentUri)===null||S===void 0)&&S.isEqual(y))return this.editor=A,A}return this.editor}handleOnCreateEditor(y){this.allEditors.push(y),this.editor=y;const S=new p.Disposable;let A=[],w=!1;return S.addDispose(y.monacoEditor.onMouseDown(T=>{if(T.target.type===g.monacoBrowser.editor.MouseTargetType.GUTTER_LINE_DECORATIONS&&T.target.element&&T.target.element.className.indexOf("comment-add")>-1){const{target:D}=T;if(D&&D.range){const{range:I}=D;this.startCommentRange=I,T.event.stopPropagation()}}else if(T.target.type===g.monacoBrowser.editor.MouseTargetType.GUTTER_GLYPH_MARGIN&&T.target.element&&T.target.element.className.indexOf("comment-thread")>-1){const{target:D}=T;if(D&&D.range){const{range:I}=D,O=this.commentsThreads.filter(M=>y.currentUri&&M.uri.isEqual(y.currentUri)&&M.range.endLineNumber===I.endLineNumber);O.length&&(O.some(R=>R.isShowWidget(y))?O.forEach(R=>R.hide(y)):O.forEach(R=>R.show(y)))}T.event.stopPropagation()}})),S.addDispose(y.monacoEditor.onMouseUp(async T=>{if(this.startCommentRange){if(w){this.renderCommentRange(y),w=!1,this.startCommentRange=null,this.endCommentRange=null;return}let D=this.startCommentRange;this.endCommentRange&&(this.endCommentRange.startLineNumber<this.startCommentRange.startLineNumber?(D.startColumn=this.endCommentRange.startColumn,D.startLineNumber=this.endCommentRange.startLineNumber):(D.endColumn=this.endCommentRange.endColumn,D.endLineNumber=this.endCommentRange.endLineNumber)),y.currentUri&&(D=await this.getValidRange(D,y.currentUri)),D&&(this.commentsThreads.some(I=>I.comments.get().length===0&&y.currentUri&&I.uri.isEqual(y.currentUri)&&I.range.startLineNumber===D.startLineNumber&&I.range.endLineNumber===D.endLineNumber)||this.createThread(y.currentUri,D).show(y),T.event.stopPropagation())}else if(T.target.type===g.monacoBrowser.editor.MouseTargetType.GUTTER_LINE_DECORATIONS&&T.target.element&&T.target.element.className.indexOf("comment-range")>-1&&T.target.element.className.indexOf("comment-thread")<0){const{target:D}=T,I=D.range;I&&(this.commentsThreads.some(O=>O.comments.get().length===0&&y.currentUri&&O.uri.isEqual(y.currentUri)&&O.range.startLineNumber===I.startLineNumber&&O.range.endLineNumber===I.endLineNumber)||this.createThread(y.currentUri,I).show(y),T.event.stopPropagation())}this.startCommentRange=null,this.endCommentRange=null})),S.addDispose(y.monacoEditor.onMouseMove(async T=>{var D,I,O;const M=y.currentUri,R=T.target.range;if(this.startCommentRange){if(!((D=T.target.element)===null||D===void 0)&&D.className||!((O=(I=T.target.element)===null||I===void 0?void 0:I.offsetParent)===null||O===void 0)&&O.className.includes("diff-hidden-lines")&&(w=!0),M&&R){let P={startLineNumber:this.startCommentRange.startLineNumber,endLineNumber:R.endLineNumber,startColumn:this.startCommentRange.startColumn,endColumn:R.endColumn};this.startCommentRange.startLineNumber>R.startLineNumber&&(P={startLineNumber:R.startLineNumber,endLineNumber:this.startCommentRange.endLineNumber,startColumn:R.startColumn,endColumn:this.startCommentRange.endColumn}),this.renderCommentRange(y,P),this.endCommentRange=R}}else if(M&&R&&await this.shouldShowHoverDecoration(M,R)){const P=[{range:(0,_.positionToRange)(R.startLineNumber),options:this.createHoverDecoration()}];A=y.monacoEditor.deltaDecorations(A,P)}})),S.addDispose(y.monacoEditor.onMouseLeave(async T=>{var D;const I=(D=T.target)===null||D===void 0?void 0:D.range,O=[];!this.startCommentRange&&I&&O.push({range:(0,_.positionToRange)(I.startLineNumber),options:this.createCommentRangeDecoration()}),A=y.monacoEditor.deltaDecorations(A,O)})),S.addDispose(this.onCommentRangeProviderChange(()=>{this.renderCommentRange(y)})),S.addDispose(p.Event.any(this.onThreadsChanged,this.onThreadsCommentChange,this.onThreadsCreated)(T=>{const D=this.getCurrentEditor(T.uri);D&&this.renderCommentRange(D),this.updateActiveThreadDecoration(void 0)})),S.addDispose(this.onDidChangeCurrentCommentThread(T=>{this.updateActiveThreadDecoration(T)})),this.tryUpdateReservedSpace(y),S.addDispose(y.monacoEditor.onDidChangeModel(()=>{this.renderCommentRange(y),this.tryUpdateReservedSpace(y)})),S}async getValidRange(y,S){if(!S)return y;const A=await this.getContributionRanges(S);if(A.length===0)return y;const w=A.find(T=>{if(y.startLineNumber>=T.startLineNumber&&y.startLineNumber<=T.endLineNumber)return!0});return w&&w.endLineNumber<y.endLineNumber?{startLineNumber:y.startLineNumber,startColumn:y.startColumn,endLineNumber:w.endLineNumber,endColumn:w.endColumn}:y}ensureCommentingRangeReservedAmount(y){const S=this.getExistingCommentEditorOptions(y),A=this.editorLineDecorationsWidthMap.get(y.getId());S.lineDecorationsWidth!==A&&y.updateOptions({lineDecorationsWidth:this.getWithCommentsLineDecorationWidth(y,S.lineDecorationsWidth)})}async tryUpdateReservedSpace(y){if(!y)return;let S=this.editorCommentingRangeSpaceReservedMap.get(y.getId())||!1;const A=y.currentUri?this.shouldShowCommentsSchemes.has(y.currentUri.scheme):!1,w=this.commentsThreads.some(D=>y.currentUri&&D.uri.isEqual(y.currentUri)&&D.comments.get().length>0),T=A||w;if(T)if(S)this.ensureCommentingRangeReservedAmount(y);else{S=!0;const{lineDecorationsWidth:D,extraEditorClassName:I}=this.getExistingCommentEditorOptions(y),O=this.getWithCommentsEditorOptions(y,I,D);this.updateEditorLayoutOptions(y,O.extraEditorClassName,O.lineDecorationsWidth)}else if(!T&&S){S=!1;const{lineDecorationsWidth:D,extraEditorClassName:I}=this.getExistingCommentEditorOptions(y),O=this.getWithoutCommentsEditorOptions(y,I,D);this.updateEditorLayoutOptions(y,O.extraEditorClassName,O.lineDecorationsWidth)}this.editorCommentingRangeSpaceReservedMap.set(y.getId(),S)}getExistingCommentEditorOptions(y){const S=y.monacoEditor.getOption(s.EditorOption.lineDecorationsWidth);let A=[];const w=y.monacoEditor.getRawOptions().extraEditorClassName;return w&&(A=w.split(" ")),{lineDecorationsWidth:S,extraEditorClassName:A}}getWithoutCommentsEditorOptions(y,S,A){let w=A;const T=S.findIndex(I=>I==="inline-comment");T>=0&&S.splice(T,1);const D=y.monacoEditor.getOptions();return D.get(s.EditorOption.folding)&&D.get(s.EditorOption.showFoldingControls)!=="never"&&(w+=11),w-=24,{extraEditorClassName:S,lineDecorationsWidth:w}}updateEditorLayoutOptions(y,S,A){y.updateOptions({extraEditorClassName:S.join(" "),lineDecorationsWidth:A})}getWithCommentsEditorOptions(y,S,A){return S.push("inline-comment"),{lineDecorationsWidth:this.getWithCommentsLineDecorationWidth(y,A),extraEditorClassName:S}}getWithCommentsLineDecorationWidth(y,S){let A=S;const w=y.monacoEditor.getOptions();return w.get(s.EditorOption.folding)&&w.get(s.EditorOption.showFoldingControls)!=="never"&&(A-=11),A+=24,this.editorLineDecorationsWidthMap.set(y.getId(),A),A}async renderCommentRange(y,S={startLineNumber:0,endLineNumber:0,startColumn:0,endColumn:0}){if(!y.currentUri)return;const A=await this.getContributionRanges(y.currentUri);if(A.length>0){const w=[];A.map(D=>{if(S.startLineNumber===0&&S.endLineNumber===0)w.push({range:D,options:this.createCommentRangeDecoration()});else if(S.startLineNumber<=D.startLineNumber&&S.endLineNumber>=D.endLineNumber)w.push({range:D,options:this.createDottedRangeDecoration()},{range:D,options:this.createThreadRangeDecoration()});else if(S.endLineNumber>=D.endLineNumber)if(S.startLineNumber<=D.endLineNumber){const I={startLineNumber:S.startLineNumber,endLineNumber:D.endLineNumber,startColumn:S.startColumn,endColumn:D.endColumn},O={startLineNumber:D.startLineNumber,endLineNumber:I.startLineNumber-1,startColumn:D.startColumn,endColumn:I.endColumn};w.push({range:O,options:this.createCommentRangeDecoration()},{range:I,options:this.createDottedRangeDecoration()},{range:I,options:this.createThreadRangeDecoration()})}else w.push({range:D,options:this.createCommentRangeDecoration()});else if(S.endLineNumber<D.endLineNumber)if(S.endLineNumber>=D.startLineNumber)if(S.startLineNumber>=D.startLineNumber){const I={startLineNumber:D.startLineNumber,startColumn:D.startColumn,endLineNumber:S.startLineNumber-1,endColumn:S.startColumn},O={startLineNumber:S.endLineNumber+1,startColumn:S.endColumn,endLineNumber:D.endLineNumber,endColumn:D.endColumn},M=S.startLineNumber!==D.startLineNumber?[{range:I,options:this.createCommentRangeDecoration()}]:[];M.push({range:S,options:this.createDottedRangeDecoration()}),M.push({range:S,options:this.createThreadRangeDecoration()}),M.push({range:O,options:this.createCommentRangeDecoration()}),w.push(...M)}else{const I={startLineNumber:D.startLineNumber,startColumn:D.startColumn,endLineNumber:S.endLineNumber,endColumn:S.endColumn},O={startLineNumber:I.endLineNumber+1,startColumn:I.endColumn,endLineNumber:D.endLineNumber,endColumn:D.endColumn};w.push({range:I,options:this.createDottedRangeDecoration()},{range:I,options:this.createThreadRangeDecoration()},{range:O,options:this.createCommentRangeDecoration()})}else w.push({range:D,options:this.createCommentRangeDecoration()})});const T=this.commentRangeDecorationMap.get(y.currentUri.toString())||[];this.commentRangeDecorationMap.set(y.currentUri.toString(),y.monacoEditor.deltaDecorations(T,w))}else this.commentRangeDecorationMap.set(y.currentUri.toString(),[])}async shouldShowHoverDecoration(y,S){return this.shouldShowCommentsSchemes.has(y.scheme)?(await this.getContributionRanges(y)).some(T=>S.startLineNumber<=T.endLineNumber):!1}createThread(y,S,A={comments:[],readOnly:!1}){const w=this.getProviderIdsByLine(S.endLineNumber)[0],T=this.injector.get(E.CommentsThread,[y,S,w,A]);return T.onDispose(()=>{this.threads.delete(T.id),this.threadsChangeEmitter.fire(T),this.decorationChangeEmitter.fire(y)}),T.onDidChange(()=>{this.threadsChangeEmitter.fire(T)}),this.threads.set(T.id,T),this.addDispose(T),this.threadsChangeEmitter.fire(T),this.threadsCreatedEmitter.fire(T),this.decorationChangeEmitter.fire(y),T}getThreadsByUri(y){return this.commentsThreads.filter(S=>S.uri.isEqual(y)).sort((S,A)=>S.range.startLineNumber-A.range.startLineNumber)}handleCommentFileNode(y){const S=[],A=[...this.threads.values()].filter(T=>T.comments.get().length),w=(0,o.default)(A,T=>T.uri);return Object.keys(w).map(T=>{var D;const I=w[T];if(I.length===0)return;const O=new p.URI(this.appConfig.workspaceDir),M=new p.URI(T),R=(D=O.relative(M))===null||D===void 0?void 0:D.toString();S.push(new f.CommentFileNode(this,I,R,M.codeUri.fsPath,this.labelService.getIcon(M),M,y))}),S}handleCommentContentNode(y){var S;const A=[];for(const w of y.threads){const T=w.comments.get(),[D]=T,I=typeof D.body=="string"?D.body:D.body.value;let O=`[Ln ${w.range.startLineNumber}]`;w.range.startLineNumber!==w.range.endLineNumber&&(O=`[Ln ${w.range.startLineNumber}-${w.range.endLineNumber}]`),A.push(new f.CommentContentNode(this,w,I,O,D.author.iconPath&&(!((S=D.author.iconPath)===null||S===void 0)&&S.authority)?this.iconService.fromIcon("",D.author.iconPath.toString(),a.IconType.Background):(0,p.getIcon)("message"),D.author,y.resource,y))}return A}handleCommentReplyNode(y){const S=[],A=y.thread,w=A.comments.get(),[T,...D]=w,I=D[D.length-1].author.name;return S.push(new f.CommentReplyNode(this,A,(0,p.formatLocalize)("comment.reply.count",D?.length||0),(0,p.formatLocalize)("comment.reply.lastReply",I),"",y.resource,y)),S}async resolveChildren(y){let S=[];if(y?f.CommentRoot.isRoot(y)?S=this.handleCommentFileNode(y):f.CommentFileNode.is(y)?S=this.handleCommentContentNode(y):f.CommentContentNode.is(y)&&(S=this.handleCommentReplyNode(y)):S.push(new f.CommentRoot(this)),S.length===1&&f.CommentRoot.isRoot(S[0]))return S;const A=this.commentsFeatureRegistry.getCommentsPanelTreeNodeHandlers();if(A.length>0)for(const w of A)S=w(S);return S}async getContributionRanges(y){const S=this.providerDecorationCache.get(y.toString());if(S)return await S.promise;const A=this.documentService.getModelReference(y,"Get Comment Range"),w=[];for(const O of this.rangeProviderMap){const[M,R]=O;w.push((async()=>{if(!A?.instance)return;const P=await R.getCommentingRanges(A.instance);return P&&P.length&&this.rangeOwner.set(M,P),P})())}const T=new p.Deferred;this.providerDecorationCache.set(y.toString(),T);const D=(await Promise.all(w)).filter(Boolean);A?.dispose();const I=(0,r.default)(D).filter(Boolean);return T.resolve(I),I}fireThreadCommentChange(y){this.threadsCommentChangeEmitter.fire(y)}registerDecorationProvider(){this.decorationProviderDisposer.dispose(),this.decorationProviderDisposer=this.editorDecorationCollectionService.registerDecorationProvider({schemes:[...this.shouldShowCommentsSchemes.values()],key:"comments",onDidDecorationChange:this.decorationChangeEmitter.event,provideEditorDecoration:y=>this.commentsThreads.map(S=>(S.uri.isEqual(y)?S.comments.get().length&&S.showWidgetsIfShowed():S.hide(),S)).filter(S=>{const A=S.uri.isEqual(y);return this.filterThreadDecoration?A&&this.filterThreadDecoration(S):A}).map(S=>({range:{startLineNumber:S.range.endLineNumber,endLineNumber:S.range.endLineNumber,startColumn:S.range.endColumn,endColumn:S.range.endColumn},options:this.createThreadDecoration(S)}))}),this.addDispose(this.decorationProviderDisposer)}registerCommentPanel(){this.layoutService.getTabbarHandler(u.CommentPanelId)||this.layoutService.collectTabbarComponent([{id:u.CommentPanelId,component:d.CommentsPanel}],{badge:this.panelBadge,containerId:u.CommentPanelId,title:(0,p.localize)("comments").toUpperCase(),hidden:!1,activateKeyBinding:"ctrlcmd+shift+c",...this.commentsFeatureRegistry.getCommentsPanelOptions()},"bottom")}get panelBadge(){const y=this.commentsThreads.length;return y?y+"":""}registerCommentRangeProvider(y,S){return this.rangeProviderMap.set(y,S),this.providerDecorationCache.clear(),this.commentRangeProviderChangeEmitter.fire(),p.Disposable.create(()=>{this.rangeProviderMap.delete(y),this.rangeOwner.delete(y),this.providerDecorationCache.clear()})}forceUpdateDecoration(){var y,S,A;const w=(y=this.workbenchEditorService.currentEditor)===null||y===void 0?void 0:y.currentUri;w&&this.decorationChangeEmitter.fire(w);const T=(A=(S=this.workbenchEditorService.currentEditorGroup)===null||S===void 0?void 0:S.diffEditor)===null||A===void 0?void 0:A.originalEditor.currentUri;T&&this.decorationChangeEmitter.fire(T)}getProviderIdsByLine(y){const S=[];if(this.rangeOwner.size===1)return[this.rangeOwner.keys().next().value];for(const A of this.rangeOwner){const[w,T]=A;T&&T.some(D=>D.startLineNumber<=y&&y<=D.endLineNumber)&&S.push(w)}return S}};t.CommentsService=c,n.__decorate([(0,l.Autowired)(l.INJECTOR_TOKEN),n.__metadata("design:type",l.Injector)],c.prototype,"injector",void 0),n.__decorate([(0,l.Autowired)(p.AppConfig),n.__metadata("design:type",Object)],c.prototype,"appConfig",void 0),n.__decorate([(0,l.Autowired)(v.IEditorDecorationCollectionService),n.__metadata("design:type",Object)],c.prototype,"editorDecorationCollectionService",void 0),n.__decorate([(0,l.Autowired)(a.IIconService),n.__metadata("design:type",Object)],c.prototype,"iconService",void 0),n.__decorate([(0,l.Autowired)(p.LabelService),n.__metadata("design:type",p.LabelService)],c.prototype,"labelService",void 0),n.__decorate([(0,l.Autowired)(u.ICommentsFeatureRegistry),n.__metadata("design:type",Object)],c.prototype,"commentsFeatureRegistry",void 0),n.__decorate([(0,l.Autowired)(v.IEditorDocumentModelService),n.__metadata("design:type",Object)],c.prototype,"documentService",void 0),n.__decorate([(0,l.Autowired)(m.IMainLayoutService),n.__metadata("design:type",Object)],c.prototype,"layoutService",void 0),n.__decorate([(0,l.Autowired)(v.WorkbenchEditorService),n.__metadata("design:type",v.WorkbenchEditorService)],c.prototype,"workbenchEditorService",void 0),n.__decorate([(0,l.Autowired)(v.ResourceService),n.__metadata("design:type",v.ResourceService)],c.prototype,"resourceService",void 0),n.__decorate([p.memoize,n.__metadata("design:type",Object),n.__metadata("design:paramtypes",[])],c.prototype,"isMultiCommentsForSingleLine",null),n.__decorate([p.memoize,n.__metadata("design:type",Object),n.__metadata("design:paramtypes",[])],c.prototype,"currentAuthorAvatar",null),n.__decorate([p.memoize,n.__metadata("design:type",Object),n.__metadata("design:paramtypes",[])],c.prototype,"filterThreadDecoration",null),t.CommentsService=c=n.__decorate([(0,l.Injectable)()],c)},54230:(L,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CommentsModule=void 0;const n=e(85608),r=e(76003),o=e(41869),l=e(69635),p=e(66480),v=e(62604),m=e(55011),_=e(47842);let s=class extends o.BrowserModule{constructor(){super(...arguments),this.contributionProvider=l.CommentsContribution,this.providers=[{token:l.ICommentsService,useClass:m.CommentsService},{token:_.CommentModelService,useClass:_.CommentModelService},{token:l.ICommentsFeatureRegistry,useClass:p.CommentsFeatureRegistry},v.CommentsBrowserContribution]}};t.CommentsModule=s,t.CommentsModule=s=n.__decorate([(0,r.Injectable)()],s)},70154:(L,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.markdownCss=void 0,t.markdownCss=`
|
|
29488
29488
|
h1, h2, h3, h4, h5, h6, p {
|
|
29489
29489
|
color: var(--foreground);
|
|
29490
29490
|
word-break: break-all;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/cli-engine",
|
|
3
|
-
"version": "3.8.1-next-
|
|
3
|
+
"version": "3.8.1-next-1740452912.0",
|
|
4
4
|
"description": "Integration engine runtime for opensumi-cli and opensumi extension",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@koa/cors": "^5.0.0",
|
|
28
28
|
"@opensumi/di": "^1.8.0",
|
|
29
|
-
"@opensumi/ide-core-browser": "3.8.1-next-
|
|
30
|
-
"@opensumi/ide-core-common": "3.8.1-next-
|
|
31
|
-
"@opensumi/ide-core-node": "3.8.1-next-
|
|
32
|
-
"@opensumi/ide-express-file-server": "3.8.1-next-
|
|
33
|
-
"@opensumi/ide-extension": "3.8.1-next-
|
|
34
|
-
"@opensumi/ide-i18n": "3.8.1-next-
|
|
35
|
-
"@opensumi/ide-main-layout": "3.8.1-next-
|
|
36
|
-
"@opensumi/ide-startup": "3.8.1-next-
|
|
29
|
+
"@opensumi/ide-core-browser": "3.8.1-next-1740452912.0",
|
|
30
|
+
"@opensumi/ide-core-common": "3.8.1-next-1740452912.0",
|
|
31
|
+
"@opensumi/ide-core-node": "3.8.1-next-1740452912.0",
|
|
32
|
+
"@opensumi/ide-express-file-server": "3.8.1-next-1740452912.0",
|
|
33
|
+
"@opensumi/ide-extension": "3.8.1-next-1740452912.0",
|
|
34
|
+
"@opensumi/ide-i18n": "3.8.1-next-1740452912.0",
|
|
35
|
+
"@opensumi/ide-main-layout": "3.8.1-next-1740452912.0",
|
|
36
|
+
"@opensumi/ide-startup": "3.8.1-next-1740452912.0",
|
|
37
37
|
"chalk": "^4.1.2",
|
|
38
38
|
"ejs": "^3.1.7",
|
|
39
39
|
"ip": "^1.1.8",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"webpack": "^5.90.0",
|
|
73
73
|
"webpack-cli": "^5.1.4"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "8a0d401874c0cb4ce0cf8f56c8bd636e0cf8b04e"
|
|
76
76
|
}
|